HA 2021.3 - Shelly Button1

Good Afternoon,

Does anyone own a Shelly button 1 and who has updated the HA to version 2021.3?

I updated yesterday and today the button only has one entity, the battery.

I don’t know if it was just mine, or if it was from the update.

The Shelly button is integrated as a device and with only one entity (battery.sensor).

The rest of the configuration is made by automation or Node Red using the event: shelly.click

Event Data:

device: "Shelly_Device_Name"
channel: 1
click_type: single or double or triple or held
3 Likes

Hello,
i don’t see any entity for Shelly Button1 ?
The integration shows me its here but not any entity for it.
Already resetted the devcie, also put on USB cable - no change.

Any hints?

Thanks, Ralf

The button does not have an entity, only the battery does. Button presses are device triggers

Thanks for the information.

I am still a bit stucked how to start any automation on this.
In my scenario, i want to turn on a device once the button has been pressed.

Anyone has an example for this?

Thanks in advance,
Ralf

Hello, I also got myself a Button1 but when trying to get it to work I got some errors and I created a post here and an issue for it on the tracker:

Forum

Tracker

Have you tried removing and adding the Button1? That enabled me to create an automation with the UI for button presses but the presses won’t be registered. Also check if you get any error logs on restart.

One example, that is working:

alias: 'SHELLY BUTTON1 - 1 CLICK'
description: ''
trigger:
  - platform: event
    event_type: shelly.click
    event_data:
      device: shellybutton1-*********
      channel: 1
      click_type: single
condition: []
action:
  - service: input_boolean.toggle
    target:
      entity_id: input_boolean.turn_on_pc_home
mode: single
1 Like

This is now a really simple task, I spent a LOT of time making changes to my config to support the device over MQTT after it was not discovered. The Shelly integration was just giving me battery state as mentioned previously, what I didnt know is it made some automations available.
What I found was that you can go into configuration > devices and then filter the list to find your shellybutton1-xxxxxxxxx device and click on it, that brings up the device view.
In the device view you get device info, but you also get options to create an automation, scene or script using the button 1. When you create an automation it gives you options for single click, double click, triple click and long press.
After that it is literally as simple as choosing the device you want to control from the list and giving the automation a name.

3 Likes

Hi,
Thank you, that saved me a lot of troubleshooting :sweat_smile: !

However I still have one problem: I configured the automation to trigger on a single press of the Button1. When I press the button, the LED flashes quickly in blue then turns green. However the automation is NOT started. This is how I confogured it:

When I run the automation manually, the correct action (toggle a Shelly1) is correctly executed.

Am I missing something here ?

Seems the shelly integration only works when connected to USB power. There was a message on facebook that indicated the event number doesn’t change when on battery power. Any suggestion to make this button work on when on battery. Doesn’t seem very useful if button has to be connected to power.

No. You can use MQTT and this will work without USB powering: Awesome Shelly Button 1 and Home Assistant integration - YouTube

Thanks for the reply.
I got it working. I set the button configuration manually in the configuration.yaml file. Sensor configuration is only required if you want battery state. The shellybutton1-98CDAC2C8E48 below is “shellybutton1-” with the button Device ID appended. The Device ID is pulled from the “Device Info” page of the shelly button1 web interface. The button must be on USB power to access the web interface.

sensor:
  - platform: mqtt
    name: "tree-button-battery"
    state_topic: "shellies/shellybutton1-98CDAC2C8E48/sensor/battery"
    value_template: "{{ value }}"
    unit_of_measurement: "%"
    icon: mdi:battery
    unique_id: 98CDAC2C8E48

On the shelly button web interface, off the Internet & Security tab → then the Advance-Developer Settings → you check Enable action execution via MQTT and then set the username, password and server for your MQTT server. I use the MQTT addon from HA, so the server name is the IP of my HA device followed by “:1883”.

Finally you need an automation in your automations.yaml file that fires when the button is pushed. The automation below toggles a smart plug (which shows as a switch in HA) that I use to turn on and off the christmas tree lights. The topic in this automation is created like the state_topic above. The trigger event can be ‘S’, ‘SS’, ‘SSS’, or 'L" for single, double, triple or long press.

 id: '1638662608166'
  alias: shell-tree-button
  description: ''
  trigger:
  - platform: mqtt
    topic: "shellies/shellybutton1-98CDAC2C8E48/input_event/0"
  condition:
      condition: template
      value_template: "{{ trigger.payload_json.event == 'S' }}"
  action:
  - service: switch.toggle
    target:
       entity_id:
         switch.tree
  mode: single

I added the above manually in the automations.yaml file, but you can use the lovelace configuration->automations->add automations option to build the automation if you desire. Easiest way to intergate different actions for diffeernt button push types is to create an automation per button push event type.

After the above is configured the button can be removed from USB power and it works fine. There is a slight delay on button push as the button has to wake up, connect to wifi and then send the MQTT message. I’m fine with the delay but some might prefer the quicker response you receive from zigbee attached buttons.

3 Likes

Haven’t used the button for a while. Pulled it out to use with Christmas lights and needed to update the yaml in the configuration.yaml file to the following:


mqtt:
  binary_sensor:

    - name: "tree-button-battery"
      state_topic: "shellies/shellybutton1-98CDAC2C8E48/sensor/battery"
      value_template: "{{ value }}"
      #unit_of_measurement: "%"
      icon: mdi:battery
      unique_id: 98CDAC2C8E48

When the message is sent from the button an error is generated because unit_of_measurement isn’t valid. The button function works so I haven’t looked into cleaning up the error.