My zigbee Aqara sensor sends X,Y and Z values only as events.
How do I run an automation based on value X exceeding 20 degrees?
The event data is this:
Iâm taking this from this how-to, but it helped me figure out how to use my tilt sensor based on zha events. I set mine up a little different but it helped me figure it out even with being a newbie.
The first condition makes it so it only triggers on a z_axis event. The one I have sends an event for each axis. Looking at your event data, your sensor reports a bit differently so it doesnât look like youâd need that to filter events. The second one is a condition to set the state based on the z_axis value.
Iâve duplicated your yaml but still canât get it to trigger-- from my event data above, I assume Iâm correctly assigning attribute_name to âXâ?
Ok, just noticed, as mentioned above itâs an array so try using trigger.event.data.args[0].X, the sensor I have reports a bit differently so was mixing up with how mine did it.
You both are just terrific, thank you.
So in trace here is the error:
Error: In âtemplateâ condition: UndefinedError: âint objectâ has no attribute âvalueâ
for this config:
Dâoh! Iâm an idiot; I deleted the â.valueâ and it WORKS!
I REALLY appreciate you two helping this newb (but I suspect what Iâm doing isnât routine stuff).
You are both officers and gentlemen.
for what itâs worth, this is what I found that worked for my Aqara vibration senor to read âcurrent_oreintatationâ. Tried a few variations based on this thread but this is what works for me.
alias: zigbee door open
description: ""
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: 503ad514d8fe108e00b0c06db1d89f6a
context: {}
condition:
- condition: template
value_template: "{{ trigger.event.data.args.Y < 1 }}"
action:
- service: notify.push_over
data:
message: door is open
mode: single
â0â is when the sensor is face down (garage door open)
â1â is when the sensor is on itâs edge with the button on top (garage door closed).
Although this thread is becoming old, the subject discussed is still highly relevant. So I thought Iâd contribute with my own solution to this problem:
The key here is to define the event command as a variable for later use:
Now itâs possible to create conditional testing on the actual value returned in the command event. In my example Iâm testing for the command to be either âonâ or âoffâ string values:
Then I create a similar test for âoffâ and I use an A/B test to halt execution if both tests are false.
This works well for me. If the command fired is either âonâ or âoffâ then if the kitchen light is on, I turn it off, and vice versa.
Thus I managed to solve the problem caused by the fact that the Namron switch sends alternating âonâ and âoffâ commands every time the button is pressed, but it has no knowledge of whether the lights are actually on or off, so the command wording itself has no real meaning. In addition, to confuse even more, the Namron switch also sends several other commands at random intervals. With the above method, all commands except âonâ and âoffâ are ignored.