ZIGBEE (ZHA): Get a Cluster Attribute that isn't normally tracked

I’m really glad I found this thread. Thanks for taking the time to figure that out!

Additionally, CASE and value comparisons seem to work pretty well. No need for additional templates, which wasn’t really suiting my needs. You could always do another query for the direct value should you need it.

   queries:
      - name: garage_tilt_sensor_x_axis
        query: "SELECT CASE WHEN value < 1000 then 'closed' WHEN value > 1000 then 'open' END result FROM attributes where ieee = 'xxxxxxxx' and cluster = 64514 and attrid = 18 "
        column: result

you’ll see your sensor state comes back as the value of ‘result’.

How do you open zigbee.db to see it’s content? What format zha uses for db?

zigbee.db is a SQLite format. SQLite Browser is what I use to view the data within.

Do you know how to read attribute which is not in zigbee.db but has value when I look with ‘Manage Clusters’?
I have Schwaiger power socket which measures delivered energy but this attribute is not in zigbee.bd.
How can I read this value from device cluster in template?

I too hope that our courageous developers start adding other clusters to ZHA.

1 Like

With ‘Manage Clusters’ is possible read all clusters and attributes.
We just need some sort of query, like platform: sql, to read directly from zigbee devices.
Maybe there is already such way, but I can’t find it.

@ratsepa You may have already done this but how I found it:

  1. Open config/zibee.db with DB Browser for SQLite
  2. Click on the Browse Data Tab
  3. Select the attributes table
  4. Under ieee Filter enter the IEEE number found under Integrations->Zigbee->configure->devices->Device Name->Under Zigbee info (just copy and paste it)

All the tracked items are will be listed there.

If its NOT tracked there, it kinda goes back to my original problem of looking for an option to poll a Zigbee attribute from automation.

2 Likes

hello friend, you did a good job, thank you
do you know how to get WYZE LOCK status, like door is opened, closed, locked manually and unlocked manually?
thank you

@akhlghatyan Sorry, I don’t have this device so I can’t say for sure. I would recommend first checking in the device states under Developer Tools->States. Most things are tracked there and can be accessed with automation.

If you can’t find it there and it is a Zigbee device, you can check under Clusters under the zigbee integration… you’ll need to hunt for it.
Congig->integrations->zigbee->devices->(device you want to check)->Manage Clusters
You select Clusters then attribute to see what is in it.

Thanks a lot, I solved my problem

Hi,

I’m using Moes TRVs. However ZHA doesn’t support battery percentage.
In clusters I found that there’s a battery low warning (binary).
Now I want to make a binary sensor with this data.
Did anyone figure out how to do this?

Thanks in advance!

This solution to read data from the smartthings sensors has been working great for over a year, but I just noticed the other day it stopped working. I’m thinking most likely it stopped after recently updating homeassistant.

Has anyone else seen this happen? It is still reading a value from the zigbee.db file but it never updates based on the orientation of the device.

I had been fighting with this issue after a recent update as well. Turns out ZHA updated their schema and the attributes table is currently called attributes_cache_v6.

So the query from above is now…

SELECT CASE WHEN value < 1000 then 'closed' WHEN value > 1000 then 'open' END result
FROM attributes_cached_v6
WHERE ieee = 'xxxxxxxx' and cluster = 64514 and attrid = 18

It looks like ZHA may be continuing with versioning their table names moving forward as well. I think I saw a reference to attributes_cached_v7 somewhere. So this issue may pop up again.

1 Like

You are a lifesaver. I’ve been trying to fix this for a while. I’ll see if it works tonight.

Unfortunately that didn’t work for me. It doesn’t produce any data. The values show up as “unknown”. When I go back to “attributes” it populates the values but I think they’re stale values.

Dang. I was hoping that would work for you. I’d also see about trying attributes_cache_v5. Depending on what version you’re on, ZHA may not be using v6 yet.

This solution worked GREAT and let me move my garage door (my last remaining sensor) off of SmartThings last year. Props to everyone above who came up with this workaround. But last weekend I came across a blog post (Using a SmartThings sensor in "garage door" mode with Home Assistant - David Boike's Blog) where they listen for a zha_event and triggered an automation if it came from the designated sensor and had values within their range. My implementation from that isn’t 100% identical as I deviated to match the initial SmartThings code for a sensor in garage door mode, but it works extremely well so far. If the v5 table doesn’t work and you’re open to an alternate way for doing this, it might be worth a look.

1 Like

Thanks for the possiblities opened up here :slight_smile: now I can check for some possible Zigbee command losses which are only reflected in not updated thermostat cluster attributes and do trigger automations based on that.

This may interest some of you: Read Zigbee attribute directly into a state . I just extended “zha_custom” - now zha-toolkit - to read zigbee attributes to a ha state.

3 Likes

Very Cool! Really what I was looking for when I posted this :smiley:
Thanks for the update

Hi, I posted an example to another thread on how to read cluster attributes to a sensor with zha-toolkit (latest version of zha-custom) : Danfoss Ally TRV working with remote temp sensor - #140 by jjrytko

2 Likes