Compare commits

..

12 Commits

Author SHA1 Message Date
Johannes
5566f20e47 fixes #61 2022-03-24 17:24:47 +01:00
Johannes
48ed2daa33 Merge pull request #59 closes #58
Add name as config item
2022-03-24 16:14:46 +01:00
Gerard
8813331299 Update README.md 2022-03-24 16:11:06 +01:00
Gerard
abf4868281 Update README.md 2022-03-24 16:10:06 +01:00
Gerard
420905db04 Add name as config item
See FR #58
2022-03-24 16:08:21 +01:00
Johannes
4151aba6ea Update README.md 2022-03-24 14:56:48 +01:00
Johannes
35b15c92e0 Merge pull request #54 from joBr99/patch-buttonPress2
Migrate to new buttonPress cmd format
2022-03-23 22:11:48 +01:00
Johannes
c40906fdfe Merge pull request #56 from britzelpuf/patch-buttonPress2
Update NsPanelTs.ts
2022-03-23 22:11:23 +01:00
britzelpuf
66a65c03e8 Update NsPanelTs.ts
Update HandleMessage function to switch
Fix tempupd
2022-03-23 22:08:25 +01:00
Johannes
20e6f21307 Migrate to new buttonPress cmd format 2022-03-23 11:25:21 +01:00
joBr99
342a97df0f don't show palette icon if color temp isn't supported (add nextion2text) 2022-03-23 10:13:32 +00:00
Johannes Braun
0d343d4919 don't show palette icon if color temp isn't supported 2022-03-23 11:13:06 +01:00
8 changed files with 65 additions and 61 deletions

View File

@@ -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*` `entityUpdateDetail,*internalName*,*tHeading*,*tHeadingColor*,*b1*,*tB1Color*,*b2*,*tB2Color*,*tText*,*tTextColor*,*sleepTimeout*`
`popupExit` `exitPopup`
### cardThermo Page ### cardThermo Page

View File

@@ -34,14 +34,14 @@ pageTest
14 Component(s) 14 Component(s)
14 Line(s) of event code 14 Line(s) of event code
14 Unique 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 screensaver
25 Component(s) 25 Component(s)
173 Line(s) of event code 173 Line(s) of event code
124 Unique 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 cardThermo
42 Component(s) 42 Component(s)
412 Line(s) of event code 412 Line(s) of event code
@@ -62,5 +62,5 @@ cardAlarm
Total Total
14 Page(s) 14 Page(s)
349 Component(s) 349 Component(s)
3105 Line(s) of event code 3108 Line(s) of event code
827 Unique line(s) of event code 828 Unique line(s) of event code

View File

@@ -844,7 +844,7 @@ Timer tmSerial
} }
}else }else
{ {
mode_temp.val=0 mode_temp.val=1
vis hTempSlider,1 vis hTempSlider,1
vis t3,1 vis t3,1
vis t4,1 vis t4,1
@@ -867,7 +867,11 @@ Timer tmSerial
}else }else
{ {
vis t0,1 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) if(mode.val==0)
{ {
vis pColorWheel,1 vis pColorWheel,1

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -412,7 +412,7 @@ class LovelaceUIPanel:
if btype == "tempUpd": if btype == "tempUpd":
temp = int(optVal)/10 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): def generate_page(self, page_number):
# get type of page # get type of page
@@ -433,8 +433,10 @@ class LovelaceUIPanel:
def generate_entities_item(self, item): def generate_entities_item(self, item):
icon = None icon = None
name = None
if type(item) is dict: 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] item = next(iter(item.items()))[0]
# type of the item is the string before the "." in the item name # 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" return f",text,{item},{get_icon_id('alert-circle-outline')},17299,Not found check, apps.yaml"
entity = self.api.get_entity(item) 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": if item_type == "cover":
icon_id = get_icon_id_ha("cover", state=entity.state, overwrite=icon) icon_id = get_icon_id_ha("cover", state=entity.state, overwrite=icon)

View File

@@ -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)
} }
} }
@@ -811,4 +808,4 @@ type Config = {
pages: (PageThermo | PageEntities | PageGrid)[], pages: (PageThermo | PageEntities | PageGrid)[],
button1Page: (PageThermo | PageEntities | PageGrid | null), button1Page: (PageThermo | PageEntities | PageGrid | null),
button2Page: (PageThermo | PageEntities | PageGrid | null), button2Page: (PageThermo | PageEntities | PageGrid | null),
}; };