mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
some changes for #608
This commit is contained in:
@@ -165,7 +165,7 @@ options are ? seperated
|
||||
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
|
||||
|
||||
`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
|
||||
|
||||
|
||||
101
HMI/code_gen/pages/cardMedia.py
Normal file
101
HMI/code_gen/pages/cardMedia.py
Normal 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)
|
||||
|
||||
|
||||
BIN
HMI/nspanel.HMI
BIN
HMI/nspanel.HMI
Binary file not shown.
BIN
HMI/nspanel.tft
BIN
HMI/nspanel.tft
Binary file not shown.
@@ -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}"
|
||||
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
|
||||
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"
|
||||
@@ -485,15 +485,6 @@ class LuiPagesGen(object):
|
||||
if "media_content_type" in entity.attributes:
|
||||
if entity.attributes.media_content_type == "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
|
||||
onoffbutton = "disable"
|
||||
if bits & 0b10000000:
|
||||
@@ -508,7 +499,12 @@ class LuiPagesGen(object):
|
||||
shuffleBtn = get_icon_id('shuffle-disabled')
|
||||
elif shuffle == True:
|
||||
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)
|
||||
|
||||
def generate_alarm_page(self, navigation, entity, overwrite_supported_modes, alarmBtn):
|
||||
@@ -639,7 +635,7 @@ class LuiPagesGen(object):
|
||||
return
|
||||
if card.cardType == "cardMedia":
|
||||
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
|
||||
if card.cardType == "cardAlarm":
|
||||
alarmBtn = card.raw_config.get("alarmControl")
|
||||
|
||||
Reference in New Issue
Block a user