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
@casperse glad you got it all working and @petro was able to help. Sorry I had been away all day and couldn’t jump in but looks like you are up and running.
I find I don’t use the input_select ever since Lovelace because the button cards do a better job. I also combine them with conditional cards to only show when the tv is on or if the room sensors are active. Just a few ideas for you. Let me know if you’re interested and I can post my lovelace code.
@Jer78 Yes I would be very happy to also look at your setup!
I am so happy the Google assistant now finally understand “Turn on TV” as a switch through Harmony, the native Harmony link never worked and only supported one HUB, and now I keep getting synch. errors even if I removed the link - What a Sh*tty way of doing a commercial integration
Anyway some quick question to both of you, would help me do things the right way
How do you control voice commands like sound levels on your amplifier?
Through Harmony remote as a switch? level 10, 20,30…
I can see that @petro have a HA supported receiver, and I believe I also might have one a “Pioneer” would that then be able to be controlled directly?
What about pause, Play, Mute do you have all of these as specific switch for each Harmony command? do they need to be linked to a specific activity?
I have been putting off Sonos integration for a very long time (I know @Jer78 have had allot of experience with that) so far I have been waiting for Sonos to come through with their voice integration for all platform (I am not a fan of IFTTT so I really don’t want to go down that road) would just Mute all Sonos speakers and Stop all playback be simple to do?
Oh another separate thing (For a separate thread) my configuration file is all in one file and it is truly getting really big. I hesitate to split it up in the already made sections, because I feel I would lack the big picture. Best option would be to put anything related to a specific task in one file “!include harmony.yaml” , but I don’t see that option available I would end up with pieces of code in multiple files like scripts, switch, automation, configuration right?
Again thanks for your valuable input spending your time to help me out, much appreciated
I don’t know about google assistant but i’ll answer these as if you are using alexa.
I used haaska, but currently I use nothing. You could fake out a volume slider as a template light and use alexa that way. I helped a guy do that here, but the code would be different for the level_template and set_level sections.
Pretty much you would treat it like a light: “Alexa, turn on Volume to 50%”.
That depends, can this component be used with your receiver? If yes, then use this.
Play would be best handled as a script, even pause. But it still won’t be phonetic because you’d have to treat it like a light or switch. The main issue here is that alexa doesn’t support these commands. The play, pause, and change volume all directly change alexa’s media (I’d expect the same behavior from GA).
Or the simplest and best solution… just use the proper buttons on the Harmony remote, the always work first time every time, don’t need to shout to compete when you have the volume to loud, don’t get Alexa doing random things because she couldn’t hear what you said or was more interested in following whatever was said on the telly than you etc etc.
Voice commands are great for a lot of things, as are screen based remotes, but for remote media consumption you still can’t beat a real button