Template issue with strptime

Hi after update the HA i have problem with this template :

{{ ((as_timestamp(strptime(state_attr("sun.sun", "next_setting"), "")) - 3600 ) - as_timestamp(strptime(state_attr("sun.sun", "next_rising"), ""))) | timestamp_custom('%H:%M') }}

i get error :
ValueError: Template error: strptime got invalid input ‘2022-08-02T18:26:15.892351+00:00’ when rendering template ‘{{ ((as_timestamp(strptime(state_attr(“sun.sun”, “next_setting”), “”)) - 3600 ) - as_timestamp(strptime(state_attr(“sun.sun”, “next_rising”), “”))) | timestamp_custom(’%H:%M’) }}

before update this work properly
can someone help me pls, very thanks :slight_smile:

You donot need the strptime when using timestamp…e.g. check this and use Dev tools > templates

{{ ((as_timestamp(state_attr("sun.sun", "next_setting")) - 3600 ) - as_timestamp(state_attr("sun.sun", "next_rising"))) | timestamp_custom('%H:%M') }}
1 Like

Thanks you.

pls mark for solution then :slight_smile:

How to do this? :grimacing:

Is not really important but nice to see for others that it is closed… in one of my posts you have icons bottom right, one of them tags for solved/solution

I don’t see that possibility, maybe it’s not possible

This is a bit off-topic, but you may want to look at the HA-Sun2 custom component which can create a number of sun-related sensors that are not included in the core Sun integration, including one that show the duration of night.