Hello,
I have defined 3 scripts to get the state of my alarm, arm it and disarm it. When I create a switch, I am able to get the alarm state and change the color and icon for the custom_button. But now I want to execute the arm/disarm script based on the state of the alarm. When I add my shell scripts as an action, it simply does not work. Anyone a suggestion? BTW I am quite a newby with HA ![]()
My code:
type: custom:button-card
name: Alarm
entity: sensor.alarm_status
show_state: true
styles:
card:
- background: "#8abbed"
- color: |
[[[
if (entity.state === 'armed')
return 'red';
if (entity.state === 'arming')
return 'yellow';
if (entity.state === 'disabled')
return 'green';
else
return 'grey';
]]]
- font-size: 12px
state:
- color: |
[[[
if (entity.state === 'armed')
return 'red';
if (entity.state === 'arming')
return 'yellow';
if (entity.state === 'disabled')
return 'green';
else
return 'grey';
]]]
state_display: |
[[[
if (entity.state === 'armed')
return 'Aan';
if (entity.state === 'arming')
return 'Gaat aan...';
else
return 'Uit';
]]]
state:
- value: armed
tap_action:
action:
service: shell_command.alarm_uit
color: red
icon: mdi:alarm-light
- value: arming
color: yellow
icon: mdi:alarm-light
- value: disabled
tap_action:
action:
service: shell_command.alarm_aan
color: green
icon: mdi:alarm-light-off
section_mode: true
grid_options:
rows: 2
columns: 4