Last active
March 13, 2023 20:10
-
-
Save pavolholes/ad1b03013e0059ad0c797065a4f6c515 to your computer and use it in GitHub Desktop.
Home Assistant Notifikacia Senzory maju problem
This file contains 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
- id: '1673221013583' | |
alias: Home Assistant Notifikacia Senzory maju problem | |
description: '' | |
trigger: | |
- platform: state | |
entity_id: | |
- sensor.senzory_s_problemom_pocet | |
condition: | |
- condition: template | |
value_template: '{{ trigger.from_state.state != ''unavailable'' }}' | |
action: | |
- choose: | |
- conditions: | |
- condition: numeric_state | |
entity_id: sensor.senzory_s_problemom_pocet | |
above: 0 | |
sequence: | |
- service: notify.mobile_app_iphonepavol | |
data: | |
title: ⚠️Senzory majú problém | |
message: '{{states(''sensor.senzory_s_problemom'')}}' | |
- conditions: | |
- condition: numeric_state | |
entity_id: sensor.senzory_s_problemom_pocet | |
below: 1 | |
sequence: | |
- service: notify.mobile_app_iphonepavol | |
data: | |
message: ✅Problémy sú vyriešené | |
title: ⚠️Senzory majú problém | |
mode: single |
This file contains 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
sensor: | |
# https://home-assistant.io/components/sensor.template/ | |
# https://www.home-assistant.io/integrations/template#legacy-sensor-configuration-format | |
- platform: template | |
sensors: | |
senzory_s_problemom: | |
friendly_name: Senzory s problémom | |
value_template: >- | |
{% set threshold_hours = 2 %} | |
Senzory s problémom dlhšie než {{threshold_hours}} hodiny: | |
{%- for state in states.binary_sensor | selectattr('attributes.device_class','defined') | selectattr('attributes.device_class', '==', 'problem') -%} | |
{%- if state.state == 'on' -%} | |
{% if (as_timestamp(now()) - as_timestamp(state.last_changed)) | int(0) | round(0) > (threshold_hours*60*60) %} | |
- {{ state.name }} | |
{%- endif -%} | |
{%- endif -%} | |
{%- endfor -%} | |
# https://www.home-assistant.io/integrations/template/ | |
template: | |
- sensor: | |
- name: "Senzory s problémom (počet)" | |
unique_id: senzory_s_problemom_pocet | |
state: >- | |
{% set threshold_hours = 2 %} | |
{%- set dev = namespace(finalCount = 0) -%} | |
{%- for state in states.binary_sensor | selectattr('attributes.device_class','defined') | selectattr('attributes.device_class', '==', 'problem') -%} | |
{%- if state.state == 'on' -%} | |
{%- if (as_timestamp(now()) - as_timestamp(state.last_changed)) | int(0) | round(0) > (threshold_hours*60*60) -%} | |
{%- set dev.finalCount = (dev.finalCount + 1) -%} | |
{%- endif -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{{- dev.finalCount -}} |
Changes in revision 8:
- fixed threshold_hours condition math
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CHanges in revision 7: