If you can post your configs, I can take a look at them and see what might be causing the issues.
Thank you so much guys! I’ve been fighting with this for days…
Input Select:
living_room_tv: name: Living Room TV options: - Select Input - Watch Apple TV - Watch TV - Play PS4 - Play Retro - Listen to Music - Power Off initial: Select Input icon: mdi:monitor
Script:
input_select_harmony: alias: "Start activity from input select" sequence: - service: remote.turn_on data_template: entity_id: remote.livingroom activity: > {% if is_state("input_select.living_room_tv", "Power Off") %} -1 {% elif is_state("input_select.living_room_tv", "Watch Apple TV") %} 18274439 {% elif is_state("input_select.living_room_tv", "Watch TV") %} 18303775 {% elif is_state("input_select.living_room_tv", "Play PS4") %} 15617589 {% elif is_state("input_select.living_room_tv", "Play Retro") %} 22105380 {% elif is_state("input_select.living_room_tv", "Listen to Music") %} 19399375 {% endif %}
Automations:
- alias: Harmony hide_entity: True trigger: platform: state entity_id: input_select.living_room_tv from: 'Select Input' action: - service: remote.turn_on entity_id: remote.livingroom data_template: activity: > {% if is_state("input_select.living_room_tv", "Watch Apple TV") %} 18274439 {% elif is_state("input_select.living_room_tv", "Watch TV") %} 18303775 {% elif is_state("input_select.living_room_tv", "Play PS4") %} 15617589 {% elif is_state("input_select.living_room_tv", "Play Retro") %} 22105380 {% elif is_state("input_select.living_room_tv", "Listen to Music") %} 19399375 {% else %} {% endif %} - service: input_select.select_option entity_id: input_select.living_room_tv data_template: option: "Select Input"
- alias: Harmony Off hide_entity: True trigger: platform: state entity_id: input_select.living_room_tv to: 'Power Off' action: - service: remote.turn_off entity_id: remote.livingroom - service: input_select.select_option entity_id: input_select.living_room_tv data_template: option: "Select Input"
Thanks again for the help, hopefully it’s something simple.
Change elif for elseif
I’m happy to change it, but isn’t ‘elif’ and ‘elseif’ basically the same thing? I’m assuming I should change all of them?
With ‘elseif’ I actually get the following error in the log:
17-02-13 15:42:43 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: invalid template (TemplateSyntaxError: Encountered unknown tag ‘elseif’. Jinja was looking for the following tags: ‘elif’ or ‘else’ or ‘endif’. The innermost block that needs to be closed is ‘if’.) for dictionary value @ data[‘action’][0][‘data_template’][‘activity’]. Got None. (See /etc/homeassistant/configuration.yaml, line 58). Please check the docs at Automation - Home Assistant
Your script will never work, because the input_select
will always be Select Input
except for a brief moment. When the user changes it to something else, it starts that activity and then changes right back to ‘Select Input’. So anytime you call the script it will default to the elif output, which is currently blank. Unless you have explicitly defined a default activity in the remote config, this will cause the error you’re experiencing.
Thanks, that makes sense. Can you recommend a harmony hub activity setup that works? I’ve tried a few, and they seem to work ok, but the PowerOff activity never worked for me, except for this setup (above).
The above setup is exactly what I use (I wrote it). It works. The only portion that doesn’t work is the script that you included. Remove it, and the rest will work fine.
Thanks, I’m not sure why I had that script there, must of been a fragment from one of the configurations I tried, that didn’t work. It’s removed.
It should work fine now. The script is what was causing the error.
Yep, it appears to be working without error. Thank you so much for the help, and for writing it!
Just out of curiosity, I should be displaying sensor.current_activity & input_select.living_room_tv in my groups/views on the UI, right? Also, should input_select.living_room_tv display the current activity, or just “Select Input”? I’m just wondering how it should work…
I display both on my frontend. input_select.living_room_tv will always display Select Input. Sensor.current_activity will display the current activity. If you group them together, it should look something like this:
Yep, that’s what I’ve got as well. Thank you so much!
Is there any chance you could send me the code on how you got your harmony to look like that I can get it to show up in my HA but it does not work still not sure what I’m doing wrong
Here’s the group:
harmony:
- sensor.current_activity
- input_select.harmony
And here’s the customization portion:
sensor.current_activity:
entity_picture: http ://wreckage.johndenverschoolofflight.com/hass/harmony.png
friendly_name: "Current Activity"
Thank you, any chance you can help me with my code this is what I’m trying to use but it does nothing at ll
remote:
- platform: harmony
name: Logitech Harmony
host: 192.168.0.25
input_select:
harmony:
name: Harmony Control
options:
- Select a Activity
- Watch Chromecast
- Watch Blu-ray
- Music
- Record Player
- Play SNES
- Play Wii
- Play PS4
icon: mdi:monitor
automation:
-
alias: Harmony
hide_entity: True
trigger:
platform: state
entity_id: input_select.harmony
from: ‘Select Input’
action:- service: remote.turn_on
entity_id: remote.logitech_harmony
data_template:
activity: >
{% if is_state(“input_select.harmony”, “Watch Chromecast”) %}
21348620
{% elif is_state(“input_select.harmony”, “Watch Blu-ray”) %}
21328230
{% elif is_state(“input_select.harmony”, “Music”) %}
23162952
{% elif is_state(“input_select.harmony”, “Record Player”) %}
21716937
{% elif is_state(“input_select.harmony”, “Play SNES”) %}
21349107
{% elif is_state(“input_select.harmony”, “Play Wii”) %}
21349086
{% elif is_state(“input_select.harmony”, “Play PS4”) %}
21513308
{% else %}
{% endif %} - service: input_select.select_option
entity_id: input_select.harmony
data_template:
option: “Select Input”
- service: remote.turn_on
-
alias: Harmony Off
hide_entity: True
trigger:
platform: state
entity_id: input_select.harmony
to: ‘Power Off’
action:- service: remote.turn_off
entity_id: remote.logitech_harmony - service: input_select.select_option
entity_id: input_select.harmony
data_template:
option: “Select Input”
- service: remote.turn_off
In the input select
you changed “Select Input” to “Select a Activity” but didn’t change the trigger in the automation to match it. In the first automation, change “from: ‘Select Input’” to “from: ‘Select a Activity’” and everything should work just fine.
Also, grammatically it should read “Select an Activity.”
Am I changing all 3 Select Input’s I’m sorry I’m only about 5 days into YAML
Yes. Since you changed the wording in the input select, you will need to update all other references to that line as well.
No need to apologize, we were all new to add like HA at one point. Knowledge comes with time. I’ve only been working with HA for about 6 months. There is still plenty that I don’t know.
Your A Genus Thank you it works, However the sensor.current_activity pulles Zero information I assume I’m missing some coding for it?
Also how do I get it to end a activity?