chunk
(Daniel Lindsay)
1
{% if is_state("sensor.filey_tide", "Falling") %}Low{% else %}High{%
endif %} is {{ min(state_attr('sensor.filey_tide',
'next_high_tide_at'), state_attr('sensor.filey_tide',
'next_low_tide_at')) }}.
Currently, my tidal sensor outputs the full date and time - using the code above how would I get JUST the time?
CURRENT
Low is 2022-08-31 13:56:32
WHAT I NEED
Low is 13:56:32
Markus99
(Mark)
2
I’ve used this with much success to convert dates / times: The EPIC Time Conversion and Manipulation Thread!
Here’s an example of what I was playing with last night to help my daughter with her morning alarm:
{% set time = states('sensor.upbr_google_alarms') %}
{% set ftime = as_timestamp(time)|timestamp_custom('%-H:%M %p') %}
{{ time }}
{{ ftime }}
Resulting in:
2022-09-01T06:05:00-05:00
6:05 AM
chunk
(Daniel Lindsay)
3
@Markus99 Thanks for this. Spent a couple of days on it and can’t seem to get this to work.
Markus99
(Mark)
4
Hmmmm…
I just put this in my template editor:
{% set time = '2022-08-31 13:56:32'%}
{% set ftime = as_timestamp(time)|timestamp_custom('%-H:%M:%S') %}
{{ time }}
{{ ftime }}
resulting in:
I simply grabbed the date/time format you pasted in your original post.
You should be able to change the %-H:%M:%S
using the link I posted previously to get to your desired format.