WTH there is no catch-all and/or default setting for state_filter and state_image in picture-elements

The state_filter and state_image element options in picture-elements need the list of all states to have a deterministic result, while for many use-cases it could be sufficient to indicate a desired state and have for everything else a default: catch-all and/or a != "desired state" condition.

Example:

  • to show/hide on a floorplan the picture of who is in the room, instead of this code configuration:
type: picture-elements
elements:
  - type: image
    entity: input_select.presence_myroom
    state_image:
      Unknown: /local/images/help-circle-outline.png
      Empty: /local/images/crop-square.png
      Someone: /local/images/account-question.png
      Person1: /local/images/person1.jpg
      Person2: /local/images/person2.jpg
      etc: /local/images/person3.jpg
      # and so on
    state_filter:
      Unknown: opacity(0)
      Empty: opacity(0)
      Someone: opacity(100)
      Person1: opacity(100)
      Person2: opacity(100)
      etc: opacity(100)
      # and so on
image: /local/images/floorplan.jpg
# etc., etc. copy the entire list in a new element for each state
  • we could have a much simpler:
type: picture-elements
elements:
  - type: image
    entity: input_select.presence_myroom
    state_image:
      'default': /local/images/help-circle-outline.png
      Person1: /local/images/person1.jpg
    state_filter:
      'default': opacity(0)
      Person1: opacity(100)
image: /local/images/floorplan.jpg
# also need to copy in a new element, but only for each Person, and much shorter

Let me know what you think.

P.S.: current existing workaround with conditional, but not as elegant as above and doesn’t work if you want to match all exclusions

type: picture-elements
elements:
  - type: conditional
    conditions:
      - entity: input_select.location_person
        state: My Room
    elements:
      - type: image
        entity: input_select.location_person
        style:
          opacity: 1
        image: /local/images/person.jpg
image: /local/images/floorplan.jpg

Same for image card with state images i think… (haven’t found a way to do a catch-all)

1 Like