{"id":83,"date":"2026-02-26T19:59:28","date_gmt":"2026-02-26T18:59:28","guid":{"rendered":"https:\/\/elrebo.de\/?p=83"},"modified":"2026-02-26T19:59:33","modified_gmt":"2026-02-26T18:59:33","slug":"shelly_plug","status":"publish","type":"post","link":"https:\/\/www.elrebo.de\/index.php\/2026\/02\/26\/shelly_plug\/","title":{"rendered":"shelly_plug"},"content":{"rendered":"\n<p id=\"block-0cfb8a78-7f9c-4098-b4fe-b30608000cbc\">An ESP-IDF component for&nbsp;<a href=\"https:\/\/elrebo.de\/index.php\/2026\/02\/20\/physical-computing\/\">Physical Computing<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-4b033aba-2a31-4956-b5d1-36a5f063d6a0\">Purpose<\/h2>\n\n\n\n<p id=\"block-d1d08013-14c7-41d6-bc31-31fd7f00b092\">Operate a Shelly Plug from an ESP32 system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-c0ec4b6c-cd95-4697-b800-d5a8e2dcf602\">How it is done<\/h2>\n\n\n\n<p id=\"block-f813434c-ae67-4bed-8e0b-5e80c7f0b3e2\">You need to include\u00a0<code>shelly_plug.hpp<\/code>.<\/p>\n\n\n\n<p id=\"block-f813434c-ae67-4bed-8e0b-5e80c7f0b3e2\">Then you define an instance of class\u00a0<code>ShellyPlug<\/code>. In the constructor of the class you define the IP address of the shelly plug.<\/p>\n\n\n\n<p>Now you can use the method <code>Switch<\/code> to switch it on or off. There is also a second version of this method with a second parameter <code>toggleAfter<\/code>. With this parameter the shelly plug state will be toggled back after the specified number of seconds.<\/p>\n\n\n\n<p>With method <code>Toggle<\/code> the state of the shelly plug is toggled.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-c316dbcb-c3c9-4a23-a3c7-d4fd1e0eb867\">Where to find it<\/h2>\n\n\n\n<p id=\"block-cc2afcf8-a2c3-4f6c-842a-a2443cfb1062\"><code>shelly_plug<\/code>\u00a0is published on the ESP Registry at\u00a0<a href=\"https:\/\/components.espressif.com\/components\/elrebo-de\/shelly_plug\">https:\/\/components.espressif.com\/components\/elrebo-de\/shelly_plug<\/a>.<\/p>\n\n\n\n<p id=\"block-2ecaabd6-5bb7-4287-bcc4-985ff1c232d5\">The source code can be found at\u00a0<a href=\"https:\/\/github.com\/elrebo-de\/shelly_plug\">https:\/\/github.com\/elrebo-de\/shelly_plug<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-cf4dee0e-a35e-4163-9fb2-e2fc7ece1f67\">How to use it<\/h2>\n\n\n\n<p id=\"block-931617c6-8adf-4eb4-85d7-1ac4f0d6a9ed\">As an ESP-IDF component\u00a0<code>shelly_plug<\/code>\u00a0must be included into idf_component.yml as a dependency. As usual this can be done by executing this command:<\/p>\n\n\n\n<p id=\"block-37ac3466-38c9-435c-9301-59bc3384f2e1\"><code>idf.py add-dependency \"elrebo-de\/shelly_plug^1.0.4\"<\/code><\/p>\n\n\n\n<p id=\"block-c35797fb-de02-421b-aecd-512cb88904a4\">In CMakeLists.txt\u00a0<code>\"elrebo-de__shelly_plug\"<\/code>\u00a0has to be added as a requirement.<\/p>\n\n\n\n<p id=\"block-e64a7152-e2b3-46ce-bc41-7ca22badb118\">Now you can include\u00a0<code>shelly_plug.hpp<\/code>\u00a0and use the ShellyPlug class in your program.<\/p>\n\n\n\n<p>With this code snippet the shelly plug at IP address 192.168.178.102 is switche on and off with the different methods of class ShellyPlug:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"713\" src=\"https:\/\/elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-19.53.41-1024x713.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-19.53.41-1024x713.png 1024w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-19.53.41-300x209.png 300w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-19.53.41-768x535.png 768w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-26-um-19.53.41.png 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>An ESP-IDF component for&nbsp;Physical Computing Purpose Operate a Shelly Plug from an ESP32 system. How it is done You need to include\u00a0shelly_plug.hpp. Then you define an instance of class\u00a0ShellyPlug. In the constructor of the class you define the IP address of the shelly plug. Now you can use the method Switch to switch it on [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oss"],"_links":{"self":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":2,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/83\/revisions\/139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media\/138"}],"wp:attachment":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}