chunkysteveo / OpenEPaperLink-HA-Weatherman

Wetherman EPaper display using OpenEPaperLink and the HA Integration
37 stars 4 forks source link

Use 24h or 12h time #2

Closed svenove closed 1 year ago

svenove commented 1 year ago

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. :)

chunkysteveo commented 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".

svenove commented 1 year ago

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 }}

chunkysteveo commented 1 year ago

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!