I’m stuck, so need some help please. I am trying to make my sun.sun sensor a bit nicer looking and successfully have this:
- platform: template
sensors:
sunphases:
entity_id: sun.sun
friendly_name: 'Sun'
value_template: >-
{% if is_state('sun.sun', 'above_horizon') %}
Sun Up
{% elif is_state('sun.sun', 'below_horizon') %}
Sun Down
{% endif %}
entity_picture_template: >-
{% if is_state('sun.sun', 'above_horizon') %}
/local/sunphases/sunsup.png
{% elif is_state('sun.sun', 'below_horizon') %}
/local/sunphases/sunsdown.png
{% endif %}
If I click on my displayed sensor - I can only see whether it is above or below the horizon, as per my definitions above. I’d like it to display extra attributes like the default sun.sun sensor shows. Namely… next_rising:
, next_setting:
and elevation:
Ideally my custom “Sunphases” sensor will show exactly like this…
I can pull the attributes with eg. {{states.sun.sun.attributes.elevation}}
. BUT I am at a complete loss as to how to implement these 3 extra attributes into my above code block. Complete loss! Do I add it into the existing value_template:
part, or do I have to define more sensors with something like sunphases.elevation
? As you can see, I am a bit lost. Please offer some tips. Thanks!
I have 2 packages here… weather and timetides
Also go up one directory level and you can see my ui-lovelace.yaml that makes the card
Is that kind of what you were looking for?
2 Likes
Hi David. That’s very impressive and it’s sparked some ideas. But I still would like to inject 3 attributes from sun.sun
into sensor.sunphases
I don’t understant what/why you want that. The sun.sun shows:
I am running Phil Bruckner’s one not the stock one… but surely you just want to show on a Lovelace card?
I don’t think short of writing your own sun component you can include them as sensor attributes… but maybe you can… I’ve just never wanted to do that.
Because I can’t have sun.sun use my custom .png files. Or can I? I thought I could only use customize.yaml to set one entity picture, not 2 as I have it in my sensor template. So once I have made the switch to sensor.sunphases, which I have displayed on a glance card - I want to click it and see all the sun stats I used to have access to. Does that make sense?
You can’t set png for attributes but you can create sensors and do that… still not sure why you want that for a more-info rather than just show on a lovelace card…
Just to save on real estate. Just a preference to have it show minimally on a glance card and then if the user wants more info you click on it. I suppose it can’t be done.
Maybe one day the developers will give us:
attributes_template:
attri.elevation: "{{states.sun.sun.attributes.elevation}}"
attri.next_rising: "{{states.sun.sun.attributes.next_rising}}"
attri.next_setting: "{{states.sun.sun.attributes.next_setting}}"
But I’m dreamin’
BTW - Thanks heaps for your screenshot. I was using northern hemisphere moon pictures. Doh! I was wondering why my filenames had the prepend “N”. Now I have “S” versions.
hahahaha!!! yeah that one got me too way back…