My Lovelace Plugins

state-switch

I like the conditional card and its ability to dynamically change the interface a bit, but if you want to switch between two different cards, you need to add two conditional cards… And if you want even more it quickly grows.

So I made state-switch which allows you to switch in a card based on a dictionary of entity states.

- type: custom:state-switch
  entity: device_tracker.my_phone
  states:
    home:
      [definition of one card]
    work:
      [definition of another card]
    not_home:
      [and yet another]

While I use this in my own configuration, I almost decided against releasing it publicly beacuse the same thing can also be done with conditional… but then I realized something… I could easily make it switch depending on user name instead.

- type: custom:state-switch
  entity: user
  default: all_other
  states:
    admin:
      type: entity-button
      entity: switch.self_destruct
    all_other:
      type: markdown
      content: >
        ## You're not supposed to be here!

5 Likes