Hey there ,
I am working with automation for input select in order to control a receiver.
I would like to avoid creating automation for any option ,
how can i combine all options and do separate actions on same automation ?
You can have multiple triggers, and you can use templates to chose an action based upon the entity, and the state.
Not sure i fully understand the syntax,
If there a file which can explain better ,
states versus action ?
Does this example help?
- id: lounge_aircon_manual
alias: 'Lounge Room Aircon'
hide_entity: true
initial_state: true
trigger:
platform: state
entity_id: input_select.lounge_ac_mode
action:
service_template: >
{% if is_state('input_select.lounge_ac_mode', 'Powerful Heat') %} shell_command.lounge_ac_powerful_heat
{% elif is_state('input_select.lounge_ac_mode', 'Normal Heat') %} shell_command.lounge_ac_normal_heat
{% elif is_state('input_select.lounge_ac_mode', 'Silent Heat') %} shell_command.lounge_ac_silent_heat
{% elif is_state('input_select.lounge_ac_mode', 'Powerful Cool') %} shell_command.lounge_ac_powerful_cool
{% elif is_state('input_select.lounge_ac_mode', 'Normal Cool') %} shell_command.lounge_ac_normal_cool
{% elif is_state('input_select.lounge_ac_mode', 'Silent Cool') %} shell_command.lounge_ac_silent_cool
{% elif is_state('input_select.lounge_ac_mode', 'Dry') %} shell_command.lounge_ac_dry
{% elif is_state('input_select.lounge_ac_mode', 'Off') %} shell_command.lounge_ac_off
{% endif %}
i guess so ,
how to link the item to the action ?
I.E
shell_command.lounge_ac_normal_cool is referring to
lounge_ac_normal_cool
The shell command is the action. It is selected by the if/else if statements.
You could also do it like this:
- id: lounge_aircon_manual
alias: 'Lounge Room Aircon'
hide_entity: true
initial_state: true
trigger:
platform: state
entity_id: input_select.lounge_ac_mode
action:
service_template: "script.{{ states('input_select.lounge_ac_mode') }}"
But your options in the input_select must exactly match the script name (no capital letters or spaces),
e.g. The input select would have to be:
lounge_ac_mode:
name: Upstairs AC Mode
options:
- 'off'
- powerful_heat
- normal_heat
- silent_heat
- powerful_cool
- normal_cool
- silent_cool
icon: mdi:air-conditioner
to match the script names. script.powerful_heat
, script.normal_heat
etc…
There is also a way to map values of the input select if you want more human readable options. Have a read of this:
where exactly do you refer the modes?
It is not clear…
i want to make one automation and combine few options under same automation settings…
I can’t make my examples any clearer. Post your input select configuration and a couple of the services that you want it to control and I will attempt to show you using your input select.
What are you using to control the receiver?
RM mini
which is working well
I’ll still help you if you do this.
Could you use the broadlink media player custom component?
Now the smart ir player. Will attach a link shortly.
@tom_l input select list will work and is certainly the answer to your original question. I have similar input select for my harmony remote.
So, I’m from the WebCoRE world and trying to consolidate some automations to have multiple ifs. It errors before saving.
Error Message malformed: Required key not provided @ data [sequence]
Can code like this even go in a script?
- id: 'cabin_mini_heating'
alias: Mini Split Heat Settings
description: 'Controls Minis in Heat'
- variables:
entities: climate.cabin_br1_mini, climate.cabin_br2_mini,
climate.cabin_kitchen_mini, climate.cabin_living_mini,
temperature: 85
- alias: Control mini splits
service: climate.set_temperature
data:
entity_id: "{{ entities }}"
temperature: "{{ temperature }}"
trigger
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Home'
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Retire'
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Night'
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Wake'
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Away'
- entity_id: input_select.cabin1_mode
for: 00:00:15
platform: state
to: 'Out'
condition:
- condition: template
value_template: '{{ (state_attr(''weather.homebody'',''temperature'')) < 55 }}'
action:
- data_template:
entity_id: >
{% if trigger.to_state.state == "Home" %}
script.change_to_home_heat
{% elif trigger.to_state.state == “Retire" %}
script.change_to_retire_heat
{% elif trigger.to_state.state == “Night" %}
script.change_to_night_heat
{% elif trigger.to_state.state == “Wake" %}
script.change_to_wake_heat
{% elif trigger.to_state.state == “Away" %}
script.change_to_away_heat
{% elif trigger.to_state.state == “Out" %}
script.change_to_out_heat
{% endif %}
service: script.turn_off`
`