Inspired by a recent post from @tv-arnd, here is a simple method to:
- See if the zigbee dongle (CC2531 in my case) is online or offline
- Switch zigbee2mqtt
permit_join
on or off - Change the level of zigbee2mqtt logging
things files
bridge.things
I use a separate things file for my Mosquitto bridge:Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
host="192.168.1.92",
secure=false,
port=1883,
clientID="OpenHAB2"
]
zigbee.things
Thing mqtt:topic:bridge "CC2531" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch : state "State" [
stateTopic = "zigbee2mqtt/bridge/state",
off="offline",
on="online"
]
Type switch : permitJoin "Permit join" [
stateTopic = "zigbee2mqtt/bridge/config",
transformationPattern="JSONPATH:$.permit_join",
commandTopic="zigbee2mqtt/bridge/config/permit_join",
off="false",
on="true"
]
Type number : logLevel "Log level" [
stateTopic = "zigbee2mqtt/bridge/config",
transformationPattern="JSONPATH:$.log_levelā©MAP:num2loglevel.map",
commandTopic="zigbee2mqtt/bridge/config/log_level",
transformationPatternOut="MAP:num2loglevel.map"
]
}
Items
zigbee.items
Switch sZigbeeDongle "Zigbee dongle " (gReachable) {channel="mqtt:topic:bridge:state"}
Switch sZigbeePermitJoin "Zigbee permit join" {channel="mqtt:topic:bridge:permitJoin"}
Number nZigbeeLogLevel "Zigbee log level" {channel="mqtt:topic:bridge:logLevel"}
Sitemap file
snippet
Text item=sZigbeeDongle label="Zigbee dongle [MAP(switch2online.map):%s]" icon="shield"
Switch item=sZigbeePermitJoin label="Zigbee permit join"
Switch item=nZigbeeLogLevel label="Zigbee log level []" mappings=[0="D", 1="I", 2="W", 3="E"]
Map files
switch2online.map
OFF=OFFLINE
ON=ONLINE
NULL=UNDEFINED
-=-
num2loglevel.map
0=debug
1=info
2=warn
3=error
debug=0
info=1
warn=2
error=3
Further
There are many more topics which could be controlled or interrogated: | Zigbee2MQTT
Hereās a similar example: