NEWS
SONOFF NSPanel mit Lovelace UI
-
@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.
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@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.
So und jetzt bitte mal die mqtt-Einstellungen aus dem mqtt.2. und aus Tasmota posten. Ich denke wir finden den Fehler noch
-
By the way, Respekt und dank für deine Geduld
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
By the way, Respekt und dank für deine Geduld
Denke ich habe was ... Bitte nach und nach..
Haken "unbedingt" raus... und raus lassen
Haken rein...
Setze mal höher
Wärst so ziemlich der erste bei dem es nicht funktioniert. Können wir irgendwie nicht auf uns sitzen lassen...
und zum Schluss noch die beiden Zeilen aktualisieren, falls noch nicht geschehen...
panelRecvTopic: 'mqtt.2.SmartHome.NSPanel_1.tele.RESULT', // anpassen panelSendTopic: 'mqtt.2.SmartHome.NSPanel_1.cmnd.CustomSend', // anpassen
-
@armilar Alles Umgesetzt, ohne Erfolg, was aber bisher immer passiert (Mit Mosqitto und über Iobroker Intern MQTT), wenn ich das Script neu gestartet oder geändert habe, das "This is taking longer ....." verschwindet für einen Moment und erscheint danach wieder, also scheint es ja doch eine Gewisse Kommunikation zu geben
-
@andreas_z sagte in SONOFF NSPanel mit Lovelace UI:
@armilar Alles Umgesetzt, ohne Erfolg, was aber bisher immer passiert (Mit Mosqitto und über Iobroker Intern MQTT), wenn ich das Script neu gestartet oder geändert habe, das "This is taking longer ....." verschwindet für einen Moment und erscheint danach wieder, also scheint es ja doch eine Gewisse Kommunikation zu geben
Okay ich gebe auf. Kannst noch mal versuchen die IP im Broker auf den Server zusetzten und beide Kisten iobroker und Panel durchstarten. Mehr geht eigentlich nicht...
-
@kuckuckmann (nur für deine Tests)
-
@andreas_z
Hi Andreas,was ich bei dem ganzen vermisse, ist die Bestätigung, dass CustomSend funktioniert.
Da ich gerade selbst damit zu kämpfen hatte, stell bitte sicher, dass der entweder aus der Tasmota Konsole oder dem Mosquitto Explorer so wie in der Anleitung im Wiki auch passiert. Ich könnte mir vorstellen, dass dies die Lösung ist.LG
-
Er funktioniert leider nicht mal aus der Konsole raus
20:23:10.191 CMD: CustomSend time~12:00
20:23:10.216 MQT: SmartHome/tasmota_E7EFAC/stat/RESULT = {"CustomSend":"Done"}
20:23:13.604 MQT: SmartHome/tasmota_E7EFAC/tele/RESULT = {"CustomRecv":"event,startup,42,eu"}Es wird nichts auf dem Display angezeigt. Zwischenzeitlich habe ich noch einmal bei 0 Angefangen und komplett neu geflasht und konfiguriert, leider mit dem selben Ergebnis.
-
@andreas_z
Hast Du es via Mosquitto probiert? -
@kuckuckmann
Aus der Konsole, über Iobroker, mit MQTT-Explorer, das blö.... Display hat keine Lust etwas anzuzeigen, außer "Waiting for content" -
@andreas_z
CMD: CustomSend time~12:00 <--- hat das einen aktuellen Zeitstempel? -
@skatbert
Gibt es bei Dir schon was neues?
Ich habe noch eine Idee: Kannst Du mal die Seiten leer machen, so das keine PageItems drauf sind und dann mal das Blättern testen? -
@kuckuckmann @Armilar
OK warum auch immer, aus irgend einem nicht Erklärbaren Grund funktioniert auf einmal das Display und zeigt alles an, letzte Aktion war das erneute kopieren des Skripts aus Notepad++Vielen vielen Dank für eure Geduld