mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
add optional timezone parameter on screensaver time (#1027)
* add optional timezone parameter on screensaver time Signed-off-by: Jean 'henyxia' Wasilewski <henyxia@revs0.com> * change config name * Update config-overview.md * Update config-overview.md --------- Signed-off-by: Jean 'henyxia' Wasilewski <henyxia@revs0.com> Co-authored-by: Johannes <29555657+joBr99@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
from dateutil import tz
|
||||||
import dateutil.parser as dp
|
import dateutil.parser as dp
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -108,10 +109,17 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
|
|
||||||
def update_time(self, kwargs):
|
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")
|
addTemplate = self._config.get("timeAdditionalTemplate")
|
||||||
addTimeText = apis.ha_api.render_template(addTemplate)
|
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):
|
def update_date(self, kwargs):
|
||||||
global babel_spec
|
global babel_spec
|
||||||
|
|||||||
@@ -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') }}"`
|
`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
|
`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
|
`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`
|
`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
|
`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
|
`screensaver` | True | complex | | configuration for screensaver; see docs for screensaver
|
||||||
|
|||||||
Reference in New Issue
Block a user