Closed svenove closed 1 year ago
I don't think there is a specified time display option in Home Assistant that you can tap into? The Met.no sensor displays the time in standard timestamp format and the template filters that to how you'd like it displayed (1 PM for example, or 13) via python "timestamp_custom".
No worries, could simply add a line in the Readme.md about what to change to use 24h instead of 12h and it could easily be changed by those who want it. :)
Btw, couldn't this be "compressed" a bit?
{{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%p') }}
isn't that the same as this?
{{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%I %p') | int }}
I'll update the readme with a 12 and 24 example.
You were close with the idea to compress it - don't want the "| int
" at the end, as that would turn it in to an integer. This is what is now in the sensor:
{{ as_timestamp(weather_home_hourly.forecast[0].datetime) | timestamp_custom('%I %p') }}
Nice and neat, thanks!
Not sure if this is a setting that can be retrieved from HASS or not, but it would be nice of the template selected 24h or 12h time based on the HASS-locale (or something?).
I manually changed all these:
{{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%p') }}
to{{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%H') | int }}
...and that did what I want, but if it was possible to have it happen automatically, that would be even better for us newbies. :)