Shelly1 configured as detached edge switch

Hi,
I have a Shelly1 installed behind a switch, which previously worked as an (attached) edge switch. Now that I installed some Zigbee bulbs there, I would not want to switch off power, but use the Shelly1 in detached mode. This means that I want to be notified in Home Assistant as soon as the switch changes the state. Now I have the problem, that I only get a shelly.click event (Shelly - Home Assistant) when the switch changes to “on”, not to “off”. This means I could only react on a switch when I either used a push button or flicked the switch twice always, which is nothing I want to do.
Is there a way to also get this shelly.click event in case that I switch “off”? Or is there any other trigger I could use to detect if the switch changed its state?
I could configure the webhooks inside the Shelly, but they issue a GET not a POST request as required for the Home Assistant integration (see Automation Trigger - Home Assistant).

Can anybody help me out?

3 Likes

So you are using a momentary push button attached to the Shelly, rather than a toggle switch?

I have toggle switches attached to my Shelly1’s running in detached mode and I get on and off switch states.

No, I am using a regular switch, no momentary button. Here is a screenshot of the settings to make it transparent:


When I push the switch to off and on again I only get this single event:
Do you know what I am doing wrong?

Yep, you are looking at events rather than states.

There should be a binary sensor associated with the Shelly 1 that will follow the switch state (on/off).

Use the state of the binary sensor as the trigger in your automation rather than events generated by the Shelly.

If you are using the Shelly integration, go to Configuration / Integrations, find your Shelly device and look at the associated entities.

If you are using MQTT, you will need to add this config to get the binary sensor:

binary_sensor:
- platform: mqtt
  state_topic: "shellies/<your_device_id_here>/input/0"
  name: "Your Switch Name Here"
  payload_on: '1'
  payload_off: '0'
  qos: 1
3 Likes

Probably those are somehow unavailable:


Would you know why this could be the case?

Click on the ..._input binary sensor and enable it in the dialogue box that pops up?

Nice, this was an easy one! Let’s see if it also contains the relevant information. I will keep you updated.

Yeah, indeed, that worked and solves a lot of problems I had. Thanks a lot for your input @tom_l !

1 Like

Same problem here. Is there any solution? What are we doing wrong?

omg… Tom you are the greatest JENIUS in the WORLD you just made me a very happy OLD MAN!!!

1 Like
alias: bedroom left button
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.bedroom_button_left1_channel_1_input
condition: []
action:
  - service: light.toggle
    data: {}
    target:
      device_id:
        - 3d3ebe7f28f3f5c7d9ff83bbfb5f246d
mode: single
2 Likes

this changes EVERYTHING FOR ME!!!

1 Like

Dear Tom,

I hope that you are well,
I have been trying to automate a light switch in my office for a few days now with still no luck.
I have a Shelly 1 installed within the light switch, this is set to Power Mode - On, Button Type Detached.

I have the following code from HA:

alias: New Automation  - Test Office
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.shelly1_office_input
condition: []
action:
  - service: light.toggle
    data:
      brightness_pct: 60
    target:
      entity_id: light.office
    enabled: true

Nothing happens when you press the toggle switch on the light switch.

The Binary sensor is sensing as the log shows:

Shelly1 Office input became unavailable
14:03:55 - 26 minutes ago

Shelly1 Office input detected power
14:03:28 - 26 minutes ago

Do you know what I am doing wrong? or could try?
thanks in advance,
kind regards
Shane