Hello everyone,
I have a question regarding he control of the ventilation.
I’m able to set the ventilation steps via the custom button cards an the tab_action. But how can I highlight the current state of the buttons? There should be one button that is “active”. I tried around the color with the current state of my ventilation sensor, but ist doesn’t work.
Any ideas?
type: horizontal-stack
title: Lüftung Stufe Tag
cards:
- type: custom:button-card
icon: mdi:fan-off
color: |-
[[[
if (state['sensor.heizung_lueftung_stufe_tag'].state === 0)
return "yellow";
else return "grey";
]]]
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 0
- type: custom:button-card
icon: mdi:fan-speed-1
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 1
- type: custom:button-card
icon: mdi:fan-speed-2
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 2
- type: custom:button-card
icon: mdi:fan-speed-3
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 3
Edit:
I found a solution with Mushroom template cards thats works fine for me:
type: horizontal-stack
title: Lüftungsstufe Tag
cards:
- type: custom:mushroom-template-card
primary: Aus
secondary: ''
icon: mdi:fan-off
entity: sensor.heizung_lueftung_stufe_tag
layout: vertical
icon_color: |
{% if is_state('sensor.heizung_lueftung_stufe_tag', '0') %}
red
{% else %}
grey
{% endif %}
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 0
- type: custom:mushroom-template-card
primary: Stufe 1
secondary: ''
icon: mdi:fan-speed-1
entity: sensor.heizung_lueftung_stufe_tag
layout: vertical
icon_color: |
{% if is_state('sensor.heizung_lueftung_stufe_tag', '1') %}
blue
{% else %}
grey
{% endif %}
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 1
- type: custom:mushroom-template-card
primary: Stufe 2
secondary: ''
icon: mdi:fan-speed-2
entity: sensor.heizung_lueftung_stufe_tag
layout: vertical
icon_color: |
{% if is_state('sensor.heizung_lueftung_stufe_tag', '2') %}
blue
{% else %}
grey
{% endif %}
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 2
- type: custom:mushroom-template-card
primary: Stufe 3
secondary: ''
icon: mdi:fan-speed-3
entity: sensor.heizung_lueftung_stufe_tag
layout: vertical
icon_color: |
{% if is_state('sensor.heizung_lueftung_stufe_tag', '3') %}
blue
{% else %}
grey
{% endif %}
tap_action:
action: call-service
service: modbus.write_register
service_data:
address: 1017
slave: 1
hub: ISG
value: 3