Hi Geoff, would you be able to post your config with “PowerToggle” example?
# Upstairs TV power on
togglepower_upstairs_tv:
alias: "Toggle TV Power"
sequence:
service: remote.send_command
data_template:
command: PowerToggle
device: 39592860
entity_id: remote.home_theatre
Thank you,
How is that “PowerToggle” command defined? Basically I’m having the same problem as you, I want to have a switch that runs two different scripts when turned on and off…
If you guys really want the feature I could make the value_template for the template switch optional. I just issued a pull request for a template light so I can control on/off/level via google home. I made the template light such that if a value_template isn’t defined it defaults to optimistic operation
my TV has discrete commands for power on, power off, and power toggle. What I wanted to do originally was one switch that performed two commands - turning on the switch would power on the tv and turning the switch off would power off the tv off - but I couldn’t get it to work. Then I realized I can just use the power toggle command and get essentially the same functionality.
Works for me
- platform: template
switches:
roku:
value_template: "{{is_state('media_player.receiver', 'on') and states.media_player.receiver.attributes.source == 'Roku'}}"
turn_on:
service: script.turn_on
entity_id: script.watch_roku
turn_off:
service: script.turn_on
entity_id: script.all_off
Unfortunately, my TV that I use this on does not report its state back to HA and it is in a separate room from my main entertainment center that is controlled by my Harmony hub. I ran an IR extender through my existing telephone lines to get it in line of sight to my upstairs tv and then use this script to turn it on and off without having to use a harmony activity (as that would interfere with an activity that was being run downstairs).
My TV doesn’t report state either (that I’m aware of). You could set up optimistic state switching using hidden input_boolean and have your scripts turn this on/off and have your value_template return its value.
Optional would be nice.
I also am looking to create a virtual switch with which I can run a turn on script and a turn off script.
If you’ve got an mqtt sever set up, an mqtt switch is just a virtual switch if nothing else is monitoring the subject to which it publishes.
It’s not as elegant as a straight up virtual switch, but it works.
This is exactly what I would like to do. I have two scripts to turn on and off my air conditioning using the Harmony exactly like Geoff_Brown is using for his TV. Have set up IFTTT rules to be able to trigger via Google Home, but would be great to use the Emulated Hue for speed and simplicity.
Did anyone come up with an elegant solution I could copy ?
any plans to make value_template optional?
I worked around this before by using input boolean but its ugly.