mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-20 13:14:44 +01:00
Merge branch 'main' into newConfigFormat
This commit is contained in:
@@ -119,7 +119,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*`
|
`entityUpdateDetail,*internalName*,*tHeading*,*tHeadingColor*,*b1*,*tB1Color*,*b2*,*tB2Color*,*tText*,*tTextColor*,*sleepTimeout*`
|
||||||
|
|
||||||
`popupExit`
|
`exitPopup`
|
||||||
|
|
||||||
### cardThermo Page
|
### cardThermo Page
|
||||||
|
|
||||||
|
|||||||
@@ -309,9 +309,9 @@ key | optional | type | default | description
|
|||||||
`class` | False | string | | The name of the Class.
|
`class` | False | string | | The name of the Class.
|
||||||
`config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel
|
`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.
|
Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -322,6 +322,7 @@ Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.
|
|||||||
- light.schreibtischlampe
|
- light.schreibtischlampe
|
||||||
- switch.deckenbeleuchtung_hinten:
|
- switch.deckenbeleuchtung_hinten:
|
||||||
icon: lightbulb
|
icon: lightbulb
|
||||||
|
name: Lampe
|
||||||
- delete
|
- delete
|
||||||
- delete
|
- delete
|
||||||
- type: cardMedia
|
- type: cardMedia
|
||||||
|
|||||||
@@ -80,6 +80,3 @@ class NsPanelLovelaceUIManager(hass.Hass):
|
|||||||
mqtt_listener = LuiMqttListener(mqtt_api, topic_recv, controller, updater)
|
mqtt_listener = LuiMqttListener(mqtt_api, topic_recv, controller, updater)
|
||||||
|
|
||||||
LOGGER.info('Started')
|
LOGGER.info('Started')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ export const config: Config = {
|
|||||||
button2Page: button2Page
|
button2Page: button2Page
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var subscriptions: any = {};
|
var subscriptions: any = {};
|
||||||
|
|
||||||
var pageId = 0;
|
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 {
|
function HandleMessage(typ: string, method: string, page: number, words: Array<string>): void {
|
||||||
if (typ == "event") {
|
if (typ == "event") {
|
||||||
var pageNum = (page % config.pages.length);
|
|
||||||
pageId = Math.abs(pageNum);
|
|
||||||
|
|
||||||
if (method == 'pageOpen' || method == 'startup') {
|
switch (method) {
|
||||||
UnsubscribeWatcher();
|
case "pageOpen":
|
||||||
|
var pageNum = (page % config.pages.length);
|
||||||
if (method == 'startup')
|
pageId = Math.abs(pageNum);
|
||||||
|
UnsubscribeWatcher();
|
||||||
|
GeneratePage(config.pages[pageId]);
|
||||||
|
break;
|
||||||
|
case "startup":
|
||||||
|
UnsubscribeWatcher();
|
||||||
HandleStartupProcess();
|
HandleStartupProcess();
|
||||||
|
break;
|
||||||
GeneratePage(config.pages[pageId]);
|
case "buttonPress2":
|
||||||
}
|
HandleButtonEvent(words);
|
||||||
|
break;
|
||||||
if (method == 'buttonPress' || method == "tempUpd") {
|
case "screensaverOpen":
|
||||||
HandleButtonEvent(words)
|
HandleScreensaver();
|
||||||
}
|
break;
|
||||||
|
case "button1":
|
||||||
if (method == 'screensaverOpen') {
|
case "button2":
|
||||||
HandleScreensaver()
|
HandleHardwareButton(method);
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
if (method == 'button1' || method == 'button2') {
|
|
||||||
HandleHardwareButton(method);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,11 +275,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
|
|
||||||
if (existsState(pageItem.id + ".GET")) {
|
if (existsState(pageItem.id + ".GET")) {
|
||||||
val = getState(pageItem.id + ".GET").val;
|
val = getState(pageItem.id + ".GET").val;
|
||||||
RegisterEntityWatcher(pageItem.id + ".GET", pageItem.id, placeId);
|
RegisterEntityWatcher(pageItem.id + ".GET");
|
||||||
}
|
}
|
||||||
else if (existsState(pageItem.id + ".SET")) {
|
else if (existsState(pageItem.id + ".SET")) {
|
||||||
val = getState(pageItem.id + ".SET").val;
|
val = getState(pageItem.id + ".SET").val;
|
||||||
RegisterEntityWatcher(pageItem.id + ".SET", pageItem.id, placeId);
|
RegisterEntityWatcher(pageItem.id + ".SET");
|
||||||
}
|
}
|
||||||
var iconColor = rgb_dec565(config.defaultColor);
|
var iconColor = rgb_dec565(config.defaultColor);
|
||||||
|
|
||||||
@@ -303,11 +302,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
var optVal = "0"
|
var optVal = "0"
|
||||||
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
||||||
val = getState(pageItem.id + ".ON_ACTUAL").val;
|
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")) {
|
else if (existsState(pageItem.id + ".ON_SET")) {
|
||||||
val = getState(pageItem.id + ".ON_SET").val;
|
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") {
|
if (val === true || val === "true") {
|
||||||
optVal = "1"
|
optVal = "1"
|
||||||
@@ -331,12 +330,12 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
if (existsState(pageItem.id + ".ON_ACTUAL")) {
|
||||||
optVal = getState(pageItem.id + ".ON_ACTUAL").val;
|
optVal = getState(pageItem.id + ".ON_ACTUAL").val;
|
||||||
unit = GetUnitOfMeasurement(pageItem.id + ".ON_ACTUAL");
|
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")) {
|
else if (existsState(pageItem.id + ".ACTUAL")) {
|
||||||
optVal = getState(pageItem.id + ".ACTUAL").val;
|
optVal = getState(pageItem.id + ".ACTUAL").val;
|
||||||
unit = GetUnitOfMeasurement(pageItem.id + ".ACTUAL");
|
unit = GetUnitOfMeasurement(pageItem.id + ".ACTUAL");
|
||||||
RegisterEntityWatcher(pageItem.id + ".ACTUAL", pageItem.id, placeId);
|
RegisterEntityWatcher(pageItem.id + ".ACTUAL");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.common.role == "value.temperature") {
|
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);
|
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)) {
|
if (subscriptions.hasOwnProperty(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
subscriptions[id] = (on({ id: id, change: 'any' }, function (data) {
|
subscriptions[id] = (on({ id: id, change: 'any' }, function (data) {
|
||||||
|
log("RegisterEntityWatcher PageId:" + pageId.toString())
|
||||||
GeneratePage(config.pages[pageId]);
|
GeneratePage(config.pages[pageId]);
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -477,11 +477,11 @@ function toggleState(id: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function HandleButtonEvent(words): void {
|
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
|
var action = false
|
||||||
if (words[7] == "1")
|
if (words[4] == "1")
|
||||||
action = true
|
action = true
|
||||||
let o = getObject(id)
|
let o = getObject(id)
|
||||||
switch (o.common.role) {
|
switch (o.common.role) {
|
||||||
@@ -496,31 +496,28 @@ function HandleButtonEvent(words): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (words[6] == "up")
|
if (words[3] == "up")
|
||||||
setState(id + ".OPEN", true)
|
setState(id + ".OPEN", true)
|
||||||
if (words[6] == "stop")
|
if (words[3] == "stop")
|
||||||
setState(id + ".STOP", true)
|
setState(id + ".STOP", true)
|
||||||
if (words[6] == "down")
|
if (words[3] == "down")
|
||||||
setState(id + ".CLOSE", true)
|
setState(id + ".CLOSE", true)
|
||||||
if (words[6] == "button") {
|
if (words[3] == "button") {
|
||||||
let switchOn = true;
|
|
||||||
if (words[5] !== "1")
|
|
||||||
switchOn = false;
|
|
||||||
toggleState(id + ".SET") ? true : toggleState(id + ".ON_SET")
|
toggleState(id + ".SET") ? true : toggleState(id + ".ON_SET")
|
||||||
}
|
}
|
||||||
if (words[6] == "positionSlider")
|
if (words[3] == "positionSlider")
|
||||||
setState(id + ".SET", parseInt(words[7]))
|
setState(id + ".SET", parseInt(words[4]))
|
||||||
|
|
||||||
if (words[6] == "brightnessSlider")
|
if (words[3] == "brightnessSlider")
|
||||||
if (existsState(id + ".SET"))
|
if (existsState(id + ".SET"))
|
||||||
setState(id + ".SET", parseInt(words[7]));
|
setState(id + ".SET", parseInt(words[4]));
|
||||||
else if (existsState(id + ".ACTUAL"))
|
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]) })
|
// out_msgs.push({ payload: id, action: "turn_on", domain: "lightBrightness", brightness: parseInt(words[7]) })
|
||||||
// if (words[6] == "colorTempSlider")
|
// if (words[6] == "colorTempSlider")
|
||||||
// out_msgs.push({ payload: id, action: "turn_on", domain: "lightTemperature", temperature: parseInt(words[7]) })
|
// out_msgs.push({ payload: id, action: "turn_on", domain: "lightTemperature", temperature: parseInt(words[7]) })
|
||||||
if (words[1] == "tempUpd") {
|
if (words[3] == "tempUpd") {
|
||||||
setState(words[3] + ".SET", parseInt(words[4]) / 10)
|
setState(id + ".SET", parseInt(words[4]) / 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user