I have a Smart Things Multi sensor(Multi4)I’ve gotten working with ZHA. There are some attributes I can’t find in the pre-made senosrs that can be found in CentraLiteAccelCluster: x_axis, y_axis and z_axis; I need these exposed since I’d like to use this as a tilt sensor.
From Home Assistant I can see the attribute value if I go to Zigbee Home Automation, select the device, select the cluster then select the attribute and press “GET ZIGBEE ATTRIBUTE” but It is not exposed as a attribute anywhere else including node-red.
Posting my solution for anyone else with this issue:
Okay, I’m experimenting with a possibility though I’m not sure how good of an idea it is.
I’ve noticed in the /config/zigbee.db that the attributes I want are tracked there so I’ve set up a sql sensor
sensor:
- platform: sql
db_url: sqlite:////config/zigbee.db
scan_interval: 10
queries:
- name: PS4_x_axis
query: "SELECT value FROM attributes where ieee = 'ieee address' and cluster = 64514 and attrid = 18"
column: "value"
- name: PS4_y_axis
query: "SELECT value FROM attributes where ieee = 'ieee address' and cluster = 64514 and attrid = 19"
column: "value"
- name: PS4_z_axis
query: "SELECT value FROM attributes where ieee = 'ieee address' and cluster = 64514 and attrid = 20"
column: "value"
I’m not sure how frequent the updates will be but I suspect it will update with the other sensor’s data such as acceleration which would be fine. I’ll post how it goes.
Update
Seems to work great! Updates are frequent enough to catch when my garage door is open. Hopefully there are no issues I’m missing.
This will allow me to use my smartthings multisensor (multi4) as a garage door tilt sensor (to tell if the garage door is open or closed).
The image shows from horizontal to vertical, so I’ll just need to add a sensor template with < 100 open and >= 100 closed.
Below is my binary_sensor setup for anyone interested. I just did 500 instead of 100 since it splits the difference.
@dargonos Do you find that the zigbee.db file gets updated fast enough with the attribute value? I’m looking to do something similar but I need to get an updated value every 1 second. It doesn’t seem like the database file is updated that often though
For my purposes it updates fast enough but it really seems to be dependant, not on the database, but how fast the Zigbee device updates. You could drop scan_interval: to 1 and see.
I’m using Multi4’s (1st gen smartthings multi sensor) and I’ve noticed that the db derived (x,y,z coords) sensor updates occur just as fast as the any other normally monitored sensor such as the acceleration sensor. With the Multi4, it updates very quickly when something is happening, such as motion, and very slowly when idle… which makes sense.
I’ve noticed the updates(at least on battery powered devices known as “sleepy” devices) are pushed typically, meaning the device decides when to send them(you can see this happen in the logs when devices are joining) so it is really up to your device you want info from.
In 0.100.x the multi-sensor is working with latest native zha setup.
I unpaired mine, reset it, and re-added it and x, y, and z showed in the logs and the binary sensor responded to vibrations without having to change a thing.
Thanks for your efforts, Jeff! This worked great until better HA support arrived.
I’m running 0.107.7 and x,y,z still don’t get added as entities.
The values do show in the logs as you stated.
Thanks a million @dargonos! This would’ve taken me quite a while to solve.
I was really disappointed because i was using this sensor thru smartthings hub and I had the xyz values. But it was a bit too far from the hub so i switched it to the ZHA hub which is closer and then discovered I’d lost what I depended on!
FYI: Using this as a tilt sensor for a spa cover. Contact sensor doesn’t work in that case because there’s too much slop in the positioning.
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’.
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?
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.
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.
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?
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.