Templating sunrise time sensor

{{states.sun.sun.attributes.next_rising}} gives me 2019-02-10T06:39:46+00:00

is it possible to strip the output so that only 06:39:46 remains? I would love that for a sensor

and if possible I would like a sensor template that shows me how many hours of the current day that the sun is above the horizon.If thats even possible…?

Yes. Try this:

{{ states.sun.sun.attributes.next_rising.state.split(' ')[1] }}

Sorry, Tom. That template won’t work to get what they want.

Try this:

{{ (states.sun.sun.attributes.next_rising.split('T')[1]).split('+')[0] }}

But even then I not sure that is what the OP wants since that gives the sunrise in UTC.

This will give it in local time (based on your timezone) and it’s easier to read :slightly_smiling_face::

{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom ('%H:%M:%S') }}


Yeah you’re right. I was using sensor.nextsunrise when trying in my template editor. Missed the different output format.

thank you, works nicely :slight_smile: