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

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.
ss

Below is my binary_sensor setup for anyone interested. I just did 500 instead of 100 since it splits the difference.

- platform: template
  sensors:
    garage_left_open:
      device_class: opening
      value_template: "{{ states('sensor.PS4_z_axis')|float > 500 }}"
6 Likes