I’ve been using zigbee2mqtt for quite some time, for details look here:
and here:
Recently I discovered a new option of zigbee2mqtt: attribute output
. This option, in company with the mqtt2 binding, provides a nice solution.
This option simply gets rid of the json
-formatted output and transmits all attributes separately.
You enable it via configuration.yaml
.
experimental:
output: attribute
The benefits are:
- no more json-encoded output => no jsonpath-transformation
- no more missing attributes in message => no Javascript-transformation
I use files for erverything, so every device uses two parts of configuration, a things and an items file. The following are my devices so far.
- Osram SmartPlug thing:
Thing topic SZLV "SZLV" @ "SZ"
{
Channels:
Type switch : state "state" [ stateTopic = "zigbee2mqtt/SZLV/state", commandTopic = "zigbee2mqtt/SZLV/set/state", on="ON", off="OFF" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/SZLV/linkquality" ]
}
- Osram SmartPlug items:
Switch SZLV_TOGGLE "Lava [%s]" <poweroutlet> {channel="mqtt:topic:broker:SZLV:state"}
Number SZLV_LINKQUALITY "SZLV [%d]" {channel="mqtt:topic:broker:SZLV:linkquality"}
- Xiaomi Aqara wireless switch WXKG11LM thing:
Thing topic SZKEY0 "SZKEY0" @ "SZ"
{
Channels:
Type string : click "click" [ stateTopic = "zigbee2mqtt/SZKEY0/click" ]
Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/SZKEY0/voltage" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/SZKEY0/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/SZKEY0/linkquality" ]
}
- Xiaomi Aqara wireless switch WXKG11LM items:
String SZKEY0_CLICK "SZKEY0 [%s]" <button> {channel="mqtt:topic:broker:SZKEY0:click"}
Number SZKEY0_VOLTAGE "SZKEY0 Volt [%d mV]" {channel="mqtt:topic:broker:SZKEY0:voltage"}
Number SZKEY0_BATTERY "SZKEY0 BAT [%.1f %%]" <battery {channel="mqtt:topic:broker:SZKEY0:battery"}
Number SZKEY0_LINKQUALITY "SZKEY0 [%d]" {channel="mqtt:topic:broker:SZKEY0:linkquality"}
- Xiaomi Aqara water leak sensor SJCGQ11LM thing:
Thing topic LEAK "LEAK" @ "B1"
{
Channels:
Type switch : water_leak "water_leak" [ stateTopic = "zigbee2mqtt/LEAK/water_leak",on="true", off="false" ]
Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/LEAK/voltage" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/LEAK/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/LEAK/linkquality" ]
}
- Xiaomi Aqara water leak sensor SJCGQ11LM items:
Switch LEAK_STATE "Leak [%s]" <water> {channel="mqtt:topic:broker:LEAK:water_leak" }
Number LEAK_VOLTAGE "Leak Volt [%d mV]" {channel="mqtt:topic:broker:LEAK:voltage"}
Number LEAK_BATTERY "Leak BAT [%.1f %%]" <battery> {channel="mqtt:topic:broker:LEAK:battery"}
Number LEAK_LINKQUALITY "LEAK [%d]" {channel="mqtt:topic:broker:LEAK:linkquality"}
- Xiaomi Aqara human body movement and illuminance sensor RTCGQ11LM thing:
Thing topic TEMD "TEMD" @ "TE"
{
Channels:
Type switch : occupancy "occupancy" [ stateTopic = "zigbee2mqtt/TEMD/occupancy", on="true", off="false" ]
Type number : illuminance "illuminance" [ stateTopic = "zigbee2mqtt/TEMD/illuminance" ]
Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/TEMD/voltage" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/TEMD/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/TEMD/linkquality" ]
}
- Xiaomi Aqara human body movement and illuminance sensor RTCGQ11LM items:
Switch TEMD_MOTION "TEMD Motion [MAP(HM-Sen-MDIR-O-2.map):%s]" <motion> {channel="mqtt:topic:broker:TEMD:occupancy" }
Number TEMD_BRIGHTNESS "TEMD Brightness [%d lumen]" {channel="mqtt:topic:broker:TEMD:illuminance"}
Number TEMD_VOLTAGE "TEMD Volt [%d mV]" {channel="mqtt:topic:broker:TEMD:voltage"}
Number TEMD_BATTERY "TEMD BAT [%.1f %%]" <battery> {channel="mqtt:topic:broker:TEMD:battery"}
Number TEMD_LINKQUALITY "TEMD [%d]" {channel="mqtt:topic:broker:TEMD:linkquality"}
- the map file HM-Sen-MDIR-O-2.map
0=keine Bewegung
1=Bewegung
-=unbekannt
OPEN=Bewegung
CLOSED=keine Bewegung
OFF=keine Bewegung
ON=Bewegung
NULL=unbekannt
- Xiaomi Aqara temperature, humidity and pressure sensor WSDCGQ11LM thing:
Thing topic KEHK "KEHK" @ "KE"
{
Channels:
Type number : temperature "temperature" [ stateTopic = "zigbee2mqtt/KEHK/temperature" ]
Type number : humidity "humidity" [ stateTopic = "zigbee2mqtt/KEHK/humidity" ]
Type number : pressure "pressure" [ stateTopic = "zigbee2mqtt/KEHK/pressure" ]
Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/KEHK/voltage" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/KEHK/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/KEHK/linkquality" ]
}
- Xiaomi Aqara temperature, humidity and pressure sensor WSDCGQ11LM items:
Number KEHK_TEMP "Kesseltemperatur [%.1f °C]" <temperature> {channel="mqtt:topic:broker:KEHK:temperature"}
Number KEHK_HUMIDITY "KEHK HUMID [%d %%]" {channel="mqtt:topic:broker:KEHK:humidity"}
Number KEHK_PRESSURE "KEHK PRESS [%d mbar]" {channel="mqtt:topic:broker:KEHK:pressure"}
Number KEHK_VOLTAGE "KEHK Volt [%d mV]" {channel="mqtt:topic:broker:KEHK:voltage"}
Number KEHK_BATTERY "KEHK BAT [%.1f %%]" <battery> {channel="mqtt:topic:broker:KEHK:battery"}
Number KEHK_LINKQUALITY "KEHK [%d]" {channel="mqtt:topic:broker:KEHK:linkquality"}
- IKEA TRADFRI remote control E1524 thing:
Thing topic SZMS "SZMS" @ "SZ"
{
Channels:
Type string : action "action" [ stateTopic = "zigbee2mqtt/SZMS/action" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/SZMS/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/SZMS/linkquality" ]
}
- IKEA TRADFRI remote control E1524 items:
String SZMS_ACTION "SZMS [%s]" <button> {channel="mqtt:topic:broker:SZMS:action"}
Number SZMS_BATTERY "SZMS BAT [%.1f %%]" <battery> {channel="mqtt:topic:broker:SZMS:battery"}
Number SZMS_LINKQUALITY "SZMS [%d]" {channel="mqtt:topic:broker:SZMS:linkquality"}