Yeah, I read and parsed this too - but this should work equally well with H M S in both locations
I didn’t know that you could do arithmetic with differing time formats is all
Learnt something new, but I always use H M S, don’t like this latin ‘sugar’
Cheers
Thanks, can you please list all of the configuration.yaml template setting ? since I am getting an error message trying your solution
Regards
David
Post your’s and I’ll help you fix it. Gotta learn to fish my friend
wow thats a great find…
traveling to the largest muslim country in the world myself shortly, this might be very practical to have at hand.
Though, I take it it calculates the prayer_times based on the HomeAssistant instance lat/long settings? Could this be made into a travel component somehow, following ones own gps coordinates?
I do have the utc-offset, but not sure if that is useful regarding the prayer-times, which probably will be not simply + or - the offset?
value_template: >
{% set state = states.device_tracker.me %}
{% if state.attributes is defined and
state.attributes.time_zone is defined and
state.attributes.time_zone != 'unknown' %}
{% set n = now() %}
{{ (n.astimezone(state.attributes.last_seen.tzinfo).utcoffset() -
n.utcoffset()).total_seconds()/3600 }}
{% else %}
unknown
{% endif %}
it would have to be made into a custom component and it would require major changes.
a I see, well maybe not remake the component, but calculate the outcome of the sensor to the time the device is in.
not familiair with these prayer standards myself, how would I be able to find the local method of calculating these times?
I’ve got this https://www.islamicfinder.org/world/indonesia/ but they dont list the method used
Maybe I should create a separate thread for this, sorry wont diverge further here, and go to Calculate islamic prayer time on device's location?
I don’t know, i didn’t make the component, I only know about it.
Perfect! Worked for me!
With a small “float-trick”, you can draw graphs also the (based on @DavidFW1960 solution):
sensor:
- platform: template
sensors:
nextsunrise:
entity_id: sun.sun
friendly_name: 'Next Sunrise'
icon_template: mdi:weather-sunset-up
unit_of_measurement: ' '
value_template: >
{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%H.%M') }}
nextsunset:
entity_id: sun.sun
friendly_name: 'Next Sunset'
icon_template: mdi:weather-sunset-down
unit_of_measurement: ' '
value_template: >
{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom('%H.%M') }}
There is a simpler way to add “Next Sunrise” and “Next Sunset” values in an entities card:
type: entities
entities:
- entity: sun.sun
name: Next Sunrise
type: attribute
attribute: next_rising
format: time
- entity: sun.sun
name: Next Sunset
type: attribute
attribute: next_setting
format: time
Beau,
Thank you for that very elegant solution.
One question: how do I get the mentioned time “below” the icon instead of next to it?
I have the problem that when I use the “Glance” card, which does put the label below the icon, not the time is shown, but the text “below horizon” or similar. I seem not to figure out how to keep the time instead…
Sorry, no idea how to do that.
You have to make a template sensor to extract an attribute for glance cards.
not the same as you asked for, but very nice indeed: GitHub - AitorDB/home-assistant-sun-card: Home assistant sun card based on Google weather design
Works perfect for me. Thank you very much!!!
Thanks Petro,
But I guess before I get that to work, I have to brush up my lexicon
I’ll look into the Template sensor stuff. Guess the concept is to just grab the value of the sun module and have it as output.
@Mariusthvdb: that is actually not bad looking at all. It will be very good Plan B for me.
Worked like a charm… any way to make it show 24 hour clock?
Yes it’s simple. Just google timestamp_custom + Jinja and it will give you what to replace timestamp_custom(’ %I:%M %p’) with
I appreciate this was a long time ago, but thanks for sharing this. It was exactly what I wanted to add for my solar panel/energy dashboard.
Looks like this repository was archived today… Are you or do you know the author?
I’ve made a copy just in case, but I’d like an OK from the author to publish that back into HACS and resume its maintenance.