for a long time now im using zigbee2mqtt on a CC2652RB. Since the beginning I used the MQTT Binding. Everything works well, except that the states of my ikea tradfri bulbs are not updating.
In the z2m frontend i setup the minimal report interval and there its working fine. When i unplug the light and plug it in again, I get the update the light is on after a minute. Openhab doesnt update the state of the light.
In the zigbee2mqtt documentation for IKEA LED1732G11 i found that for the state i should send a message to zigbee2mqtt/FRIENDLY_NAME/get with payload `{“state”: “”}
This is unusual. I have this setup and this setup, and if I use the physical light switch to turn the bulbs on and off, their eventual on status is definitely updated in openHAB.
Have you verified that your MQTT broker (as opposed to zigbee2mqtt) is receiving/publishing a status at the time? Use MQTT Explorer or mqtt.fx to check.
It cuts out the MQTT middleman - ZigBee directly into openHAB.
Create a new rule to ask your device if what state it is.
rule "Get State of light"
when
Item cron "0/30 0 0 ? * * *"
then
val mqttActions = getActions("mqtt","mqtt:broker:myMQTTBroker")
mqttActions.publishMQTT("zigbee2mqtt/FRIENDLY_NAME/get", "{\"state\": \"\"}")
logInfo("Get State Light" , "FRIENDLY_NAME" )
end
Openhab will then send a message to the light {"state": ""} ever 30 seconds. You should be able to monitor it in another program like http://mqtt-explorer.com/
Do this and tell us what else you see. What is the message the light sends to MQTT to tell you what the state is?
I still get the same error when i trigger the rule. i think its because we send a empty state value instead of On/off, but thats what the documentation says.
Just dont understand why the setting of hafniumzinc is working and the exact same does not for me, nether your suggetion does.
But if i get the event from the broker, there is something wrong with my bridge or channel, like its ignoring the new message. Just dont know what else can i do here. i found some channel options in the UI but none of them sound like could solve my problem.
Does the availibility of the channel make any difference to this issue?
I cant make the thing work in the UI. I made a broker with the UI which goes online but the generic mqtt thing stays offline no matter if i select my text file generated broker or the UI generated one.
What am I missing here?
EDIT: now its kind of working but also quite strange.
First i changed the experimental feature “output” in zigbee2mqtt configuration from json to attribute like described in the second link of @hafniumzinc.
Then the UI generated generic mqtt thing “Kitchen Light Test” was online for a moment. I created the channel and linked it to an item all by the UI.
Now the thing and the channel are offline but the Item linked to it is working!? And it even updates when I change the state of the bulb unplug the bulb.
I will check how to get the availability to text based and other differences I find to make my text based setting run. The UI is more comfortable but in the end less flexible. Thats why i will keep the text based configuration (as soon as its working )
EDIT 2:
i did a reboot of openhab and now all is online and even the text file generated kitchen switch is reacting to manual manipulation of the bulb.
Now both switches change to ON a few seconds after power on the bulb.
What i forget to mention above is that i also added availability with 5 seconds to zigbee2mqtt configuration (before it was deactivated). So I still understand it completly but looks like availability has an effect here
I do the same. The first linked tutorial is file based configuration. The first link in the second linked tutorial takes you to a tutorial with file based configurations. Example:
Note that openHAB isn’t very good at picking up changes to the Things files on the fly. You can restart openHAB like you’ve done, or I do this.
I have no opinion on if you should use text based config or UI. I simply don’t care enough how you want to do it. UI has the benefit of syntax checking but I use VSCode through SSH to do all my config in text.