Advertisement
supremesports

Toggling icon

Oct 19th, 2019
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.23 KB | None | 0 0
  1. sensor:
  2.   - platform: template
  3.     sensors:
  4.       toggling_icon_sensor:
  5.         friendly_name: Toggling Icon
  6.         value_template: >
  7.           {% if true %}
  8.             Flash
  9.           {% else %}
  10.             Steady
  11.           {% endif %}
  12.         icon_template: >
  13.          {% elif is_state('sensor.toggling_icon_sensor', 'Flash') %}
  14.             {% if states('counter.heartbeat_counter')|int % 2 == 0 %}
  15.               mdi:recycle
  16.             {% else %}
  17.               mdi:trash-can
  18.             {% endif %}
  19.           {% else %}
  20.             mdi:trash-can
  21.           {% endif %}
  22.  
  23. counter:
  24.   heartbeat_counter:
  25.     name: Heartbeat Counter
  26.     restore: true
  27.     minimum: 1
  28.     maximum: 9999
  29.     initial: 1
  30.     step: 1
  31.  
  32. automation:
  33.   - alias: Publish Heartbeat
  34.     trigger:
  35.       - platform: time_pattern
  36.         seconds: '/1'
  37.     action:
  38.       - service: counter.increment
  39.         entity_id: counter.heartbeat_counter
  40.          
  41.   - alias: Reset Heartbeat
  42.     trigger:
  43.       - platform: template
  44.         value_template: '{{ (states.counter.heartbeat_counter.state|int) >= (states.counter.heartbeat_counter.attributes.maximum|int) }}'
  45.         for: "00:00:01"
  46.     action:
  47.       - service: counter.reset
  48.         entity_id: counter.heartbeat_counter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement