Show next dawn/next dusk in lovelace entities card

noob question: I’d like to put the time of the next dawn/next dusk in an entities card from the sun component. I am not sure how to extract this information from the component, although i feel this should be quite easy! In my ui-lovelace.yaml I’ve tried:

views:
  - title: Climate
    cards:
      - type: entities
        title: Solar info
        entities:
          - entity: sun.next_dusk
          - entity: sun.next_dawn

In my configuration.yaml I also have

sun:

And i am getting the “Entity not available, etc” highlighted in yellow in the output

1 Like

I think this is the best you’ll get unless something else has been added to change Lovelace funtionality:

Thanks finity, i gave it a go without any success, although i am unsure my implementation was correct. I copied the js file to /config/www/ and included this at the top of my ui-lovelace.yaml:

resources:
  - url: /local/entity-attributes-card.js?v=2
    type: js

Then:

views:
  - title: CLimate
    cards:
      - type: custom:entity-attributes-card
        title: Attributes Card
        heading_name: List
        heading_state: States
        filter:
          include:
            - key: sun.next_dusk

Take a look here to create a sensor from an attribute:

1 Like

That’s too easy!

I was looking for new-fangled Lovelace way of doing things…:smile:

This way you can not only display it - like @jamq’s solution does and I have a few of these myself - it also allows you to refer to the sensors in automations.

1 Like

Agreed.

I was just responding to the OP’s use case.

Your way is definitely better if you have the need to use the sensor in further automations.

Just depends on what you’re trying to do.

And as much as I like Lovelace, I find myself too often trying to ‘put programmatic approaches’ into what I think I should keep to ‘just setting up display functionality’.

Just tried @chairstacker’s solution and got it to work! So thank you. :smiley:

Your solution was also more generally helpful in helping me to understand how the attributes of components such as sun are structured.