thomasloven / lovelace-state-switch

🔹Dynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

Can we have as "else" state please? #42

Closed Corneloues closed 3 years ago

Corneloues commented 3 years ago

Like a case statement, it would be great if there was an else: option. I have a series of state switches that work together, based on an input_select, but I don't need to track every single value in each switch. In essence I need:

states:
  'specific':
    type: button
    ...
  else:
    type: button
    ...

This would save me having to replicate the same card multiple times.

Corneloues commented 3 years ago

Of course we don't need an 'else' state. Just set the default to a state called else:


- type: 'custom:state-switch'
  entity: <entity>
  default: else
  transition: flip
  states:
    <the_one_you_really_need>:
      type: button
      ...
    else:
      type: button
      ...