NEWS
SONOFF NSPanel mit Lovelace UI
-
-
@kuckuckmann sagte in SONOFF NSPanel mit Lovelace UI:
wurden in das Wiki auf GitHub zu übertragen. Vlt. kannst Du mal reinschauen und dies auch unter dem Video verlinken?
Gerne, habe ich als ersten Link drunter gepackt!
-
Hallo zusammen, Inspiriert von euren Ideen, Umsetzungen habe ich mich entschlossen mit einem ersten Panel zu starten. Gemäß Anleitung habe ich alles geflasht, konfiguriert, angelegt. Leider hänge ich nun seit einigen Tagen erfolglos an dem folgenden Fehler und komme einfach nicht weiter:
Erstellt habe ich die TS-Scripte wie in der Anleitung beschrieben, also zuerst nur die Pfade für MQTT und 0_userdata angepasst.
09:07:43.736 error javascript.0 (1008056) script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154javascript.0 2022-09-23 09:07:43.737 error at processImmediate (node:internal/timers:468:21) javascript.0 2022-09-23 09:07:43.736 error at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/main.js:1504:17) javascript.0 2022-09-23 09:07:43.736 error at /opt/iobroker/node_modules/iobroker.javascript/main.js:2017:17 javascript.0 2022-09-23 09:07:43.736 error at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1990:37) javascript.0 2022-09-23 09:07:43.736 error at createVM (/opt/iobroker/node_modules/iobroker.javascript/main.js:1679:24) javascript.0 2022-09-23 09:07:43.736 error at Object.createScript (node:vm:265:10) javascript.0 2022-09-23 09:07:43.736 error at new Script (node:vm:100:7) javascript.0 2022-09-23 09:07:43.736 error SyntaxError: await is only valid in async functions and the top level bodies of modules javascript.0 2022-09-23 09:07:43.736 error ^^^^^ javascript.0 2022-09-23 09:07:43.736 error await Datenpunkte_anlegen(); javascript.0 2022-09-23 09:07:43.736 error script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154
Ich komme nicht über diesen Punkt hinaus. Ich hoffe Ihr habt einen hilfreichen Tip für mich.
System:
javascript.0 v6.0.3
Node.js v16.17.0 -
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
Hallo zusammen, Inspiriert von euren Ideen, Umsetzungen habe ich mich entschlossen mit einem ersten Panel zu starten. Gemäß Anleitung habe ich alles geflasht, konfiguriert, angelegt. Leider hänge ich nun seit einigen Tagen erfolglos an dem folgenden Fehler und komme einfach nicht weiter:
Erstellt habe ich die TS-Scripte wie in der Anleitung beschrieben, also zuerst nur die Pfade für MQTT und 0_userdata angepasst.
09:07:43.736 error javascript.0 (1008056) script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154javascript.0 2022-09-23 09:07:43.737 error at processImmediate (node:internal/timers:468:21) javascript.0 2022-09-23 09:07:43.736 error at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/main.js:1504:17) javascript.0 2022-09-23 09:07:43.736 error at /opt/iobroker/node_modules/iobroker.javascript/main.js:2017:17 javascript.0 2022-09-23 09:07:43.736 error at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1990:37) javascript.0 2022-09-23 09:07:43.736 error at createVM (/opt/iobroker/node_modules/iobroker.javascript/main.js:1679:24) javascript.0 2022-09-23 09:07:43.736 error at Object.createScript (node:vm:265:10) javascript.0 2022-09-23 09:07:43.736 error at new Script (node:vm:100:7) javascript.0 2022-09-23 09:07:43.736 error SyntaxError: await is only valid in async functions and the top level bodies of modules javascript.0 2022-09-23 09:07:43.736 error ^^^^^ javascript.0 2022-09-23 09:07:43.736 error await Datenpunkte_anlegen(); javascript.0 2022-09-23 09:07:43.736 error script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154
Ich komme nicht über diesen Punkt hinaus. Ich hoffe Ihr habt einen hilfreichen Tip für mich.
System:
javascript.0 v6.0.3
Node.js v16.17.0Hmmm. Das Script scheitert aus meiner Sicht an einer Funktion "await Datenpunkte_anlegen();"
Ich kenne diese Funktion nicht. Hast du etwas erweitert?
Wenn du diesen roten Fehlerbalken bekommst, dann gibt es auf der rechten Seite auch mindestens einen roten Punkt, der den Fehler im Skript (dort auch rot unterstrichen) anzeigt. Ist da etwas rot?
Etwa so...
Die Zeilennummer ist im ioBroker keine Unterstützung. Es wird definitiv nicht die Definition dieser Konstante sein (Zeilennummer).
-
@armilar Leider ist kein roter Balken in dem gesamten Verlauf sichtbar, erweitert habe ich auch nichts, das Script habe ich nach Anleitung kopiert und nur den export-Part bisher angepasst:
export const config: Config = { panelRecvTopic: 'mqtt.1.SmartHome.NSPanel_1.tele.RESULT', // anpassen panelSendTopic: 'mqtt.1.SmartHome.NSPanel_1.cmnd.CustomSend', // anpassen firstScreensaverEntity: { ScreensaverEntity: "accuweather.0.Daily.Day1.Day.PrecipitationProbability", ScreensaverEntityIcon: "weather-pouring", ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100} }, secondScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.WindSpeed", ScreensaverEntityIcon: "weather-windy", ScreensaverEntityText: "Wind", ScreensaverEntityUnitText: "km/h", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 180} }, thirdScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.UVIndex", ScreensaverEntityIcon: "solar-power", ScreensaverEntityText: "UV", ScreensaverEntityUnitText: "", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 9} }, fourthScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.RelativeHumidity", ScreensaverEntityIcon: "water-percent", ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100, 'val_best': 65} }, alternativeScreensaverLayout: false, autoWeatherColorScreensaverLayout: true, mrIcon1ScreensaverEntity: { ScreensaverEntity: 'mqtt.1.SmartHome.NSPanel_1.stat.POWER1', ScreensaverEntityIcon: 'light-switch', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off }, mrIcon2ScreensaverEntity: { ScreensaverEntity: 'mqtt.1.SmartHome.NSPanel_1.stat.POWER2', ScreensaverEntityIcon: 'lightbulb', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off }, timeoutScreensaver: 15, dimmode: 20,
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@armilar Leider ist kein roter Balken in dem gesamten Verlauf sichtbar, erweitert habe ich auch nichts, das Script habe ich nach Anleitung kopiert und nur den export-Part bisher angepasst:
export const config: Config = { panelRecvTopic: 'mqtt.1.SmartHome.NSPanel_1.tele.RESULT', // anpassen panelSendTopic: 'mqtt.1.SmartHome.NSPanel_1.cmnd.CustomSend', // anpassen firstScreensaverEntity: { ScreensaverEntity: "accuweather.0.Daily.Day1.Day.PrecipitationProbability", ScreensaverEntityIcon: "weather-pouring", ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100} }, secondScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.WindSpeed", ScreensaverEntityIcon: "weather-windy", ScreensaverEntityText: "Wind", ScreensaverEntityUnitText: "km/h", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 180} }, thirdScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.UVIndex", ScreensaverEntityIcon: "solar-power", ScreensaverEntityText: "UV", ScreensaverEntityUnitText: "", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 9} }, fourthScreensaverEntity: { ScreensaverEntity: "accuweather.0.Current.RelativeHumidity", ScreensaverEntityIcon: "water-percent", ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%", ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100, 'val_best': 65} }, alternativeScreensaverLayout: false, autoWeatherColorScreensaverLayout: true, mrIcon1ScreensaverEntity: { ScreensaverEntity: 'mqtt.1.SmartHome.NSPanel_1.stat.POWER1', ScreensaverEntityIcon: 'light-switch', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off }, mrIcon2ScreensaverEntity: { ScreensaverEntity: 'mqtt.1.SmartHome.NSPanel_1.stat.POWER2', ScreensaverEntityIcon: 'lightbulb', ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: Off }, timeoutScreensaver: 15, dimmode: 20,
Neben dem Script gibt es diesen Schraubenschlüssel. Bitte mal verbose anhaken, script kompilieren und dann den Inhalt aus dem Log senden. Finde das sehr mysteriös -
javascript.0 2022-09-23 11:26:32.057 error at processImmediate (node:internal/timers:468:21) javascript.0 2022-09-23 11:26:32.057 error at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/main.js:1504:17) javascript.0 2022-09-23 11:26:32.057 error at /opt/iobroker/node_modules/iobroker.javascript/main.js:2017:17 javascript.0 2022-09-23 11:26:32.057 error at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1990:37) javascript.0 2022-09-23 11:26:32.057 error at createVM (/opt/iobroker/node_modules/iobroker.javascript/main.js:1679:24) javascript.0 2022-09-23 11:26:32.057 error at Object.createScript (node:vm:265:10) javascript.0 2022-09-23 11:26:32.057 error at new Script (node:vm:100:7) javascript.0 2022-09-23 11:26:32.057 error SyntaxError: await is only valid in async functions and the top level bodies of modules javascript.0 2022-09-23 11:26:32.057 error ^^^^^ javascript.0 2022-09-23 11:26:32.057 error await Datenpunkte_anlegen(); javascript.0 2022-09-23 11:26:32.057 error script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154 javascript.0 2022-09-23 11:26:32.054 info script.js.common.NSPanel_1: TypeScript compilation successful javascript.0 2022-09-23 11:26:29.430 info script.js.common.NSPanel_1: compiling TypeScript source... javascript.0 2022-09-23 11:26:29.396 debug File /home/Javascript/common/NSPanel_1.ts change
Nachtrag: Ich habe angefangen meine anderen Scripte einmal zu deaktivieren, auf halber Strecke fing das nspanel.ts Script dann plötzlich an zu laufen, kann aber noch nicht sagen welches Script es war. Zumindest sind nun die Datenpunkte schon einmal angelegt
11:42:20.850 info javascript.0 (1013313) script.js.common.NSPanel_1: compiling TypeScript source...
11:42:21.046 info javascript.0 (1013313) script.js.common.NSPanel_1: source code did not change, using cached compilation result...
11:42:21.065 info javascript.0 (1013313) script.js.common.NSPanel_1: registered 12 subscriptions, 6 schedules, 0 messages, 0 logs and 0 file subscriptions
11:42:21.372 warn javascript.0 (1013313) at script.js.common.NSPanel_1:1185:46
11:42:21.372 warn javascript.0 (1013313) at step (script.js.common.NSPanel_1:33:23)
11:42:21.372 warn javascript.0 (1013313) at Object.next (script.js.common.NSPanel_1:14:53)
11:42:21.372 warn javascript.0 (1013313) at fulfilled (script.js.common.NSPanel_1:5:58) -
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
javascript.0 2022-09-23 11:26:32.057 error at processImmediate (node:internal/timers:468:21) javascript.0 2022-09-23 11:26:32.057 error at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/main.js:1504:17) javascript.0 2022-09-23 11:26:32.057 error at /opt/iobroker/node_modules/iobroker.javascript/main.js:2017:17 javascript.0 2022-09-23 11:26:32.057 error at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1990:37) javascript.0 2022-09-23 11:26:32.057 error at createVM (/opt/iobroker/node_modules/iobroker.javascript/main.js:1679:24) javascript.0 2022-09-23 11:26:32.057 error at Object.createScript (node:vm:265:10) javascript.0 2022-09-23 11:26:32.057 error at new Script (node:vm:100:7) javascript.0 2022-09-23 11:26:32.057 error SyntaxError: await is only valid in async functions and the top level bodies of modules javascript.0 2022-09-23 11:26:32.057 error ^^^^^ javascript.0 2022-09-23 11:26:32.057 error await Datenpunkte_anlegen(); javascript.0 2022-09-23 11:26:32.057 error script.js.common.NSPanel_1 compile failed: at script.js.common.NSPanel_1:154 javascript.0 2022-09-23 11:26:32.054 info script.js.common.NSPanel_1: TypeScript compilation successful javascript.0 2022-09-23 11:26:29.430 info script.js.common.NSPanel_1: compiling TypeScript source... javascript.0 2022-09-23 11:26:29.396 debug File /home/Javascript/common/NSPanel_1.ts change
Bekomme immer noch nicht auf den Schirm, wo dieser Funktionsaufruf await Datenpunkte_anlegen() herkommt . Also ein Funktionsaufruf, der in einer Funktion aufgerufen wird, die nicht async ist... Und vor allem, die kein Teil dieses Scriptes ist?
Welche Version vom JS-Controller und welche NodeJS Version benutzt du?
Nachtrag - gute Idee - Die Lokalisierung des Skriptes nacheinander. Ist bestimmt diese komische Funktion drin
-
@armilar
javascript.0 v6.0.3
Node.js v16.17.0 -
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@armilar
javascript.0 v6.0.3
Node.js v16.17.0Siehe Erweiterung (Nachtrag) und wenn du diesen ominösen Funktionsaufruf gefunden hast, dann entweder "async" vor die function oder "await" rausnehmen
Beschreibe "auf halber Strecke fing das nspanel.ts Script dann plötzlich an zu laufen". Funktioniert das Panel nun oder nicht?
Wenn ich tippen müsste, dann würde ich sagen: "sehe mal in das andere Script "testansage" im global-Verzeichnis, ob das diese Funktion hat."
-
@armilar
Das Verursachende Script habe ich gefunden, eine Altlast aus den Anfängen mit Alexa, dieses habe ich nun deaktiviert und wird auch nicht mehr benötigt.
Auf dem Panel selbst wird leider noch nichts angezeigt, aktuell wird an mqtt.1.SmartHome.NSPanel_1.cmnd.CustomSend immer timeout~15 gesendet
Es war die Testansage -
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@armilar
Das Verursachende Script habe ich gefunden, eine Altlast aus den Anfängen mit Alexa, dieses habe ich nun deaktiviert und wird auch nicht mehr benötigt.
Auf dem Panel selbst wird leider noch nichts angezeigt, aktuell wird an mqtt.1.SmartHome.NSPanel_1.cmnd.CustomSend immer timeout~15 gesendet
Es war die TestansageDas kostet dich mindestens einen Daumen nach oben
Die Nachricht ist perfekt. Jetzt haben wir wahrscheinlich noch ein Problem im mqtt.1.
Edit:
Was macht denn das Panel gerade? Waiting for content?
Kommt im mqtt.1.SmartHome.NSPanel_1.tele.RESULT etwas an?
Häufigste Ursachen:
- mqtt.1. hat einen Port eingestellt, der bereits in mqtt.0. oder sonsoff.0. oder shelly.0. verwendet wird.
- mqtt.1. ist falsch konfiguriert in der Instanz
- berry-Driver ist nicht korrekt installiert. Dann alle Daten rauswerfen und autoexec.be neu anlegen + starten
- tasmota hat die falschen mqtt Einstellungen (auch Portnummer sollte analog mqtt.1. sein)
Hier findest du ebenfalls Hinweise und Configs für mqtt.X. :
https://github.com/joBr99/nspanel-lovelace-ui/wiki/ioBroker---Basisinstallation (Punkt 4 und 6) -
@armilar Daumen hoch auf jeden Fall
Waiting for content.
Als MQTT verwende ich mosquitto, hier funktioniert die Anbindung:
1663929903: New connection from 192.168.178.140:62638 on port 1883.
1663929903: New client connected from 192.168.178.140:62638 as NSPanel_1 (p2, c1, k30, u'DVES_E7EFAC').Der IOBroker ist nur als Client konfiguriert.
Im mqtt.1.SmartHome.NSPanel_1.tele.RESULT kommt an:
{"CustomRecv":"event,startup,42,eu"}Im MQTT kommt auch etwas an:
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@armilar
Waiting for content.
Als MQTT verwende ich mosquitto, hier funktioniert die Anbindung:
1663929903: New connection from 192.168.178.140:62638 on port 1883.
1663929903: New client connected from 192.168.178.140:62638 as NSPanel_1 (p2, c1, k30, u'DVES_E7EFAC').Der IOBroker ist nur als Client konfiguriert.
Im mqtt.1.SmartHome.NSPanel_1.tele.RESULT kommt an:
{"CustomRecv":"event,startup,42,eu"}Im MQTT kommt auch etwas an:
Berry Driver nochmal neu gemacht? Also autoexe.be und autoexec.bec weggeworfen?
https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be
danach Panel restarten
und falls dann immer noch nicht funktioniert nochmal:
FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v3.4.0.tft
Das Tasmota und das Script sprechen schon miteinander. Das Nextion aber noch nicht mit Tasmota...
-
14:31:31.836 CMD: FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v3.4.0.tft 14:31:31.853 MQT: SmartHome/NSPanel_1/stat/RESULT = {"FlashNextion":"Done"} 14:31:31.894 FLH: host: nspanel.pky.eu, port: 80, get: /lovelace-ui/github/nspanel-v3.4.0.tft 14:31:33.187 FLH: Send (High Speed) flash start 14:31:33.621 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 0, "time_elapsed": 0}} 14:31:34.169 FLH: host: nspanel.pky.eu, port: 80, get: /lovelace-ui/github/nspanel-v3.4.0.tft 14:31:35.294 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 90, "time_elapsed": 2}} 14:31:36.710 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 91, "time_elapsed": 3}} 14:31:39.662 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 92, "time_elapsed": 6}} 14:31:42.604 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 93, "time_elapsed": 9}} 14:31:45.691 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 94, "time_elapsed": 12}} 14:31:48.630 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 95, "time_elapsed": 15}} 14:31:51.587 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 96, "time_elapsed": 18}} 14:31:54.341 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 97, "time_elapsed": 21}} 14:31:57.284 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 98, "time_elapsed": 24}} 14:32:00.266 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 99, "time_elapsed": 27}} 14:32:00.673 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.701 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:32:06.709 NXP: Screen Initialized 14:32:06.831 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.930 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.993 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"}
Keine Ahnung was da schief läuft, die autoexec.be habe ich nun zum x-ten mal erneuert (alte Dateien zuvor gelöscht), dann nspanel-v3.4.0.tft erneut geflasht, das fängt dann aber nicht bei 1% an sondern wie oben zu sehen bei 90%
00:00:00.003 HDW: ESP32-D0WD-V3 00:00:00.088 UFS: FlashFS mounted with 292 kB free 00:00:00.182 CFG: Loaded from File, Anzahl 21 00:00:00.197 QPC: Count 1 00:00:00.423 BRY: Berry initialized, RAM used=3735 bytes 00:00:00.455 Projekt tasmota - Tasmota Version 12.1.1(tasmota)-2_0_4_1(2022.08.25 11:41:45) 00:00:00.173 NXP: Initializing Driver 00:00:00.181 BRY: Successfully loaded 'autoexec.be' 00:00:01.889 WIF: verbinden mit AP1 suppe2 Channel 6 BSSId 2C:3A:FD:A2:BE:A6 in Modus 11n als NSPanel-1-4012... 00:00:06.127 RSL: RESULT = {"CustomRecv":"event,startup,42,eu"} 00:00:06.765 WIF: verbunden 14:36:26.131 HTP: Web-Server aktiv bei NSPanel-1-4012 mit IP-Adresse 192.168.178.140 14:36:27.787 QPC: Reset 14:36:30.757 MQT: Verbindungsversuch... 14:36:30.796 MQT: verbunden 14:36:30.802 MQT: SmartHome/NSPanel_1/tele/LWT = Online (beibehalten) 14:36:30.806 MQT: SmartHome/NSPanel_1/cmnd/POWER = 14:36:30.823 MQT: SmartHome/NSPanel_1/tele/INFO1 = {"Info1":{"Module":"NSPanel","Version":"12.1.1(tasmota)","FallbackTopic":"cmnd/NSPanel_1_fb/","GroupTopic":"SmartHome/tasmotas/cmnd/"}} 14:36:30.842 MQT: SmartHome/NSPanel_1/tele/INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"NSPanel-1-4012","IPAddress":"192.168.178.140"}} 14:36:30.858 MQT: SmartHome/NSPanel_1/tele/INFO3 = {"Info3":{"RestartReason":"Software reset CPU","BootCount":10}} 14:36:30.863 MQT: SmartHome/NSPanel_1/stat/RESULT = {"POWER1":"OFF"} 14:36:30.867 MQT: SmartHome/NSPanel_1/stat/POWER1 = OFF 14:36:30.882 MQT: SmartHome/NSPanel_1/stat/RESULT = {"POWER2":"OFF"} 14:36:30.886 MQT: SmartHome/NSPanel_1/stat/POWER2 = OFF 14:36:32.098 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:32.214 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:32.258 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:32.560 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:34.949 MQT: SmartHome/NSPanel_1/tele/STATE = {"Time":"2022-09-23T14:36:34","Uptime":"0T00:00:15","UptimeSec":15,"Heap":133,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":70,"MqttCount":1,"Berry":{"HeapUsed":13,"Objects":213},"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"suppe2","BSSId":"2C:3A:FD:A2:BE:A6","Channel":6,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:06"}} 14:36:34.996 MQT: SmartHome/NSPanel_1/tele/SENSOR = {"Time":"2022-09-23T14:36:34","ANALOG":{"Temperature1":3.6},"ESP32":{"Temperature":67.8},"TempUnit":"C"} 14:36:38.352 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:38.473 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:38.524 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:38.581 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.359 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:44.430 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.476 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.524 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:50.335 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:50.452 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"}
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
14:31:31.836 CMD: FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v3.4.0.tft 14:31:31.853 MQT: SmartHome/NSPanel_1/stat/RESULT = {"FlashNextion":"Done"} 14:31:31.894 FLH: host: nspanel.pky.eu, port: 80, get: /lovelace-ui/github/nspanel-v3.4.0.tft 14:31:33.187 FLH: Send (High Speed) flash start 14:31:33.621 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 0, "time_elapsed": 0}} 14:31:34.169 FLH: host: nspanel.pky.eu, port: 80, get: /lovelace-ui/github/nspanel-v3.4.0.tft 14:31:35.294 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 90, "time_elapsed": 2}} 14:31:36.710 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 91, "time_elapsed": 3}} 14:31:39.662 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 92, "time_elapsed": 6}} 14:31:42.604 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 93, "time_elapsed": 9}} 14:31:45.691 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 94, "time_elapsed": 12}} 14:31:48.630 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 95, "time_elapsed": 15}} 14:31:51.587 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 96, "time_elapsed": 18}} 14:31:54.341 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 97, "time_elapsed": 21}} 14:31:57.284 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 98, "time_elapsed": 24}} 14:32:00.266 MQT: SmartHome/NSPanel_1/tele/RESULT = {"Flashing":{"complete": 99, "time_elapsed": 27}} 14:32:00.673 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.701 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:32:06.709 NXP: Screen Initialized 14:32:06.831 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.930 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:32:06.993 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"}
Keine Ahnung was da schief läuft, die autoexec.be habe ich nun zum x-ten mal erneuert (alte Dateien zuvor gelöscht), dann nspanel-v3.4.0.tft erneut geflasht, das fängt dann aber nicht bei 1% an sondern wie oben zu sehen bei 90%
00:00:00.003 HDW: ESP32-D0WD-V3 00:00:00.088 UFS: FlashFS mounted with 292 kB free 00:00:00.182 CFG: Loaded from File, Anzahl 21 00:00:00.197 QPC: Count 1 00:00:00.423 BRY: Berry initialized, RAM used=3735 bytes 00:00:00.455 Projekt tasmota - Tasmota Version 12.1.1(tasmota)-2_0_4_1(2022.08.25 11:41:45) 00:00:00.173 NXP: Initializing Driver 00:00:00.181 BRY: Successfully loaded 'autoexec.be' 00:00:01.889 WIF: verbinden mit AP1 suppe2 Channel 6 BSSId 2C:3A:FD:A2:BE:A6 in Modus 11n als NSPanel-1-4012... 00:00:06.127 RSL: RESULT = {"CustomRecv":"event,startup,42,eu"} 00:00:06.765 WIF: verbunden 14:36:26.131 HTP: Web-Server aktiv bei NSPanel-1-4012 mit IP-Adresse 192.168.178.140 14:36:27.787 QPC: Reset 14:36:30.757 MQT: Verbindungsversuch... 14:36:30.796 MQT: verbunden 14:36:30.802 MQT: SmartHome/NSPanel_1/tele/LWT = Online (beibehalten) 14:36:30.806 MQT: SmartHome/NSPanel_1/cmnd/POWER = 14:36:30.823 MQT: SmartHome/NSPanel_1/tele/INFO1 = {"Info1":{"Module":"NSPanel","Version":"12.1.1(tasmota)","FallbackTopic":"cmnd/NSPanel_1_fb/","GroupTopic":"SmartHome/tasmotas/cmnd/"}} 14:36:30.842 MQT: SmartHome/NSPanel_1/tele/INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"NSPanel-1-4012","IPAddress":"192.168.178.140"}} 14:36:30.858 MQT: SmartHome/NSPanel_1/tele/INFO3 = {"Info3":{"RestartReason":"Software reset CPU","BootCount":10}} 14:36:30.863 MQT: SmartHome/NSPanel_1/stat/RESULT = {"POWER1":"OFF"} 14:36:30.867 MQT: SmartHome/NSPanel_1/stat/POWER1 = OFF 14:36:30.882 MQT: SmartHome/NSPanel_1/stat/RESULT = {"POWER2":"OFF"} 14:36:30.886 MQT: SmartHome/NSPanel_1/stat/POWER2 = OFF 14:36:32.098 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:32.214 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:32.258 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:32.560 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:34.949 MQT: SmartHome/NSPanel_1/tele/STATE = {"Time":"2022-09-23T14:36:34","Uptime":"0T00:00:15","UptimeSec":15,"Heap":133,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":70,"MqttCount":1,"Berry":{"HeapUsed":13,"Objects":213},"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"suppe2","BSSId":"2C:3A:FD:A2:BE:A6","Channel":6,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:06"}} 14:36:34.996 MQT: SmartHome/NSPanel_1/tele/SENSOR = {"Time":"2022-09-23T14:36:34","ANALOG":{"Temperature1":3.6},"ESP32":{"Temperature":67.8},"TempUnit":"C"} 14:36:38.352 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:38.473 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:38.524 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:38.581 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.359 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:44.430 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.476 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:44.524 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"} 14:36:50.335 MQT: SmartHome/NSPanel_1/tele/RESULT = {"CustomRecv":"event,startup,42,eu"} 14:36:50.452 MQT: SmartHome/NSPanel_1/stat/RESULT = {"CustomSend":"Done"}
Sieht für mich auch alles normal aus.
Was passiert, wenn du in die Tasmota-Console das Command eingibst?
CustomSend time~12:00
mqtt.1. empfängt zwar Daten, aber wie sieht es mit dem Senden aus?
Ich sag es ja ungern, aber evtl. mal den Weg ohne den Mosquitto wie beschrieben versuchen
Also nur weil in dem Datenpunkt CustomSend Daten drin stehen, heißt das noch nicht, dass dein Mosquitto die auch auf das Device bringt.
Und für den Fall das du es testest, verwende bitte nicht schon wieder den Port 1883
-
Wenn FlashNextion geht, sollte das Berry Skript passen, wenn über MQTT trotzdem nichts kommt, ist es in der regel etwas mit den tasmota mqtt settings
-
Grundsätzlich scheint etwas über MQTT anzukommen, das Schalten von POWER1 manuell über das Objekt SmartHome/NSPanel_1/cmnd/POWER funktioniert.
Wenn ich CustomSend time~12:00 in der Konsole absende, wird aber nichts auf dem Display angezeigt.
autexec.be:# Sonoff NSPanel Tasmota Lovelace UI Berry Driver | code by joBr99 # based on; # Sonoff NSPanel Tasmota (Nextion with Flashing) driver | code by peepshow-21 # based on; # Sonoff NSPanel Tasmota driver v0.47 | code by blakadder and s-hadinger # Example Flash # FlashNextion http://ip-address-of-your-homeassistant:8123/local/nspanel.tft # FlashNextion http://nspanel.pky.eu/lui.tft class Nextion : Driver static header = bytes('55BB') static flash_block_size = 4096 var flash_mode var flash_start_millis var flash_size var flash_written var flash_buff var flash_offset var awaiting_offset var tcp var ser var last_per var url def split_55(b) var ret = [] var s = size(b) var i = s-2 # start from last-1 while i > 0 if b[i] == 0x55 && b[i+1] == 0xBB ret.push(b[i..s-1]) # push last msg to list b = b[(0..i-1)] # write the rest back to b end i -= 1 end ret.push(b) return ret end def crc16(data, poly) if !poly poly = 0xA001 end # CRC-16 MODBUS HASHING ALGORITHM var crc = 0xFFFF for i:0..size(data)-1 crc = crc ^ data[i] for j:0..7 if crc & 1 crc = (crc >> 1) ^ poly else crc = crc >> 1 end end end return crc end # encode using custom protocol 55 BB [payload length] [payload length] [payload] [crc] [crc] def encode(payload) var b = bytes() b += self.header b.add(size(payload), 2) # add size as 2 bytes, little endian b += bytes().fromstring(payload) var msg_crc = self.crc16(b) b.add(msg_crc, 2) # crc 2 bytes, little endian return b end def encodenx(payload) var b = bytes().fromstring(payload) b += bytes('FFFFFF') return b end def sendnx(payload) import string var payload_bin = self.encodenx(payload) self.ser.write(payload_bin) log(string.format("NXP: Nextion command sent = %s",str(payload_bin)), 3) end def send(payload) var payload_bin = self.encode(payload) if self.flash_mode==1 log("NXP: skipped command becuase still flashing", 3) else self.ser.write(payload_bin) log("NXP: payload sent = " + str(payload_bin), 3) end end def write_to_nextion(b) self.ser.write(b) end def screeninit() log("NXP: Screen Initialized") self.sendnx("recmod=1") end def write_block() import string log("FLH: Read block",3) while size(self.flash_buff)<self.flash_block_size && self.tcp.connected() if self.tcp.available()>0 self.flash_buff += self.tcp.readbytes() else tasmota.delay(50) log("FLH: Wait for available...",3) end end log("FLH: Buff size "+str(size(self.flash_buff)),3) var to_write if size(self.flash_buff)>self.flash_block_size to_write = self.flash_buff[0..self.flash_block_size-1] self.flash_buff = self.flash_buff[self.flash_block_size..] else to_write = self.flash_buff self.flash_buff = bytes() end log("FLH: Writing "+str(size(to_write)),3) var per = (self.flash_written*100)/self.flash_size if (self.last_per!=per) self.last_per = per tasmota.publish_result(string.format("{\"Flashing\":{\"complete\": %d, \"time_elapsed\": %d}}",per , (tasmota.millis()-self.flash_start_millis)/1000), "RESULT") end if size(to_write)>0 self.flash_written += size(to_write) self.ser.write(to_write) end log("FLH: Total "+str(self.flash_written),3) if (self.flash_written==self.flash_size) log("FLH: Flashing complete - Time elapsed: %d", (tasmota.millis()-self.flash_start_millis)/1000) self.flash_mode = 0 self.ser = nil tasmota.gc() self.ser = serial(17, 16, 115200, serial.SERIAL_8N1) end end def every_100ms() import string if self.ser.available() > 0 var msg = self.ser.read() if size(msg) > 0 log(string.format("NXP: Received Raw = %s",str(msg)), 3) if (self.flash_mode==1) var strv = msg[0..-4].asstring() if string.find(strv,"comok 2")>=0 log("FLH: Send (High Speed) flash start") self.flash_start_millis = tasmota.millis() #self.sendnx(string.format("whmi-wris %d,115200,res0",self.flash_size)) self.sendnx(string.format("whmi-wris %d,921600,res0",self.flash_size)) self.ser = serial(17, 16, 921600, serial.SERIAL_8N1) elif size(msg)==1 && msg[0]==0x08 log("FLH: Waiting offset...",3) self.awaiting_offset = 1 elif size(msg)==4 && self.awaiting_offset==1 self.awaiting_offset = 0 self.flash_offset = msg.get(0,4) log("FLH: Flash offset marker "+str(self.flash_offset),3) if self.flash_offset != 0 self.open_url_at(self.url, self.flash_offset) self.flash_written = self.flash_offset end self.write_block() elif size(msg)==1 && msg[0]==0x05 self.write_block() else log("FLH: Something has gone wrong flashing display firmware ["+str(msg)+"]",2) end else var msg_list = self.split_55(msg) for i:0..size(msg_list)-1 msg = msg_list[i] if size(msg) > 0 if msg == bytes('000000FFFFFF88FFFFFF') self.screeninit() elif size(msg)>=2 && msg[0]==0x55 && msg[1]==0xBB var jm = string.format("{\"CustomRecv\":\"%s\"}",msg[4..-3].asstring()) tasmota.publish_result(jm, "RESULT") elif msg[0]==0x07 && size(msg)==1 # BELL/Buzzer tasmota.cmd("buzzer 1,1") else var jm = string.format("{\"nextion\":\"%s\"}",str(msg[0..-4])) tasmota.publish_result(jm, "RESULT") end end end end end end end def begin_nextion_flash() self.flash_written = 0 self.awaiting_offset = 0 self.flash_offset = 0 self.sendnx('DRAKJHSUYDGBNCJHGJKSHBDN') self.sendnx('recmod=0') self.sendnx('recmod=0') self.flash_mode = 1 self.sendnx("connect") end def open_url_at(url, pos) self.url = url import string var host var port var s1 = string.split(url,7)[1] var i = string.find(s1,":") var sa if i<0 port = 80 i = string.find(s1,"/") sa = string.split(s1,i) host = sa[0] else sa = string.split(s1,i) host = sa[0] s1 = string.split(sa[1],1)[1] i = string.find(s1,"/") sa = string.split(s1,i) port = int(sa[0]) end var get = sa[1] log(string.format("FLH: host: %s, port: %s, get: %s",host,port,get)) self.tcp = tcpclient() self.tcp.connect(host,port) log("FLH: Connected:"+str(self.tcp.connected()),3) var get_req = "GET "+get+" HTTP/1.0\r\n" get_req += string.format("Range: bytes=%d-\r\n", pos) get_req += string.format("HOST: %s:%s\r\n\r\n",host,port) self.tcp.write(get_req) var a = self.tcp.available() i = 1 while a==0 && i<5 tasmota.delay(100*i) tasmota.yield() i += 1 log("FLH: Retry "+str(i),3) a = self.tcp.available() end if a==0 log("FLH: Nothing available to read!",3) return end var b = self.tcp.readbytes() i = 0 var end_headers = false; var headers while i<size(b) && headers==nil if b[i..(i+3)]==bytes().fromstring("\r\n\r\n") headers = b[0..(i+3)].asstring() self.flash_buff = b[(i+4)..] else i += 1 end end #print(headers) # check http respose for code 200/206 if string.find(headers,"200 OK")>0 || string.find(headers,"206 Partial Content")>0 log("FLH: HTTP Respose is 200 OK or 206 Partial Content",3) else log("FLH: HTTP Respose is not 200 OK or 206 Partial Content",3) print(headers) return -1 end # only set flash size if pos is zero if pos == 0 # check http respose for content-length var tag = "Content-Length: " i = string.find(headers,tag) if (i>0) var i2 = string.find(headers,"\r\n",i) var s = headers[i+size(tag)..i2-1] self.flash_size=int(s) end log("FLH: Flash file size: "+str(self.flash_size),3) end end def flash_nextion(url) self.flash_size = 0 var res = self.open_url_at(url, 0) if res != -1 self.begin_nextion_flash() end end def init() log("NXP: Initializing Driver") self.ser = serial(17, 16, 115200, serial.SERIAL_8N1) self.flash_mode = 0 end end var nextion = Nextion() tasmota.add_driver(nextion) def get_current_version(cmd, idx, payload, payload_json) import string var version_of_this_script = 4 var jm = string.format("{\"nlui_driver_version\":\"%s\"}", version_of_this_script) tasmota.publish_result(jm, "RESULT") end tasmota.add_cmd('GetDriverVersion', get_current_version) def update_berry_driver(cmd, idx, payload, payload_json) def task() import string var cl = webclient() cl.begin(payload) var r = cl.GET() if r == 200 print("Sucessfully downloaded nspanel-lovelace-ui berry driver") else print("Error while downloading nspanel-lovelace-ui berry driver") end r = cl.write_file("autoexec.be") if r < 0 print("Error while writeing nspanel-lovelace-ui berry driver") else print("Sucessfully written nspanel-lovelace-ui berry driver") var s = load('autoexec.be') if s == true var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "succeeded") tasmota.publish_result(jm, "RESULT") else var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "failed") tasmota.publish_result(jm, "RESULT") end end end tasmota.set_timer(0,task) tasmota.resp_cmnd_done() end tasmota.add_cmd('UpdateDriverVersion', update_berry_driver) def flash_nextion(cmd, idx, payload, payload_json) def task() nextion.flash_nextion(payload) end tasmota.set_timer(0,task) tasmota.resp_cmnd_done() end def send_cmd(cmd, idx, payload, payload_json) nextion.sendnx(payload) tasmota.resp_cmnd_done() end def send_cmd2(cmd, idx, payload, payload_json) nextion.send(payload) tasmota.resp_cmnd_done() end tasmota.add_cmd('Nextion', send_cmd) tasmota.add_cmd('CustomSend', send_cmd2) tasmota.add_cmd('FlashNextion', flash_nextion)
MQTT-Settings:
Sonstige Einstellungen/Vorlage
{"NAME":"NSPanel","GPIO":[0,0,0,0,3872,0,0,0,0,0,32,0,0,0,0,225,0,480,224,1,0,0,0,33,0,0,0,0,0,0,0,0,0,0,4736,0],"FLAG":0,"BASE":1}
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
Grundsätzlich scheint etwas über MQTT anzukommen, das Schalten von POWER1 manuell über das Objekt SmartHome/NSPanel_1/cmnd/POWER funktioniert.
Wenn ich CustomSend time~12:00 in der Konsole absende, wird aber nichts auf dem Display angezeigt.
autexec.be:# Sonoff NSPanel Tasmota Lovelace UI Berry Driver | code by joBr99 # based on; # Sonoff NSPanel Tasmota (Nextion with Flashing) driver | code by peepshow-21 # based on; # Sonoff NSPanel Tasmota driver v0.47 | code by blakadder and s-hadinger # Example Flash # FlashNextion http://ip-address-of-your-homeassistant:8123/local/nspanel.tft # FlashNextion http://nspanel.pky.eu/lui.tft class Nextion : Driver static header = bytes('55BB') static flash_block_size = 4096 var flash_mode var flash_start_millis var flash_size var flash_written var flash_buff var flash_offset var awaiting_offset var tcp var ser var last_per var url def split_55(b) var ret = [] var s = size(b) var i = s-2 # start from last-1 while i > 0 if b[i] == 0x55 && b[i+1] == 0xBB ret.push(b[i..s-1]) # push last msg to list b = b[(0..i-1)] # write the rest back to b end i -= 1 end ret.push(b) return ret end def crc16(data, poly) if !poly poly = 0xA001 end # CRC-16 MODBUS HASHING ALGORITHM var crc = 0xFFFF for i:0..size(data)-1 crc = crc ^ data[i] for j:0..7 if crc & 1 crc = (crc >> 1) ^ poly else crc = crc >> 1 end end end return crc end # encode using custom protocol 55 BB [payload length] [payload length] [payload] [crc] [crc] def encode(payload) var b = bytes() b += self.header b.add(size(payload), 2) # add size as 2 bytes, little endian b += bytes().fromstring(payload) var msg_crc = self.crc16(b) b.add(msg_crc, 2) # crc 2 bytes, little endian return b end def encodenx(payload) var b = bytes().fromstring(payload) b += bytes('FFFFFF') return b end def sendnx(payload) import string var payload_bin = self.encodenx(payload) self.ser.write(payload_bin) log(string.format("NXP: Nextion command sent = %s",str(payload_bin)), 3) end def send(payload) var payload_bin = self.encode(payload) if self.flash_mode==1 log("NXP: skipped command becuase still flashing", 3) else self.ser.write(payload_bin) log("NXP: payload sent = " + str(payload_bin), 3) end end def write_to_nextion(b) self.ser.write(b) end def screeninit() log("NXP: Screen Initialized") self.sendnx("recmod=1") end def write_block() import string log("FLH: Read block",3) while size(self.flash_buff)<self.flash_block_size && self.tcp.connected() if self.tcp.available()>0 self.flash_buff += self.tcp.readbytes() else tasmota.delay(50) log("FLH: Wait for available...",3) end end log("FLH: Buff size "+str(size(self.flash_buff)),3) var to_write if size(self.flash_buff)>self.flash_block_size to_write = self.flash_buff[0..self.flash_block_size-1] self.flash_buff = self.flash_buff[self.flash_block_size..] else to_write = self.flash_buff self.flash_buff = bytes() end log("FLH: Writing "+str(size(to_write)),3) var per = (self.flash_written*100)/self.flash_size if (self.last_per!=per) self.last_per = per tasmota.publish_result(string.format("{\"Flashing\":{\"complete\": %d, \"time_elapsed\": %d}}",per , (tasmota.millis()-self.flash_start_millis)/1000), "RESULT") end if size(to_write)>0 self.flash_written += size(to_write) self.ser.write(to_write) end log("FLH: Total "+str(self.flash_written),3) if (self.flash_written==self.flash_size) log("FLH: Flashing complete - Time elapsed: %d", (tasmota.millis()-self.flash_start_millis)/1000) self.flash_mode = 0 self.ser = nil tasmota.gc() self.ser = serial(17, 16, 115200, serial.SERIAL_8N1) end end def every_100ms() import string if self.ser.available() > 0 var msg = self.ser.read() if size(msg) > 0 log(string.format("NXP: Received Raw = %s",str(msg)), 3) if (self.flash_mode==1) var strv = msg[0..-4].asstring() if string.find(strv,"comok 2")>=0 log("FLH: Send (High Speed) flash start") self.flash_start_millis = tasmota.millis() #self.sendnx(string.format("whmi-wris %d,115200,res0",self.flash_size)) self.sendnx(string.format("whmi-wris %d,921600,res0",self.flash_size)) self.ser = serial(17, 16, 921600, serial.SERIAL_8N1) elif size(msg)==1 && msg[0]==0x08 log("FLH: Waiting offset...",3) self.awaiting_offset = 1 elif size(msg)==4 && self.awaiting_offset==1 self.awaiting_offset = 0 self.flash_offset = msg.get(0,4) log("FLH: Flash offset marker "+str(self.flash_offset),3) if self.flash_offset != 0 self.open_url_at(self.url, self.flash_offset) self.flash_written = self.flash_offset end self.write_block() elif size(msg)==1 && msg[0]==0x05 self.write_block() else log("FLH: Something has gone wrong flashing display firmware ["+str(msg)+"]",2) end else var msg_list = self.split_55(msg) for i:0..size(msg_list)-1 msg = msg_list[i] if size(msg) > 0 if msg == bytes('000000FFFFFF88FFFFFF') self.screeninit() elif size(msg)>=2 && msg[0]==0x55 && msg[1]==0xBB var jm = string.format("{\"CustomRecv\":\"%s\"}",msg[4..-3].asstring()) tasmota.publish_result(jm, "RESULT") elif msg[0]==0x07 && size(msg)==1 # BELL/Buzzer tasmota.cmd("buzzer 1,1") else var jm = string.format("{\"nextion\":\"%s\"}",str(msg[0..-4])) tasmota.publish_result(jm, "RESULT") end end end end end end end def begin_nextion_flash() self.flash_written = 0 self.awaiting_offset = 0 self.flash_offset = 0 self.sendnx('DRAKJHSUYDGBNCJHGJKSHBDN') self.sendnx('recmod=0') self.sendnx('recmod=0') self.flash_mode = 1 self.sendnx("connect") end def open_url_at(url, pos) self.url = url import string var host var port var s1 = string.split(url,7)[1] var i = string.find(s1,":") var sa if i<0 port = 80 i = string.find(s1,"/") sa = string.split(s1,i) host = sa[0] else sa = string.split(s1,i) host = sa[0] s1 = string.split(sa[1],1)[1] i = string.find(s1,"/") sa = string.split(s1,i) port = int(sa[0]) end var get = sa[1] log(string.format("FLH: host: %s, port: %s, get: %s",host,port,get)) self.tcp = tcpclient() self.tcp.connect(host,port) log("FLH: Connected:"+str(self.tcp.connected()),3) var get_req = "GET "+get+" HTTP/1.0\r\n" get_req += string.format("Range: bytes=%d-\r\n", pos) get_req += string.format("HOST: %s:%s\r\n\r\n",host,port) self.tcp.write(get_req) var a = self.tcp.available() i = 1 while a==0 && i<5 tasmota.delay(100*i) tasmota.yield() i += 1 log("FLH: Retry "+str(i),3) a = self.tcp.available() end if a==0 log("FLH: Nothing available to read!",3) return end var b = self.tcp.readbytes() i = 0 var end_headers = false; var headers while i<size(b) && headers==nil if b[i..(i+3)]==bytes().fromstring("\r\n\r\n") headers = b[0..(i+3)].asstring() self.flash_buff = b[(i+4)..] else i += 1 end end #print(headers) # check http respose for code 200/206 if string.find(headers,"200 OK")>0 || string.find(headers,"206 Partial Content")>0 log("FLH: HTTP Respose is 200 OK or 206 Partial Content",3) else log("FLH: HTTP Respose is not 200 OK or 206 Partial Content",3) print(headers) return -1 end # only set flash size if pos is zero if pos == 0 # check http respose for content-length var tag = "Content-Length: " i = string.find(headers,tag) if (i>0) var i2 = string.find(headers,"\r\n",i) var s = headers[i+size(tag)..i2-1] self.flash_size=int(s) end log("FLH: Flash file size: "+str(self.flash_size),3) end end def flash_nextion(url) self.flash_size = 0 var res = self.open_url_at(url, 0) if res != -1 self.begin_nextion_flash() end end def init() log("NXP: Initializing Driver") self.ser = serial(17, 16, 115200, serial.SERIAL_8N1) self.flash_mode = 0 end end var nextion = Nextion() tasmota.add_driver(nextion) def get_current_version(cmd, idx, payload, payload_json) import string var version_of_this_script = 4 var jm = string.format("{\"nlui_driver_version\":\"%s\"}", version_of_this_script) tasmota.publish_result(jm, "RESULT") end tasmota.add_cmd('GetDriverVersion', get_current_version) def update_berry_driver(cmd, idx, payload, payload_json) def task() import string var cl = webclient() cl.begin(payload) var r = cl.GET() if r == 200 print("Sucessfully downloaded nspanel-lovelace-ui berry driver") else print("Error while downloading nspanel-lovelace-ui berry driver") end r = cl.write_file("autoexec.be") if r < 0 print("Error while writeing nspanel-lovelace-ui berry driver") else print("Sucessfully written nspanel-lovelace-ui berry driver") var s = load('autoexec.be') if s == true var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "succeeded") tasmota.publish_result(jm, "RESULT") else var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "failed") tasmota.publish_result(jm, "RESULT") end end end tasmota.set_timer(0,task) tasmota.resp_cmnd_done() end tasmota.add_cmd('UpdateDriverVersion', update_berry_driver) def flash_nextion(cmd, idx, payload, payload_json) def task() nextion.flash_nextion(payload) end tasmota.set_timer(0,task) tasmota.resp_cmnd_done() end def send_cmd(cmd, idx, payload, payload_json) nextion.sendnx(payload) tasmota.resp_cmnd_done() end def send_cmd2(cmd, idx, payload, payload_json) nextion.send(payload) tasmota.resp_cmnd_done() end tasmota.add_cmd('Nextion', send_cmd) tasmota.add_cmd('CustomSend', send_cmd2) tasmota.add_cmd('FlashNextion', flash_nextion)
MQTT-Settings:
Sonstige Einstellungen/Vorlage
{"NAME":"NSPanel","GPIO":[0,0,0,0,3872,0,0,0,0,0,32,0,0,0,0,225,0,480,224,1,0,0,0,33,0,0,0,0,0,0,0,0,0,0,4736,0],"FLAG":0,"BASE":1}
Das mqtt.1. muss in beide Richtungen kommunizieren. RESULT funktioniert. Teste es doch bitte so wie beschrieben. Deinen Mosquitto kannst du anschließend immer noch bemühen.
-
@armilar
Habe ich, MQTT.2 ist als Server (mit anderem Port) konfiguriert und identischem Resultat, es wird nichts auf dem Display angezeigt:mqtt.2 2022-09-23 19:32:17.692 info Client [NSPanel_1] publishOnSubscribe send all known states mqtt.2 2022-09-23 19:32:17.691 info Client [NSPanel_1] publishOnSubscribe send all known states mqtt.2 2022-09-23 19:32:17.689 info Client [NSPanel_1] publishOnSubscribe send all known states mqtt.2 2022-09-23 19:32:17.492 info Client [NSPanel_1] subscribes on "cmnd/NSPanel_1_fb/#" with regex /^mqtt\.2\.cmnd\.NSPanel_1_fb(\..*)?/ mqtt.2 2022-09-23 19:32:17.492 info Client [NSPanel_1] subscribes on "cmnd/NSPanel_1_fb/#" with regex /^cmnd\.NSPanel_1_fb(\..*)?/ mqtt.2 2022-09-23 19:32:17.491 info Client [NSPanel_1] subscribes on "SmartHome/tasmotas/cmnd/#" with regex /^mqtt\.2\.SmartHome\.tasmotas\.cmnd(\..*)?/ mqtt.2 2022-09-23 19:32:17.490 info Client [NSPanel_1] subscribes on "SmartHome/tasmotas/cmnd/#" with regex /^SmartHome\.tasmotas\.cmnd(\..*)?/ mqtt.2 2022-09-23 19:32:17.489 info Client [NSPanel_1] subscribes on "SmartHome/NSPanel_1/cmnd/#" with regex /^mqtt\.2\.SmartHome\.NSPanel_1\.cmnd(\..*)?/ mqtt.2 2022-09-23 19:32:17.489 info Client [NSPanel_1] subscribes on "SmartHome/NSPanel_1/cmnd/#" with regex /^SmartHome\.NSPanel_1\.cmnd(\..*)?/ mqtt.2 2022-09-23 19:32:17.454 info Client [NSPanel_1] connected with secret 1663954337450_1441 mqtt.2 2022-09-23 19:32:07.977 info Client [NSPanel_1] connection closed: closed javascript.0 2022-09-23 19:30:27.658 info script.js.common.NSPanel_1: registered 12 subscriptions, 6 schedules, 0 messages, 0 logs and 0 file subscriptions javascript.0 2022-09-23 19:30:27.636 info script.js.common.NSPanel_1: TypeScript compilation successful javascript.0 2022-09-23 19:30:25.964 info script.js.common.NSPanel_1: compiling TypeScript source... javascript.0 2022-09-23 19:30:25.924 debug File /home/Javascript/common/NSPanel_1.ts change javascript.0 2022-09-23 19:30:25.924 info Stop script script.js.common.NSPanel_1 javascript.0 2022-09-23 19:30:25.917 debug Update /home/Javascript/common/NSPanel_1.ts on disk
Werte im Script habe ich auf MQTT.2 geändert gehabt.