I’m using openhab for home automation for more than a year with a lot of devices and this time I’d like to use it to get data from Xiaomi Aqara sensors using CC2531 USB stick.
To be honest I feel a bit lost here. I’ve managed to install and run zigbee2mqtt service as described here https://www.zigbee2mqtt.io/getting_started/running_zigbee2mqtt.html
and I also managed to pair one of sensors. below you can find my current configuration.yaml of zigbee2mqtt
I wasn’t able to proceed nor with ZigBee Binding neither with MQTT Binding. I’ve went through topics when it was described that bridges are necessary to run it, and on others that bridges are no longer required for openhab to talk to mqtt.
My questions:
which binding should I use?
is there anything else I should install/configure?
does anyone has working configuration to share here with short description?
So I assume that binding you have is MQTT binding.
Where to define username and password from configuration.yaml then?
When I put thing like below
Thing topic xiaomi_aqara_1 "Temperature" @ "Garage"
{
Channels:
Type number : temperature "temperature" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/temperature" ]
Type number : humidity "humidity" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/humidity" ]
Type number : pressure "pressure" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/pressure" ]
Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/voltage" ]
Type number : battery "battery" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/battery" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/xiaomi_aqara_1/linkquality" ]
}
I receive error like below
2020-07-07 17:43:41.170 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'zigbee.things'
2020-07-07 17:43:41.203 [WARN ] [.thing.internal.GenericThingProvider] - Thing topic does not have a bridge so it needs to be defined in full notation like <bindingId>:topic:xiaomi_aqara_1
Do I need the bridge or not? How to add/define the bridge?
And when I try to use items as below
Number Garage_TEMP "Garage Temp [%.1f °C]" <temperature> (Zigbee) {channel="mqtt:topic:broker:xiaomi_aqara_1:temperature"}
Number Garage_HUMIDITY "Garage HUMID [%d %%]" {channel="mqtt:topic:broker:xiaomi_aqara_1:humidity"}
Number Garage_PRESSURE "Garage PRESS [%d mbar]" {channel="mqtt:topic:broker:xiaomi_aqara_1:pressure"}
Number Garage_VOLTAGE "Garage Volt [%d mV]" {channel="mqtt:topic:broker:xiaomi_aqara_1:voltage"}
Number Garage_BATTERY "Garage BAT [%.1f %%]" <battery> {channel="mqtt:topic:broker:xiaomi_aqara_1:battery"}
Number Garage_LINKQUALITY "Garage [%d]" {channel="mqtt:topic:broker:xiaomi_aqara_1:linkquality"}
I have no values returned. How can I check within mqtt service that my devideis providing values?
Hmm … once I executed sudo service zigbee2mqtt restart && sudo journalctl -u zigbee2mqtt.service -f
it started to work, I need to check why service was not working since system started, however no it looks as below
Thank you a lot @chrode
Yep, valid point. This was rather dirty config just for make it running and I didn’t put much attention to this flag, however I will change this for sure. Thanks!
I’ve just received my Aqara Magic Cube, and I’m able to see for example action and angle in openhab using below configuration
Things file (inside previously creted bridge)
Thing topic cube “Xiaomi” @ “Cube”
{
Channels:
Type string : action “action” [ stateTopic = “zigbee2mqtt/cube/action” ]
Type number : angle “angle” [ stateTopic = “zigbee2mqtt/cube/angle” ]
}
Items file
String AT_Office_ACTION “Akcja” (AT_Office) {channel=“mqtt:topic:openhabBroker:cube:action”}
Number AT_Office_ANGLE “Angle” (AT_Office) {channel=“mqtt:topic:openhabBroker:cube:angle”}
However from some reason rule on channel is not working at all. Rule is not triggered, however during rule file refresh there are no errors logged.
rule “Turn on the light”
when
Channel “mqtt:topic:openhabBroker:cube:action” triggered
then
logInfo(“Debug”, “Rule: Turn on the lamp test”)
var actionName = receivedEvent.getEvent()
logInfo(“Debug”, “Rule: Turn on the lamp action:” + actionName)
switch(actionName) {
case “slide”: {
AT_Office_Light.sendCommand(ON)
}
case “rotate_left”: {
AT_Office_Light.sendCommand(ON)
}
case “rotate_right”: {
AT_Office_Light.sendCommand(ON)
}
}
end
And this for example works
rule “Turn on the light”
when
Item AT_Office_ACTION received update
then
logInfo(“Debug”, “Rule: Turn on the lamp test”)
var state = AT_Office_ACTION.state
logInfo(“Debug”, “Rule: Turn on the lamp action:” + state)
end
Is there a reason to not to use second approach and what causes an issue with first one
Another question … I have currently several Aquara temperature sensors and Aqara magic cube working well. Recently I decided to buy also Aqara smart plug. I want to use it as repeater (and it doing it weel) but I also want to control it. I have it already visible in both OpenHab and MQTT explorer, however I can’t find a way to control it. Is there any way to do so?
Thing topic smart_plug_1 "Xiaomi" @ "Plug1"
{
Channels:
Type string : state "state" [ stateTopic = "zigbee2mqtt/smart_plug_1/state" ]
Type number : power "power" [ stateTopic = "zigbee2mqtt/smart_plug_1/power" ]
Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/smart_plug_1/linkquality" ]
}
String AT_Office_Plug_STATE “State” (Home, AT) {channel=“mqtt:topic:openhabBroker:smart_plug_1:state”}
Number AT_Office_Plug_POWER “Power [%d]” (Home, AT) {channel=“mqtt:topic:openhabBroker:smart_plug_1:power”}
Number AT_Office_Cube_LINKQUALITY “Link quality [%d]” (Home) {channel=“mqtt:topic:openhabBroker:smart_plug_1:linkquality”}