I have various non “AV” devices being controlled by my harmony hub. One of them is a fan that I can turn on, off. Is it possible to have a switch in the HA front end that simply send a command to the Harmony ?
I know how to send a command through an automation, but not add a switch that sends a command.
You should be able to do this with a template switch. The turn on and turn off actions would be done calling the Harmony service and sending the appropriate commands.
I am trying to convert my functionally Harmony scripts to switches (I think Homekit need the state for on and off) Just running the scripts kind of works but the “tiles” of Homekit keeps spinning…
So I used the scripts for activities: (THEY WORK!)
# Harmoney scripts
tv_stuen_activity_on:
alias: "Tænd se Film og TV"
sequence:
- service: remote.turn_on
entity_id: remote.HUB_STUEN
data:
activity: 'Se Film og TV'
tv_stuen_activity_off:
alias: "Sluk se Film & TV"
sequence:
- service: remote.turn_off
entity_id: remote.HUB_STUEN
data:
activity: 'Se Film og TV'
When I switch the switch it starts the TV and flips back on the UI? making it impossible to turn it off?
Shouldn’t it keep the state ON for the on script?
Hi there, I have the exact same configuration as @Jer78, 2 scripts for on and off combined with a switch in the config file. It works to a certain extent, in my case I use it to turn on and off zones on my music system. My issue is that with this process the switch does not “remember” the state and HA status and my Amp status get out of sync. Same problem as what @casperse highlights. For what it’s worth, my post is here : Template switches and scripts to control an IR device.
Also, as a beginner, I do not understand what the value template line in the code does. Can someone explain its purpose ?
The value template is a template that gets the value of the current state. So if you run the script, the script is on until it finished then turns off, which would incorrectly turn your switch off. What you want to do is use the match the value of the current activity of your remote (which is an attribute of remote component) to the switch.
Here’s an example…You’ll need to change REMOTENAME to whatever your remote is called. And the ACTIVITY NAME to an activity such as “Watch TV” that you want the switch to match the state of.
switch:
tv_stuen:
value_template: "{{ is_state_attr('remote.hub_stuen', 'current_activity', 'Se Film og TV')}}"
turn_on:
service: script.turn_on
entity_id: script.tv_stuen_activity_on
turn_off:
service: script.turn_on
entity_id: script.tv_stuen_activity_off
And like before the switch turns on TV and flickers back to off again?
my hub is named remote.hub_stuen and the activity is from the Harmony.conf file generated by HA
It should temporarily flicker off because the remote hasn’t updated the activity right away but it should turn itself back on within seconds. Can you see if that works after a few seconds?
@petro looks interesting! but I havent started to use lovelace, to much time getting it just working! @Jer78 YOUR RIGHT! - THANKS ALLOT - I Just needed a little patience! It goes back after some seconds!
Thanks again @Jer78 I have been reading allot of your post and I found your input to using a “input_select”
(I would still need the above switch setup with Home kit and Google assistant! ) does it still work?
If I can bother you with one more question, using this input select like this (I have two Hubs):
input_select:
hub_stuen:
name: TV stuen
options:
- 'Select Activity'
- 'Se Film og TV'
- 'Lyt til Sonos'
- 'PowerOff'
initial: 'Select Activity'
icon: mdi:television
hub_aktivitet:
name: TV Aktivitetsrum
options:
- 'Select Activity'
- 'Play a PS4 Game'
- 'Play a Wii Game'
- 'Chromecast'
- 'PowerOff'
initial: 'Select Activity'
icon: mdi:monitor
I would need the my activities, I found different examples one that used automation scripts and another I dont really know what is? script? - I haven’t been able to find out how to insert this to my configuration file?
Do you still use this?
automation: ???
I also found other setup like the above but that had 2 automation (Allot of code to get this working!) 1) # Will update the input select when the activity is changed using the harmony remote or other device 2) # will start an Harmony activity once it’s selected from the input select in the frontend
But if I am correct the above code doesn’t need this?
Still new to this but I am a quick learner (At least that’s what I tell myself LOL)
Again thanks this forum is a lifesaver!
Best regards
Casperse
For voice I really need the switch but for the hass.io UI the selection would be nice LOL
(Google assistant can only pair with one hub, creating switches solves that limitations!)
Seems the second part above is also automation: ? and not a script:
Yes, those automations are needed for the input_selects to work. One automation that changes the remote via the interface. And one automation that changes the interface via the remote.
@petro YES! its actually working, the missing bit was that I couldn’t tell that it as automation and not a script
One thing, when I select the drop down and an activity, it goes back to the standard “Select Activity” I would like it to stay on the selected activity? - I have initial: Select Activity but that shouldn’t be the problem?
input_select:
hub_stuen:
name: TV stuen
options:
- 'Select Activity'
- 'Se Film og TV'
- 'Lyt til Sonos'
- 'PowerOff'
initial: 'Select Activity'
icon: mdi:television
I’m guessing that one of your scripts handles that for you. Check these 2 scripts and make sure they aren’t setting back the input_select to defualts: input_select_harmony_aktivitetsrum, input_select_harmony_stuen
Looking at your setup and icons it looks really nice! - is all the plugins native to hass.io?
I have everything in switches or light now (Except my Zones are all Sonos but that have so far been to complicated to get working, just wish there was a easy way to get it working with google assistant (Sonos should come out with something soon?)… not to impressed by it - it was just released last week supporting danish…I can see you have a ECHO to bad it doesn’t support danish yet
Thanks again this has been a great learning experience for me