Lovelace UI Sunset Filter

Hey, just getting started with Lovelace but I was wondering if anyone knows of a way I could have my Lovelace UI only show certain entities or a specific card only after sunset. I don’t want my floodlights/outdoor lights to show up unless the sun is down… any suggestions would be appreciated.

Because Lovelace updates dynamically from the .yaml file, I wonder if it would be possible to set up an automation that at a specified time would switch out the entire ui_lovelace.yaml file with an alternate version. It might be totally not possible, but it’s a thought!

That sounds like a good idea I could probably do it with a command line script… thanks.

I think you can use the entity-filter to handle this. Here’s something I’ve added to display weather warnings which is conditional on having an active warning. You could probably utilize the sun state (above/below horizon) for state_filter.

      - type: entity-filter
        entities:
          - sensor.pws_alerts
        state_filter:
          - '1'
          - '2'
          - '3'
          - '4'
        card:
          type: markdown
          content: >
            ## {{ sensor.pws_alerts.attributes.Description }}

            {{ sensor.pws_alerts.attributes.Message }}

            Expires at {{ sensor.pws_alerts.attributes.Expires }}
        show_empty: false

Edit: Eh, it doesn’t quite work like desired. If you use a glance card, it displays the entities with the specified state. It’s not obvious how you can display different entities, based on the state of another entity. Here’s my code if you’d like to try it out. It appears that the entities specified in the bottom are ineffective/ignored.

  - type: entity-filter
    entities:
      - sun.sun
      - light.porch_lights
      - light.driveway_lights
      - switch.wemo_walkway_lights
    state_filter:
      - "above_horizon"
      - "on"
    card:
      type: glance
      title: Devices
      entities:
        - light.porch_lights
        - light.driveway_lights
        - switch.wemo_walkway_lights
    show_empty: false