I have two cats at home and try to build an automation using an Aqara vibration sensor integrated via Deconz-addon. It should detect if the toiletseat is open but nobody is in the bathroom anymore. the presence is being detected with a motion sensor.
question
How can I get the data from msg.data.state in order to build an automation based only on the second value? -72 means open , 0 means closed. I tried a switch-node which should read the values but havent had any luck. the tiltangle doesnt work reliable, otherwise I would have used it.
maybe I can replace the tiltangle with the orienation in the template (toiletseat) and adjust the values (open, closed)?
any help would be appreciated to make the world for cats a bit safer
Mmmh, let me see if I understand the situation.
You want an alert if the bathroom is empty of people and the toilet seat is up.
You have a sensor that tells you if the bathroom is empty of people and another one telling you the state of the toilet seat.
So far you seem to be spot on with the purpose of your automation.
What is not working exactly?
PS: your world is a better place already if you can count on family members to shut the damn toilet seat
Ok wait, I get it - your sensor returns the whole triplet of data instead of just -72.
That is interesting, is it json formatted maybe? What do the other numbers represent? Did you try to play with the developer’s tool model page to see if you can regex it out of the sensor?
first of all thanks for your quick reply, you fully understand the situation yeah, the problem is that the orientation is being reported as a triplet. here an example from the dev-tools. the values represent the axis x,y,z.
Ok - the best way to start would be to see how HA sees the sensor. In your post above I see a mix of sensors and binary_sensor plus some debug that doesn’t look HA (it’s Node-Red?).
What do you have in HA for that vibration_8 device?
You could search it in the Developers tools → States page. If it’s a sensor with attributes then we can try to pull the info out of it, but we need to see the exact output.
Hi. I’m doing very much the same thing, and can’t seem to quite get it; do you mind sharing your code for the working templates?
Mine is for a humble garage door though, haha!
Much appreciated!
I get values from the sensor of around 2 for open, and -71 for closed on the second orientation figure; my statement returns this as closed though, when it should read open.
got ya. actually I have around the same values. In my case I only wanted to get the data from the orientation and then I use it in Node-RED to either send a message when the value is -5 or -15. at -5 its “closed” at -15 its “open”. in the event its open and the light in the bathroom is off, it will send a message via Pushover to my phone.
if you use Node-RED you could set up a flow with an event state-node and a switch.
Cool! Yeah me too now - somewhere along the line I got confused by the dashes and put them into my spreadsheet of figures as negative when I was orignally assesing the sonsor.
BTW - not sure if this is relevant as I’m a total noob, but: