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*`
`popupExit`
`exitPopup`
### cardThermo Page

View File

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

View File

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

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.
`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

View File

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

View File

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