I need to check status of a light switch, so if turned off needs to be switched back on. I found some help and modified as below but doesn’t work… I’m stuck! lol
Any help appreciated.
# Bathroom LEDs
trigger:
platform: state
entity_id: switch.64038777a4cf12d20030_2
to: 'off'
for:
seconds: 5
action:
service: homeassistant.turn_on
entity_id: switch.64038777a4cf12d20030_2
Are you getting any errors in your logs? Can you turn it back on by manually making the service call using the developer tools (or if you have a button for this on your UI)?
Oh no… update. If I switch the light switch off via HA everything works perfectly however, if I switch it off via the Tuya light switch it does not get switched back on?
That mean HA do not get the state update from the Tuya intergration. or delay? so the switch.64038777a4cf12d20030_2 state never change to “off” hence automation not triggered.
Hi - after up to 15mins it does reset, so going to look at Tuya local installation. Tuya’s cloud is way too slow in updating HA. Will post update when sorted…
Update: setup Tuya Local and now switches back on straight away - yippee! So, after some digging it appears that the Tuya servers are very slow in communication with HA; however, it does work but takes around 15mins.
But, the plot thickens…
There are two smart bulbs connected to the switch, and come on by PIR activation. But if the switch goes off, when switched back on by HA they come on - using regular Tuya integration my code switched them off which is correct. i.e. they only come on when the PIR detects movement.
Now, using local Tuya, the LEDs do not switch off and can’t be switched off via HA at all.
Code as below - any ideas peeps?
- alias: Bathroom LED Switch - always on
trigger:
platform: state
entity_id: switch.local_tuya_bathroom_leds
to: 'off'
for:
seconds: 5
action:
- service: switch.turn_on
entity_id: switch.local_tuya_bathroom_leds
- service: light.turn_off
entity_id: light.bathroom_led_l
- service: light.turn_off
entity_id: light.bathroom_led_r
If I try and switch off the LEDs on Lovelace it shows them as already off - switch them on then off makes no difference (LEDs remain on), switch them on and leave in that state within a couple of seconds they switch to off, but the LEDs remain on.