Skip to content

Instantly share code, notes, and snippets.

@01-Scripts
Last active January 19, 2025 21:11
Show Gist options
  • Save 01-Scripts/5f9af1e4dcc8cfe027f64c5fd5646f3b to your computer and use it in GitHub Desktop.
Save 01-Scripts/5f9af1e4dcc8cfe027f64c5fd5646f3b to your computer and use it in GitHub Desktop.
Update climate entities offset with a different sensor value
blueprint:
name: Update Entity Offset with Switch
description: Update the offset attribute of an entity based on another sensor's
state
domain: automation
input:
sensor_to_monitor:
name: Sensor to Monitor
description: The sensor whose state will be used to update the "offset" attribute
selector:
entity:
domain:
- sensor
device_class:
- temperature
multiple: false
sensor_to_adjust:
name: Sensor to Adjust offset
description: The sensor whose state will be updated by the "offset" attribute
selector:
entity:
domain:
- sensor
device_class:
- temperature
multiple: false
entity_to_update:
name: Entity to Update
description: The number entity of the climate entity that will be updated
selector:
entity:
domain:
- number
multiple: false
threshold:
name: Threshold
description: The maximum difference between the two sensors to trigger the automation
selector:
number:
min: 0.0
max: 2.0
step: 0.1
unit_of_measurement: °C
mode: slider
start_time:
name: When the automation starts.
selector:
time: {}
end_time:
name: When the automation stops.
selector:
time: {}
time_interval_minutes:
name: Time Interval (minutes)
description: The interval in minutes for the calibration to trigger
default: 15
selector:
number:
min: 1.0
max: 60.0
unit_of_measurement: minutes
mode: slider
step: 1.0
variables:
entity_to_update: !input entity_to_update
sensor_to_monitor: !input sensor_to_monitor
sensor_to_adjust: !input sensor_to_adjust
current_time: '{{ now().strftime(''%H:%M'') }}'
interval: !input time_interval_minutes
trigger:
- platform: state
entity_id: !input sensor_to_adjust
condition:
- condition: and
conditions:
- condition: time
after: !input start_time
before: !input end_time
action:
- if:
- condition: numeric_state
entity_id:
- !input sensor_to_monitor
- !input sensor_to_adjust
value_template: '{{ (states(sensor_to_monitor)|float - states(sensor_to_adjust)|float)|abs
}}'
above: !input threshold
then:
- service: number.set_value
target:
entity_id: !input entity_to_update
data:
value: '{{( states(entity_to_update)|float if states(entity_to_update) is not
none else 0 ) + ((states(sensor_to_monitor)|float - states(sensor_to_adjust)|float)
if states(sensor_to_monitor) is not none and states(sensor_to_adjust) is not
none else 0 ) | round(1)}}'
trace:
stored_traces: 120
@01-Scripts
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment