From 71e16f19904b3b346ece987f1e07c54fb1bf1702 Mon Sep 17 00:00:00 2001 From: Ron Schaeffer Date: Thu, 20 May 2021 15:01:30 +0100 Subject: [PATCH] Update shelly.markdown (#17626) Co-authored-by: Franck Nijhof --- source/_integrations/shelly.markdown | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/source/_integrations/shelly.markdown b/source/_integrations/shelly.markdown index e50e6e914b6..dfdc1be7ad8 100644 --- a/source/_integrations/shelly.markdown +++ b/source/_integrations/shelly.markdown @@ -70,9 +70,44 @@ Shelly device relays are added to the Home Assistant by default as `switch` enti ## Events -If the **BUTTON TYPE** of the switch connected to the device is set to `momentary` or `detached switch`, integration fires events when the switch is used. You can use these events in your automations. +If the **BUTTON TYPE** of the switch connected to the device is set to `momentary` or `detached switch`, integration fires events under the type `shelly.click` when the switch is used. You can use these events in your automations. -### Automation examples +Also, some devices do not add an entity for the button/switch. For example, the Shelly Button1 has only one entity for the battery level. It does not have an entity for the button itself. To trigger automations based on button presses, use the `shelly.click` event. + +### Listening for events + +You can subscribe to the `shelly.click` event type in [Developer Tools/Events](/docs/tools/dev-tools/) in order to examine the event data JSON for the correct parameters to use in your automations. For example, `shelly.click` returns event data JSON similar to the following when you press the Shelly Button1. + +```json +Event 0 fired 9:53 AM: +{ + "event_type": "shelly.click", + "data": { + "device_id": "e09c64a22553484d804353ef97f6fcd6", + "device": "shellybutton1-A4C12A45174", + "channel": 1, + "click_type": "single" + }, + "origin": "LOCAL", + "time_fired": "2021-04-28T08:53:12.755729+00:00", + "context": { + "id": "e0f379706563aaa0c2c1fda5174b5a0e", + "parent_id": null, + "user_id": null + } +} +``` + +### Automations + +The simplest way to create automations is to use the Home Assistant automation editor. For example, to set an automation triggered by a double press of a particular Shelly Button1: + +1. In the Triggers section of the automation, set Trigger Type to `Device`. +2. In the Device dropdown menu. find the Shelly Button1. +3. In the Trigger dropdown menu, select `Button double clicked`. +4. Set any conditions and actions to complete your automation. + +You can also create automations using YAML, for example: ```yaml - alias: "Toggle living room light"