Hi,
I’m developing a new driver for a Zigbee Occupancy Sensor (SONOFF SNZB-06P) using the ZigBeeDevice library.
I’m able to add the device into HomeyPro App and I do see in the debug the occupancy status change correctly and a report being received in Homey. But I cannot read its occupancy status.
The reason is that the reportParser in ZigBeeDevice.js is not able to read the attribute value in the Cluster report as a 0 or 1.
Instead, in the debug I see the the attribute is printed as a Bitmap [ ]. See below two examples of this attribute when occupancy is detected or not.
Below, the payloadReport is the output of: console.log(‘payload[report]:’, payload[report]);
##== OCCUPANCY = FALSE
2024-01-02T15:36:44.391Z [log] [ManagerDrivers] [Driver:snzb-06p-occupancy-sensor] [Device:8a4597e6-f717-438f-a69d-7f9aef124a80] [dbg] get → alarm_motion → read attribute (cluster: occupancySensing, attributeId: occupancy, endpoint: 1) → raw result: { occupancy: Bitmap [ ] }
2024-01-02T15:36:44.392Z [log] [ManagerDrivers] [Driver:snzb-06p-occupancy-sensor] [Device:8a4597e6-f717-438f-a69d-7f9aef124a80] [dbg] handle report (cluster: occupancySensing, capability: alarm_motion), raw payload: { occupancy: Bitmap [ ] }
payload[report]: Bitmap [ ]
##== OCCUPANCY = TRUE
2024-01-02T15:42:34.308Z [log] [ManagerDrivers] [Driver:snzb-06p-occupancy-sensor] [Device:8a4597e6-f717-438f-a69d-7f9aef124a80] [dbg] handle report (cluster: occupancySensing, capability: alarm_motion), raw payload: { occupancy: Bitmap [ occupied ] }
payload[report]: Bitmap [ occupied ]
I’ve tried reading this attribute in several ways: I tried comparing with integer 1 or char ‘1’, treat it as an Array and access position [0], without success.
Any hint on how I can read the Bitmap [ ] value of this attribute?
According to the ZCL this should be a bit set to 0 or 1.
Disclaimer: This is my first attempt at writing an App for HomeyPro and I’m not a pro developer, even though I’ve programmed in Java, C++, C, etc in University.
Cheers,
Ricardo