From f4e7089a81bdaccd155f56b7cd1953793e6fc24a Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 00:07:26 +0000 Subject: [PATCH 1/7] Initial blueprint --- blueprints/hive_external_sensor.yaml | 107 +++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 blueprints/hive_external_sensor.yaml diff --git a/blueprints/hive_external_sensor.yaml b/blueprints/hive_external_sensor.yaml new file mode 100644 index 000000000..304b69067 --- /dev/null +++ b/blueprints/hive_external_sensor.yaml @@ -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 \ No newline at end of file From f2e4e3ddb8d45093fd3864c52bf7d3013d10d1eb Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 21:36:47 +0000 Subject: [PATCH 2/7] noop script --- scripts/noop.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 scripts/noop.yaml diff --git a/scripts/noop.yaml b/scripts/noop.yaml new file mode 100644 index 000000000..61eb260d5 --- /dev/null +++ b/scripts/noop.yaml @@ -0,0 +1,4 @@ +--- +alias: noop +sequence: + - delay: "00:00:00" From 1a2a93331f0f0c4bdf8750380c04f009d4d37e87 Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 22:23:59 +0000 Subject: [PATCH 3/7] Needs to be in automation directory --- blueprints/{ => automation}/hive_external_sensor.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename blueprints/{ => automation}/hive_external_sensor.yaml (100%) diff --git a/blueprints/hive_external_sensor.yaml b/blueprints/automation/hive_external_sensor.yaml similarity index 100% rename from blueprints/hive_external_sensor.yaml rename to blueprints/automation/hive_external_sensor.yaml From 480b681a859c6066c68bd3342cb391ce0ba791d9 Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 22:44:25 +0000 Subject: [PATCH 4/7] Guest bedroom tRV sync attempt --- packages/guest_bedroom_trv.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 packages/guest_bedroom_trv.yaml diff --git a/packages/guest_bedroom_trv.yaml b/packages/guest_bedroom_trv.yaml new file mode 100644 index 000000000..ac32b1036 --- /dev/null +++ b/packages/guest_bedroom_trv.yaml @@ -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 + From 7e3794ee880ce772be6bcf0e27e9dd1ad72a0a10 Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 22:57:06 +0000 Subject: [PATCH 5/7] Fix linting --- packages/cheerlights.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/cheerlights.yaml b/packages/cheerlights.yaml index 6ff834d0f..3ce4cbefc 100644 --- a/packages/cheerlights.yaml +++ b/packages/cheerlights.yaml @@ -139,9 +139,6 @@ automation: platform: mqtt topic: cheerlightsRGB condition: - #- condition: numeric_state - # entity_id: sensor.average_external_light_level - # below: 300 - condition: time after: '16:00:00' before: '23:00:00' @@ -176,6 +173,5 @@ automation: - light.decking_lights - light.under_bed_lights - light.glow_orbs - #- light.tin_hut_shelving data: transition: 10 From eb740e875166349746df66a2bbb018ef427ee7bd Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 22:57:34 +0000 Subject: [PATCH 6/7] Fix linting --- packages/guest_bedroom_trv.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/guest_bedroom_trv.yaml b/packages/guest_bedroom_trv.yaml index ac32b1036..f19606b92 100644 --- a/packages/guest_bedroom_trv.yaml +++ b/packages/guest_bedroom_trv.yaml @@ -1,3 +1,4 @@ +--- timer: guest_trv_sync: duration: "00:01:00" @@ -11,4 +12,3 @@ automation: max_update_timer_id: timer.guest_trv_sync temp_sensor_id: sensor.guest_room_multi_sensor_temperature ally_device: 7133d762ca5a8fc8d651233b92a425ac - From 8d016500e95ea1d4b3213522ac0cb84704224877 Mon Sep 17 00:00:00 2001 From: Kyle Gordon Date: Sat, 2 Dec 2023 22:58:03 +0000 Subject: [PATCH 7/7] Morelint fixe --- .../automation/hive_external_sensor.yaml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/blueprints/automation/hive_external_sensor.yaml b/blueprints/automation/hive_external_sensor.yaml index 304b69067..4a447fa91 100644 --- a/blueprints/automation/hive_external_sensor.yaml +++ b/blueprints/automation/hive_external_sensor.yaml @@ -11,8 +11,8 @@ blueprint: selector: device: entity: - - domain: - - climate + - domain: + - climate multiple: false temp_sensor_id: name: Temperature Sensor @@ -21,9 +21,9 @@ blueprint: selector: entity: domain: - - sensor + - sensor device_class: - - temperature + - temperature multiple: false max_update_timer_id: name: Timer entity @@ -34,7 +34,7 @@ blueprint: selector: entity: domain: - - timer + - timer multiple: false variables: device: !input ally_device @@ -59,12 +59,12 @@ variables: 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 + - 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: @@ -104,4 +104,4 @@ action: data: duration: '{{ max_update_minutes * 60 }}' mode: single -max_exceeded: silent \ No newline at end of file +max_exceeded: silent