Skip to content

Instantly share code, notes, and snippets.

@dwardu89
Created November 6, 2022 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwardu89/ea8aacbf136d9913e0d3dd5d1281aea9 to your computer and use it in GitHub Desktop.
Save dwardu89/ea8aacbf136d9913e0d3dd5d1281aea9 to your computer and use it in GitHub Desktop.
Hive TRV Load Balancing Home Assistant Blueprint
blueprint:
domain: automation
name: Hive TRV Room Load Balancing
description: >
Calculate and send room mean load every 15min to
load balance TRVs in the same room, via zigbee2mqtt.
Uses Danfoss recommended calculation (Hive TRV is based off Danfoss).
input:
hive_trv_devices:
name: Hive TRV Device
description: Select all Hive TRVs located in the same room
selector:
device:
manufacturer: Hive
entity:
domain: climate
multiple: true
variables:
devices: !input hive_trv_devices
room_load_mean: >
{% set load_estimate_entities = devices|map("device_entities")
|sum(start=[])|select('match', '.*load_estimate$')|list %}
{% set valid_states = expand(load_estimate_entities)|select
|selectattr('last_changed', 'ge', now() - timedelta(minutes = 90))
|map(attribute="state")|map("int",-8000)|select("ge",-500)|list %}
{% if valid_states|count == 0 %}
Unknown
{% else %}
{{ (valid_states|sum / valid_states|count) | round }}
{% endif %}
trigger:
- platform: time_pattern
minutes: /15
condition:
- condition: template
value_template: "{{ room_load_mean != 'Unknown' }}"
action:
- repeat:
for_each: !input hive_trv_devices
sequence:
- service: mqtt.publish
data:
topic: "zigbee2mqtt/{{ device_attr(repeat.item, 'name') }}/set/load_room_mean"
payload_template: "{{ room_load_mean }}"
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment