Take a look at the states dev tool. It’ll tell you what entity_ids exist in your system. Some will present as “switch”. Depends on the platform.
You can create an arbitrary switch that’ll call existing services/scripts with a template switch.
Also - If your remote is a Harmony hub, you can skip all of this and connect the hub directly to the Alexa. I just recently picked up a Harmony hub and it’s impressive. The remote doesn’t have an IR blaster - all communication comes from the hub. The remote just tells the hub “I pressed this button” and the hub does the right thing. That means that if you say “Alexa, turn on Netflix”, the remote magically assumes all Netflix controls.
I’m using harmony but it is downstairs in my main theatre. I ran an ir extender upstairs only to control volume and power. Since harmony only lets you specify one activity at a time, I have to run discrete device commands through scripts (as I’ve described above) so that if someone is watching a movie downstairs the person upstairs can still tell Alexa to turn on the tv, etc.
I have looked at switch templates but can’t figure out what to put for template value as there is no state for the switch to check - harmony cannot read the stage of this upstairs tv.
Edit : if possible, I’m hoping to create a switch that toggles two scripts - one for power on and the other for power off of the upstairs tv.
Edit: Oops, this is the script I am using so far (for power On):
# Upstairs TV power on
turn_on_upstairs_tv:
alias: "turn on the upstairs tv"
sequence:
service: remote.send_command
data_template:
command: PowerOn
device: 39592860
entity_id: remote.home_theatre
The only thing I can think of is ugly and certainly seems like a Rube Goldberg: Have the switch change the state of an input boolean and create automations that trigger on that state change.
But that makes me feel bad just suggesting it. Sorry I can’t think of a more-efficient solution.
I want to but only to say your idea of a generic switch that works like the command line or template switch but allows use of scripts, services, scenes etc to be used for off or on would be extremely useful, particularly with the emulated hue component. It seems like something that should be easy to implement?
I use this method of two different scripts with Ha-Bridge to an “off” so there is a workaround for voice control if needed.
I was thinking about this post while I was at work today trying to link a combination of maybe 3 input booleans and either an automation or script with conditions but cant quite resolve it.
Edit: took too long typing and @ih8gates jumped in with the boolean already.
Yeah, I assumed such a function already existed but I understand that it probably wasn’t really necessary until alexa really caught on. Hopefully someone can implement it, I will give a look into feature requests to see if such a thing has already been suggested.
I think I found a working solution. Instead of making a script for 'on' and one for 'off', I noticed there is a PowerToggle command as well. I changed it to use one script with the PowerToggle command called ‘tv’ and in emulated hue, I set the script domain as off_maps_to_on_domains:
going to test it out. This may solve my problem for the tv power but there are still many other uses to make a generic switch a worthy feature.
Edit: so that worked! but… after alexa runs the script she says “sorry, the device blahblahblah is not responding (or disconnected, or something)”
How do I get alexa to ignore that?
I am having the same issue. Looks like the fix was merged 11 days ago into the dev branch. The last release was 15 days ago. Hopefully this will filter through in the next version or two.
# 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
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…