im trying to change the state of switch toggle of a sonoff.
ive created binary sensor thats ping every 10 sec the sonoff device and return 0 for offline and 1 for online state.
next step is to set the automation for toggle the HA switch off when binary sensor is not find the sonoff connected to the network.
i use :
automation:
alias: “turn off light toggle when sonofflr2 poweroff”
trigger:
platform: state
entity_id: binary_sensor.sonofflr2
to: ‘0’
action:
service: switch.turn_off
entity_id: switch.living_room_light_2
Try ‘off’ instead of ‘0’ in the to: ‘0’ trigger also use the code blocks when posting code please otherwise it’s difficult to help when we can’t see the spacing.
@keithh666 may be correct here regarding the trigger. The way to confirm is to check your states tab and view the state of binary_sensor.sonofflr2
You should also be able to look at the state for the automation and see it’s last_triggered attribute to tell if it ran. If it is running correctly, the issue is with the action.