Created
January 9, 2023 08:23
-
-
Save pavolholes/0ead164a85e358d86c6d9aa59df73af3 to your computer and use it in GitHub Desktop.
Home Assistant Notifikacia Senzory baterie pod 40%
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: '1673216789297' | |
alias: Home Assistant Notifikacia Senzory baterie pod 40% | |
description: '' | |
trigger: | |
- platform: state | |
entity_id: | |
- sensor.senzory_s_bateriou_pod_40_pocet | |
condition: | |
- condition: template | |
value_template: '{{ trigger.from_state.state != ''unavailable'' }}' | |
action: | |
- choose: | |
- conditions: | |
- condition: numeric_state | |
entity_id: sensor.senzory_s_bateriou_pod_40_pocet | |
above: 0 | |
sequence: | |
- service: notify.mobile_app_iphonepavol | |
data: | |
title: "\U0001FAABSenzory majú slabú batériu" | |
message: '{{states(''sensor.senzory_s_bateriou_pod_40'')}}' | |
- conditions: | |
- condition: numeric_state | |
entity_id: sensor.senzory_s_bateriou_pod_40_pocet | |
below: 1 | |
sequence: | |
- service: notify.mobile_app_iphonepavol | |
data: | |
message: ✅Problémy sú vyriešené | |
title: "\U0001FAABSenzory majú slabú batériu" |
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_bateriou_pod_40: | |
friendly_name: Senzory s batériou pod 40% | |
value_template: >- | |
{%- set domains = ['sensor'] -%} | |
{%- set threshold = 40 -%} | |
{%- set exclude_entities = ['sensor.iphonepavol_battery_level','sensor.tabletlenovo_battery_level','sensor.tabletlenovofkb_browser_battery'] -%} | |
Senzory s batériou pod 40%: | |
{%- for domain in domains -%} | |
{%- for item in states[domain] | rejectattr('state', 'in', ['unavailable', 'unknown']) -%} | |
{%- if item.entity_id not in exclude_entities -%} | |
{%- if item.attributes.battery_level is defined -%} | |
{%- set level = item.attributes.battery_level|int(0) -%} | |
{% if level|int(0) > 0 and level < threshold %} | |
- {{ item.attributes.friendly_name }} ({{ item.attributes['battery_level']|int(0)}}%) | |
{%- endif -%} | |
{%- endif -%} | |
{%- if item.attributes.device_class is defined and item.attributes.device_class == 'battery' -%} | |
{%- set level = item.state|int(0) -%} | |
{% if level > 0 and level <= threshold %} | |
- {{ item.attributes.friendly_name }} ({{ item.state|int(0) }}%) | |
{%- endif -%} | |
{%- endif %} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
# https://www.home-assistant.io/integrations/template/ | |
template: | |
- sensor: | |
- name: "Senzory s batériou pod 40% (počet)" | |
unique_id: senzory_s_bateriou_pod_40_pocet | |
state: >- | |
{%- set domains = ['sensor'] -%} | |
{%- set threshold = 40 -%} | |
{%- set dev = namespace(finalCount = 0) -%} | |
{%- set exclude_entities = ['sensor.iphonepavol_battery_level','sensor.tabletlenovo_battery_level','sensor.tabletlenovofkb_browser_battery'] -%} | |
{%- for domain in domains -%} | |
{%- for item in states[domain] | rejectattr('state', 'in', ['unavailable', 'unknown']) -%} | |
{%- if item.entity_id not in exclude_entities -%} | |
{%- if item.attributes.battery_level is defined -%} | |
{%- set level = item.attributes.battery_level|int(0) -%} | |
{% if level|int(0) > 0 and level < threshold %} | |
{%- set dev.finalCount = (dev.finalCount + 1) -%} | |
{%- endif -%} | |
{%- endif -%} | |
{%- if item.attributes.device_class is defined and item.attributes.device_class == 'battery' -%} | |
{%- set level = item.state|int(0) -%} | |
{% if level > 0 and level <= threshold %} | |
{%- set dev.finalCount = (dev.finalCount + 1) -%} | |
{%- endif -%} | |
{%- endif %} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ dev.finalCount }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment