diff --git a/HMI/README.md b/HMI/README.md index 7950e59f..164155c8 100644 --- a/HMI/README.md +++ b/HMI/README.md @@ -94,9 +94,418 @@ change the page type: ### screensaver page -`weatherUpdate~tMainIcon~tMainText~tForecast1~tF1Icon~tForecast1Val~tForecast2~tF2Icon~tForecast2Val~tForecast3~tF3Icon~tForecast3Val~tForecast4~tF4Icon~tForecast4Val~optionalLayoutIcon~optionalLayoutText~altIconFont~altIconFont` +Example default layout: `weatherUpdate~~~A~21130~~-0.7C~~~B~63469~Sat~3.6C~~~C~35957~Sun~3.9C~~~D~31728~Mon~4.3C~~~E~35957~Tue~3.6C` +Example alternative layout: `weatherUpdate~~~A~21130~~-0.7C~~~B~63469~Sat~3.6C~~~C~35957~Sun~3.9C~~~D~31728~Mon~4.3C~~~E~35957~Tue~3.6C~~~F~21130~~23.6C` -`color~background~time~timeAMPM~date~tMainIcon~tMainText~tForecast1~tForecast2~tForecast3~tForecast4~tF1Icon~tF2Icon~tF3Icon~tF4Icon~tForecast1Val~tForecast2Val~tForecast3Val~tForecast4Val~bar~tMRIcon~tMR` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter NumberCategoryLocationTypeFieldAddional Information
0instructioninstructionweatherupdate
1Main IconEntity Definitiontypeignored
2intNameEntityignored
3icon
4iconColor
5displayNameignored
6optionalValue
7First Forecast IconEntity Definitiontypeignored
8intNameEntityignored
9icon
10iconColor
11displayName
12optionalValue
13Second Forecast IconEntity Definitiontypeignored
14intNameEntityignored
15icon
16iconColor
17displayName
18optionalValue
19Third Forecast IconEntity Definitiontypeignored
20intNameEntityignored
21icon
22iconColor
23displayName
24optionalValue
25Fourth Forecast IconEntity Definitiontypeignored
26intNameEntityignored
27icon
28iconColor
29displayName
30optionalValue
31Alternative Layout IconEntity Definitiontypeignored
32intNameEntityignored
33icon
34iconColor
35displayNameignored
36optionalValue
+ +`color~background~tTime~timeAMPM~tDate~tMainText~tForecast1~tForecast2~tForecast3~tForecast4~tForecast1Val~tForecast2Val~tForecast3Val~tForecast4Val~bar~tMainTextAlt2~tMR~tTimeAdd` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter NumberCategoryLocationTypeFieldAddional Information
0instructioncolor
1background
2tTime
3timeAMPM
4tDate
5tMainText
6tForecast1
7tForecast2
8tForecast3
9tForecast4
10tForecast1Val
11tForecast2Val
12tForecast3Val
13tForecast4Val
14bar
15tMainTextAlt2
16tMR
17tTimeAdd
`notify~heading~text` diff --git a/HMI/code_gen/pages/out.txt b/HMI/code_gen/pages/out.txt new file mode 100644 index 00000000..307a2fe3 --- /dev/null +++ b/HMI/code_gen/pages/out.txt @@ -0,0 +1,402 @@ + +// data available +if(usize>1) +{ + bufferPos=0 + while(bufferPos= fid: - up = we.attributes.forecast[fid]['datetime'] - up = dp.parse(up).astimezone() - if babel_spec is not None: - if same_day: - up = babel.dates.format_time(up, "H:mm", locale=self._locale) - else: - up = babel.dates.format_date(up, "E", locale=self._locale) - else: - if same_day: - up = up.strftime('%H:%M') - else: - up = up.strftime('%a') - icon = get_icon_ha(we_name, stateOverwrite=we.attributes.forecast[fid]['condition']) - if i == 1: - state["tF1Icon"] = we.attributes.forecast[fid]['condition'] - elif i == 2: - state["tF2Icon"] = we.attributes.forecast[fid]['condition'] - elif i == 3: - state["tF3Icon"] = we.attributes.forecast[fid]['condition'] - elif i == 4: - state["tF4Icon"] = we.attributes.forecast[fid]['condition'] - down = convert_temperature(we.attributes.forecast[fid]['temperature'], unit) - else: - up = "" - icon = "" - down = "" - else: - apis.ha_api.log(f"Forecast {i} is overriden with {wOF}") - icon = wOF.get("icon") - name = wOF.get("name") - entity = apis.ha_api.get_entity(wOF.get("entity")) - up = name if name is not None else entity.attributes.friendly_name - icon = get_icon_ha(wOF.get("entity"), overwrite=icon) - if "color" in wOF: - if theme is None: - theme = {} - color = wOF.get("color") - if type(color) is dict: - for overwrite_state, overwrite_val in color.items(): - if overwrite_state == entity.state: - color = overwrite_val - if i == 1: - theme["tF1Icon"] = color - elif i == 2: - theme["tF2Icon"] = color - elif i == 3: - theme["tF3Icon"] = color - elif i == 4: - theme["tF4Icon"] = color - - unit_of_measurement = entity.attributes.get("unit_of_measurement", "") - down = f"{entity.state} {unit_of_measurement}" - weather_res+=f"~{up}~{icon}~{down}" - - altLayout = "~" - if self._config._config_screensaver.raw_config.get("alternativeLayout", False): - indoorTemp = self._config._config_screensaver.raw_config.get("indoorTemp") - if indoorTemp is not None and apis.ha_api.entity_exists(indoorTemp.get("entity","")): - entity = apis.ha_api.get_entity(indoorTemp.get("entity")) - icon = get_icon_ha(indoorTemp.get("entity"), overwrite=indoorTemp.get("icon")) - unit_of_measurement = entity.attributes.get("unit_of_measurement", "") - altLayout = f"~{icon}{entity.state}{unit_of_measurement}" - else: - altLayout = f"~{get_icon_id('water-percent')}{we.attributes.humidity} %" - self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}") + self._send_mqtt_msg(f"weatherUpdate{item_str}") def update_status_icons(self): status_res = "" @@ -397,6 +343,21 @@ class LuiPagesGen(object): elif entityType == "timer": entityTypePanel = "timer" value = get_translation(self._locale, f"backend.component.timer.state._.{entity.state}") + elif entityType == "weather": + entityTypePanel = "text" + unit = get_attr_safe(entity, "temperature_unit", "") + if type(item.stype) == int and len(entity.attributes.forecast) >= item.stype: + fdate = dp.parse(entity.attributes.forecast[item.stype]['datetime']).astimezone() + global babel_spec + if babel_spec is not None: + name = babel.dates.format_date(fdate, "E", locale=self._locale) + else: + name = fdate.strftime('%a') + icon_id = get_icon_ha(entityId, stateOverwrite=entity.attributes.forecast[item.stype]['condition']) + value = f'{entity.attributes.forecast[item.stype].get("temperature", "")}{unit}' + color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=entity.attributes.forecast[item.stype]['condition'], overwrite=colorOverride) + else: + value = f'{get_attr_safe(entity, "temperature", "")}{unit}' else: name = "unsupported" return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}" diff --git a/apps/nspanel-lovelace-ui/luibackend/theme.py b/apps/nspanel-lovelace-ui/luibackend/theme.py index 48eda7aa..cdba1b9b 100644 --- a/apps/nspanel-lovelace-ui/luibackend/theme.py +++ b/apps/nspanel-lovelace-ui/luibackend/theme.py @@ -27,25 +27,6 @@ default_screensaver_color_mapping = { "tTimeAdd": "65535" } -default_weather_icon_color_mapping = { - #"item-per HA" "color in decimal RGB 565 (0-65535)" - "clear-night": "35957", #50% grey - "cloudy": "31728", #grey-blue - "exceptional": "63488", #red - "fog": "21130", #75% grey - "hail": "65535", #white - "lightning": "65120", #golden-yellow - "lightning-rainy": "50400", #dark-golden-yellow - "partlycloudy": "35957", #50% grey - "pouring": "249", #blue - "rainy": "33759", #light-blue - "snowy": "65535", #white - "snowy-rainy": "44479", #light-blue-grey - "sunny": "63469", #bright-yellow - "windy": "35957", #50% grey - "windy-variant": "35957" #50% grey -} - def get_screensaver_color_output(theme, state=None): color_output = "color" for key in default_screensaver_color_mapping: @@ -66,8 +47,6 @@ def map_color(key, theme, state=None): def map_weather_icon_color(key, theme, state): if key in state and state[key] in theme: config_color = rgb_dec565(theme[state[key]]) - elif key in state and state[key] in default_weather_icon_color_mapping: - config_color = default_weather_icon_color_mapping[state[key]] else: config_color = "65535" return config_color