Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External rooms sensor for Hive/Danfoss #496

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
107 changes: 107 additions & 0 deletions blueprints/automation/hive_external_sensor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
blueprint:
domain: automation
name: Danfoss Ally Ext Temp Z2M v2
description: >
Update Danfoss Ally TRV external temperature with min/max refresh rate, via zigbee2mqtt.
input:
ally_device:
name: Ally TRV Device
description: Temperature reading will be sent to this device.
selector:
device:
entity:
- domain:
- climate
multiple: false
temp_sensor_id:
name: Temperature Sensor
description: >
External sensor from which the temperature will be read. Expects data format 12.3.
selector:
entity:
domain:
- sensor
device_class:
- temperature
multiple: false
max_update_timer_id:
name: Timer entity
description: >
Timer that will trigger at maximum update interval if source sensor has not
changed. Sets automatically to 30min for covered, 3h for uncovered. Use separate
timer for each automation.
selector:
entity:
domain:
- timer
multiple: false
variables:
device: !input ally_device
temp_sensor_id: !input temp_sensor_id
radiator_covered_state: >
{{ states( device_entities(device) | select('match', '.*radiator_covered$')
| first) }}
min_update_minutes: |
{% if radiator_covered_state == 'off' %}
30
{% elif radiator_covered_state == 'on' %}
5
{% else %}
script.noop
{% endif %}
max_update_minutes: |
{% if radiator_covered_state == 'off' %}
180
{% elif radiator_covered_state == 'on' %}
30
{% else %}
script.noop
{% endif %}
trigger:
- platform: state
entity_id: !input temp_sensor_id
- platform: event
event_type: timer.finished
event_data:
entity_id: !input max_update_timer_id
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ states(temp_sensor_id) is not none }}"
- condition: template
value_template: "{{ states(temp_sensor_id) | float(0) > 0 }}"
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: >-
{% set number_entity = device_entities(device) |
select('search', 'number.*_external_measured_room_sensor') |
list | first %} {{ ((states(number_entity) | float(0) -
states(temp_sensor_id) | float * 100) | round(0)) | abs >=10
}}
- condition: template
value_template: >-
{% set last_trigger = state_attr(this.entity_id,
'last_triggered') %} {{ last_trigger is none or now() -
last_trigger > timedelta(seconds=min_update_minutes * 60) }}
- condition: state
entity_id: !input max_update_timer_id
state: idle
action:
- service: mqtt.publish
data:
topic: >-
zigbee2mqtt/{{ device_attr(device, 'name')
}}/set/external_measured_room_sensor
payload_template: '{{ (states(temp_sensor_id) | float * 100) | round(0) }}'
- service: timer.start
target:
entity_id: !input max_update_timer_id
data:
duration: '{{ max_update_minutes * 60 }}'
mode: single
max_exceeded: silent
14 changes: 14 additions & 0 deletions packages/guest_bedroom_trv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
timer:
guest_trv_sync:
duration: "00:01:00"

automation:
- alias: Guest TRV Test
description: ""
use_blueprint:
path: hive_external_sensor.yaml
input:
max_update_timer_id: timer.guest_trv_sync
temp_sensor_id: sensor.guest_room_multi_sensor_temperature
ally_device: 7133d762ca5a8fc8d651233b92a425ac
4 changes: 4 additions & 0 deletions scripts/noop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
alias: noop
sequence:
- delay: "00:00:00"