I am trying to set up a switch template and am finding very strange results.
Scenario: I have a TV to turn on/of using an IR Blaster. I have TV_ON and TV_OFF scripts that work but I have to tell Echo “turn on TV_OFF” to generate the ‘off’ event - not optimal.
I want to be able to tell Echo (and eventually Almond) to turn the TV on or off so I created a virtual switch using the Switch Template code below. FYI: I use ‘fred’ as a name for the TV.
The end result is very unpredictable. When I tell Echo to turn on or off ‘fred’, Echo will turn on or off another device altogether. Today, after restarting HA and resyncing Alexa/Echo, instead of turning off the TV, HA performed (per the log): LED Cabinet Front turned off by Home Assistant Cloud
Prior to HA restart Echo would send a command to the TiVo and sometimes not the same command.
No idea what or why this happens. BTW: Almond does not know what a ‘fred’ is at all.
switch:
- platform: template
switches:
fred:
friendly_name: "TV"
turn_on:
service: script.turn_on
entity_id: script.turn_on_tv
turn_off:
service: script.turn_on
entity_id: script.turn_off_tv