Hi @ehendrix. I saw your posing some Harmony automasations that made me see that i could maby learn a thing or to and clean upp my own code.
I saw the post you done and what id like to see is the following. Your script.remote_harmony_poweroff and script.remote_harmony_start_activity
Could you maby show me? Right now my automasation does everything but select the correkt input_select when starting upp.
Id realy appriciate it. And ty for your work for the community.
I have the following within my automation to set my input_select on startup:
- alias: 'Setup after startup'
hide_entity: true
initial_state: on
trigger:
- platform: homeassistant
event: start
action:
# Turn off the automation to enable an activity based on the input_select.
# Need to do this 1st time as the state can go from PowerOff to an activity.
- service: automation.turn_off
entity_id: automation.Harmony_Activity_Selected
# Set the input select box to current activity for the family room.
- service: input_select.select_option
entity_id: input_select.family_room_tv
data_template:
option: "{{ state_attr('remote.family_room','current_activity') }}"
# Set the input select box to current activity for the master bedroom.
- service: input_select.select_option
entity_id: input_select.master_bedroom_tv
data_template:
option: "{{ state_attr('remote.master_bedroom','current_activity') }}"
- delay: 00:00:01 # Wait 1 second before turning on the automation again.
# Now turn the automation on again, from now on we should act on it.
- service: automation.turn_on
entity_id: automation.Harmony_Activity_Selected
And here is what I have then for both when an activity is selected from within HASS:
- alias: "Harmony_Activity_Selected"
hide_entity: true
trigger:
- platform: state
entity_id: input_select.family_room_tv
- platform: state
entity_id: input_select.master_bedroom_tv
condition:
- condition: template
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
- condition: template
value_template: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
{{ trigger.to_state.state != state_attr("remote." + room,'current_activity') }}
action:
service_template: >
{% if is_state(trigger.entity_id, "PowerOff") %}
script.remote_harmony_poweroff
{% else %}
script.remote_harmony_start_activity
{% endif %}
data_template:
room: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
{{ room }}
activity: " {{ trigger.to_state.state }} "
And here when an activity is selected from somewhere else (i.e. remote):
- alias: "Harmony_Update_Activity_Selected"
hide_entity: true
initial_state: on
trigger:
- platform: state
entity_id: remote.family_room
- platform: state
entity_id: remote.master_bedroom
action:
service: input_select.select_option
data_template:
entity_id: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
input_select.{{ room }}_tv
option: "{{ state_attr(trigger.entity_id,'current_activity') }}"