Thanks for the replies so far.
I don’t think a Blueprint is what I’m looking for. I understand it would probably work but I would prefer not to have multiple automations created when I’m hoping that one will suffice. Obviously if my aim isn’t possible, a Blueprint is my next port of call.
Here’s the YAML for my automation (I should attribute https://www.reddit.com/r/homeassistant/comments/18dm9gc/finally_got_heating_control_set_up_with_boost/ which is where I got the original code that I’m now adapting to my own needs)
alias: Heating Boost Start/Cancel/Finish V1
description: ""
triggers:
- entity_id:
- input_button.antstudyheating_boost_start
id: heatingBoostStart
trigger: state
- entity_id:
- input_button.antstudyheating_boost_cancel
id: heatingBoostCancel
trigger: state
- event_type: timer.finished
event_data:
entity_id: timer.antstudyheating_boost_time
id: heatingBoostExpire
trigger: event
conditions: []
actions:
- action: notify.mobile_app_ants_iphone
metadata: {}
data:
message: "{{ room_name }}"
- action: notify.mobile_app_ants_iphone
metadata: {}
data:
message: >-
{{ trigger.entity_id | replace('input_button.','',1) |
replace('_boost_cancel','',1) | replace('_boost_start','',1) }}
enabled: false
- choose:
- conditions:
- condition: trigger
id:
- heatingBoostStart
sequence:
- target:
entity_id: input_boolean.{{room_name}}_boost
data: {}
action: input_boolean.turn_on
- target:
entity_id: switch.{{room_name}}_schedules
data: {}
action: switch.turn_off
- data:
preset_mode: none
action: climate.set_preset_mode
target:
entity_id: climate.{{room_name}}
- target:
entity_id: climate.{{room_name}}
data:
temperature: "{{states('input_number. ' ~ room_name ~ '_boost_temperature')}}"
action: climate.set_temperature
- target:
entity_id: timer.{{room_name}}_boost_time
data: {}
action: timer.start
- target:
entity_id: input_select.{{room_name}}_boost_time_options
data:
option: none
action: input_select.select_option
- conditions:
- condition: trigger
id:
- heatingBoostCancel
- heatingBoostExpire
sequence:
- target:
entity_id:
- input_boolean.{{room_name}}_boost
device_id: []
area_id: []
data: {}
action: input_boolean.turn_off
- target:
entity_id: switch.{{room_name}}_schedules
data: {}
action: switch.turn_off
enabled: false
- target:
entity_id: switch.{{room_name}}_schedules
data: {}
action: switch.turn_on
- action: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.{{room_name}}_boost_time
variables:
room_name: >-
{% if trigger.id == "heatingBoostExpire" %} {{trigger.event.data.entity_id
| replace ('timer.','',1) | replace ('_boost_time','',1)}} {%- else -%}
{{trigger.entity_id | replace('input_button.','',1) |
replace('_boost_cancel','',1) | replace ('_boost_start','',1) }} {%- endif -%}
mode: single
Issue 1
As you’ll see at the bottom, I have hardcoded the variable room_name. I’d like to set it to
{{ trigger.entity_id }}
but it gets replaced with the text I posted above when I click save and reload the editor.
In fact, I’d need to set it to
{{ trigger.entity_id | replace('input_button.','',1) | replace('_boost_cancel','',1) | replace('_boost_start','',1) }}
but this produces a duplicated mapping key error - not too sure why (it does work for the disabled step which sends it to my mobile as a notification). If I keep just one replace, it doesn’t error.
Issue 2
I need to include {{room_name}} in the triggers at the top as I aim for this to work for mulitple rooms. I had a quick play with a state trigger but I wans’t able to get it to work. As the first two triggers are based on the button state changing which changes state to the date/time it was pressed, I’m not sure how I can evaluate something to true for the template unless I’m missing something.
Issue 3
I haven’t got around to trying to work out how to fix this as there are larger issues to resolve first but I need to find a way to integrate {{room_name}} into the following line
temperature: "{{states('input_number.antstudyheating_boost_temperature')}}"
Obviously, if these problems can’t be fixed, I’ll look at Blueprint option.
Thanks again.