# Unable to read Cluster attribute (new ZigBeeDevice driver)

**URL:** <https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734>\
**Category:** Developers\
**Tags:** app, zigbee, homey-pro\
**Created:** [January 2, 2024, 4:01pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734 "2024-01-02T16:01:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardo\_Santos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_santos/32/79224_2.png) [@Ricardo\_Santos](https://community.homey.app/u/Ricardo_Santos)\
**Post date:** [January 2, 2024, 4:01pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/1 "2024-01-02T16:01:45Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/a/2a61f180bec758cc20e0f82e253c589a45e92b52.png)

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

---

<div class="post-metadata">

**Author:** ![Ricardo\_Santos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_santos/32/79224_2.png) [@Ricardo\_Santos](https://community.homey.app/u/Ricardo_Santos)\
**Post date:** [January 2, 2024, 5:02pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/2 "2024-01-02T17:02:46Z")

</div>

I believe the cluster definition for this sensor may require update, as it has a TODO comment in the Homey cluster definition (file: zigbee-clusters/lib/clusters/occupancySensing.js):

–snip–  
const ATTRIBUTES = {  
occupancy: { id: 0, type: ZCLDataTypes.map8(‘occupied’) }, **// TODO: verify this bitmap**  
–snip–

I’ll look into it, but in case there’s some insight on how to correct it, it’s highly appreciated.  
Thanks!

Cheers,  
Ricardo

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 2, 2024, 5:30pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/3 "2024-01-02T17:30:11Z")

</div>

Try [`getBit(0)`](https://github.com/athombv/node-data-types/blob/6adc1f6c6f455a243d9d84b22eb5f6daf67f759e/lib/DataTypes.js#L62) (or possibly `getBit(1)`).

---

<div class="post-metadata">

**Author:** ![Ricardo\_Santos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_santos/32/79224_2.png) [@Ricardo\_Santos](https://community.homey.app/u/Ricardo_Santos)\
**Post date:** [January 2, 2024, 6:05pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/4 "2024-01-02T18:05:38Z")

</div>

It worked with getBit(0), @robertklep!  
Many thanks for the hint and very fast reply. 😉

Cheers,  
Ricardo

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 3, 2024, 6:22am UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/5 "2024-01-03T06:22:09Z")

</div>

I couldn’t find anything related to this in the documentation, I had to search through the various modules to find where `Bitmap` was defined and how to use it 🤔

---

<div class="post-metadata">

**Author:** ![Ricardo\_Santos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_santos/32/79224_2.png) [@Ricardo\_Santos](https://community.homey.app/u/Ricardo_Santos)\
**Post date:** [January 3, 2024, 5:24pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/6 "2024-01-03T17:24:02Z")

</div>

Any chance you can point me where to find it in the modules?  
I’m new to programming in Homey and not sure where to find it.

Thanks.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 3, 2024, 6:47pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/7 "2024-01-03T18:47:42Z")

</div>

> [@Ricardo\_Santos](#):
>
> Any chance you can point me where to find it in the modules?

I linked to the relevant module, `@athombv/data-types`: [GitHub - athombv/node-data-types: Binary Data Parsers](https://github.com/athombv/node-data-types)

---

<div class="post-metadata">

**Author:** ![Ricardo\_Santos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_santos/32/79224_2.png) [@Ricardo\_Santos](https://community.homey.app/u/Ricardo_Santos)\
**Post date:** [January 5, 2024, 4:07pm UTC](https://community.homey.app/t/unable-to-read-cluster-attribute-new-zigbeedevice-driver/99734/8 "2024-01-05T16:07:35Z")

</div>

Many thanks @robertklep!  
This is really helpful.

Cheers,  
Ricardo
