openHAB2 und MQTT 2.4

Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.

Moderatoren: seppy, udo1toni

Antworten
Benutzeravatar
netZr0t
Beiträge: 56
Registriert: 9. Jan 2018 10:22
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von netZr0t »

... Frage bezüglich mqtt2 und Homie Convention

https://homieiot.github.io/

Heißt das, dass wenn ich im tasmota den topic homie/sonoff_s01 nenne, er in Zukunft ggf. vom Openhab paperui als Thing erkannt wird?



Gesendet von meinem MI 6 mit Tapatalk


Benutzeravatar
netZr0t
Beiträge: 56
Registriert: 9. Jan 2018 10:22
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von netZr0t »

madmike hat geschrieben:Hallo netZrüT,

Hast du mal ein Beispiel wie dein Thing bzw Item aussieht ??
LG
Micha
Hi, ich habe es nochnicht gemacht. Aber werde mich hieran orientieren:
https://community.openhab.org/t/using-s ... ding/59969
Er hat wirklich für so ziemlich alles im Sonnoff einen Channel definiert.
Ich werde erst Mal nur den Schalter machen

Code: Alles auswählen

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" @ "MQTT" [ host="x.x.x.x", secure=false, port=1883, qos=0, retain=false, clientid="Oh2Mqtt2Thing", //certificate="", //certificatepin=false, //publickey="", //publickeypin=false, keep_alive_time=30000, reconnect_time=60000, //lastwill_message="", //lastwill_qos=1, //lastwill_topic="", username="mymqttuser", password="mymqttpass" ] { // Sonoff Power Switch 01 Thing mqtt:topic:SonoffPs01 "Sonoff Power Switch 01" @ "MQTT" 
{ 
Channels: 
Type switch : switch "Power Switch" [ stateTopic="tasmota/sonoff-ps01/POWER", commandTopic="tasmota/sonoff-ps01/cmnd/POWER", 
//retained=false, //postCommand="", //transformationPattern="JSONPATH:$.POWER", //formatBeforePublish="%s", on="ON", off="OFF" ] 
Type string : state01 "Switch State 01" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ] Type string : state02 "Switch State 02" [ stateTopic="stat/sonoff-ps01/POWER", on="ON", off="OFF" ] 
Type string : state03 "Switch State 03" [ stateTopic="stat/sonoff-ps01/RESULT", transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ] Type number : vcc "VCC" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Vcc" ] 
Type string : wifi-ap "Wifi AP" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Wifi.AP" ] 
Type string : wifi-ssid "Wifi SSID" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Wifi.SSId" ] 
Type string : wifi-channel "Wifi Channel" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Wifi.Channel" ] 
Type string : wifi-rssi "Wifi RSSI" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ] 
Type string : uptime "Uptime" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Uptime" ] 
Type string : time "Time" [ stateTopic="tasmota/sonoff-ps01/STATE", transformationPattern="JSONPATH:$.Time" ] 
Type string : devicestate "Device State" [ stateTopic="tasmota/sonoff-ps01/LWT" ] 
} 

// Sonoff Power Switch 02 Thing mqtt:topic:SonoffPs02 "Sonoff 

Power Switch 02" @ "MQTT" { Channels: Type switch : switch "Power Switch" [ stateTopic="tasmota/sonoff-ps02/POWER", commandTopic="tasmota/sonoff-ps02/cmnd/POWER", //retained=false, //postCommand="", //transformationPattern="JSONPATH:$.POWER", //formatBeforePublish="%s", on="ON", off="OFF" ] 
Type string : state02 "Switch State 02" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ] Type string : state02 "Switch State 02" [ stateTopic="stat/sonoff-ps02/POWER", on="ON", off="OFF" ] 
Type string : state03 "Switch State 03" [ stateTopic="stat/sonoff-ps02/RESULT", transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ] Type number : vcc "VCC" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Vcc" ] 
Type string : wifi-ap "Wifi AP" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Wifi.AP" ] 
Type string : wifi-ssid "Wifi SSID" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Wifi.SSId" ] 
Type string : wifi-channel "Wifi Channel" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Wifi.Channel" ] 
Type string : wifi-rssi "Wifi RSSI" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ] 
Type string : uptime "Uptime" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Uptime" ] Type string : time "Time" [ stateTopic="tasmota/sonoff-ps02/STATE", transformationPattern="JSONPATH:$.Time" ] 
Type string : devicestate "Device State" [ stateTopic="tasmota/sonoff-ps02/LWT" ] 
} 
}

madmike
Beiträge: 278
Registriert: 15. Apr 2018 17:09
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von madmike »

Was ich nicht ganz verstehe ist die erste Zeile in Anführungszeichen setzt du doch deine Bezeichnung für den Broker was ist dann das @ MQTT ??

madmike
Beiträge: 278
Registriert: 15. Apr 2018 17:09
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von madmike »

und muss ich nun das Binding setzen oder nicht ??? alles rätselhaft war irgendwie vorher einfacher.

Benutzeravatar
netZr0t
Beiträge: 56
Registriert: 9. Jan 2018 10:22
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von netZr0t »

ja das binding musst du installieren. was das @ "MQTT" bedeutet weiss ich nicht. *EDIT* das ist der String, der in der UI unter Location auftaucht

Ich habe jetzt mal den ganzen thing part übernommen und nur im broker Abschnitt meine Daten eingetragen. Der Broker ist jetzt in der PaperUI online sichtbar.
Bild
mache jetzt mal mit einem sonoff thing weiter
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Zuletzt geändert von netZr0t am 19. Dez 2018 15:58, insgesamt 1-mal geändert.

