Compare commits

...

4 Commits

Author SHA1 Message Date
Johannes
415813d847 implements #654 2022-12-31 14:41:59 +01:00
Johannes Braun
2bc83a2e11 add hmi 2022-12-29 16:39:28 +01:00
Johannes Braun
eac9a73f8a add serial code 2022-12-29 16:38:58 +01:00
Johannes
80670a4722 started on backend changes for new thermo page format 2022-12-29 16:37:52 +01:00
5 changed files with 90 additions and 97 deletions

View File

@@ -100,6 +100,8 @@ change the page type:
`notify~heading~text`
`statusUpdate~icon1~icon1Color~icon2~icon2~icon2color~icon1font~icon2font`
### cardEntities Page
Structure (Category): `entityUpd~title~[navigation]~[entity_information]`

View File

@@ -26,50 +26,16 @@ text += """
//tempStep
spstr strCommand.txt,tTmp.txt,"~",20
covx tTmp.txt,xTempStep1.val,0,0
// disable all buttons
vis bt0,0
vis bt1,0
vis bt2,0
vis bt3,0
vis bt4,0
vis bt5,0
vis bt6,0
vis bt7,0
"""
start = 21
for i in range(0,8):
idxstart = start + i*4
text += f"""
//bt{i}
spstr strCommand.txt,bt{i}.txt,"~",{idxstart}
if(bt{i}.txt!="")
{{
// set text color on active state
spstr strCommand.txt,tTmp.txt,"~",{idxstart+1}
covx tTmp.txt,bt{i}.pco2,0,0
// set state
spstr strCommand.txt,tTmp.txt,"~",{idxstart+2}
covx tTmp.txt,bt{i}.val,0,0
// save action
spstr strCommand.txt,va{i}.txt,"~",{idxstart+3}
//enable
vis bt{i},1
}}"""
text += """
//Text tCurTempLbl
spstr strCommand.txt,tCurTempLbl.txt,"~",53
spstr strCommand.txt,tCurTempLbl.txt,"~",21
//Text tStateLbl
spstr strCommand.txt,tStateLbl.txt,"~",54
//Text tALbl
spstr strCommand.txt,tALbl.txt,"~",55
spstr strCommand.txt,tStateLbl.txt,"~",22
//Text tCF
spstr strCommand.txt,tCF.txt,"~",56
spstr strCommand.txt,tCF.txt,"~",23
tCF1.txt=tCF.txt
tCF2.txt=tCF.txt
//Second Temperature
spstr strCommand.txt,tTmp.txt,"~",57
spstr strCommand.txt,tTmp.txt,"~",24
if(tTmp.txt!="")
{
covx tTmp.txt,xTempDest2.val,0,0
@@ -87,15 +53,46 @@ text += """
vis tCF2,1
}
//Show btDetail
spstr strCommand.txt,tTmp.txt,"~",58
if(tTmp.txt!="1")
spstr strCommand.txt,tTmp.txt,"~",25
if(tTmp.txt=="enable")
{
vis btDetail,1
}else
{
vis btDetail,0
}
}
""" + sharedfoot
"""
print(text)
start = 26
for i in range(1,9):
idxstart = start + (i-1)*6
item = f"""
// get Type
spstr strCommand.txt,tTmp.txt,"~",{idxstart}
if(tTmp.txt=="delete"||tTmp.txt=="")
{{
vis bEntity{i},0
}}else
{{
// get internal name
spstr strCommand.txt,entn{i}.txt,"~",{idxstart+1}
// change icon
spstr strCommand.txt,bEntity{i}.txt,"~",{idxstart+2}
vis bEntity{i},1
// change icon color
spstr strCommand.txt,tTmp.txt,"~",{idxstart+3}
covx tTmp.txt,sys0,0,0
bEntity{i}.pco=sys0
}}
"""
print(item)
print("""
}
""" + sharedfoot
)

Binary file not shown.

Binary file not shown.

View File

