mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-20 14:37:01 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5566f20e47 | ||
|
|
48ed2daa33 | ||
|
|
8813331299 | ||
|
|
abf4868281 | ||
|
|
420905db04 | ||
|
|
4151aba6ea | ||
|
|
35b15c92e0 | ||
|
|
c40906fdfe | ||
|
|
66a65c03e8 | ||
|
|
20e6f21307 | ||
|
|
342a97df0f | ||
|
|
0d343d4919 |
@@ -117,7 +117,7 @@ The following message can be used to update the content on the cardEntities Page
|
||||
|
||||
`entityUpdateDetail,*internalName*,*tHeading*,*tHeadingColor*,*b1*,*tB1Color*,*b2*,*tB2Color*,*tText*,*tTextColor*,*sleepTimeout*`
|
||||
|
||||
`popupExit`
|
||||
`exitPopup`
|
||||
|
||||
### cardThermo Page
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ pageTest
|
||||
14 Component(s)
|
||||
14 Line(s) of event code
|
||||
14 Unique line(s) of event code
|
||||
popupLight
|
||||
26 Component(s)
|
||||
304 Line(s) of event code
|
||||
167 Unique line(s) of event code
|
||||
screensaver
|
||||
25 Component(s)
|
||||
173 Line(s) of event code
|
||||
124 Unique line(s) of event code
|
||||
popupLight
|
||||
26 Component(s)
|
||||
307 Line(s) of event code
|
||||
168 Unique line(s) of event code
|
||||
cardThermo
|
||||
42 Component(s)
|
||||
412 Line(s) of event code
|
||||
@@ -62,5 +62,5 @@ cardAlarm
|
||||
Total
|
||||
14 Page(s)
|
||||
349 Component(s)
|
||||
3105 Line(s) of event code
|
||||
827 Unique line(s) of event code
|
||||
3108 Line(s) of event code
|
||||
828 Unique line(s) of event code
|
||||
|
||||
@@ -844,7 +844,7 @@ Timer tmSerial
|
||||
}
|
||||
}else
|
||||
{
|
||||
mode_temp.val=0
|
||||
mode_temp.val=1
|
||||
vis hTempSlider,1
|
||||
vis t3,1
|
||||
vis t4,1
|
||||
@@ -867,7 +867,11 @@ Timer tmSerial
|
||||
}else
|
||||
{
|
||||
vis t0,1
|
||||
vis bColor,1
|
||||
//only enable bColor button if color temp is also supported
|
||||
if(mode_temp.val==1)
|
||||
{
|
||||
vis bColor,1
|
||||
}
|
||||
if(mode.val==0)
|
||||
{
|
||||
vis pColorWheel,1
|
||||
|
||||
BIN
HMI/nspanel.HMI
BIN
HMI/nspanel.HMI
Binary file not shown.
BIN
HMI/nspanel.tft
BIN
HMI/nspanel.tft
Binary file not shown.
@@ -309,9 +309,9 @@ key | optional | type | default | description
|
||||
`class` | False | string | | The name of the Class.
|
||||
`config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel
|
||||
|
||||
### Override Icons
|
||||
### Override Icons or Names
|
||||
|
||||
To override Icons of entities you can configure an icon name in your configuration, please see the following example.
|
||||
To override Icons or Names of entities you can configure an icon and/or name in your configuration, please see the following example.
|
||||
Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.
|
||||
|
||||
```yaml
|
||||
@@ -322,6 +322,7 @@ Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.
|
||||
- light.schreibtischlampe
|
||||
- switch.deckenbeleuchtung_hinten:
|
||||
icon: lightbulb
|
||||
name: Lampe
|
||||
- delete
|
||||
- delete
|
||||
- type: cardMedia
|
||||
|
||||
@@ -412,7 +412,7 @@ class LovelaceUIPanel:
|
||||
|
||||
if btype == "tempUpd":
|
||||
temp = int(optVal)/10
|
||||
self.api.get_entity(msg[3]).call_service("set_temperature", temperature=temp)
|
||||
self.api.get_entity(entity_id).call_service("set_temperature", temperature=temp)
|
||||
|
||||
def generate_page(self, page_number):
|
||||
# get type of page
|
||||
@@ -433,8 +433,10 @@ class LovelaceUIPanel:
|
||||
|
||||
def generate_entities_item(self, item):
|
||||
icon = None
|
||||
name = None
|
||||
if type(item) is dict:
|
||||
icon = next(iter(item.items()))[1]['icon']
|
||||
icon = next(iter(item.items()))[1].get('icon')
|
||||
name = next(iter(item.items()))[1].get('name')
|
||||
item = next(iter(item.items()))[0]
|
||||
|
||||
# type of the item is the string before the "." in the item name
|
||||
@@ -449,7 +451,7 @@ class LovelaceUIPanel:
|
||||
return f",text,{item},{get_icon_id('alert-circle-outline')},17299,Not found check, apps.yaml"
|
||||
|
||||
entity = self.api.get_entity(item)
|
||||
name = entity.attributes.friendly_name
|
||||
name = name if name is not None else entity.attributes.friendly_name
|
||||
|
||||
if item_type == "cover":
|
||||
icon_id = get_icon_id_ha("cover", state=entity.state, overwrite=icon)
|
||||
|
||||
@@ -92,8 +92,6 @@ export const config: Config = {
|
||||
button2Page: button2Page
|
||||
};
|
||||
|
||||
|
||||
|
||||
var subscriptions: any = {};
|
||||
|
||||
var pageId = 0;
|
||||
@@ -149,28 +147,29 @@ function SendToPanel(val: Payload | Payload[]): void {
|
||||
|
||||
function HandleMessage(typ: string, method: string, page: number, words: Array<string>): void {
|
||||
if (typ == "event") {
|
||||
var pageNum = (page % config.pages.length);
|
||||
pageId = Math.abs(pageNum);
|
||||
|
||||
if (method == 'pageOpen' || method == 'startup') {
|
||||
UnsubscribeWatcher();
|
||||
|
||||
if (method == 'startup')
|
||||
switch (method) {
|
||||
case "pageOpen":
|
||||
var pageNum = (page % config.pages.length);
|
||||
pageId = Math.abs(pageNum);
|
||||
UnsubscribeWatcher();
|
||||
GeneratePage(config.pages[pageId]);
|
||||
break;
|
||||
case "startup":
|
||||
UnsubscribeWatcher();
|
||||
HandleStartupProcess();
|
||||
|
||||
GeneratePage(config.pages[pageId]);
|
||||
}
|
||||
|
||||
if (method == 'buttonPress' || method == "tempUpd") {
|
||||
HandleButtonEvent(words)
|
||||
}
|
||||
|
||||
if (method == 'screensaverOpen') {
|
||||
HandleScreensaver()
|
||||
}
|
||||
|
||||
if (method == 'button1' || method == 'button2') {
|
||||
HandleHardwareButton(method);
|
||||
break;
|
||||
case "buttonPress2":
|
||||
HandleButtonEvent(words);
|
||||
break;
|
||||
case "screensaverOpen":
|
||||
HandleScreensaver();
|
||||
break;
|
||||
case "button1":
|
||||
case "button2":
|
||||
HandleHardwareButton(method);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,11 +275,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
||||
|
||||
if (existsState(pageItem.id + ".GET")) {
|
||||
val = getState(pageItem.id + ".GET").val;
|
||||
RegisterEntityWatcher(pageItem.id + ".GET", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".GET");
|
||||
}
|
||||
else if (existsState(pageItem.id + ".SET")) {
|
||||
val = getState(pageItem.id + ".SET").val;
|
||||
RegisterEntityWatcher(pageItem.id + ".SET", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".SET");
|
||||
}
|
||||
var iconColor = rgb_dec565(config.defaultColor);
|
||||
|
||||
@@ -303,11 +302,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
||||
var optVal = "0"
|
||||
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
||||
val = getState(pageItem.id + ".ON_ACTUAL").val;
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_ACTUAL", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_ACTUAL");
|
||||
}
|
||||
else if (existsState(pageItem.id + ".ON_SET")) {
|
||||
val = getState(pageItem.id + ".ON_SET").val;
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_SET", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_SET");
|
||||
}
|
||||
if (val === true || val === "true") {
|
||||
optVal = "1"
|
||||
@@ -331,12 +330,12 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
||||
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
||||
optVal = getState(pageItem.id + ".ON_ACTUAL").val;
|
||||
unit = GetUnitOfMeasurement(pageItem.id + ".ON_ACTUAL");
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_ACTUAL", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".ON_ACTUAL");
|
||||
}
|
||||
else if (existsState(pageItem.id + ".ACTUAL")) {
|
||||
optVal = getState(pageItem.id + ".ACTUAL").val;
|
||||
unit = GetUnitOfMeasurement(pageItem.id + ".ACTUAL");
|
||||
RegisterEntityWatcher(pageItem.id + ".ACTUAL", pageItem.id, placeId);
|
||||
RegisterEntityWatcher(pageItem.id + ".ACTUAL");
|
||||
}
|
||||
|
||||
if (o.common.role == "value.temperature") {
|
||||
@@ -384,11 +383,12 @@ function GetIconColor(pageItem: PageItem, value: (boolean | number), useColors:
|
||||
return rgb_dec565(pageItem.offColor !== undefined ? pageItem.offColor : config.defaultOffColor);
|
||||
}
|
||||
|
||||
function RegisterEntityWatcher(id: string, entityId: string, placeId: number): void {
|
||||
function RegisterEntityWatcher(id: string): void {
|
||||
if (subscriptions.hasOwnProperty(id)) {
|
||||
return;
|
||||
}
|
||||
subscriptions[id] = (on({ id: id, change: 'any' }, function (data) {
|
||||
log("RegisterEntityWatcher PageId:" + pageId.toString())
|
||||
GeneratePage(config.pages[pageId]);
|
||||
}))
|
||||
}
|
||||
@@ -477,11 +477,11 @@ function toggleState(id: string): boolean {
|
||||
}
|
||||
|
||||
function HandleButtonEvent(words): void {
|
||||
let id = words[4]
|
||||
let id = words[2]
|
||||
|
||||
if (words[6] == "OnOff" && existsObject(id)) {
|
||||
if (words[3] == "OnOff" && existsObject(id)) {
|
||||
var action = false
|
||||
if (words[7] == "1")
|
||||
if (words[4] == "1")
|
||||
action = true
|
||||
let o = getObject(id)
|
||||
switch (o.common.role) {
|
||||
@@ -496,31 +496,28 @@ function HandleButtonEvent(words): void {
|
||||
}
|
||||
}
|
||||
|
||||
if (words[6] == "up")
|
||||
if (words[3] == "up")
|
||||
setState(id + ".OPEN", true)
|
||||
if (words[6] == "stop")
|
||||
if (words[3] == "stop")
|
||||
setState(id + ".STOP", true)
|
||||
if (words[6] == "down")
|
||||
if (words[3] == "down")
|
||||
setState(id + ".CLOSE", true)
|
||||
if (words[6] == "button") {
|
||||
let switchOn = true;
|
||||
if (words[5] !== "1")
|
||||
switchOn = false;
|
||||
if (words[3] == "button") {
|
||||
toggleState(id + ".SET") ? true : toggleState(id + ".ON_SET")
|
||||
}
|
||||
if (words[6] == "positionSlider")
|
||||
setState(id + ".SET", parseInt(words[7]))
|
||||
if (words[3] == "positionSlider")
|
||||
setState(id + ".SET", parseInt(words[4]))
|
||||
|
||||
if (words[6] == "brightnessSlider")
|
||||
if (words[3] == "brightnessSlider")
|
||||
if (existsState(id + ".SET"))
|
||||
setState(id + ".SET", parseInt(words[7]));
|
||||
setState(id + ".SET", parseInt(words[4]));
|
||||
else if (existsState(id + ".ACTUAL"))
|
||||
setState(id + ".ACTUAL", parseInt(words[7]));
|
||||
setState(id + ".ACTUAL", parseInt(words[4]));
|
||||
// out_msgs.push({ payload: id, action: "turn_on", domain: "lightBrightness", brightness: parseInt(words[7]) })
|
||||
// if (words[6] == "colorTempSlider")
|
||||
// out_msgs.push({ payload: id, action: "turn_on", domain: "lightTemperature", temperature: parseInt(words[7]) })
|
||||
if (words[1] == "tempUpd") {
|
||||
setState(words[3] + ".SET", parseInt(words[4]) / 10)
|
||||
if (words[3] == "tempUpd") {
|
||||
setState(id + ".SET", parseInt(words[4]) / 10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user