This script is an Area-based variation of an entity-based blueprint to adjust a thermostats temperature setting relative to its current value. Scripts created with this blueprint will target all climate entities in one or more Areas.
In order to keep setup simple for the new user this script is intended for, it has a few built-in limitations:
- When using
heat_coolmode, the script can set either high or low target temp… not both. - While it can be targeted at multiple Areas, it will not work if the
climateentities in those Areas use a mixture ofheat_cooland single set-point actions.
Please post any issues you discover, I will happily attempt to correct them. However, please do not post requests to add features such as being able to use entities to provide the value for the temperature change or doing away with the limitations noted above. As stated, one of the primary goals of this blueprint is to keep the setup simple.
blueprint:
name: Area-based Increase or Decrease Target Temperature (Relative)
description: Increase or decrease the temperature a given number of degrees relative
to the current setting
domain: script
input:
area:
selector:
area:
multiple: true
entity:
- domain:
- climate
name: Target Area
description: Select the Areas being targeted. Do not combine Areas if it will
create a mix of devices that do and do not use heat/cool mode.
deg_change:
default: 1
name: Default Temperature Offset
description: This value will be used unless changed in the script action. Use
negative numbers to decrease set point value.
selector:
number:
min: -15.0
max: 15.0
step: 0.1
mode: slider
my_section:
name: For climate entities that use heat/cool mode.
icon: mdi:cog
description: These options should only be changed if your climate entity uses heat/cool mode.
collapsed: true
input:
hvac_action:
default: false
name: Heat/Cool Mode
description: Turn on if your thermostat is using heat/cool mode, otherwise leave
off.
selector:
boolean: {}
low_high:
default: Low (heating)
name: Temperature Target Type
description: Select which set point you want to adjust.
selector:
select:
options:
- High (cooling)
- Low (heating)
custom_value: false
sort: false
multiple: false
source_url: https://community.home-assistant.io/t/area-based-increase-or-decrease-target-temperature/919867
mode: queued
fields:
temp_offset:
default: !input deg_change
name: Temperature Offset
description: The number of degrees to adjust the set point. Use negative numbers
to decrease set point value.
selector:
number:
min: -15
max: 15
step: 0.1
variables:
areas: !input area
targets: |
{% set ent_list = areas|map('area_entities')|flatten|list %}
{{ent_list|select('match','climate.')|list }}
deg_change: !input deg_change
offset: '{{ deg_change|float(0) if temp_offset is undefined else temp_offset|float(0)}}'
h_c: !input hvac_action
l_h: !input low_high
sequence:
- repeat:
for_each: '{{targets}}'
sequence:
- variables:
temp_max: '{{state_attr(repeat.item,''max_temp'') | float(90)}}'
temp_min: '{{state_attr(repeat.item,''min_temp'') | float(0)}}'
- choose:
- conditions:
- condition: template
value_template: '{{ h_c }}'
sequence:
- variables:
orig_high: '{{state_attr(repeat.item, ''target_temp_high'')|float(0)}}'
orig_low: '{{state_attr(repeat.item, ''target_temp_low'')|float(0)}}'
- action: climate.set_temperature
target:
entity_id: '{{ repeat.item }}'
data:
target_temp_high: '{{ ([orig_high + offset, temp_max] | min) if l_h ==''High (cooling)'' else orig_high }}'
target_temp_low: '{{ orig_low if l_h == ''High (cooling)'' else ([orig_low+offset, temp_min] | max) }}'
hvac_mode: heat_cool
default:
- action: climate.set_temperature
target:
entity_id: '{{repeat.item}}'
data:
temperature: '{{([temp_min, state_attr(repeat.item, ''temperature'')|float(0) + offset, temp_max]|sort)[1]}}'