Openhab 2.4 MQTT aqara and Shelly working Example

  • Platform information:
    • openHAB version: 2.4 and 2.5

Hi all,

after having a hard time with new mqtt and my zoo of sensors I want to show all how it is working. I am using the zigbee2mqtt software from Koen Kanters ( https://github.com/Koenkk ) with the CC2531 USB stick as a bridge.

I have following devices configured until now and will update once I have added more:

Shelly H&T ( Humidity and temperature )
aqara door and window sensor
aqara tempreature

This configuration needs openhab 2.4 installed and the MQTT Binding from David Graeff installed.

This is my working mqtt.things file:


Bridge mqtt:broker:myMQTTBroker [ host="pinky", secure=false]
{
    
    // zigbee2mqtt Bridge information

    Thing topic zigbeeMQTT "Zigbee2mqtt" {
    Channels:
        Type switch : permitJoin         [ stateTopic="zigbee2mqtt/bridge/config/permit_join", on="true", off="false" ]
        Type string : state              [ stateTopic="zigbee2mqtt/bridge/state" ]
        //Type string : logType            [ stateTopic="zigbee2mqtt/bridge/log",  transformationPattern="JSONPATH:$.type" ]
        //Type string : logMessage         [ stateTopic="zigbee2mqtt/bridge/log",  transformationPattern="JSONPATH:$.message" ]
    }


    // aqara Temperature and Humidity Sensor

    Thing topic zigbeeSensorWZ "Wohnzimmer Sensor" {
    Channels:
        Type number : temperature        [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.temperature" ]
        Type number : humidity           [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.humidity" ]
        Type number : pressure           [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.pressure" ]
        Type number : voltage            [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.voltage" ]
        Type number : battery            [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.battery" ]
        Type number : linkquality        [ stateTopic="zigbee2mqtt/Temperatur_WZ",  transformationPattern="JSONPATH:$.linkquality" ]
    } 

    // aqara door and windows contact 
    Thing topic zigbeeBK "Balkontuer" {
        Channels:
            Type string : status  
                [ stateTopic="zigbee2mqtt/Fenstersensor_BK", transformationPattern="JSONPATH:$.contact" ]
            Type number : voltage 
                [ stateTopic="zigbee2mqtt/Fenstersensor_BK", transformationPattern="JSONPATH:$.voltage" ]
            Type number : battery 
                [ stateTopic="zigbee2mqtt/Fenstersensor_BK", transformationPattern="JSONPATH:$.battery" ]
            Type number : linkquality 
                [ stateTopic="zigbee2mqtt/Fenstersensor_BK", transformationPattern="JSONPATH:$.linkquality" ]

    } 

    // shelly H&T Sensor original firmware !!no tasmota!!
   Thing topic TemperaturEsszimmer "Esszimmer Sensor" {
    Channels:
        Type number : temperature        [ stateTopic="shellies/shellyht-5A8AF2/sensor/temperature"]
        Type number : humidity           [ stateTopic="shellies/shellyht-5A8AF2/sensor/humidity" ]
        Type number : battery            [ stateTopic="shellies/shellyht-5A8AF2/sensor/battery" ]
       }
}

and the items.file for these devices:

// Control zigbee2mqtt
Group  gZigbeeMQTT    "Zigbee2mqtt"
String ZigbeeState               "Zigbee2mqtt state"                  <switch>    (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:state" }
Switch ZigbeePermitJoin          "Permit join new devices"            <switch>    (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:permitJoin" }
String ZigbeeLogType             "Zigbee2mqtt log type"                           (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:logType" }
String ZigbeeLogMessage          "Zigbee2mqtt log message"                        (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:logMessage" }


// Xiaomi Aqara temperature, humidity and pressure sensor WSDCGQ11LM
Group  gZigbeeSensor    "Zigbee Sensors"

Number ZigbeeSensorWZTemperature  "Sensor WZ Temperature [%.1f ┬░C]"  <temperature>  (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:temperature" }
Number ZigbeeSensorWZHumidity     "Sensor WZ Humidity [%.1f %%]"     <humidity>     (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:humidity" }
Number ZigbeeSensorWZPressure     "Sensor WZ Pressure  [%d hPa]"     <pressure>     (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:pressure" }
Number ZigbeeSensorWZLinkQuality  "Sensor WZ Link Quality [%d]"      <network>      (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:linkquality" }
Number ZigbeeSensorWZVoltage      "Sensor WZ Voltage [%d mV]"        <energy>       (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:voltage" }
Number ZigbeeSensorWZBattery      "Sensor WZ Battery [%.1f %%]"      <battery>      (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:battery" }

// aqara door and windows contact 

String ZigbeeBKContact      "Balkont├╝r Status [%s]"      <switch>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:status" }
Number ZigbeeBKLinkQuality  "Balkont├╝r Link Quality [%d]"      <network>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:linkquality" }
Number ZigbeeBKVoltage      "Balkont├╝r Voltage [%d mV]"        <energy>       (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:voltage" }
Number ZigbeeBKBattery      "Balkont├╝r Battery [%.1f %%]"      <battery>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:battery" }

 // shelly H&T Sensor original firmware !!no tasmota!!
Number TemperaturEsszimmerTemperature  "Sensor EZ Temperature [%.1f ┬░C]"  <temperature>  (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:temperature" }
Number TemperaturEsszimmerHumidity     "Sensor EZ Humidity [%.1f %%]"     <humidity>     (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:humidity" }
Number TemperaturEsszimmerBattery      "Sensor EZ Battery [%.1f %%]"      <battery>      (gZigbeeSensor)     
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:battery" }
// Control zigbee2mqtt
Group  gZigbeeMQTT    "Zigbee2mqtt"
String ZigbeeState               "Zigbee2mqtt state"                  <switch>    (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:state" }
Switch ZigbeePermitJoin          "Permit join new devices"            <switch>    (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:permitJoin" }
String ZigbeeLogType             "Zigbee2mqtt log type"                           (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:logType" }
String ZigbeeLogMessage          "Zigbee2mqtt log message"                        (gZigbeeMQTT) { channel="mqtt:topic:myMQTTBroker:zigbeeMQTT:logMessage" }


// Xiaomi Aqara temperature, humidity and pressure sensor WSDCGQ11LM
Group  gZigbeeSensor    "Zigbee Sensors"

Number ZigbeeSensorWZTemperature  "Sensor WZ Temperature [%.1f ┬░C]"  <temperature>  (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:temperature" }
Number ZigbeeSensorWZHumidity     "Sensor WZ Humidity [%.1f %%]"     <humidity>     (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:humidity" }
Number ZigbeeSensorWZPressure     "Sensor WZ Pressure  [%d hPa]"     <pressure>     (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:pressure" }
Number ZigbeeSensorWZLinkQuality  "Sensor WZ Link Quality [%d]"      <network>      (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:linkquality" }
Number ZigbeeSensorWZVoltage      "Sensor WZ Voltage [%d mV]"        <energy>       (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:voltage" }
Number ZigbeeSensorWZBattery      "Sensor WZ Battery [%.1f %%]"      <battery>      (gZigbeeSensor) { channel="mqtt:topic:myMQTTBroker:zigbeeSensorWZ:battery" }

// aqara door and windows contact 

String ZigbeeBKContact      "Balkont├╝r Status [%s]"      <switch>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:status" }
Number ZigbeeBKLinkQuality  "Balkont├╝r Link Quality [%d]"      <network>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:linkquality" }
Number ZigbeeBKVoltage      "Balkont├╝r Voltage [%d mV]"        <energy>       (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:voltage" }
Number ZigbeeBKBattery      "Balkont├╝r Battery [%.1f %%]"      <battery>      (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:zigbeeBK:battery" }

 // shelly H&T Sensor original firmware !!no tasmota!!
Number TemperaturEsszimmerTemperature  "Sensor EZ Temperature [%.1f ┬░C]"  <temperature>  (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:temperature" }
Number TemperaturEsszimmerHumidity     "Sensor EZ Humidity [%.1f %%]"     <humidity>     (gZigbeeSensor) 
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:humidity" }
Number TemperaturEsszimmerBattery      "Sensor EZ Battery [%.1f %%]"      <battery>      (gZigbeeSensor)     
    { channel="mqtt:topic:myMQTTBroker:TemperaturEsszimmer:battery" }

next steps/what is missing:

The aqara contact Sensors deliver still true ( door closed ) and false ( door open ). This has to be changed to open and close.

furthermore I have to add still my shelly 2 devices configured as roller shutter for my roller.
I know, that this is not yet proper implemented in openhab, but anyway I am creating rulesets in node red, so the devices can easily triggered from there, but I want to use openhab nodes in node red.

If you have any questions donÔÇÖt hasitete to contact me

regards

Hi,
to show a proper contact do this:
https://community.openhab.org/t/mqtt-2-4-zigbee2mqtt-xiaomi-aqara-sensors-sample-config/64118/5

1 Like