Here’s a code that will make your icon change every second:
sensor:
- platform: template
sensors:
toggling_icon_sensor:
friendly_name: Toggling Icon
value_template: >
{% if true %}
Flash
{% else %}
Steady
{% endif %}
icon_template: >
{% elif is_state('sensor.toggling_icon_sensor', 'Flash') %}
{% if states('counter.heartbeat_counter')|int % 2 == 0 %}
mdi:recycle
{% else %}
mdi:trash-can
{% endif %}
{% else %}
mdi:trash-can
{% endif %}
counter:
heartbeat_counter:
name: Heartbeat Counter
restore: true
minimum: 1
maximum: 9999
initial: 1
step: 1
automation:
- alias: Publish Heartbeat
trigger:
- platform: time_pattern
seconds: '/1'
action:
- service: counter.increment
entity_id: counter.heartbeat_counter
- alias: Reset Heartbeat
trigger:
- platform: template
value_template: '{{ (states.counter.heartbeat_counter.state|int) >= (states.counter.heartbeat_counter.attributes.maximum|int) }}'
for: "00:00:01"
action:
- service: counter.reset
entity_id: counter.heartbeat_counter
Video: https://www.facebook.com/jean.gauthier.96/videos/10157567254297270/
Here’s a code that will make you icon color flash every second:
sensor:
- platform: template
sensors:
flashing_pulse:
entity_id:
- sensor.dates_second
value_template: >
{% if states('sensor.dates_second')|int % 2 == 0 %}
on
{% else %}
off
{% endif %}
flashing_icon_sensor:
entity_id:
- sensor.dates_second
value_template: >
on
customize:
sensor.flashing_icon_sensor:
custom_ui_state_card: state-card-custom-ui
templates:
icon_color: >
if (entities['sensor.flashing_pulse'].state === 'on') return '#FFC000';
return '#2F7EFD';
counter:
heartbeat_counter:
name: Heartbeat Counter
restore: true
minimum: 1
maximum: 9999
initial: 1
step: 1
automation:
- alias: Publish Heartbeat
trigger:
- platform: time_pattern
seconds: '/1'
action:
- service: counter.increment
entity_id: counter.heartbeat_counter
- alias: Reset Heartbeat
trigger:
- platform: template
value_template: '{{ (states.counter.heartbeat_counter.state|int) >= (states.counter.heartbeat_counter.attributes.maximum|int) }}'
for: "00:00:01"
action:
- service: counter.reset
entity_id: counter.heartbeat_counter
Video: https://www.facebook.com/jean.gauthier.96/videos/10157567550057270/