EDIT Button Entity Row isn’t maintain anymore. I replaced it with Paper Buttons Row (via HACS)
Hi All!
Can’t imagine my question was not asked yet but i am unable to find the correct answer, so here it comes.
I currently have running Home Assistant 0.99.3 with a Xiaomi Gateway as (basic) Alarm.
Recently i have added ‘Button Entity Row’ to my project and ‘Clear Theme Dark’.
This gives me the option to give a custom card which can look like this:
On the page shown above there is a simple card above ‘Lampen’. Behind these buttons i can configure scene’s, script’s of switches (maybe even more).
What do i want to accomplish, the 3th button is a button to arm/disarm my alarm. This is working but what i am missing is that the button changes/shows the state of the alarm.
After some googling i found a thread advising me to create a custom sensor where i would change the icon state of the custom sensor following the state of the switch (if that makes sense)
code:
- platform: template
sensors:
alarm_status:
value_template: '{{ states.switch.xiaomi_gateway_alarm.attributes.state_value}}'
friendly_name: 'Alarm Status'
icon_template: '{%- if is_state("switch.xiaomi_gateway_alarm", "on") %}mdi:shield-home{% else %}mdi:shield-home-outline{%- endif %}'
In the below screen also a view of the developer tools (filtered on my alarm)
Then there is the code i have for my Custom Card found in my RAW Config Editor:
- badges: []
cards:
- buttons:
- entity: scene.thuis
icon: 'mdi:home'
style:
- color: white
- entity: scene.tv_kijken
icon: 'mdi:television'
style:
- color: white
- entity: switch.xiaomi_gateway_alarm
icon: 'mdi:shield-home'
style:
- color: white
- entity: scene.slapen
icon: 'mdi:brightness-3'
style:
- color: white
- entity: scene.alloff
icon: 'mdi:close-box'
style:
- color: white
type: 'custom:button-entity-row'
for the entity ‘switch.xiaomi_gateway_alarm’ i tried the following for ‘icon:’ but all outputted just the code as plain text instead of the value.
- entity: switch.xiaomi_gateway_alarm
icon: '{{ states.sensor.alarm_status.attributes.icon}}'
- entity: switch.xiaomi_gateway_alarm
icon: "if (state === 'on') return 'mdi:shield-home'; else return 'mdi:shield-home-outline';"
- entity: switch.xiaomi_gateway_alarm
icon: >
{% if is_state('switch.xiaomi_gateway_alarm','on') %} mdi:shield-home-
{% else %} mdi:shield-home-outline
% endif %}
I tried to explain as clearly as possible and hope it makes sense and there is an solution to it.
(Bonus would be to change the color)