ebnerjoh
(Johannes Ebner)
1
Hi,
I am getting from a weatherstation the time of the latest values via unix time.
I am trying now to convert this via a template, but it doesnt work.
I have the following template, which delivers me the unix time:
sensors:
weather_datetime_template:
value_template: '{{ states.sensor.weather_datetime.state }}'
What do I have to do to get a readable date/time?
Br,
Johannes
finity
2
What do you mean by “unix time”? is it a epoch timestamp or something else?
Post the state of the sensor.weather_datetime.
ebnerjoh
(Johannes Ebner)
3
Hi,
This is the state: 1547396700.0
Br,
Johannes
daveyrb
(Daveyrb)
4
Try This:
‘{{ states.sensor.weather_datetime.state | int | timestamp_custom("%d.%m.%Y %H:%M")}}’
2 Likes
finity
5
try:
{{ states.sensor.weather_datetime.state | timestamp_custom('%Y/%m/%d %H:%M:%S') }}
that will return the date & time in this format “2019/01/13 11:25:00” based on the state you gave me above.
And now for shameless self-promotion I created a thread on manipulating dates & times here:
Maybe you will find it helpful.
1 Like
ebnerjoh
(Johannes Ebner)
6
Thanks daveyrb, that worked.