Advertisement
kenvase

Untitled

Nov 2nd, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.18 KB | None | 0 0
  1. Automations.yaml
  2. - alias: 'Battery Alert'
  3.   initial_state: 'on'
  4.   trigger:
  5.     - platform: state
  6.       entity_id: sensor.battery_status
  7.   action:
  8.     - service: persistent_notification.create
  9.       data_template:
  10.         title: Low Battery levels
  11.         notification_id: low-battery-alert
  12.         message: >
  13.           Check battery: {{ states('sensor.battery_status') }}
  14.     - service: notify.Familje_Alerts
  15.       data_template:
  16.         message: >
  17.           Check battery: {{ states('sensor.battery_status') }}
  18.  
  19.  
  20. sensor.yaml
  21.   - platform: template
  22.     sensors:
  23.       battery_status:
  24.         friendly_name: "Battery Status"
  25.         value_template: >-
  26.           {%- set threshold = 30 -%}
  27.           {%- set domains = ['light', 'switch', 'sensor', 'zwave', 'binary_sensor', 'camera'] -%}
  28.           {%- for domain in domains -%}
  29.           {%- 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)) -%}
  30.               {{ item.name }}{%- if not loop.last %}, {% endif -%}
  31.           {%- endfor -%}
  32.           {%- endfor -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement