State trigger for attributes

I have a device (Aqara Door Sensor) and their integration via zigbee2mqtt reports the actual useful state as an attribute. Now i am wondering how i could use this as a trigger for a flow using the “trigger: state” node.

For other entities which are reporting their useful state as a real state, i have used this node with two constraints like “previous state was not abc” and “current state is abc” so that it does not trigger the flow in between. I am not sure if i could describe this correctly, so let’s see an example:
For the door sensor i am not able to access current_state and previous_state since i am working with attributes. Now when i create a trigger like “attribute.sensor is ‘closed’”, then the flow will be triggered whenever i close the door. However when i keep the door closed and somehow nodered decides to check all the attributes again, it will see that the door is closed and trigger the flow again even when it wasn’t open in between.

For real states i could solve this, like i said, with the current_state and previous_state and only let the node emit something when both values differ. How could i solve that with just a plain attribute? Adding a variable in between that will track the changed attribute?

Can you create a template sensor for that attribute (https://www.home-assistant.io/integrations/binary_sensor.template/) and use that in your NR automation ?

1 Like

Thats a good idea, and i think it will solve the problem. Thank you.