Hey & Happy Holidays! Sorry for this very simple question, but I’m clearly to stupid for home assistant.
I’m trying to build an automation to turn of my TV. I wrote a JavaScript to turn off the TV, that was the easy part. Now I need to configure a switch. Here is what I did so far:
Works as expected, nothing to see here. The only problem: The switch needs to figure out when the TV is on.
So far I tried: command_state: "ping -c 1 -w 1 192.168.7.37"
This is supposed to ping the TVs IP. Doesn’t seem to get updated ever.
value_template: "{{ is_state('device_tracker.9c80dfd389f8', 'home') }}"
My device tracker tracks the TV okayish, I hoped this would just set the state of the switch to the state of the device. It doesn’t.
So now I need to add an automation:
automation 2:
alias: Set TV switch
trigger:
- platform: state
entity_id: device_tracker.9c80dfd389f8
action:
So what do I need to do to set the state of the switch to the value of the device tracker? Is there a better solution? Where find I a good reference for home assistant? Please help!
The way I did it now is create a dummy switch that gets turned on when the tracker tells it my TV is on, then group the dummy switch together with the real switch, because otherwise mine would turn my tv off as soon as it got tracked
I’m pretty sure I tried something along these lines, but it didn’t work: it wouldn’t update the current state of the switch. I think the value_template never got triggered.