Last active
February 19, 2026 23:30
-
-
Save t3hk0d3/e253ba35cc7bc65e5289b3b87edb94dc to your computer and use it in GitHub Desktop.
Home Assistant Sonoff TRVZB Dynamic External Temperature Automation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: "Dynamic Sonoff TRVZB External Temperature Updater" | |
| description: "Set Sonoff TRVZB External temperature sensor to average measured temperature in TRVs area" | |
| domain: automation | |
| input: | |
| run_interval: | |
| name: "Run Interval" | |
| description: | | |
| How often this automation will be executed (in minutes). | |
| Recommended - every 5 minutes (default) | |
| default: 5 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 3600 | |
| unit_of_measurement: minutes | |
| mode: box | |
| temp_sensor_label: | |
| name: Temperature Sensor Label | |
| description: | | |
| Label used to identify valid room temperature sensors. | |
| This is imporant, because otherwise random temperature sensors can be used - eg CPU temperature, TRV's own internal temperature, etc | |
| selector: | |
| label: | |
| mode: single | |
| triggers: | |
| - trigger: time_pattern | |
| minutes: !input run_interval | |
| actions: | |
| - variables: | |
| temp_label: !input temp_sensor_label | |
| temp_hysteresis: 0.5 | |
| labeled_sensors: "{{ label_entities(temp_label) }}" | |
| all_trvs: | | |
| {{ states.number | |
| | selectattr('attributes.device_class', 'eq', 'temperature') | |
| | selectattr('entity_id', 'search', '_external_temperature_input$') | |
| | map(attribute='entity_id') | |
| | list }} | |
| - repeat: | |
| for_each: "{{ areas() }}" | |
| sequence: | |
| - variables: | |
| current_area: "{{ repeat.item }}" | |
| trvs_in_area: "{{ area_entities(current_area) | select('in', all_trvs) | list }}" | |
| value_template: "{{ trvs_in_area | length > 0 }}" | |
| - variables: | |
| avg_temp: | | |
| {{ area_entities(current_area) | |
| | select('in', labeled_sensors) | |
| | reject('is_hidden_entity') | |
| | select('is_state_attr', 'device_class', 'temperature') | |
| | map('states') | |
| | map('float', -999) | |
| | reject('eq', -999) | |
| | average(-999) }} | |
| - condition: template | |
| value_template: "{{ avg_temp > -999 }}" | |
| - action: number.set_value | |
| data: | |
| entity_id: "{{ trvs_in_area }}" | |
| value: "{{ avg_temp }}" | |
| - action: select.select_option | |
| data: | |
| entity_id: >- | |
| {{ trvs_in_area | map('device_id') | map('device_entities') | | |
| flatten | select('search', '_temperature_sensor_select$') | list | |
| }} | |
| option: external | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment