MQTT2_SERVER - LWT bei/nach shutdown restart

Begonnen von TomLee, 07 Juni 2024, 16:30:03

Vorheriges Thema - Nächstes Thema

rudolfkoenig

Zitatso zu verstehen das der Server dann beim zweiten Verbindungsversuch das LWT sendet oder nicht ?
Ja, beim zweiten CONNECT sollte ein Verbindungsabbruch und damit ein LWT erfolgen.
Ist im MQTT2_SEVER z.Zt. nicht korrekt implementiert, d.h. deswegen kriegst Du kein LWT.

TomLee

Weil mir das auf meinem Hauptsystem mit verbose 5 bei MQTT2_SERVER zuviel ist, hab ich das mal bei einer nackten FHEM-Installation auf einer Pi Zero w nachvollzogen und zusammengefasst.

restart nur mit der MQTT2_SERVER Definition, einem MQTT2_DEVICE und einem Debug-notify:
Tasmota-Konsole
15:19:04.968 CMD: mqttretry
15:19:04.973 MQT: stat/tasmota_D836BC/RESULT = {"MqttRetry":10}
15:19:16.671 CMD: mqttkeepalive
15:19:16.677 MQT: stat/tasmota_D836BC/RESULT = {"MqttKeepAlive":30}
15:19:28.436 MQT: Attempting connection...
15:19:28.449 MQT: Connect failed to 192.168.188.28:1883, rc -2. Retry in 10 sec
15:19:39.441 MQT: Attempting connection...
15:19:42.226 MQT: Connected
15:19:42.230 MQT: tele/tasmota_D836BC/LWT = Online (retained)
15:19:42.233 MQT: cmnd/tasmota_D836BC/POWER =

Logfile
2024-06-17_15:19:23 Logfile clear
2024.06.17 15:19:27 0: Server shutdown
2024.06.17 15:19:31 1: Including fhem.cfg
2024.06.17 15:19:33 3: WEB: port 8083 opened
2024.06.17 15:19:33 2: eventTypes: loaded 51 lines from ./log/eventTypes.txt
2024.06.17 15:19:34 3: MQTT2_Server: port 1883 opened
2024.06.17 15:19:34 1: Including ./log/fhem.save
2024.06.17 15:19:34 1: Messages collected while initializing FHEM:SecurityCheck:
  WEB is not password protected

Protect this FHEM installation by configuring the allowed device allowed
You can disable this message with attr global motd none

2024.06.17 15:19:34 1: usb create starting
2024.06.17 15:19:34 3: Probing ZWDongle device /dev/serial1
2024.06.17 15:19:35 3: Probing CUL device /dev/ttyAMA0
2024.06.17 15:19:35 3: Probing TCM_ESP3 device /dev/ttyAMA0
2024.06.17 15:19:36 3: Probing ZWDongle device /dev/ttyAMA0
2024.06.17 15:19:36 3: Probing SIGNALDuino device /dev/ttyAMA0
2024.06.17 15:19:36 3: Probing MYSENSORS device /dev/ttyAMA0
2024.06.17 15:19:36 3: Probing ArduCounter device /dev/ttyAMA0
2024.06.17 15:19:36 3: Probing ElsnerWS device /dev/ttyAMA0
2024.06.17 15:19:37 3: Probing FRM device /dev/ttyAMA0
2024.06.17 15:19:43 1: usb create end
2024.06.17 15:19:43 0: Featurelevel: 6.3
2024.06.17 15:19:43 0: Server started with 11 defined entities (fhem.pl:28849/2024-05-07 perl:5.032001 os:linux user:fhem pid:12966)
2024.06.17 15:19:43 4: Connection accepted from MQTT2_Server_192.168.188.203_56951
2024.06.17 15:19:43 5: in@192.168.188.203:56951 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:19:43 5: out@192.168.188.203:56951 CONNACK:  (2)(0)(0)
2024.06.17 15:19:43 5: in@192.168.188.203:56951 PUBLISH: 1(31)(0)(23)tele/tasmota_D836BC/LWTOnline
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC PUBLISH tele/tasmota_D836BC/LWT:Online
2024.06.17 15:19:43 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Online
2024.06.17 15:19:43 5: in@192.168.188.203:56951 PUBLISH: 0(27)(0)(25)cmnd/tasmota_D836BC/POWER
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC PUBLISH cmnd/tasmota_D836BC/POWER:
2024.06.17 15:19:43 5: in@192.168.188.203:56951 SUBSCRIBE: (130)(26)(0)(2)(0)(21)cmnd/tasmota_D836BC/#(0)
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC SUBSCRIBE
2024.06.17 15:19:43 4:   topic:cmnd/tasmota_D836BC/# qos:0
2024.06.17 15:19:43 5: out@192.168.188.203:56951 SUBACK: (144)(3)(0)(2)(0)
2024.06.17 15:19:43 5: in@192.168.188.203:56951 SUBSCRIBE: (130)(20)(0)(3)(0)(15)cmnd/tasmotas/#(0)
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC SUBSCRIBE
2024.06.17 15:19:43 4:   topic:cmnd/tasmotas/# qos:0
2024.06.17 15:19:43 5: out@192.168.188.203:56951 SUBACK: (144)(3)(0)(3)(0)
2024.06.17 15:19:43 5: in@192.168.188.203:56951 SUBSCRIBE: (130)(26)(0)(4)(0)(21)cmnd/DVES_D836BC_fb/#(0)
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC SUBSCRIBE
2024.06.17 15:19:43 4:   topic:cmnd/DVES_D836BC_fb/# qos:0
2024.06.17 15:19:43 5: out@192.168.188.203:56951 SUBACK: (144)(3)(0)(4)(0)
2024.06.17 15:19:43 5: in@192.168.188.203:56951 PUBLISH: 1(132)(7)(0)%tasmota/discovery/E86BEAD836BC/config{"ip":"192.168.188.203","dn":"Tasmota","fn":["Tasmota",null,null,null,null,null,null,null],"hn":"tasmota-D836BC-5820-eth","mac":"E86BEAD836BC","md":"WT32-Eth01","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"13.4.0","t":"tasmota_D836BC","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":0,"lt_st":0,"bat":0,"dslp":0,"sho":[],"sht":[],"ver":1}
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC PUBLISH tasmota/discovery/E86BEAD836BC/config:{"ip":"192.168.188.203","dn":"Tasmota","fn":["Tasmota",null,null,null,null,null,null,null],"hn":"tasmota-D836BC-5820-eth","mac":"E86BEAD836BC","md":"WT32-Eth01","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"13.4.0","t":"tasmota_D836BC","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":0,"lt_st":0,"bat":0,"dslp":0,"sho":[],"sht":[],"ver":1}
2024.06.17 15:19:43 5: in@192.168.188.203:56951 PUBLISH: 1(212)(1)(0)&tasmota/discovery/E86BEAD836BC/sensors{"sn":{"Time":"2024-06-17T15:19:42","ENERGY":{"consumption":31.3254,"supply":0.0000,"power":30,"voltage":234.6,"current":0.25,"phaseangle":335.0,"frequency":49.9}},"ver":1}
2024.06.17 15:19:43 4:   MQTT2_Server_192.168.188.203_56951 DVES_D836BC PUBLISH tasmota/discovery/E86BEAD836BC/sensors:{"sn":{"Time":"2024-06-17T15:19:42","ENERGY":{"consumption":31.3254,"supply":0.0000,"power":30,"voltage":234.6,"current":0.25,"phaseangle":335.0,"frequency":49.9}},"ver":1}

Es erfolgt kein offline, ein fehlgeschlagener Wiederverbindungsversuch direkt beim neustarten des FHEM-Server. 16 s bis zur Initialisierung.



restart zusätzlich mit einer FRITZBOX Definition:

15:35:20.142 MQT: Attempting connection...
15:35:20.157 MQT: Connect failed to 192.168.188.28:1883, rc -2. Retry in 10 sec
15:35:31.144 MQT: Attempting connection...
15:35:35.221 MQT: Connect failed to 192.168.188.28:1883, rc -4. Retry in 20 sec
15:35:56.502 MQT: Attempting connection...
15:35:56.625 MQT: Connected
15:35:56.629 MQT: tele/tasmota_D836BC/LWT = Online (retained)
15:35:56.632 MQT: cmnd/tasmota_D836BC/POWER =

2024-06-17_15:35:06 Logfile clear
2024.06.17 15:35:08 0: Server shutdown
2024.06.17 15:35:22 1: Including fhem.cfg
2024.06.17 15:35:24 3: WEB: port 8083 opened
2024.06.17 15:35:24 2: eventTypes: loaded 55 lines from ./log/eventTypes.txt
2024.06.17 15:35:24 3: MQTT2_Server: port 1883 opened
2024.06.17 15:35:28 1: Including ./log/fhem.save
2024.06.17 15:35:28 1: Messages collected while initializing FHEM:SecurityCheck:
  WEB is not password protected

Protect this FHEM installation by configuring the allowed device allowed
You can disable this message with attr global motd none

2024.06.17 15:35:28 1: usb create starting
2024.06.17 15:35:28 3: Probing ZWDongle device /dev/serial1
2024.06.17 15:35:29 3: Probing CUL device /dev/ttyAMA0
2024.06.17 15:35:29 3: Probing TCM_ESP3 device /dev/ttyAMA0
2024.06.17 15:35:30 3: Probing ZWDongle device /dev/ttyAMA0
2024.06.17 15:35:30 3: Probing SIGNALDuino device /dev/ttyAMA0
2024.06.17 15:35:30 3: Probing MYSENSORS device /dev/ttyAMA0
2024.06.17 15:35:30 3: Probing ArduCounter device /dev/ttyAMA0
2024.06.17 15:35:30 3: Probing ElsnerWS device /dev/ttyAMA0
2024.06.17 15:35:31 3: Probing FRM device /dev/ttyAMA0
2024.06.17 15:35:37 1: usb create end
2024.06.17 15:35:37 0: Featurelevel: 6.3
2024.06.17 15:35:37 0: Server started with 12 defined entities (fhem.pl:28849/2024-05-07 perl:5.032001 os:linux user:fhem pid:13064)
2024.06.17 15:35:37 3: telnetForBlockingFn_1718631337.33007: port 45381 opened
2024.06.17 15:35:37 4: Connection accepted from MQTT2_Server_192.168.188.203_56956
2024.06.17 15:35:37 5: in@192.168.188.203:56956 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:35:37 4:   MQTT2_Server_192.168.188.203_56956 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:35:37 5: out@192.168.188.203:56956 CONNACK:  (2)(0)(0)
2024.06.17 15:35:37 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Offline
2024.06.17 15:35:37 1: DEBUG>Offline
2024.06.17 15:35:37 4: Connection closed for MQTT2_Server_192.168.188.203_56956: EOF
2024.06.17 15:35:46 3: [Fritzbox1 | 7490 | 113.07.57 | Set_check_APIs.6161] - BASIC:Response -> luaQuery:200 luaData:200 TR064:200
2024.06.17 15:35:56 4: Connection accepted from MQTT2_Server_192.168.188.203_56957
2024.06.17 15:35:56 5: in@192.168.188.203:56957 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:35:56 5: out@192.168.188.203:56957 CONNACK:  (2)(0)(0)
2024.06.17 15:35:56 5: in@192.168.188.203:56957 PUBLISH: 1(31)(0)(23)tele/tasmota_D836BC/LWTOnline
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 DVES_D836BC PUBLISH tele/tasmota_D836BC/LWT:Online
2024.06.17 15:35:56 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Online
2024.06.17 15:35:56 5: in@192.168.188.203:56957 PUBLISH: 0(27)(0)(25)cmnd/tasmota_D836BC/POWER
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 DVES_D836BC PUBLISH cmnd/tasmota_D836BC/POWER:
2024.06.17 15:35:56 5: in@192.168.188.203:56957 SUBSCRIBE: (130)(26)(0)(2)(0)(21)cmnd/tasmota_D836BC/#(0)
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 DVES_D836BC SUBSCRIBE
2024.06.17 15:35:56 4:   topic:cmnd/tasmota_D836BC/# qos:0
2024.06.17 15:35:56 5: out@192.168.188.203:56957 SUBACK: (144)(3)(0)(2)(0)
2024.06.17 15:35:56 5: in@192.168.188.203:56957 SUBSCRIBE: (130)(20)(0)(3)(0)(15)cmnd/tasmotas/#(0)
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 DVES_D836BC SUBSCRIBE
2024.06.17 15:35:56 4:   topic:cmnd/tasmotas/# qos:0
2024.06.17 15:35:56 5: out@192.168.188.203:56957 SUBACK: (144)(3)(0)(3)(0)
2024.06.17 15:35:56 5: in@192.168.188.203:56957 SUBSCRIBE: (130)(26)(0)(4)(0)(21)cmnd/DVES_D836BC_fb/#(0)
2024.06.17 15:35:56 4:   MQTT2_Server_192.168.188.203_56957 DVES_D836BC SUBSCRIBE
2024.06.17 15:35:56 4:   topic:cmnd/DVES_D836BC_fb/# qos:0
2024.06.17 15:35:56 5: out@192.168.188.203:56957 SUBACK: (144)(3)(0)(4)(0)

offline erfolgt einmal, siehe Debug Ausgabe. Zwei fehlgeschlagene Wiederverbindungsversuche, einmal der direkt beim neustarten und einmal noch vor kurz vor der Initialisierung. 29 s bis zur Initialisierung.



restart zusätzlich noch eine FB_CALLMONITOR

15:54:22.539 MQT: Attempting connection...
15:54:22.551 MQT: Connect failed to 192.168.188.28:1883, rc -2. Retry in 10 sec
15:54:33.544 MQT: Attempting connection...
15:54:37.560 MQT: Connect failed to 192.168.188.28:1883, rc -4. Retry in 20 sec
15:54:58.530 MQT: Attempting connection...
15:55:02.547 MQT: Connect failed to 192.168.188.28:1883, rc -4. Retry in 30 sec
15:55:33.635 MQT: Attempting connection...
15:55:33.777 MQT: Connected
15:55:33.780 MQT: tele/tasmota_D836BC/LWT = Online (retained)
15:55:33.784 MQT: cmnd/tasmota_D836BC/POWER =

2024-06-17_15:54:17 Logfile clear
2024.06.17 15:54:20 0: Server shutdown
2024.06.17 15:54:24 1: Including fhem.cfg
2024.06.17 15:54:26 3: WEB: port 8083 opened
2024.06.17 15:54:27 2: eventTypes: loaded 57 lines from ./log/eventTypes.txt
2024.06.17 15:54:27 3: MQTT2_Server: port 1883 opened
2024.06.17 15:54:31 3: Opening cm_bla1 device 192.168.188.1:1012
2024.06.17 15:54:31 1: Including ./log/fhem.save
2024.06.17 15:54:31 1: Messages collected while initializing FHEM:SecurityCheck:
  WEB is not password protected

Protect this FHEM installation by configuring the allowed device allowed
You can disable this message with attr global motd none

2024.06.17 15:54:51 3: [cm_bla1 | readPhonebook.1410] - EVENT: read 3 contacts from remote phonebook "Telefonbuch"
2024.06.17 15:54:54 3: [cm_bla1 | readPhonebook.1410] - EVENT: read 193 contacts from remote phonebook "Mobil"
2024.06.17 15:54:56 3: [cm_bla1 | readPhonebook.1410] - EVENT: read 123 contacts from remote phonebook "Iphone-Kontakte"
2024.06.17 15:55:00 1: usb create starting
2024.06.17 15:55:00 3: Probing ZWDongle device /dev/serial1
2024.06.17 15:55:01 3: Probing CUL device /dev/ttyAMA0
2024.06.17 15:55:01 3: Probing TCM_ESP3 device /dev/ttyAMA0
2024.06.17 15:55:02 3: Probing ZWDongle device /dev/ttyAMA0
2024.06.17 15:55:02 3: Probing SIGNALDuino device /dev/ttyAMA0
2024.06.17 15:55:02 3: Probing MYSENSORS device /dev/ttyAMA0
2024.06.17 15:55:02 3: Probing ArduCounter device /dev/ttyAMA0
2024.06.17 15:55:02 3: Probing ElsnerWS device /dev/ttyAMA0
2024.06.17 15:55:03 3: Probing FRM device /dev/ttyAMA0
2024.06.17 15:55:09 1: usb create end
2024.06.17 15:55:09 0: Featurelevel: 6.3
2024.06.17 15:55:09 0: Server started with 13 defined entities (fhem.pl:28849/2024-05-07 perl:5.032001 os:linux user:fhem pid:13218)
2024.06.17 15:55:09 3: telnetForBlockingFn_1718632509.29074: port 35577 opened
2024.06.17 15:55:09 4: Connection accepted from MQTT2_Server_192.168.188.203_56966
2024.06.17 15:55:09 3: cm_bla1 device opened
2024.06.17 15:55:09 4: Connection accepted from MQTT2_Server_192.168.188.203_56967
2024.06.17 15:55:09 5: in@192.168.188.203:56966 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:55:09 4:   MQTT2_Server_192.168.188.203_56966 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:55:09 5: out@192.168.188.203:56966 CONNACK:  (2)(0)(0)
2024.06.17 15:55:09 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Offline
2024.06.17 15:55:09 1: DEBUG>Offline
2024.06.17 15:55:09 4: Connection closed for MQTT2_Server_192.168.188.203_56966: EOF
2024.06.17 15:55:09 5: in@192.168.188.203:56967 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:55:09 4:   MQTT2_Server_192.168.188.203_56967 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:55:09 5: out@192.168.188.203:56967 CONNACK:  (2)(0)(0)
2024.06.17 15:55:09 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Offline
2024.06.17 15:55:09 1: DEBUG>Offline
2024.06.17 15:55:09 4: Connection closed for MQTT2_Server_192.168.188.203_56967: EOF
2024.06.17 15:55:15 3: [Fritzbox1 | 7490 | 113.07.57 | Set_check_APIs.6161] - BASIC:Response -> luaQuery:200 luaData:200 TR064:200
2024.06.17 15:55:33 4: Connection accepted from MQTT2_Server_192.168.188.203_56968
2024.06.17 15:55:33 5: in@192.168.188.203:56968 CONNECT: (16)L(0)(4)MQTT(4)(238)(0)(30)(0)(11)DVES_D836BC(0)(23)tele/tasmota_D836BC/LWT(0)(7)Offline(0)(6)Thomas(0)(9)123456789
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 cid:DVES_D836BC CONNECT V:4 keepAlive:30 LWT:tele/tasmota_D836BC/LWT:Offline usr:Thomas
2024.06.17 15:55:33 5: out@192.168.188.203:56968 CONNACK:  (2)(0)(0)
2024.06.17 15:55:33 5: in@192.168.188.203:56968 PUBLISH: 1(31)(0)(23)tele/tasmota_D836BC/LWTOnline
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 DVES_D836BC PUBLISH tele/tasmota_D836BC/LWT:Online
2024.06.17 15:55:33 5: MQTT2_Server: dispatch autocreate=simple\000DVES_D836BC\000tele/tasmota_D836BC/LWT\000Online
2024.06.17 15:55:33 5: in@192.168.188.203:56968 PUBLISH: 0(27)(0)(25)cmnd/tasmota_D836BC/POWER
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 DVES_D836BC PUBLISH cmnd/tasmota_D836BC/POWER:
2024.06.17 15:55:33 5: in@192.168.188.203:56968 SUBSCRIBE: (130)(26)(0)(2)(0)(21)cmnd/tasmota_D836BC/#(0)
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 DVES_D836BC SUBSCRIBE
2024.06.17 15:55:33 4:   topic:cmnd/tasmota_D836BC/# qos:0
2024.06.17 15:55:33 5: out@192.168.188.203:56968 SUBACK: (144)(3)(0)(2)(0)
2024.06.17 15:55:33 5: in@192.168.188.203:56968 SUBSCRIBE: (130)(20)(0)(3)(0)(15)cmnd/tasmotas/#(0)
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 DVES_D836BC SUBSCRIBE
2024.06.17 15:55:33 4:   topic:cmnd/tasmotas/# qos:0
2024.06.17 15:55:33 5: out@192.168.188.203:56968 SUBACK: (144)(3)(0)(3)(0)
2024.06.17 15:55:33 5: in@192.168.188.203:56968 SUBSCRIBE: (130)(26)(0)(4)(0)(21)cmnd/DVES_D836BC_fb/#(0)
2024.06.17 15:55:33 4:   MQTT2_Server_192.168.188.203_56968 DVES_D836BC SUBSCRIBE
2024.06.17 15:55:33 4:   topic:cmnd/DVES_D836BC_fb/# qos:0
2024.06.17 15:55:33 5: out@192.168.188.203:56968 SUBACK: (144)(3)(0)(4)(0)

wie man sieht, offline wird jetzt zweimal gesetzt. Drei fehlgeschlagene Wiederverbindungsversuche, einmal der direkt beim neustarten und jetzt zwei mal vor der Initialisierung, weils jetzt 49 s bis zur Initialisierung sind.



rudolfkoenig

Das Problem kann man auch einfacher nachstellen, mit fhem.cfg:
define m2s MQTT2_SERVER 1883
attr m2s verbose 5
{ sleep 15 }
und der FHEM-Start sofort gefolgt von
mosquitto_sub -k 5 --will-topic LWTopic --will-payload LWmsg -v -t #

Leider hat etwas Experimentieren damit mein Weltbild erschuettert: accept genehmigt keineswegs den Connect der anderen Seite, das macht der Kernel, und nimmt auch gerne schon Daten entgegen.
Bis FHEM zum accept kommt, hat mosquitto_sub drei Verbindungen aufgebaut, MQTT-CONNECT Nachrichten geschickt, und die ersten zwei auch schon zugemacht.
Fuer FHEM schaut das so aus, als ob schnell hintereinander 3 CONNECTs kommen, diese werden mit CONNACK beantwortet (write meldet kein Fehler!), und danach zwei Verbindungen sofort zugemacht werden ohne DISCONNECT. Deswegen wird das LWT fuer beide brav verteilt.

Ich habe dieses Problem jetzt entschaerft, indem ich den Port erst oeffne, nachdem die Initialisierung fertig ist.
Bin gespannt auf die Nebeneffekte.