Xiaomi aqara vibration sensor binary sensor versus last state attribute

I’m new to Home Assistant (running Home Assistant OS btw on a Raspi), how do I add this to my setup?

Ciao Fabietto, did you find a solution? I am trying to do the same…
I have an aqara vibration sensor attached to the garage door. I can get it to send notifications to my phone when the y axis changes, but i would also like to display the door as “open” or “closed” depending on the value of that y axis.

Ciao Amberclust, I finally found a solution with a template and also the change of the icon from closed to opened, the only thing I did not fixed yet is the icon colour, even if I write “state_color: true” this doesn’t work for the template, but I think is only a little more searching to find the right code. I’m using the aqara vibration not on a garage port but on a normal house window that has an angled way of opening, I copy here the code of the sensor and a picture of the card in lovelace, except from “Ribalta cucina” all other doors/windows are set as device_class: windows so the icon change in automatic and the code state_color work for those entities.

yaml sensor template code for aqara vibration: Ribalta cucina

Immagine 2022-05-23 220239