I’m creating an automation to send a notification triggered by my aqara door and window sensors. I’m communicating with them via MQTT facilitated by zigbee2mqtt.
Using the State trigger type, I can get the notification to fire if I leave the From and To fields blank. It fires once when I open the door and again when I close it.
But I can’t figure out what to put in the From and To fields to trigger only when the door is opened. I’ve tried variations of true/false. off/on, Open/Closed.
Looking at the States tab in Developer Tools, the sensor state is listed as “off” when the door is closed and “on” when the door is open. So it seems like that should work, but it doesn’t.
How do I find this information? Thanks!
Here is the YAML from automations.yaml although I’m trying to configure it from the frontend for ease of maintenance:
- id: '1602534906807'
alias: Notify me if the door opens and I am not at home
- platform: state
message: door opened
In your explanation you haven’t mentioned anything about the state attribute contact but i can see that you are checking it’s state for trigger. Why is it so?
Thanks for pointing me in the right direction! The choices were: Battery, Contact, Linkquality, Voltage, Friendly Name, or Device Class, so I chose Contact, but I realized I can also just leave it blank. I removed it altogether and now it’s working!
The From/To attribute is set to “off”/“on” per the State tab.
Thanks for the help!
There was never a reason to include it.
Your automation uses a State Trigger. By adding this line:
you instructed the State Trigger to monitor not the binary_sensor’s state but one its attributes called
contact. However, a binary_sensor doesn’t normally have an attribute with that name. Basically you created a State Trigger that monitors a non-existent attribute (and explains why it failed to trigger).
Regardless of a binary_sensor’s
device_class, its state is either
device_class governs how
off are displayed in the Lovelace UI (example: as
Closed for a
I see this happening all the time lately.
It seems that the UI editor isn’t doing a very good job of labeling things as optional or describing how/when to use the different options.