Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Automations.yaml
- - alias: 'Battery Alert'
- initial_state: 'on'
- trigger:
- - platform: state
- entity_id: sensor.battery_status
- action:
- - service: persistent_notification.create
- data_template:
- title: Low Battery levels
- notification_id: low-battery-alert
- message: >
- Check battery: {{ states('sensor.battery_status') }}
- - service: notify.Familje_Alerts
- data_template:
- message: >
- Check battery: {{ states('sensor.battery_status') }}
- sensor.yaml
- - platform: template
- sensors:
- battery_status:
- friendly_name: "Battery Status"
- value_template: >-
- {%- set threshold = 30 -%}
- {%- set domains = ['light', 'switch', 'sensor', 'zwave', 'binary_sensor', 'camera'] -%}
- {%- for domain in domains -%}
- {%- for item in states[domain] if ((item.attributes.battery_low is defined and item.attributes['battery_low'] == true) or (item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold)) -%}
- {{ item.name }}{%- if not loop.last %}, {% endif -%}
- {%- endfor -%}
- {%- endfor -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement