Zigbee2mqtt command


(Gildas Meda) #1

Hello,I searched in vain how to write a post, that’s why I write to you directly inbox
i have problem with zigbee2mqtt.
i use xiaomi aqara device. For aqara switch, (wall switch, socket plug, wireless switch)… i don’t understand how to send command. i can’t control device via openhab. please help

.thing file

Bridge mqtt:broker:mybroker [ host="localhost", port=1883, secure=false ]
{
// Door sensors
Thing topic doorsensor1 "doorsensor1" {
Channels:
    Type contact : contact "Contact"        [ stateTopic="zigbee2mqtt/doorsensor1", transformationPattern="JS:getZigbeeContact2Contact.js"]
    Type number : voltage "Voltage"         [ stateTopic="zigbee2mqtt/doorsensor1", transformationPattern="JSONPATH:$.voltage"]
    Type number : battery "Battery"         [ stateTopic="zigbee2mqtt/doorsensor1", transformationPattern="JSONPATH:$.battery"]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/doorsensor1", transformationPattern="JSONPATH:$.linkquality" ]

}

Thing topic wirelessdoubleswitch1 "wirelessdoubleswitch1" {
Channels:
    Type string : click "Click"             [ stateTopic="zigbee2mqtt/wirelessdoubleswitch1", commandTopic="zigbee2mqtt/wirelessdoubleswitch1/system/set", transformationPattern="JS:getZigbeeClick.js" ]
    Type number : voltage  "Voltage"        [ stateTopic="zigbee2mqtt/wirelessdoubleswitch1",  transformationPattern="JSONPATH:$.voltage" ]
    Type number : battery  "Battery"        [ stateTopic="zigbee2mqtt/wirelessdoubleswitch1",  transformationPattern="JSONPATH:$.battery" ]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/wirelessdoubleswitch1",  transformationPattern="JSONPATH:$.linkquality" ]
}

Thing topic wallsocketplug1 "wallsocketplug1" {
Channels:
    Type switch : command "State"           [ stateTopic="zigbee2mqtt/wallsocketplug1", commandTopic="zigbee2mqtt/wallsocketplug1/system/set", transformationPattern="JSONPATH:$.power" ]
    Type number : power "Power"             [ stateTopic="zigbee2mqtt/wallsocketplug1", transformationPattern="JSONPATH:$.power"] 
    Type number : voltage  "Voltage"        [ stateTopic="zigbee2mqtt/wallsocketplug1", transformationPattern="JSONPATH:$.consumption" ]
    Type number : temperature "Temperature" [ stateTopic="zigbee2mqtt/wallsocketplug1", transformationPattern="JSONPATH:$.temperature"]
    Type number : battery  "Battery"        [ stateTopic="zigbee2mqtt/wallsocketplug1", transformationPattern="JSONPATH:$.battery" ]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/wallsocketplug1", transformationPattern="JSONPATH:$.linkquality" ]
}

Thing topic wallsingleswitch1 "wallsingleswitch1" {
Channels:
    Type switch : command "State"           [ stateTopic="zigbee2mqtt/wallsingleswitch1", commandTopic="zigbee2mqtt/wallsingleswitch1/state" ]
    Type number : power "Power"             [ stateTopic="zigbee2mqtt/wallsingleswitch1", transformationPattern="JSONPATH:$.power"] 
    Type number : voltage  "Voltage"        [ stateTopic="zigbee2mqtt/wallsingleswitch1", transformationPattern="JSONPATH:$.consumption" ]
    Type number : temperature "Temperature" [ stateTopic="zigbee2mqtt/wallsingleswitch1", transformationPattern="JSONPATH:$.temperature"]
    Type number : battery  "Battery"        [ stateTopic="zigbee2mqtt/wallsingleswitch1", transformationPattern="JSONPATH:$.battery" ]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/wallsingleswitch1", transformationPattern="JSONPATH:$.linkquality" ]
}

/*
Thing topic aqaradoorsensor2 "Door Sensor 2"  @ "Upper Floor" {
        Channels:
            Type contact : status "Status" [ stateTopic="mqtt/zigbee2mqtt/Aqara_DoorSensor2", transformationPattern="JS:doorsensor.js" ]
            Type number : voltage "Voltage"[ stateTopic="mqtt/zigbee2mqtt/Aqara_DoorSensor2", transformationPattern="JSONPATH:$.voltage" ]
            Type number : battery "Battery"[ stateTopic="mqtt/zigbee2mqtt/Aqara_DoorSensor2", transformationPattern="JSONPATH:$.battery" ]
            Type number : linkquality "RSSI"[ stateTopic="mqtt/zigbee2mqtt/Aqara_DoorSensor2", transformationPattern="JSONPATH:$.linkquality" ]


    } 
*/

// Weather sensors
Thing topic humiditysensor1 "humiditysensor1" {
Channels:
    Type number : temperature "Temperature" [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.temperature"]
    Type number : humidity "Humidity"       [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.humidity"]
    Type number : pressure "Pressure"       [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.pressure"]
    Type number : voltage "Voltage"         [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.voltage"]
    Type number : battery "Battery"         [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.battery"]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/humiditysensor1", transformationPattern="JSONPATH:$.linkquality" ]

}

//Motion sensors
Thing topic motionsensor1 "motionsensor1" {
Channels:
    Type switch : motion "Motion"           [ stateTopic="zigbee2mqtt/motionsensor1", transformationPattern="JS:getZigbeeOccupancy2Switch.js"]
    Type number : brightness "Brightness"   [ stateTopic="zigbee2mqtt/motionsensor1", transformationPattern="JSONPATH:$.illuminance"]
    Type number : voltage "Voltage"         [ stateTopic="zigbee2mqtt/motionsensor1", transformationPattern="JSONPATH:$.voltage"]
    Type number : battery "Battery"         [ stateTopic="zigbee2mqtt/motionsensor1", transformationPattern="JSONPATH:$.battery"]
    Type number : linkquality "Linkquality" [ stateTopic="zigbee2mqtt/motionsensor1", transformationPattern="JSONPATH:$.linkquality" ]
}

/*
//Water Sensors
Thing topic watersensormeteringcloset "WaterSensorMeteringCloset" {
Channels:
    Type contact : contact "Contact"   [ stateTopic="zigbee2mqtt/LeakageMeteringCloset", transformationPattern="JS:getZigbeeLeak2Contact.js"]
    Type number : voltage "Voltage"    [ stateTopic="zigbee2mqtt/LeakageMeteringCloset", transformationPattern="JSONPATH:$.voltage"]
    Type number : battery "Battery"    [ stateTopic="zigbee2mqtt/LeakageMeteringCloset", transformationPattern="JSONPATH:$.battery"]
}
*/
}

.items

// Xiaomi Aqara wireless buttons WXKG01LM
Group  gZigbeeButton    "Zigbee Buttons"

String WirelessDoubleSwitch1Button       "Click [%s]"            <button>          (gZigbeeButton)  ["Switchable"] { channel="mqtt:topic:mybroker:wirelessdoubleswitch1:click" }
Number WirelessDoubleSwitch1LinkQuality  "Réseau [%d]"           <network>         (gZigbeeButton) { channel="mqtt:topic:mybroker:wirelessdoubleswitch1:linkquality" }
Number WirelessDoubleSwitch1Voltage      "Voltage [%d mV]"       <energy>          (gZigbeeButton) { channel="mqtt:topic:mybroker:wirelessdoubleswitch1:voltage" }
Number WirelessDoubleSwitch1Battery      "Batterie [%.1f %%]"    <battery>         (gZigbeeButton) { channel="mqtt:topic:mybroker:wirelessdoubleswitch1:battery" }


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

Number  HumiditySensor1Temperature  "Temperature [%.2f °C]"   <temperature>         (gZigbeeSensor)  ["CurrentTemperature"] { channel="mqtt:topic:mybroker:humiditysensor1:temperature" }
Number  HumiditySensor1Humidity     "Humidité [%.2f %%]"      <humidity>            (gZigbeeSensor)  ["CurrentHumidity"] { channel="mqtt:topic:mybroker:humiditysensor1:humidity" }
Number  HumiditySensor1Pressure     "Pression [%d hPa]"       <pressure>            (gZigbeeSensor) { channel="mqtt:topic:mybroker:humiditysensor1:pressure" }
Number  HumiditySensor1Voltage      "Voltage [%d mV]"         <energy>              (gZigbeeSensor) { channel="mqtt:topic:mybroker:humiditysensor1:voltage" }
Number  HumiditySensor1Battery      "Batterie [%.1f %%]"      <battery>             (gZigbeeSensor) { channel="mqtt:topic:mybroker:humiditysensor1:battery" }
Number  HumiditySensor1LinkQuality  "Réseau [%d]"             <qualityofservice>    (gZigbeeSensor) { channel="mqtt:topic:mybroker:humiditysensor1:linkquality" }


Contact DoorSensor1                 "Porte [%s]"              <door>                (gZigbeeSensor)  ["Switchable"] { channel="mqtt:topic:mybroker:doorsensor1:contact" }
Number  DoorSensor1Voltage          "Voltage [%d mV]"         <energy>              (gZigbeeSensor) { channel="mqtt:topic:mybroker:doorsensor1:voltage" }
Number  DoorSensor1Battery          "Batterie [%.1f %%]"      <battery>             (gZigbeeSensor) { channel="mqtt:topic:mybroker:doorsensor1:battery" }
Number  Doorsensor1LinkQuality      "Réseau [%d]"             <qualityofservice>    (gZigbeeSensor) { channel="mqtt:topic:mybroker:doorsensor1:linkquality" }


String  MotionSensor1               "Mouvement [%s]"          <motion>              (gZigbeeSensor)  ["Switchable"] { channel="mqtt:topic:mybroker:motionsensor1:motion" }
Number  MotionSensor1Brightness     "Luminescance [%d lumen]" <sun>                 (gZigbeeSensor) { channel="mqtt:topic:mybroker:motionsensor1:brightness" }
Number  MotionSensor1Voltage        "Voltage [%d mV]"         <energy>              (gZigbeeSensor) { channel="mqtt:topic:mybroker:motionsensor1:voltage" }
Number  MotionSensor1Battery        "Batterie [%.1f %%]"      <battery>             (gZigbeeSensor) { channel="mqtt:topic:mybroker:motionsensor1:battery" }
Number  MotionSensor1LinkQuality    "Réseau [%d]"             <qualityofservice>    (gZigbeeSensor) { channel="mqtt:topic:mybroker:motionsensor1:linkquality" }

Switch  WallSocketPlug1             "Etat [%s]"               <poweroutlet_eu>      (gZigbeeSensor)  ["Switchable"] { channel="mqtt:topic:mybroker:wallsocketplug1:command" }
Number  WallSocketPlug1Power        "Puissance [%d watt]"     <line>                (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsocketplug1:power" }
Number  WallSocketPlug1Voltage      "Voltage [%d mV]"         <energy>              (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsocketplug1:voltage" }
Number  WallSocketPlug1Temperature  "Temperature [%.2f °C]"   <temperature>         (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsocketplug1:temperature" }
Number  WallSocketPlug1Consumption  "Batterie [%.1f %%]"      <line>                (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsocketplug1:consumption" }
Number  WallSocketPlug1LinkQuality  "Réseau [%d]"             <qualityofservice>    (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsocketplug1:linkquality" }

Switch  WallSingleSwitch1             "Etat [%s]"               <light>              (gZigbeeSensor)  ["Switchable"] { channel="mqtt:topic:mybroker:wallsingleswitch1:command:ON" }
Number  WallSingleSwitch1Power        "Puissance [%d watt]"     <line>               (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsingleswitch1:power" }
Number  WallSingleSwitch1Voltage      "Voltage [%d mV]"         <energy>             (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsingleswitch1:voltage" }
Number  WallSingleSwitch1Temperature  "Temperature [%.2f °C]"   <temperature>        (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsingleswitch1:temperature" }
Number  WallSingleSwitch1Consumption  "Batterie [%.1f %%]"      <line>               (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsingleswitch1:consumption" }
Number  WallSingleSwitch1LinkQuality  "Réseau [%d]"             <qualityofservice>   (gZigbeeSensor) { channel="mqtt:topic:mybroker:wallsingleswitch1:linkquality" }



(Vincent Regaud) made this topic public #2

(CM6.5 H102) #3

I suggest starting with a single device such as the wallsocketplug1. After successfully switching the device on and off then work to add the other values.

Once you have a single device and all it’s values working move to the next device.