diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index aa8d0f97..a9e157b6 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -1,4 +1,5 @@ import datetime +from dateutil import tz import dateutil.parser as dp import time @@ -108,10 +109,17 @@ class LuiPagesGen(object): def update_time(self, kwargs): - time = datetime.datetime.now().strftime(self._config.get("timeFormat")) + time = None + # get current time, with timezone if set + if self._config.get("timezone"): + timezone = tz.gettz(self._config.get("timezone")) + time = datetime.datetime.now(tz=timezone) + else: + time = datetime.datetime.now() + nice_time = time.strftime(self._config.get("timeFormat")) addTemplate = self._config.get("timeAdditionalTemplate") addTimeText = apis.ha_api.render_template(addTemplate) - self._send_mqtt_msg(f"time~{time}~{addTimeText}") + self._send_mqtt_msg(f"time~{nice_time}~{addTimeText}") def update_date(self, kwargs): global babel_spec diff --git a/docs/config-overview.md b/docs/config-overview.md index c0d8caaa..d532403c 100644 --- a/docs/config-overview.md +++ b/docs/config-overview.md @@ -68,6 +68,7 @@ key | optional | type | default | description `dateAdditionalTemplate` | True | string | `""` | Addional Text dispayed after Date, can contain a Homeassistant Template Example `" - {{ states('sun.sun') }}"` `timeAdditionalTemplate` | True | string | `""` | Addional Text dispayed below Time, can contain a Homeassistant Template `dateFormat` | True | string | `%A, %d. %B %Y` | date format used if babel is not installed +`timezone` | True | string | "" | Timezone for the time on the panel: `Europe/Berlin` - See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of TZ Identifiers (supported from upcoming version v4.4) `defaultBackgroundColor` | True | string | ha-dark | backgroud color of all cards, valid values: `black`, `ha-dark` `cards` | False | complex | | configuration for cards that are displayed on panel; see docs for cards `screensaver` | True | complex | | configuration for screensaver; see docs for screensaver