@@ -401,13 +401,12 @@ class LuiPagesGen(object):
command += self.generate_entities_item(item, cardType, tempUnit)
self._send_mqtt_msg(command)
def generate_thermo_page(self, navigation, title, entity, temp_unit, overwrite_supported_modes):
def generate_thermo_page(self, navigation, title, entity, temp_unit, entities, overwrite_supported_modes):
item = entity.entityId
if(temp_unit == "celsius"):
temperature_unit_icon = get_icon_id("temperature-celsius")
temperature_unit = "°C"
else:
temperature_unit_icon = get_icon_id("temperature-fahrenheit")
temperature_unit = "°F"
@@ -415,83 +414,78 @@ class LuiPagesGen(object):
if not apis.ha_api.entity_exists(item):
command = f"entityUpd~Not found~{navigation}~{item}~check~220~apps.yaml~150~300~5~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Please~your~~"
else:
entity = apis.ha_api.get_entity(item)
heading = title if title != "unknown" else entity.attributes.friendly_name
current_temp = get_attr_safe(entity, "current_temperature", "")
dest_temp = get_attr_safe(entity, "temperature", None)
ha_entity = apis.ha_api.get_entity(item)
heading = title if title != "unknown" else ha_entity.attributes.friendly_name
current_temp = get_attr_safe(ha_entity, "current_temperature", "")
dest_temp = get_attr_safe(ha_entity, "temperature", None)
dest_temp2 = ""
if dest_temp is None:
dest_temp = get_attr_safe(entity, "target_temp_high", 0)
dest_temp2 = get_attr_safe(entity, "target_temp_low", None)
dest_temp = get_attr_safe(ha_entity, "target_temp_high", 0)
dest_temp2 = get_attr_safe(ha_entity, "target_temp_low", None)
if dest_temp2 != None and dest_temp2 != "null":
dest_temp2 = int(dest_temp2*10)
else:
dest_temp2 = ""
dest_temp = int(dest_temp*10)
hvac_action = get_attr_safe(entity, "hvac_action", "")
hvac_action = get_attr_safe(ha_entity, "hvac_action", "")
state_value = ""
if hvac_action != "":
state_value = get_translation(self._locale, f"frontend.state_attributes.climate.hvac_action.{hvac_action}")
state_value += "\r\n("
state_value += get_translation(self._locale, f"backend.component.climate.state._.{entity.state}")
state_value += get_translation(self._locale, f"backend.component.climate.state._.{ha_entity.state}")
if hvac_action != "":
state_value += ")"
min_temp = int(get_attr_safe(entity, "min_temp", 0)*10)
max_temp = int(get_attr_safe(entity, "max_temp", 0)*10)
step_temp = int(get_attr_safe(entity, "target_temp_step", 0.5)*10)
min_temp = int(get_attr_safe(ha_entity, "min_temp", 0)*10)
max_temp = int(get_attr_safe(ha_entity, "max_temp", 0)*10)
step_temp = int(get_attr_safe(ha_entity, "target_temp_step", 0.5)*10)
icon_res_list = []
icon_res = ""
hvac_modes = get_attr_safe(entity, "hvac_modes", [])
currently_translation = get_translation(self._locale, "frontend.ui.card.climate.currently")
state_translation = get_translation(self._locale, "frontend.ui.panel.config.devices.entities.state")
detailPage = ""
if any(x in ["preset_modes", "swing_modes", "fan_modes"] for x in ha_entity.attributes):
detailPage = "enable"
#hvac_modes = get_attr_safe(ha_entity, "hvac_modes", [])
#if overwrite_supported_modes is not None:
# hvac_modes = overwrite_supported_modes
#for mode in hvac_modes:
# icon_id = get_icon_ha(item, stateOverwrite=mode)
# color_on = 64512
# if mode in ["auto", "heat_cool"]:
# color_on = 1024
# if mode == "heat":
# color_on = 64512
# if mode == "off":
# color_on = 35921
# if mode == "cool":
# color_on = 11487
# if mode == "dry":
# color_on = 60897
# if mode == "fan_only":
# color_on = 35921
# state = 0
# if(mode == ha_entity.state):
# state = 1
item_str = ""
for eitem in entities:
item_str += self.generate_entities_item(eitem, "cardGrid")
hvac_modes = get_attr_safe(ha_entity, "hvac_modes", [])
if overwrite_supported_modes is not None:
hvac_modes = overwrite_supported_modes
for mode in hvac_modes:
icon_id = get_icon_ha(item, stateOverwrite=mode)
color_on = 64512
if mode in ["auto", "heat_cool"]:
color_on = 1024
if mode == "heat":
color_on = 64512
if mode == "off":
color_on = 35921
if mode == "cool":
color_on = 11487
if mode == "dry":
color_on = 60897
if mode == "fan_only":
color_on = 35921
state = 0
if(mode == entity.state):
state = 1
icon_res_list.append(f"~{icon_id}~{color_on}~{state}~{mode}")
item_str += self.generate_entities_item(entity, "cardGrid")
icon_res = "".join(icon_res_list)
if len(icon_res_list) == 1 and not self._config.get("model") == "us-p":
icon_res = "~"*4 + icon_res_list[0] + "~"*4*6
elif len(icon_res_list) == 2 and not self._config.get("model") == "us-p":
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4*2 + icon_res_list[1] + "~"*4*2
elif len(icon_res_list) == 3 and not self._config.get("model") == "us-p":
icon_res = "~"*4*2 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4
elif len(icon_res_list) == 4 and not self._config.get("model") == "us-p":
icon_res = "~"*4 + icon_res_list[0] + "~"*4 + icon_res_list[1] + "~"*4 + icon_res_list[2] + "~"*4 + icon_res_list[3]
elif len(icon_res_list) >= 5 or self._config.get("model") == "us-p":
icon_res = "".join(icon_res_list) + "~"*4*(8-len(icon_res_list))
currently_translation = get_translation(self._locale, "frontend.ui.card.climate.currently")
state_translation = get_translation(self._locale, "frontend.ui.panel.config.devices.entities.state")
action_translation = get_translation(self._locale, "frontend.ui.card.climate.operation").replace(' ','\r\n')
detailPage = ""
if any(x in ["preset_modes", "swing_modes", "fan_modes"] for x in entity.attributes):
detailPage = "1"
command = f"entityUpd~{heading}~{navigation}~{item}~{current_temp} {temperature_unit}~{dest_temp}~{state_value}~{min_temp}~{max_temp}~{step_temp}{icon_res}~{currently_translation}~{state_translation}~{action_translation}~{temperature_unit_icon}~{dest_temp2}~{detailPage}"
command = f"entityUpd~{heading}~{navigation}~{item}~{current_temp} {temperature_unit}~{dest_temp}~{state_value}~{min_temp}~{max_temp}~{step_temp}~{currently_translation}~{state_translation}~{temperature_unit_icon}~{dest_temp2}~{detailPage}{item_str}"
self._send_mqtt_msg(command)
def generate_media_page(self, navigation, title, entity, entities, mediaBtn):
entityId = entity.entityId
if entity.status is not None: