I set up an automation recently so that when I turn my tv on or off, my philips hue sync box will also turn on or off with it. I noticed the other day when watching tv that the sync box and lights would keep turning off randomly and then I realized, it’s turning off because the wi-fi is dropping my from my LG TV and the automation is recognizing this as “off”.
I updated my script (below) so that it specifically checks from an “on” state to off AND that the state is not “unavailable” but if I disconnect my tv wifi it still turns off.
What is the best way to handle this scenario for wifi drops?
alias: Turn Sync Box Off
description: ""
triggers:
- entity_id:
- media_player.lg_tv
from:
- "on"
- playing
- paused
to:
- "off"
trigger: state
conditions:
- condition: not
conditions:
- condition: state
entity_id: media_player.lg_tv
state: unavailable
actions:
- type: turn_off
device_id: c307838310b84b444d0063f46d41af98
entity_id: b0d837eefe47f3f5d56a4b607b395611
domain: switch
- type: turn_off
device_id: c307838310b84b444d0063f46d41af98
entity_id: 8b1f552a4db65d3eb585f1ad98fe96fb
domain: switch
- type: turn_off
device_id: 622fc40a66055d5f46d634299c7a0b43
entity_id: e186f5b773ec95a2a33d0cb62f8167ee
domain: light
mode: single
I’ve modified my script. I guess it was setup that way with the device ID’s because I used the visual editors.
So I just tested by removing my tv from the wifi connection and you can see the trigger activates, but it looks like for some reason the wifi disconnection is sending a “Turned off” followed by a “Became unavailable” about 10 seconds later. I did not turn off the TV at these times, just disconnected from the wifi.
You are not going to be able to filter that out. There is no way to tell if the TV turned off because you turned it off or because you disconnected the wifi.
You need to open an issue for whatever integration you are using to connect the TV to home assistant.
Yeah, unfortunate. I’ll have to see if I can tie this to something else. Maybe I can just check to make sure the tv has been off for x minutes before I shut off the sync box, that way momentary drops don’t trigger it.