zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Question regarding cache_state and sensor mqtt message

Open kimonm opened this issue 8 years ago • 2 comments

With configuration "cache_state: true," the mqtt message includes the last state event for sensors, even if not updated. (I understand why.) However, with the DJT11LM motion sensor, this means the last event (e.g., vibration) is sent when the sensor is just updating the battery status. I don't see how to identify that this isn't a new event.

Is the best practice to have fromZigbee.js entry define a state such as "idle" if the data field isn't set? Or is there a better way? I could change the code for DJT11LM to be something like:

if (msg.data.data['85']) { const data = msg.data.data['85']; result.event = vibrationLookup[data]; } else { result.event = 'idle'; }

kimonm avatar Oct 01 '18 18:10 kimonm

The action key is not cached due to https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/controller.js#L327

Could you provide your log?

Koenkk avatar Oct 02 '18 11:10 Koenkk

Thanks for the explanation. I found the error in my code - it was an older version using event key rather than action. Btw, really excellent documentation. The work is appreciated.

kimonm avatar Oct 02 '18 23:10 kimonm