Replies: 11 comments 10 replies
-
I have much working, just not able to get the state on startup. Assuming that state is not a retained message, based on looking at incoming state messages, I tried to However, when I try to get current state of an Aqara door sensor using the same payload I get the error Here is the state message that I get from an Aqara door sensor. I get this message by activating the sensor.
So, any pointers would be appreciate on how to get the state of devices, since device state does not appear to be retrained! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Last update for a bit. Curious, I looked at the front end extension code. If I understand correctly when the front end is started by z2m it pulls the state from internal z2m and sends them out for the front end to receive. I don't claim to fully understand if that's right but if true it explains how the front end has initial device state. https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/extension/frontend.ts#L113-L140 |
Beta Was this translation helpful? Give feedback.
-
I have been working on this all day. I finally stumbled on a Reddit post that describes how to fix. I still have two questions though.
The fix, if others are wondering came from this post: https://www.reddit.com/r/homeassistant/comments/w9daui/some_zigbee2mqtt_devices_have_wrong_state_after/ Specifically, adding the following to your z2m configuration.yaml:
|
Beta Was this translation helpful? Give feedback.
-
Anybody? Should I even being turning on retain globally? |
Beta Was this translation helpful? Give feedback.
-
I do this using a homebrew extension:
You can query the state (or all devices) or both device definition and state by sending: Responses look are posted back on topics Note that the unloading/re-loading of extensions seems to have a bug, and you may end up with both the old and new extensions firing, until you restart the server. |
Beta Was this translation helpful? Give feedback.
-
@MatAtBread hey thanks for sharing this . its a extension right? i havent worked with java script , i can add this extension to z2m using the instructions provided in the website right? Can anybody provide insight to create a custom converter to get sensor status . any help would be much appreciated |
Beta Was this translation helpful? Give feedback.
-
It's a custom extension. You can load (copy paste) it remotely via the "extensions" menu item in the UI |
Beta Was this translation helpful? Give feedback.
-
its a TuYa door sensor |
Beta Was this translation helpful? Give feedback.
-
Check the instructions in the above repo. You'll need a new concertor. I'd say there's a 90% chance there already a definition for it, but maybe not your variant (assuming Z2M didn't identify it). In which case you'd only need to add the model or manufacturer's ID to the existing definition for Z2M to find it |
Beta Was this translation helpful? Give feedback.
-
hello @MatAtBread i have impelemented the above extension to get the state of the device i have managed to get the state of individual devices by using |
Beta Was this translation helpful? Give feedback.
-
here is the updated code suggest edits to perform the above
|
Beta Was this translation helpful? Give feedback.
-
I'm working on some Python code that connects to the mosquitto broker (as a Home Assistant plugin). My initial subscribe is for
zigbee2mqtt/#
. I receive a number of messages from the bridge, for examplezigbee2mqtt/bridge/devices
among others. What I don't receive is the state of the devices.I understood the state to be a retained message and should receive the state on connect.
Any pointers would be appreciated on how to get the device state on connect. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions