Seite 1 von 1

MQTT Thing online obwohl offline

Verfasst: 4. Okt 2020 20:37
von Epicblue
Hallo zusammen,

ich beschäftige mich seit kurzem mit MQTT. Ich habe ein paar Steckdosen von Gosund eingebunden. Das funktioniert auch soweit. Leider werden die Steckdosen "things" im Paper UI immer als online angezeigt, obwohl diese ausgesteckt (also stromlos) sind.

Hier ist meine Konfiguration.
Mqtt.things:

Code: Alles auswählen

Bridge mqtt:broker:Mosquitto "Mosquitto" @ "mqtt" [
    host="192.168.2.202", // anpassen
    port=1883,
    clientID="openhab", 
    username="openhabian",
    password="openhabian"
] {
    Thing topic Steckdose1 "Steckdose 1" @ "mqtt" {
        Channels:
            Type switch : PowerSwitch   "Steckdose 1 Schalten"      [ stateTopic="stat/Steckdose1/POWER" , transformationPattern="JSONPATH:$.POWER" , commandTopic="cmnd/Steckdose1/POWER", on="ON", off="OFF" ]
            Type string : SSID          "WLAN SSID"                 [ stateTopic= "tele/Steckdose1/STATE", transformationPattern="JSONPATH:$.Wifi.SSId" ]
            Type number : RSSI          "WLAN Signalstärke"         [ stateTopic= "tele/Steckdose1/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ]
            Type string : Uptime        "Uptime"                    [ stateTopic= "tele/Steckdose1/STATE", transformationPattern="JSONPATH:$.Uptime" ]
            Type number : EnergyTotal   "Energie in kwH"            [ stateTopic= "tele/Steckdose1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total" ]
            Type number : Voltage       "Spannung in V"             [ stateTopic= "tele/Steckdose1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage" ]      
    }

Re: MQTT Thing online obwohl offline

Verfasst: 4. Okt 2020 21:00
von peter-pan
Ich denke, das hängt damit zusammen, dass das "Thing" auch tatsächlich funktioniert und auch mit dem Broker verbunden ist. Was halt nicht funktioniert ist, die Kommunikation zwischen der Steckdose und OH und dass die Befehle die aus OH gesendet werden nicht mehr am Device ankommen, bzw. keine neuen Daten von OH über den Broker mehr empfangen werden, bis auf eine Information, den LWT (last will testament). Der zeigt an, ob noch Verbindung besteht.

Hier solltest du noch einen entsprechenden Channel im Thing und ein passendes Item dazu anlegen:

Thing-Channel:

Code: Alles auswählen

Type switch : reachable "Reachable"  [ stateTopic="tele/Steckdose1/LWT",transformationPattern="MAP:reachable.map" ]
.items:

Code: Alles auswählen

Switch    Gosund_socket_01_Unreach  "Gosund Switch 01 Erreichbarkeit [%s]" <siren1> (gGosunds,gLWT)  { channel="mqtt:topic:dein Broker:Steckdose1:reachable" }     
Dann kannst du sehen, ob deine Steckdose noch da ist oder entfernt wurde.

Re: MQTT Thing online obwohl offline

Verfasst: 4. Okt 2020 23:48
von udo1toni
Mit der aktuellen Version von openHAB (2.5.9) kannst Du pro mqtt Thing ein extra Topic angeben, welches das Thing ONLINE/OFFLINE schaltet. Das sollte auch in der offiziellen Doku stehen... Bin aber gerade etwas beschäftigt, also schau selbst mal...


Gesendet von iPad mit Tapatalk