some changes for #608

This commit is contained in:
joBr99
2022-12-06 19:01:50 +01:00
parent 792798a3cf
commit cdfb3767de
5 changed files with 110 additions and 13 deletions

View File

@@ -165,7 +165,7 @@ options are ? seperated
onoffbtn has to be`disable` to disable the on off btn onoffbtn has to be`disable` to disable the on off btn
tIconBtnEntityName is the entiy name used in the button event for pressing the upper left icon tIconBtnEntityName is the entiy name used in the button event for pressing the upper left icon
`entityUpd~*heading*~*navigation*~*internalNameEntiy*~*icon*~iconcolor~*title*~titlecolor~*author*~authorcolor~*volume*~*playpauseicon*~currentSpeaker~speakerList-seperated-by-?~onoffbtn~tIconBtnEntityName,iconShuffle` `entityUpd~*heading*~*navigation*~*internalNameEntiy*~*icon*~iconcolor~*title*~titlecolor~*author*~authorcolor~*volume*~*playpauseicon*~onoffbtn~tIconBtnEntityType~tIconBtnEntityName~iconShuffle[~*type*~*internalNameEntity*~*iconId*~*iconColor*~*displayNameEntity*~*optionalValue*]x4`
### cardAlarm Page ### cardAlarm Page

View File

@@ -0,0 +1,101 @@
from shared import *
head = sharedhead + """
if(tInstruction.txt=="entityUpd")
{
// command format: entityUpd,heading,navigation,[,type,internalName,iconId,iconColor,displayName,optionalValue]x6
spstr strCommand.txt,tHeading.txt,"~",1
""" + navigation
print(head)
print("""
//entity name
spstr strCommand.txt,entn.txt,"~",3
//icon
spstr strCommand.txt,tIcon.txt,"~",4
//icon farbe
spstr strCommand.txt,tTmp.txt,"~",5
if(tTmp.txt!="")
{
covx tTmp.txt,tIcon.pco,0,0
}
//title
spstr strCommand.txt,tTitle.txt,"~",6
//title farbe
spstr strCommand.txt,tTmp.txt,"~",7
if(tTmp.txt!="")
{
covx tTmp.txt,tTitle.pco,0,0
}
//author
spstr strCommand.txt,tAuthor.txt,"~",8
//author farbe
spstr strCommand.txt,tTmp.txt,"~",9
if(tTmp.txt!="")
{
covx tTmp.txt,tAuthor.pco,0,0
}
//volume
spstr strCommand.txt,tTmp.txt,"~",10
covx tTmp.txt,sys0,0,0
hVolume.val=sys0
//icon
spstr strCommand.txt,tPlayPause.txt,"~",11
// on off button
spstr strCommand.txt,tTmp.txt,"~",12
if(tTmp.txt=="disable")
{
vis t5,0
}else
{
vis t5,1
covx tTmp.txt,t5.pco,0,0
}
//tIconBtnEntityType
spstr strCommand.txt,vaMenu.txt,"~",13
//tIconBtnEntityName
spstr strCommand.txt,vaMenu.txt,"~",14
// shuffel btn
spstr strCommand.txt,tTmp.txt,"~",15
if(tTmp.txt=="disable")
{
vis tShuffle,0
}else
{
vis tShuffle,1
tShuffle.txt=tTmp.txt
}
""")
start = 16
for i in range(1,6):
idxstart = start + (i-1)*6
item = f"""
// get Type
spstr strCommand.txt,type{i}.txt,"~",{idxstart}
// get internal name
spstr strCommand.txt,entn{i}.txt,"~",{idxstart+1}
if(type{i}.txt=="delete"||type{i}.txt=="")
{{
vis tEntity{i},0
vis bEntity{i},0
}}else
{{
// 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
// set name
spstr strCommand.txt,tEntity{i}.txt,"~",{idxstart+4}
vis tEntity{i},1
}}
"""
print(item)
foot = """
}
""" + sharedfoot
print(foot)

Binary file not shown.

Binary file not shown.

View File

@@ -470,7 +470,7 @@ class LuiPagesGen(object):
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}{icon_res}~{currently_translation}~{state_translation}~{action_translation}~{temperature_unit_icon}~{dest_temp2}~{detailPage}"
self._send_mqtt_msg(command) self._send_mqtt_msg(command)
def generate_media_page(self, navigation, title, entity, mediaBtn): def generate_media_page(self, navigation, title, entity, entities, mediaBtn):
item = entity.entityId item = entity.entityId
if not apis.ha_api.entity_exists(item): if not apis.ha_api.entity_exists(item):
command = f"entityUpd~Not found~{navigation}~{item}~{get_icon_id('alert-circle-outline')}~Please check your~apps.yaml in AppDaemon~~0~{get_icon_id('alert-circle-outline')}~~~disable" command = f"entityUpd~Not found~{navigation}~{item}~{get_icon_id('alert-circle-outline')}~Please check your~apps.yaml in AppDaemon~~0~{get_icon_id('alert-circle-outline')}~~~disable"
@@ -485,15 +485,6 @@ class LuiPagesGen(object):
if "media_content_type" in entity.attributes: if "media_content_type" in entity.attributes:
if entity.attributes.media_content_type == "music": if entity.attributes.media_content_type == "music":
icon = get_icon_id("music") icon = get_icon_id("music")
source = get_attr_safe(entity, "source", "")
speakerlist = get_attr_safe(entity, "source_list",[])
if source in speakerlist:
# move current source to the end of the list
speakerlist.remove(source)
speakerlist.append(source)
if len(speakerlist) == 1:
speakerlist = []
speakerlist = "?".join(speakerlist)
bits = entity.attributes.supported_features bits = entity.attributes.supported_features
onoffbutton = "disable" onoffbutton = "disable"
if bits & 0b10000000: if bits & 0b10000000:
@@ -508,7 +499,12 @@ class LuiPagesGen(object):
shuffleBtn = get_icon_id('shuffle-disabled') shuffleBtn = get_icon_id('shuffle-disabled')
elif shuffle == True: elif shuffle == True:
shuffleBtn = get_icon_id('shuffle') shuffleBtn = get_icon_id('shuffle')
command = f"entityUpd~{heading}~{navigation}~{item}~{icon}~~{title}~~{author}~~{volume}~{iconplaypause}~{source}~{speakerlist[:200]}~{onoffbutton}~{mediaBtn}~{shuffleBtn}"
item_str = ""
for item in entities:
item_str += self.generate_entities_item(item, "cardGrid")
command = f"entityUpd~{heading}~{navigation}~{item}~{icon}~~{title}~~{author}~~{volume}~{iconplaypause}~{onoffbutton}~test~{mediaBtn}~{shuffleBtn}~{item_str}"
self._send_mqtt_msg(command) self._send_mqtt_msg(command)
def generate_alarm_page(self, navigation, entity, overwrite_supported_modes, alarmBtn): def generate_alarm_page(self, navigation, entity, overwrite_supported_modes, alarmBtn):
@@ -639,7 +635,7 @@ class LuiPagesGen(object):
return return
if card.cardType == "cardMedia": if card.cardType == "cardMedia":
mediaBtn = card.raw_config.get("mediaControl", "") mediaBtn = card.raw_config.get("mediaControl", "")
self.generate_media_page(navigation, card.title, card.entity, mediaBtn) self.generate_media_page(navigation, card.title, card.entity, card.entities, mediaBtn)
return return
if card.cardType == "cardAlarm": if card.cardType == "cardAlarm":
alarmBtn = card.raw_config.get("alarmControl") alarmBtn = card.raw_config.get("alarmControl")