I have the following card in Lovelace UI:
- type: icon
icon: mdi:pause
tap_action:
action: call-service
service: vacuum.pause
service_data:
entity_id: vacuum.vacuum_1st_floor
hold_action:
action: none
entity: vacuum.vacuum_1st_floor
style:
top: 93%
left: 35%
color: '#3090C7'
- type: icon
icon: mdi:play
tap_action:
action: call-service
service: vacuum.start
service_data:
entity_id: vacuum.vacuum_1st_floor
hold_action:
action: none
entity: vacuum.vacuum_1st_floor
style:
top: 93%
left: 20%
color: '#3090C7'
My issue is that I just can’t get those two icons replaced with a single icon that changes the status based on vacuums status. This is what I’ve come up with for now, but I can’t get it to work. In addition I need the tap_action to change with the icon. So I need to send the .start command when the play-icon is shown and .pause when the pause-icon is visible…:
sensor:
- platform: template
sensors:
vacuum_2nd_floor_start_pause:
friendly_name: Start/Pause
entity_id:
- vacuum.vacuum_2nd_floor
value_template: '{{ states.vacuum.vacuum_2nd_floor.attributes.status }}'
icon_template: >
{% set val = states.vacuum.vacuum_2nd_floor.attributes.status %}
{% if val == 'Cleaning' %}
mdi:pause
{% elif val == 'Returning home' %}
mdi:pause
{% else %}
mdi:play
{% endif %}
Is a sensor the right way of doing this? How can I tell the picture-element to use whatever mdi icon comes back from the sensor? Any tips are highly appreciated, been spending 8+ hours on this now, so beginning to go kind of crazy