{"id":1300,"date":"2023-02-16T23:36:43","date_gmt":"2023-02-16T21:36:43","guid":{"rendered":"https:\/\/cln.io\/blog\/?p=1300"},"modified":"2023-02-17T13:08:32","modified_gmt":"2023-02-17T11:08:32","slug":"adding-a-switchbot-bot-to-homekit-with-home-assistant","status":"publish","type":"post","link":"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/","title":{"rendered":"Adding a SwitchBot Bot to HomeKit (with Home Assistant)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We will explore the way to add a switchbot to homekit using home assistant<br>this does not require a SwitchBot Hub (Mini), it uses direct bluetooth communication<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On this page<\/p>\n\n\n\n<nav aria-label=\"Table of Contents\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#adding-the-switchbot-to-home-assistant\">Adding the SwitchBot to home assistant<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#securing-the-switchbot-with-a-password\">&#8216;securing&#8217; the SwitchBot with a password<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#pairing-with-home-assistant\">Pairing with Home Assistant<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#adding-switchbot-to-homekit\">Adding SwitchBot to HomeKit<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#adding-a-virtual-switch-input-boolean-to-home-assistant\">Adding a virtual switch (input boolean) to Home Assistant<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#exposing-our-input-boolean-virtual-switch-to-homekit\">Exposing our input_boolean \/ virtual switch to HomeKit<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#via-yaml\">Via YAML<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#via-the-ui\">Via the UI <\/a><\/li><\/ol><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#adding-the-automation-logic-to-trigger-the-actual-switchbot\">Adding the automation logic to trigger the actual SwitchBot<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#securing-the-switchbot-toggle-advanced\">&#8216;Securing&#8217; (&#x1f926;&#x1f3fb;&#x200d;&#x2640;&#xfe0f;) the SwitchBot toggle [advanced]<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#implementation\">Implementation<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#buzzer-logic-launch-opening-sequence\">[BUZZER LOGIC] Launch opening sequence<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#buzzer-logic-confirm-button\">[BUZZER LOGIC] Confirm button<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/cln.io\/blog\/adding-a-switchbot-bot-to-homekit-with-home-assistant\/#buzzer-logic-stop-homekit-turn-on\">[BUZZER LOGIC] stop homekit turn on<\/a><\/li><\/ol><\/li><\/ol><\/li><\/ol><\/nav>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-the-switchbot-to-home-assistant\">Adding the SwitchBot to home assistant<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure you have set up Bluetooth on home assistant (so its configured)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"181\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image.png\" alt=\"\" class=\"wp-image-1301\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"securing-the-switchbot-with-a-password\">&#8216;securing&#8217; the SwitchBot with a password<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">before trying to add the SwitchBot I strongly suggest putting a password on the SwitchBot<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0876-1024x687.jpg\" alt=\"\" class=\"wp-image-1302\" width=\"800\" height=\"536\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0876-1024x687.jpg 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0876-300x201.jpg 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0876-768x516.jpg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0876.jpg 1284w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">open the SwitchBot app, and head over to your device (hit the entire tile, not the circle)<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"1024\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877-689x1024.jpg\" alt=\"\" class=\"wp-image-1303\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877-689x1024.jpg 689w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877-202x300.jpg 202w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877-768x1142.jpg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877-1033x1536.jpg 1033w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0877.jpg 1284w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><figcaption class=\"wp-element-caption\">head over to password<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"822\" height=\"1024\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879-822x1024.jpg\" alt=\"\" class=\"wp-image-1304\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879-822x1024.jpg 822w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879-241x300.jpg 241w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879-768x956.jpg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879-1233x1536.jpg 1233w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0879.jpg 1284w\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" \/><figcaption class=\"wp-element-caption\">and set a password (more like a pin code, but hey, 4 characters yay)<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"pairing-with-home-assistant\">Pairing with Home Assistant<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For me, it showed up &#8216;automatically&#8217; in home assistant notifications<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"261\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-1.png\" alt=\"\" class=\"wp-image-1305\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-1.png 493w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-1-300x159.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">If not head over to integrations and add SwitchBot<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"266\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_gLVTF2tZhK.png\" alt=\"\" class=\"wp-image-1307\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_gLVTF2tZhK.png 511w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_gLVTF2tZhK-300x156.png 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><figcaption class=\"wp-element-caption\">look for the SwitchBot integration and click next<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"442\" height=\"276\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_OrkFXT5PpK.png\" alt=\"\" class=\"wp-image-1306\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_OrkFXT5PpK.png 442w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_OrkFXT5PpK-300x187.png 300w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><figcaption class=\"wp-element-caption\">it should ask you for the Bluetooth password &amp; click submit<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"287\" height=\"155\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-2.png\" alt=\"\" class=\"wp-image-1308\"\/><figcaption class=\"wp-element-caption\">&#x1f389;there it is<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"993\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-3-1024x993.png\" alt=\"\" class=\"wp-image-1309\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-3-1024x993.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-3-300x291.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-3-768x745.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-3.png 1068w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">the devices states<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-switchbot-to-homekit\">Adding SwitchBot to HomeKit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, there are a couple of ways to get the SwitchBot into HomeKit, in my case I use the SwitchBot to buzz myself into my apartment since I have not found time to reverse engineer the proprietary protocols used by our intercom (just to keep myself busy) but then the other expression comes up in my head &#8220;if it works it&#8217;s not stupid&#8221; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">anyhow, if your SwitchBot would be turning on a coffee machine I would not worry too much about directly exposing it to HomeKit as a misunderstood command by Siri or an accidental &#8220;Hey Siri turn everything on&#8221; won&#8217;t leave your front door open &#x1f605;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">currently, in my case, the SwitchBot works a bit funny in Home Assistant, as the toggle buttons don&#8217;t nicely swap from &#8220;turn on to turn off&#8221; since a press on &#8220;turn on&#8221; does the full motion on the SwitchBot to lower the lever press the button and retract it (I have it configured that way)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"156\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-16.png\" alt=\"\" class=\"wp-image-1335\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-16.png 589w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-16-300x79.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">so in my case, if I press to turn off it will trigger the SwitchBot and buzz the door, and the same with a turn on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So what I propose in this situation is to make a &#8220;virtual&#8221; switch within Home Assistant, expose that to HomeKit and power it with automation to deal with the actual SwitchBot itself<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"adding-a-virtual-switch-input-boolean-to-home-assistant\">Adding a virtual switch (input boolean) to Home Assistant<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can do this via <a rel=\"noreferrer noopener\" href=\"https:\/\/www.home-assistant.io\/integrations\/input_boolean\/\" target=\"_blank\">YAML<\/a> or via the Helpers (&#x2b05;&#xfe0f; suggested way)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Head over to settings &gt; devices &amp; services &gt; (on top of the screen) Helper &gt; (right down corner) &gt; + create helper<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"450\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/01\/image.png\" alt=\"\" class=\"wp-image-1259\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/01\/image.png 693w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/01\/image-300x195.png 300w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"427\" height=\"822\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-17.png\" alt=\"\" class=\"wp-image-1336\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-17.png 427w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-17-156x300.png 156w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><figcaption class=\"wp-element-caption\">create a toggle<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"413\" height=\"313\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-18.png\" alt=\"\" class=\"wp-image-1337\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-18.png 413w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-18-300x227.png 300w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><figcaption class=\"wp-element-caption\">hit create<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"528\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-19.png\" alt=\"\" class=\"wp-image-1338\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-19.png 570w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-19-300x278.png 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><figcaption class=\"wp-element-caption\">after creation check the entity ID of the input_boolean<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Now we have a helper toggle we can use!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"403\" height=\"138\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_rtTRKjEosW.gif\" alt=\"\" class=\"wp-image-1339\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"exposing-our-input-boolean-virtual-switch-to-homekit\">Exposing our input_boolean \/ virtual switch to HomeKit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have our &#8216;virtual switch&#8217; lets expose it to HomeKit<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As you will see I run my HomeKit configs in inclusion mode, meaning only what I chose will be exposed to homekit (allowing me to keep it clean in HomeKit)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"via-yaml\">Via YAML<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">homekit:\n  - name: \"HA Utility Bridge\"\n    filter:\n      include_entities:\n        - input_boolean.switchbot<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"via-the-ui\">Via the UI <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Go to your Home Assistant integrations and configure your HomeKit integration<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-20.png\" alt=\"\" class=\"wp-image-1340\" width=\"283\" height=\"193\"\/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"820\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_IzKI4VKeag.png\" alt=\"\" class=\"wp-image-1345\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_IzKI4VKeag.png 610w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/brave_IzKI4VKeag-223x300.png 223w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><figcaption class=\"wp-element-caption\">I run Bridge Mode and Include<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"612\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-21.png\" alt=\"\" class=\"wp-image-1346\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-21.png 609w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-21-300x300.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-21-150x150.png 150w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><figcaption class=\"wp-element-caption\">select input boolean to be exposed<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"359\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-22.png\" alt=\"\" class=\"wp-image-1347\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-22.png 589w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-22-300x183.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><figcaption class=\"wp-element-caption\">select our &#8216;virtual&#8217; switch here<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Give Home Assistant a quick restart (since I&#8217;m using YAML) and it should show up in your Home<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"409\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/A48964DB-2A21-44C6-AFED-883FB68CF47A-1024x409.jpeg\" alt=\"\" class=\"wp-image-1348\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/A48964DB-2A21-44C6-AFED-883FB68CF47A-1024x409.jpeg 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/A48964DB-2A21-44C6-AFED-883FB68CF47A-300x120.jpeg 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/A48964DB-2A21-44C6-AFED-883FB68CF47A-768x307.jpeg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/A48964DB-2A21-44C6-AFED-883FB68CF47A.jpeg 1284w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">I&#8217;ve put it into a separate room, and renamed both the room and the switch<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-the-automation-logic-to-trigger-the-actual-switchbot\">Adding the automation logic to trigger the actual SwitchBot<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So there are a couple of things we have to do<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check if the virtual (HomeKit) switch was turned on<\/li>\n\n\n\n<li>Toggle the SwitchBot itself (in our case a turn off will trigger the SwitchBot, so will a turn on, so we are OK with a toggle)<\/li>\n\n\n\n<li>turn the virtual switch back off (so its state is reflected in HomeKit)<\/li>\n\n\n\n<li>[OPTIONAL] check if the source of the event was HomeKit<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"477\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-23-1024x477.png\" alt=\"\" class=\"wp-image-1349\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-23-1024x477.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-23-300x140.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-23-768x357.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-23.png 1072w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">alias: SwitchBot\ndescription: \"\"\ntrigger:\n  - platform: state\n    entity_id:\n      - input_boolean.switchbot\n    to: \"on\"\n    from: \"off\"\ncondition: []\naction:\n  - service: switch.toggle\n    data: {}\n    target:\n      entity_id: switch.bot_a1ac\n  - service: input_boolean.turn_off\n    data: {}\n    target:\n      entity_id: input_boolean.switchbot\nmode: single\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">there we have it! when you toggle the switch in HomeKit it will toggle the SwitchBot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"securing-the-switchbot-toggle-advanced\">&#8216;Securing&#8217; (&#x1f926;&#x1f3fb;&#x200d;&#x2640;&#xfe0f;) the SwitchBot toggle [advanced]<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Since Siri does so well at understanding what we ask of it, I want to avoid triggering our door buzzer, or prevent a &#8216;Hey Siri turn everything on&#8217; would also trigger the switchbot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I have come up with some dumb &#8216;anti mistake&#8217; solution and it works as follows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2 virtual switches:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start door sequence<\/li>\n\n\n\n<li>Confirm door sequence<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The way I&#8217;ve implemented this is as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you switch [start door] it will turn on [confirm door]<\/li>\n\n\n\n<li>after 3 seconds they both turn off again (making it hard for voice usage\/voice assistant hacking)<\/li>\n\n\n\n<li>within those 3 seconds you have to turn OFF [confirm door]<\/li>\n\n\n\n<li>if [confirmed door] gets turned OFF and [start door] is still on trigger the actual SwitchBot<\/li>\n\n\n\n<li>turn all switches off<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"912\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-32.png\" alt=\"\" class=\"wp-image-1378\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-32.png 788w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-32-259x300.png 259w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-32-768x889.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">it looks like this in HomeKit<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"191\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-24.png\" alt=\"\" class=\"wp-image-1350\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-24.png 664w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-24-300x86.png 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/figure>\n<\/div>\n\n\n<figure class=\"wp-block-video\"><video height=\"352\" style=\"aspect-ratio: 848 \/ 352;\" width=\"848\" controls src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/IMG_0914.mov\"><\/video><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"implementation\">Implementation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You will need 2 input_boolean&#8217;s <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"898\" height=\"114\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-25.png\" alt=\"\" class=\"wp-image-1352\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-25.png 898w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-25-300x38.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-25-768x97.png 768w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">and I&#8217;ve made 3 automations, and I&#8217;m sure they can be improved, do leave feedback! &#x1f9e1;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"359\" height=\"166\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-26.png\" alt=\"\" class=\"wp-image-1353\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-26.png 359w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-26-300x139.png 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Launch opening sequence: toggle confirm button on<\/li>\n\n\n\n<li>Confirm button: the logic to toggle the SwitchBot<\/li>\n\n\n\n<li>stop homekit turn on: just turns off the confirm button if you turn it on yourself (by pressing it or voice commands)<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"buzzer-logic-launch-opening-sequence\">[BUZZER LOGIC] Launch opening sequence<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The idea is as follows:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the door buzzer switch (step 1) is turned on for atleast 1 second<br>and the source was HomeKit and the confirm (step 2) button is off, then turn on the confirm button (step 2)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">also turn everything back off after 3 seconds<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"526\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-27-1024x526.png\" alt=\"\" class=\"wp-image-1354\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-27-1024x526.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-27-300x154.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-27-768x395.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-27.png 1099w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">alias: \"[BUZZER LOGIC] Launch opening sequence\"\ndescription: \"\"\ntrigger:\n  - platform: state\n    entity_id:\n      - input_boolean.door_buzzer\n    from: \"off\"\n    to: \"on\"\n    for:\n      hours: 0\n      minutes: 0\n      seconds: 1\ncondition:\n  - condition: template\n    value_template: \"{{ trigger.to_state.context.parent_id == none }}\"\n    alias: only run when SOURCE is HOMEKIT (parent == none)\naction:\n  - if:\n      - condition: and\n        conditions:\n          - condition: state\n            entity_id: input_boolean.door_buzzer\n            state: \"on\"\n            alias: buzzer ON\n          - condition: state\n            entity_id: input_boolean.door_buzzer_confirm\n            state: \"off\"\n            alias: confirm OFF\n        alias: check if buzzer is ON and confirm is OFF\n    then:\n      - service: input_boolean.turn_on\n        data: {}\n        target:\n          entity_id: input_boolean.door_buzzer_confirm\n        alias: turn on confirm\n      - delay:\n          hours: 0\n          minutes: 0\n          seconds: 5\n          milliseconds: 0\n      - service: input_boolean.turn_off\n        data: {}\n        target:\n          entity_id:\n            - input_boolean.door_buzzer\n            - input_boolean.door_buzzer_confirm\n        alias: turn both back off\n    else:\n      - service: input_boolean.turn_off\n        data: {}\n        target:\n          entity_id:\n            - input_boolean.door_buzzer\n            - input_boolean.door_buzzer_confirm\nmode: single\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"buzzer-logic-confirm-button\">[BUZZER LOGIC] Confirm button<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The idea is as follows: if the confirm switch is turned off and stays of for 1 seconds, check if the source was HomeKit (since we turn off our switch with automations) check if the launch switch (step 1) is still turned on and confirm is turned off (step 2) then we trigger the SwitchBot and turn off all the switches again <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-29-1024x541.png\" alt=\"\" class=\"wp-image-1356\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-29-1024x541.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-29-300x159.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-29-768x406.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-29.png 1094w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">alias: \"[BUZZER LOGIC] Confirm button\"\ndescription: \"\"\ntrigger:\n  - platform: state\n    entity_id:\n      - input_boolean.door_buzzer_confirm\n    from: \"on\"\n    to: \"off\"\n    for:\n      hours: 0\n      minutes: 0\n      seconds: 1\ncondition:\n  - condition: template\n    value_template: \"{{ trigger.to_state.context.parent_id == none }}\"\n    alias: only run when SOURCE is HOMEKIT (parent == none)\naction:\n  - if:\n      - condition: and\n        conditions:\n          - condition: state\n            entity_id: input_boolean.door_buzzer\n            state: \"on\"\n            for:\n              hours: 0\n              minutes: 0\n              seconds: 0\n            alias: buzzer ON\n          - condition: state\n            entity_id: input_boolean.door_buzzer_confirm\n            state: \"off\"\n            alias: Confirm OFF\n    then:\n      - service: input_boolean.turn_off\n        data: {}\n        target:\n          entity_id:\n            - input_boolean.door_buzzer\n            - input_boolean.door_buzzer_confirm\n      - type: toggle\n        device_id: 0fb91ad50d8c35dc82db35d667e6977c\n        entity_id: switch.bot_a1ac\n        domain: switch\n    else:\n      - service: input_boolean.turn_off\n        data: {}\n        target:\n          entity_id:\n            - input_boolean.door_buzzer\n            - input_boolean.door_buzzer_confirm\n    alias: check for BUZZER == on and CONFIRM == off\nmode: single\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"buzzer-logic-stop-homekit-turn-on\">[BUZZER LOGIC] stop homekit turn on<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This just turns off the confirm button when its turned on by HomeKit (so this way only our automations can turn it on) its not foolproof due delays and stuff, but its sufficient for me <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"526\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-30-1024x526.png\" alt=\"\" class=\"wp-image-1357\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-30-1024x526.png 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-30-300x154.png 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-30-768x394.png 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/image-30.png 1100w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">alias: \"[BUZZER LOGIC] stop homekit turn on\"\ndescription: \"\"\ntrigger:\n  - platform: state\n    entity_id:\n      - input_boolean.door_buzzer_confirm\n    to: \"on\"\ncondition:\n  - condition: template\n    value_template: \"{{ trigger.to_state.context.parent_id == none }}\"\n    alias: only run when SOURCE is HOMEKIT (parent == none)\naction:\n  - service: input_boolean.turn_off\n    data: {}\n    target:\n      entity_id:\n        - input_boolean.door_buzzer_confirm\n        - input_boolean.door_buzzer\nmode: single\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash-1024x576.jpg\" alt=\"\" class=\"wp-image-1360\" srcset=\"https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash-1024x576.jpg 1024w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash-300x169.jpg 300w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash-768x432.jpg 768w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash-1536x864.jpg 1536w, https:\/\/cln.io\/blog\/wp-content\/uploads\/2023\/02\/thomas-bennie-4D22-YTLewU-unsplash.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/@thomasbennie?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noreferrer noopener\">Thomas Bennie<\/a> on <a href=\"https:\/\/unsplash.com\/photos\/4D22-YTLewU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noreferrer noopener\">Unsplash<\/a><\/figcaption><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>We will explore the way to add a switchbot to homekit using home assistantthis does not require a SwitchBot Hub (Mini), it uses direct bluetooth communication On this page Adding the SwitchBot to home assistant [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1359,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,20,4,19],"tags":[],"class_list":["post-1300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-dyi","category-homeassistant","category-homekit"],"_links":{"self":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/1300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/comments?post=1300"}],"version-history":[{"count":5,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/1300\/revisions"}],"predecessor-version":[{"id":1379,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/posts\/1300\/revisions\/1379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/media\/1359"}],"wp:attachment":[{"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/media?parent=1300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/categories?post=1300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cln.io\/blog\/wp-json\/wp\/v2\/tags?post=1300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}