I’ve been reading posts about integrating Harmony Hub Activities into my new Home Assistant installation (MacOS Python), and have tried a bunch of suggestions but can’t seem to get it right. I’m still very new at this language. I would like to add three Harmony Activities as switches to Home Assistant, and see them in HomeKit so I can trigger them by voice using my phone.
Any help would be greatly appreciated!
Here is my configuration.yaml:
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: xxxxx
longitude: -xxxx
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 14
# metric for Metric, imperial for Imperial
unit_system: imperial
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/New_York
# Customization file
customize: !include customize.yaml
# Show links to resources in log and frontend
introduction:
# Enables the frontend
frontend:
# Enables configuration UI
config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
# Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true
# Discover some devices automatically
discovery:
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Enables support for tracking state changes over time
history:
# View all events in a logbook
logbook:
# Enables a map showing the location of tracked devices
map:
# Track the sun
sun:
# Weather prediction
sensor:
- platform: yr
# Text to speech
tts:
- platform: google
# Cloud
cloud:
# Homekit
homekit:
#Climate
climate:
- platform: radiotherm
#Weather
sensor:
- platform: darksky
api_key: xxxxxxxxx
monitored_conditions:
- temperature
- apparent_temperature
- wind_speed
- precip_type
#Harmony
remote:
- platform: harmony
name: livingroom
host: 192.168.1.10
#Switch
switch:
- platform: template
switches:
# apple tv activity
apple_tv:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', ‘APPLE TV’) }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: ‘APPLE TV’
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
# digital music activity
music:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', 'Listen to Digital Music') }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'Listen to Digital Music'
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
# radio activity
radio:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', 'Listen to Radio') }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'Listen to Radio'
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
#Weather
sensor:
- platform: yweather
monitored-conditions:
- weather
- weather-current
- temp-min
- temp-max
- wind-speed
- pressure
- visibility
- humidity
- temperature
#Garage
cover:
- platform: myq
username: xxxxxxxxx
password: xxxxxxx
type: chamberlain
The service: remote.turn_on under the turn_off: section should be service: remote.turn_off(for apple_tv, music and radio).
Try using the activity ID number where it says activity:. This can be found in the same directory as your configuration.yaml file, in a file called “harmony_harmony_hub.conf”. Open this up and you’ll see your activities listed at the top with a series of numbers (i.e. 2543934 - AppleTV). You would set activity: 2543934 in this example. For PowerOff, you’ll see it listed as -1 so you would set activity: -1
The Harmony Hub is automatically discoverable by the discovery: feature of Home Assistant so it’s not required to use remote: with your harmony info. It shouldn’t matter though.
Can you see the Harmony Hub from the “States” page under “Developer tools”? It should say remote.livingroom in your case.
I did some more searching and found some other examples to try and copy. I’m still getting errors when I check the config and I can’t figure out what is going wrong. I appreciate any help, thanks!
You need to replace the ??? in the value_template: field with the actual name of the activity in the harmony_hub.conf file.
Are you sure the name: field under remote: matches what your actual Harmony Hub is called? It has to be exact.
By default, you should have group: !include groups.yaml near the top of your configuration.yaml file. This means anything related to groups should go in the groups.yaml file and not your configuration.yaml file like you have.
As I mentioned before, are you seeing the Harmony Hub actually show up in Home Assistant? You can check this in the “States” page under “Developer tools” from the HA web UI. Usually the first step when I add anything new is to add just the component first to make sure it shows up in HA before I start adding switches or anything.
And you’re probably saying “But petro, they look the same”. And the answer is no, they aren’t. Take a look at your question marks. Look in the ‘bad’ example, and look at the quotes. Now look at the second example. Do the quotes look the same? No they don’t. You cannot use ‘Microsoft word’ quotes as characters for encapsulating strings.
So in the end, your switch catagory should look like this:
#Switch
switch:
- platform: template
switches:
# apple tv activity
apple_tv:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', 'APPLE TV') }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'APPLE TV'
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
# digital music activity
music:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', 'Listen to Digital Music') }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'Listen to Digital Music'
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
# radio activity
radio:
value_template: "{{ is_state_attr('remote.livingroom', 'current_activity', 'Listen to Radio') }}"
turn_on:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'Listen to Radio'
turn_off:
service: remote.turn_on
data:
entity_id: remote.livingroom
activity: 'PowerOff'
Word of advice. Never copy from unformatted code. These quotes are a byproduct of that. Use a text editor and never place your code into Microsoft word or any word like editor. I recommend using notepad++.
Great catch! I just copied @travtufts YAML and tried to fix most of the errors I saw (I use Atom) - definitely missed that one. Hopefully he’s able to get this to work now.
Thanks for the tips, shred, and thank you for the explanation on syntax and proper formatting, petro! I installed ATOM with the yaml linter plugin, and after tweaking some indentations and other stuff I have it all working.
One last question for you HA gurus: If I have Harmony Activities in separate rooms that I want to be able to run at the same time, what do I need to change in the code? I only entered in a few activities to start, but now that it works I’d like to be able to have the stereo or A/C on in another room while also having the “Apple TV” activity in the main room.
The way it’s set up now only one activity can be active at any time through Home Assistant.
There is a work around, if you add buttons to a existing device and use the remote to program commands from the new device you could place multiple devices on one activity without going over the device limit of the harmony hub.
For example I can control my Tv, av switch box, fireplace and a 2nd tv all from my “Vizio” remote in the harmony app. This way I can create one activity and have multiple buttons control multiple devices just from the one harmony “remote” I hope this makes sense to you!
Also would like to if anyone got activities states to report properly in HomeKit. Currently Homebridge is running flawlessly for me but I would like to have everything in Home Assistant rather than running Homebridge on the side. If it requires a ton of custom setup and fooling around though it may not be worth my time since Homebridge just works out of the box with very little setup.
New HA user. Thanks for the suggestions above. I now have my Harmony Hub activities showing on my Apple Home app and have been using my HomePod with Siri for flawless voice control.
If possible, I would like to add a few more functions to this setup where I can ask Siri to pause/play and mute/unmute through Harmony Hub, but I can’t get it to work. The component itself—a receiver— is old school with no internet access, so I am stuck using Harmony for control. I have tried altering the switch template platform to send commands, but this does not work, or probably I am doing something wrong.