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.
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 (```).
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.