Using ‘state-switch’ by @thomasloven for essentially radio buttons. I have this essentially working as I expect, however I need to know 2 things:
- is it possible to shorten my yaml code? For each button there are 4 states: 0, 1, 2, 3 and 3 of those states are identical. Is there way to express states: ‘0’ and then states: ‘1’, ‘2’,‘3’ for the first button, etc. Wording it another way: for each of 4 buttons there is 24 lines of repetitive yaml that I should be able to eliminate. Essentially 212 total lines should be able to be 116 but I can’t figure out how to express 1|2|3: as a single
<state>:
EDIT#1: yaml has been simplfied. @JTPublic points out below that is a great use for the default:
attribute. That worked.
Still needing help with #2 tho… it’s a CSS question essentially… not my stong point but normally I can figure it out… not this time.
- any suggestions how I can get the icon to show the ‘on’ state for the selected button? When I originally conceived this mess (lol) I thought state_color: would work, but I understand now why I was mistaken. I also have card-mod installed and I’ve been messing with it for
anseveral hour but so far no wins.
Edit 2:
I win! finally figured out the CSS to use a card-mod style:
element:
style: |
:host {
--paper-item-icon-color: #1A89F5;
}
Thanks in Advance for any helpful suggestions!!!
type: grid
columns: 4
title: Front Lights
cards:
- type: 'custom:state-switch'
entity: sensor.sfrontlightswitch_ha
transition: null
transition_time: 0
states:
'0':
type: button
tap_action:
action: none
entity: null
name: Day
icon: 'mdi:lightbulb'
state_color: true
'1':
type: button
entity: null
name: Day
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: 011F
command: run_then
isy: ISY
'2':
type: button
entity: null
name: Day
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: 011F
command: run_then
isy: ISY
'3':
type: button
entity: null
name: Day
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: 011F
command: run_then
isy: ISY
- type: 'custom:state-switch'
entity: sensor.sfrontlightswitch_ha
transition: null
transition_time: 0
states:
'0':
type: button
entity: null
name: Evening
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0120'
command: run_then
isy: ISY
'1':
type: button
tap_action:
action: none
entity: null
name: Evening
icon: 'mdi:lightbulb'
icon_state: true
'2':
type: button
entity: null
name: Evening
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0120'
command: run_then
isy: ISY
'3':
type: button
entity: null
name: Evening
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0120'
command: run_then
isy: ISY
- type: 'custom:state-switch'
entity: sensor.sfrontlightswitch_ha
transition: null
transition_time: 0
states:
'0':
type: button
entity: null
name: Late Night
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0121'
command: run_then
isy: ISY
'1':
type: button
entity: null
name: Late Night
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0121'
command: run_then
isy: ISY
'2':
type: button
tap_action:
action: none
entity: null
name: Late Night
icon: 'mdi:lightbulb'
icon_state: true
'3':
type: button
entity: null
name: Late Night
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0121'
command: run_then
isy: ISY
- type: 'custom:state-switch'
entity: sensor.sfrontlightswitch_ha
transition: null
transition_time: 0
states:
'0':
type: button
entity: null
name: Bright
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0122'
command: run_then
isy: ISY
'1':
type: button
entity: null
name: Bright
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0122'
command: run_then
isy: ISY
'2':
type: button
entity: null
name: Bright
icon: 'mdi:lightbulb'
icon_state: false
tap_action:
action: call-service
service: isy994.send_program_command
service_data:
address: '0122'
command: run_then
isy: ISY
'3':
type: button
tap_action:
action: none
entity: null
name: Bright
icon: 'mdi:lightbulb'
icon_state: true
=