mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
alternaitve layout screensaver
This commit is contained in:
39
README.md
39
README.md
@@ -250,7 +250,7 @@ Please see [appdaemon.yaml](appdaemon/appdaemon.yaml) as an exmaple.
|
|||||||
### Configure your NSPanel in AppDaemon
|
### Configure your NSPanel in AppDaemon
|
||||||
|
|
||||||
Confiure your NSPanel as you like, you need to edit the `apps.yaml` inside of your Appdaemon config folder.
|
Confiure your NSPanel as you like, you need to edit the `apps.yaml` inside of your Appdaemon config folder.
|
||||||
You can have multiple nspanel sections.
|
You can have multiple nspanel sections. There are some more exmaples in the appdaemon folder of this repo.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
@@ -270,19 +270,45 @@ nspanel-1:
|
|||||||
value: 0
|
value: 0
|
||||||
locale: "de_DE" # used for translations in translations.py and for localized date if babel python package is installed
|
locale: "de_DE" # used for translations in translations.py and for localized date if babel python package is installed
|
||||||
screensaver:
|
screensaver:
|
||||||
weather: weather.k3ll3r
|
entity: weather.k3ll3r
|
||||||
cards:
|
cards:
|
||||||
- type: cardEntities
|
- type: cardEntities
|
||||||
entities:
|
entities:
|
||||||
- entity: light.example_item
|
- entity: switch.example_item
|
||||||
name: NameOverride
|
name: NameOverride
|
||||||
|
icon: lightbulb
|
||||||
- entity: light.example_item
|
- entity: light.example_item
|
||||||
title: Example Entities
|
- entity: cover.example_item
|
||||||
|
- entity: input_boolean.example_item
|
||||||
|
title: Example Entities 1
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: switch.example_item
|
||||||
|
- entity: delete
|
||||||
|
- entity: cover.example_item
|
||||||
|
- entity: input_boolean.example_item
|
||||||
|
title: Example Entities 2
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: binary_sensor.example_item
|
||||||
|
- entity: sensor.example_item
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: number.example_item
|
||||||
|
title: Example Entities 3
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: scenes.example_item
|
||||||
|
- entity: script.example_item
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: input_button.example_item
|
||||||
|
title: Example Entities 4
|
||||||
- type: cardGrid
|
- type: cardGrid
|
||||||
entities:
|
entities:
|
||||||
- entity: select.example_item
|
|
||||||
- entity: select.example_item
|
|
||||||
- entity: light.example_item
|
- entity: light.example_item
|
||||||
|
- entity: switch.example_item
|
||||||
|
- entity: delete
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: cover.example_item
|
||||||
title: Exmaple Gird
|
title: Exmaple Gird
|
||||||
- type: cardThermo
|
- type: cardThermo
|
||||||
entity: climate.example_item
|
entity: climate.example_item
|
||||||
@@ -338,6 +364,7 @@ key | optional | type | default | description
|
|||||||
`weatherOverrideForecast3` | True | string | `None` | sensor entity from home assistant here to override the third weather forecast item on the screensaver
|
`weatherOverrideForecast3` | True | string | `None` | sensor entity from home assistant here to override the third weather forecast item on the screensaver
|
||||||
`weatherOverrideForecast4` | True | string | `None` | sensor entity from home assistant here to override the forth weather forecast item on the screensaver
|
`weatherOverrideForecast4` | True | string | `None` | sensor entity from home assistant here to override the forth weather forecast item on the screensaver
|
||||||
`doubleTapToUnlock` | True | boolean | `False` | requires to tap screensaver two times
|
`doubleTapToUnlock` | True | boolean | `False` | requires to tap screensaver two times
|
||||||
|
`alternativeLayout` | True | boolean | `False` | alternative layout with humidity
|
||||||
`key` | True | string | `None` | Used by navigate items
|
`key` | True | string | `None` | Used by navigate items
|
||||||
|
|
||||||
#### Schedule sleep brightness
|
#### Schedule sleep brightness
|
||||||
|
|||||||
@@ -15,19 +15,50 @@ nspanel-1:
|
|||||||
value: 0
|
value: 0
|
||||||
locale: "de_DE" # used for translations in translations.py and for localized date if babel python package is installed
|
locale: "de_DE" # used for translations in translations.py and for localized date if babel python package is installed
|
||||||
screensaver:
|
screensaver:
|
||||||
weather: weather.k3ll3r
|
entity: weather.k3ll3r
|
||||||
|
weatherOverrideForecast4:
|
||||||
|
entity: sensor.example_item
|
||||||
|
name: name
|
||||||
|
icon: lightbulb
|
||||||
|
alternativeLayout: True
|
||||||
cards:
|
cards:
|
||||||
- type: cardEntities
|
- type: cardEntities
|
||||||
entities:
|
entities:
|
||||||
- entity: light.example_item
|
- entity: switch.example_item
|
||||||
name: NameOverride
|
name: NameOverride
|
||||||
|
icon: lightbulb
|
||||||
- entity: light.example_item
|
- entity: light.example_item
|
||||||
title: Example Entities
|
- entity: cover.example_item
|
||||||
|
- entity: input_boolean.example_item
|
||||||
|
title: Example Entities 1
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: switch.example_item
|
||||||
|
- entity: delete
|
||||||
|
- entity: cover.example_item
|
||||||
|
- entity: input_boolean.example_item
|
||||||
|
title: Example Entities 2
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: binary_sensor.example_item
|
||||||
|
- entity: sensor.example_item
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: number.example_item
|
||||||
|
title: Example Entities 3
|
||||||
|
- type: cardEntities
|
||||||
|
entities:
|
||||||
|
- entity: scenes.example_item
|
||||||
|
- entity: script.example_item
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: input_button.example_item
|
||||||
|
title: Example Entities 4
|
||||||
- type: cardGrid
|
- type: cardGrid
|
||||||
entities:
|
entities:
|
||||||
- entity: select.example_item
|
|
||||||
- entity: select.example_item
|
|
||||||
- entity: light.example_item
|
- entity: light.example_item
|
||||||
|
- entity: switch.example_item
|
||||||
|
- entity: delete
|
||||||
|
- entity: button.example_item
|
||||||
|
- entity: cover.example_item
|
||||||
title: Exmaple Gird
|
title: Exmaple Gird
|
||||||
- type: cardThermo
|
- type: cardThermo
|
||||||
entity: climate.example_item
|
entity: climate.example_item
|
||||||
|
|||||||
@@ -77,13 +77,14 @@ class LuiBackendConfig(object):
|
|||||||
}],
|
}],
|
||||||
'screensaver': {
|
'screensaver': {
|
||||||
'type': 'screensaver',
|
'type': 'screensaver',
|
||||||
'weather': 'weather.example',
|
'entity': 'weather.example',
|
||||||
'weatherUnit': 'celsius',
|
'weatherUnit': 'celsius',
|
||||||
'weatherOverrideForecast1': None,
|
'weatherOverrideForecast1': None,
|
||||||
'weatherOverrideForecast2': None,
|
'weatherOverrideForecast2': None,
|
||||||
'weatherOverrideForecast3': None,
|
'weatherOverrideForecast3': None,
|
||||||
'weatherOverrideForecast4': None,
|
'weatherOverrideForecast4': None,
|
||||||
'doubleTapToUnlock': False
|
'doubleTapToUnlock': False,
|
||||||
|
'alternativeLayout': False
|
||||||
},
|
},
|
||||||
'hiddenCards': []
|
'hiddenCards': []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ class LuiController(object):
|
|||||||
self.register_callbacks()
|
self.register_callbacks()
|
||||||
|
|
||||||
# register callbacks for each time
|
# register callbacks for each time
|
||||||
if type(self._config.get("brightnessScreensaver")) == list:
|
if type(self._config.get("sleepBrightness")) == list:
|
||||||
for index, timeset in enumerate(self._config.get("brightnessScreensaver")):
|
for index, timeset in enumerate(self._config.get("sleepBrightness")):
|
||||||
self._ha_api.run_daily(self.update_screensaver_brightness, timeset["time"], value=timeset["value"])
|
self._ha_api.run_daily(self.update_screensaver_brightness, timeset["time"], value=timeset["value"])
|
||||||
|
|
||||||
# calculate current brightness
|
# calculate current brightness
|
||||||
self.current_screensaver_brightness = self.calc_current_screensaver_brightness()
|
self.current_screensaver_brightness = self.calc_current_screensaver_brightness()
|
||||||
# call update_screensaver_brightness on changes of entity configured in brightnessScreensaverTracking
|
# call update_screensaver_brightness on changes of entity configured in brightnessScreensaverTracking
|
||||||
bst = self._config.get("brightnessScreensaverTracking")
|
bst = self._config.get("sleepTracking")
|
||||||
if bst is not None and self._ha_api.entity_exists(bst):
|
if bst is not None and self._ha_api.entity_exists(bst):
|
||||||
self._ha_api.listen_state(self.update_screensaver_brightness_state_callback, entity_id=bst)
|
self._ha_api.listen_state(self.update_screensaver_brightness_state_callback, entity_id=bst)
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ class LuiController(object):
|
|||||||
self._pages_gen.update_date("")
|
self._pages_gen.update_date("")
|
||||||
|
|
||||||
# set screensaver timeout
|
# set screensaver timeout
|
||||||
timeout = self._config.get("timeoutScreensaver")
|
timeout = self._config.get("sleepTimeout")
|
||||||
self._send_mqtt_msg(f"timeout~{timeout}")
|
self._send_mqtt_msg(f"timeout~{timeout}")
|
||||||
|
|
||||||
# set current screensaver brightness
|
# set current screensaver brightness
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
def update_screensaver_weather(self):
|
def update_screensaver_weather(self):
|
||||||
global babel_spec
|
global babel_spec
|
||||||
we_name = self._config.get("screensaver.weather")
|
screensaver_config = self._config._config_screensaver
|
||||||
unit = self._config.get("screensaver.weatherUnit")
|
we_name = self._config._config_screensaver.entity.entityId
|
||||||
|
unit = self._config._config_screensaver.raw_config.get("weatherUnit", "celsius")
|
||||||
|
|
||||||
if self._ha_api.entity_exists(we_name):
|
if self._ha_api.entity_exists(we_name):
|
||||||
we = self._ha_api.get_entity(we_name)
|
we = self._ha_api.get_entity(we_name)
|
||||||
@@ -75,7 +76,7 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
weather_res = ""
|
weather_res = ""
|
||||||
for i in range(1,5):
|
for i in range(1,5):
|
||||||
wOF = self._config.get(f"screensaver.weatherOverrideForecast{i}")
|
wOF = self._config._config_screensaver.raw_config.get(f"weatherOverrideForecast{i}")
|
||||||
if wOF is None:
|
if wOF is None:
|
||||||
up = we.attributes.forecast[i-1]['datetime']
|
up = we.attributes.forecast[i-1]['datetime']
|
||||||
up = datetime.datetime.fromisoformat(up)
|
up = datetime.datetime.fromisoformat(up)
|
||||||
@@ -87,16 +88,20 @@ class LuiPagesGen(object):
|
|||||||
down = convert_temperature(we.attributes.forecast[i-1]['temperature'], unit)
|
down = convert_temperature(we.attributes.forecast[i-1]['temperature'], unit)
|
||||||
else:
|
else:
|
||||||
LOGGER.info(f"Forecast {i} is overriden with {wOF}")
|
LOGGER.info(f"Forecast {i} is overriden with {wOF}")
|
||||||
icon = wOF.iconOverride
|
icon = wOF.get("icon")
|
||||||
name = wOF.nameOverride
|
name = wOF.get("name")
|
||||||
entity = self._ha_api.get_entity(wOF.entityId)
|
entity = self._ha_api.get_entity(wOF.get("entity"))
|
||||||
up = name if name is not None else entity.attributes.friendly_name
|
up = name if name is not None else entity.attributes.friendly_name
|
||||||
icon = get_icon_id_ha("sensor", state=entity.state, device_class=entity.attributes.get("device_class", ""), overwrite=icon)
|
icon = get_icon_id_ha("sensor", state=entity.state, device_class=entity.attributes.get("device_class", ""), overwrite=icon)
|
||||||
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
||||||
down = f"{entity.state} {unit_of_measurement}"
|
down = f"{entity.state} {unit_of_measurement}"
|
||||||
weather_res+=f"~{up}~{icon}~{down}"
|
weather_res+=f"~{up}~{icon}~{down}"
|
||||||
|
|
||||||
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}")
|
altLayout = ""
|
||||||
|
if self._config._config_screensaver.raw_config.get("alternativeLayout", False) is True:
|
||||||
|
altLayout = f"~26~{we.attributes.humidity} %"
|
||||||
|
|
||||||
|
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
|
||||||
|
|
||||||
def generate_entities_item(self, entity):
|
def generate_entities_item(self, entity):
|
||||||
entityId = entity.entityId
|
entityId = entity.entityId
|
||||||
@@ -326,6 +331,9 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
def render_card(self, card, send_page_type=True):
|
def render_card(self, card, send_page_type=True):
|
||||||
LOGGER.info(f"Started rendering of page {card.pos} with type {card.cardType}")
|
LOGGER.info(f"Started rendering of page {card.pos} with type {card.cardType}")
|
||||||
|
if len(self._config._config_cards) == 1:
|
||||||
|
navigation = "0|0"
|
||||||
|
else:
|
||||||
navigation = "1|1"
|
navigation = "1|1"
|
||||||
if card.pos is None:
|
if card.pos is None:
|
||||||
navigation = "2|0"
|
navigation = "2|0"
|
||||||
|
|||||||
70
info.md
70
info.md
@@ -2,72 +2,4 @@
|
|||||||
|
|
||||||
Checkout [README](https://github.com/joBr99/nspanel-lovelace-ui/blob/main/README.md) for detailed Instructions.
|
Checkout [README](https://github.com/joBr99/nspanel-lovelace-ui/blob/main/README.md) for detailed Instructions.
|
||||||
|
|
||||||
### App Configuration
|

|
||||||
|
|
||||||
```yaml
|
|
||||||
---
|
|
||||||
nspanel-1:
|
|
||||||
module: nspanel-lovelace-ui
|
|
||||||
class: NsPanelLovelaceUIManager
|
|
||||||
config:
|
|
||||||
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
|
|
||||||
panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend"
|
|
||||||
updateMode: "auto-notify"
|
|
||||||
timeoutScreensaver: 20
|
|
||||||
#brightnessScreensaver: 10
|
|
||||||
brightnessScreensaver:
|
|
||||||
- time: "7:00:00"
|
|
||||||
value: 10
|
|
||||||
- time: "23:00:00"
|
|
||||||
value: 0
|
|
||||||
locale: "de_DE" # only used if babel python package is installed
|
|
||||||
dateFormatBabel: "full" # only used if babel python package is installed
|
|
||||||
# formatting options on https://babel.pocoo.org/en/latest/dates.html?highlight=name%20of%20day#date-fields
|
|
||||||
timeFormat: "%H:%M"
|
|
||||||
dateFormat: "%A, %d. %B %Y" # ignored if babel python package is installed
|
|
||||||
weather: weather.example
|
|
||||||
pages:
|
|
||||||
- type: cardEntities
|
|
||||||
heading: Example Page 1
|
|
||||||
items:
|
|
||||||
- cover.example_cover
|
|
||||||
- switch.example_switch
|
|
||||||
- input_boolean.example_input_boolean
|
|
||||||
- sensor.example_sensor
|
|
||||||
- type: cardEntities
|
|
||||||
heading: Example Page 2
|
|
||||||
items:
|
|
||||||
- button.example_button
|
|
||||||
- input_button.example_input_button
|
|
||||||
- light.light_example
|
|
||||||
- delete # (read this as 'empty')
|
|
||||||
- type: cardEntities
|
|
||||||
heading: Example Page 3
|
|
||||||
items:
|
|
||||||
- scene.example_scene
|
|
||||||
- delete
|
|
||||||
- delete
|
|
||||||
- delete
|
|
||||||
- type: cardGrid
|
|
||||||
heading: Example Page 4
|
|
||||||
items:
|
|
||||||
- light.light_example
|
|
||||||
- button.example_button
|
|
||||||
- cover.example_cover
|
|
||||||
- scene.example_scene
|
|
||||||
- switch.example_switch
|
|
||||||
- delete
|
|
||||||
- type: cardThermo
|
|
||||||
heading: Exmaple Thermostat
|
|
||||||
item: climate.example_climate
|
|
||||||
- type: cardMedia
|
|
||||||
item: media_player.spotify_user
|
|
||||||
- type: cardAlarm
|
|
||||||
item: alarm_control_panel.alarmo
|
|
||||||
```
|
|
||||||
|
|
||||||
key | optional | type | default | description
|
|
||||||
-- | -- | -- | -- | --
|
|
||||||
`module` | False | string | | The module name of the app.
|
|
||||||
`class` | False | string | | The name of the Class.
|
|
||||||
`config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel
|
|
||||||
Reference in New Issue
Block a user