madmike
Beiträge: 278
Registriert: 15. Apr 2018 17:09
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von madmike »

ok ich bin gespannt

Benutzeravatar
netZr0t
Beiträge: 56
Registriert: 9. Jan 2018 10:22
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von netZr0t »

Code: Alles auswählen

Bridge mqtt:broker:mosquitto "Mosquitto MQTT Broker" @ "MQTT" [ 
  host="192.168.178.xx",
  secure=false,
  port=1883,
  qos=0,
  retain=false,
  clientid="Oh2Mqtt2Thing",
  //certificate="",
  //certificatepin=false,
  //publickey="",
  //publickeypin=false,
  keep_alive_time=30000,
  reconnect_time=60000,
  //lastwill_message="",
  //lastwill_qos=1,
  //lastwill_topic="",
  username="xxxxxxxx",
  password="xxxxxxxx"
]
{
    // Sonoff sonoff_s04 mehrfachstecker s04
  Thing mqtt:topic:sonoff_s04 "Mehrfachstecker Sonoffbasic_s04" @ "MQTT"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="homie/sonoff_s04/POWER", 
            commandTopic="homie/sonoff_s04/cmnd/POWER",
            //retained=false,
            //postCommand="",
            //transformationPattern="JSONPATH:$.POWER", 
            //formatBeforePublish="%s",
            on="ON",
            off="OFF"          
          ]
          Type string : state01 "Switch State 01" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.POWER",
            on="ON",
            off="OFF"
          ]
          Type string : state02 "Switch State 02" [ 
            stateTopic="homie/sonoff_s04/POWER",
            on="ON",
            off="OFF"
          ]
          Type string : state03 "Switch State 03" [ 
            stateTopic="homie/sonoff_s04/RESULT",
            transformationPattern="JSONPATH:$.POWER",
            on="ON",
            off="OFF"
          ]
          Type number : vcc "VCC" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Vcc"
          ]
          Type string : wifi-ap "Wifi AP" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Wifi.AP"
          ]
          Type string : wifi-ssid "Wifi SSID" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Wifi.SSId"
          ]
          Type string : wifi-channel "Wifi Channel" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Wifi.Channel"
          ]
          Type string : wifi-rssi "Wifi RSSI" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Wifi.RSSI"
          ]
          Type string : uptime "Uptime" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Uptime"
          ]
          Type string : time "Time" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.Time"
          ]
          Type string : devicestate "Device State" [ 
            stateTopic="homie/sonoff_s04/LWT"
          ]
    }
 }
     
wichtig ist, dass du erstmal den mosquitto und den einen sonoff als Thing im PaperUI hast.

Ich habe festgestellt, dass die beste Methode ist Änderungen wirksam zu bekommen ist erstmal im xxx.things // vor die Bridge zu schreiben, kurz zu sichern, im PAperUI checken, dass keine Things vorhanden sind, falls doch loeschen ... anschliessend die beiden // wieder wegmachen um die Things aus dem file scharfzuschalten. Teilweise bekommt man sonst die schalter things nicht online.

so sieht das item aus:

Code: Alles auswählen

Switch mehrfachstecker_Switch "SPS01 Switch" <light> (SonoffPowerSwitches_Basic) { channel="mqtt:topic:sonoff_s04:switch" }
soniffsmqttpaperui.PNG
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.

madmike
Beiträge: 278
Registriert: 15. Apr 2018 17:09
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von madmike »

Hört sich spannend an, werde ich gleich mal selbst probieren. Das sind deine Einträge als Thing und Item und dem Thing Sonoff mußt du dann den Broker voranstellen habe ich das richtig verstanden ??
Ergo kommt die Frage auf muss ich nun jeden Schalter als Thing anlegen, oder kann ich den Broker voran schreibend alle Sonoffs so in ein Thing schreiben. Zum anderen siehst du nun auch die Rückmeldung ob das Item geschaltet hat?

Benutzeravatar
netZr0t
Beiträge: 56
Registriert: 9. Jan 2018 10:22
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von netZr0t »

so sieht die thing.thing struktur aus :

Bridge [ ] // das ist der link zum mosquitto broker
{
Thing { } //das ist ein sonoff
Thing { } //das ist ein sonoff
}

und ja die sonoffs schalten
du musst fuer jeden sonoff ein Thing schreiben (ist ja schnell kopiert , du musst ja nicht wie im Beispiel alle Channels "bereitstellen". i.d.R. reicht ja der switch kanal

z.b. so:

Code: Alles auswählen

Thing mqtt:topic:sonoff_s04 "Mehrfachstecker Sonoffbasic_s04" @ "MQTT"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="homie/sonoff_s04/POWER", 
            commandTopic="homie/sonoff_s04/cmnd/POWER",
            on="ON",
            off="OFF"          
          ]
          Type string : state01 "Switch State 01" [ 
            stateTopic="homie/sonoff_s04/STATE",
            transformationPattern="JSONPATH:$.POWER",
            on="ON",
            off="OFF"
 }

madmike
Beiträge: 278
Registriert: 15. Apr 2018 17:09
Answers: 0

Re: openHAB2 und MQTT 2.4

Beitrag von madmike »

He super ich werde es gleich malprobieren danke für Deine Unterstützung
mfg
Micha

Antworten