SNZB-01 as event trigger

Hi Guys,

I’m simply trying to use a sonoff button as a lightswitch to toggle my bedroom light. I’ve tried creating the automation using this code which has worked for someone else in another post:

trigger:
  - platform: state
    entity_id: sensor.sonoff_a48004a098
    to: 'single'

But I simply can’t get anything to happen even though the event is logged when listening.

Any help is appreciated.

Try to remove single quotes around single.

I have exactly the same code without quotes and it works perfectly.

Thanks for the reply but sadly still no dice. This is what I have currently:

Please, paste the code following

to know how to copy and paste code, so anybody here can try your code and most probably your problem will be solved. Basically, wrap your block in three backticks (```).

My code is posted in the OP my friend.

You are right, but the problem is that the trigger you have in the OP is different from what you have in the screen capture.

If you press the three vertical dots and select edit in yaml, you’ll see you have something similar to:

trigger:
  - platform: event
    event_type: state_changed
    event_data:
      trigger:
        - platform: state
          entity_id: sensor.sonoff_a48004a098
          to: single

while you should have something like:

trigger:
  - platform: state
    entity_id:
      - sensor.sonoff_a48004a098
    to: single

That’s the reason I asked for the complete yaml code and not only the portion you posted in your OP, which was correct, but not if used as event_data inside an event platform trigger.