I currently stuck, so please excuse this probably dumb question. I am trying to run an automation based on “presence”, which does not work yet and I don’t know why.
The “automation” task is quite simple (I think):
My TV is on a RF power outlet, so when I have turned the TV off, I want to switch it off completely after a while. (TV off --> turn power outet off.)
I can also turn on the power outlet with a remote which is not monitored, I’m trying to “correct” the state as well for this case. (TV on --> power outlet must be on --> set power outlet on in HA)
I can see the status of my TV based on network presence (and it’s correctly shown as ‘home’ or not in HA).
Therefore I tried this, but it does not seem to work. From my understanding, the automation is not triggered. Any help is appreciated.
- id: 'turn_off_tv_plug'
alias: Turn off TV-Plug
trigger:
- entity_id: device_tracker.tv
platform: state
for:
minutes: 5
to: 'not_home'
action:
service: switch.turn_off
entity_id: switch.tv_plug
- id: 'correct_tv_state'
alias: Correct TV State
trigger:
- entity_id: device_tracker.tv
platform: state
to: 'home'
action:
- entity_id: switch.tv_plug
service: switch.turn_on
Thanks very much!
Fo
EDIT: As this came up twice, I think I did not describe the second automation clear enough. I can turn on the rf power outlet manually, so HA does not know it is on (but it is physically on). So the TV can be on even though HA still thinks that the outlet is off. Therefore the second automation should not actually turn it on but only set the correct state (as it is already on) in HA.
I can turn the switch on and off from the HA interface, but it will not turn off based on the autmation.
The second autmation should also work as the power source is not actually off. I can turn it on directly, without HA. In this case the power source (433 Mhz outlet) would be on but HA still shows it switched off. As the TV will be online, I 'm trying to use this as an indicator to correct the state.
Thank you for your reply. I will try your suggestion when I’m back home.
I also edited my initial post with some explanation for the second automation, I agree that it seems ridiculous, but it actually makes sense in the current implementation.