Had a few issues getting Shelly buttons working in a docker HA via the Shelly integration and native API for automatons. So thought I’d put up some notes as reference and for any other newbies that get stuck.
To get the buttons working in automatons etc I had to do the following:
- Add the button to Shelly App and update the firmware.
- Plug the button into a charger and connect to the local web-server (http://buttons_ip_address).
- Enable CoIoT under Internet & Security > Advanced - Developer Settings > Enable CoIoT (see Fig 1):
- Set CoIoT peer to:
my_HA_ip_address:5683
- Save the configuration and reboot the button: Settings > Device Reboot > Device Reboot.
- On the HA host open the port 5683
- For me that was:
sudo ufw allow 5683/udp
- Possibly if your docker is locked down you may need to add permissions to the Docker configure to access that port as well.
- For me that was:
- Added the button to HA (auto detected).
- Under developer tools go to Events and enter
shelly.click
into the‘Start Listening’
field and click ‘Start Listening’ - Press the button and you should get some JSON data similar to this:
{ "event_type": "shelly.click", "data": { "device_id": "6xxxxxxxxxxxxxxxxxxxxxxxx", "device": "shellybutton1-9xxxxxxxxxx", "channel": 1, "click_type": "single", "generation": 1 }, "origin": "LOCAL", "time_fired": "2022-01-01T08:59:11.764987+00:00", "context": { "id": "axxxxxxxxxxxxxxxxxxxxxxxxx", "parent_id": null, "user_id": null } }
- Copy the device_id
- And note the click_type which should correspond to what you did, single, double, triple or long.
- Create a new automation:
- In Triggers
- Set Trigger type to: Event
- Set Event type to: shelly.click
- Add the following to Event data:
device_id: 6xxxxxxxxxxxxxxxxxxxxxxxx click_type: single
- Then set up your conditions and actions and you should have a functioning automation linked to the shelly button event. You can then add different automatons for each type of click (single, double, triple, long).
Hopefully that helps.
Fig 1)