I am trying to get today’s sunset time to use in a TTS script to my Alexa device. If I use this code:
sun_nextsunset:
device_class: timestamp
friendly_name: 'Next Sunset'
value_template: >
{{ as_timestamp(state_attr('sun.sun','next_setting')) | timestamp_local }}
I get the value of “February 8, 2022 5:21 PM”, I’m trying to get just the “5:21 PM” part. When I try this code I get an “Unknown” result:
sun_nextsunsettime:
device_class: timestamp
friendly_name: 'Next Sunset Time'
value_template: >
{{ as_timestamp(state_attr('sun.sun','next_setting')) | timestamp_custom('%I:%M %p') }}
I’m not sure if it’s typo, a formatting error, or me just not knowing what I’m doing. A nudge in the right direction would be appreciated.