Aqara Vibration/Tilt sensor

Posted on
Thu Feb 20, 2020 3:05 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Aqara Vibration/Tilt sensor

Hi Joe,
So I have the vibration sensor now, and it detects tilt/vibration/drop and reports through a single action payload. As well as this it sends details on 3 axis rotation. The payload is this.

Code: Select all
{"battery":100,"voltage":3095,"linkquality":99,"angle":77,"angle_x":3,"angle_y":0,"angle_z":87,"angle_x_absolute":87,"angle_y_absolute":90,"strength":72,"action":"vibration"}

"action" can take value of vibration or tilt or drop. It takes a few minutes for the action payload to be cleared after vibration is sent. However on drop and tit, the message with blank action payload is sent immediately.

What I cant seem to do is trigger a generic sensor to turn on if the action changes. I have tried generic and motion, and putting On Value as either vibration or "vibration" with payload key as action.

Does this still expect boolean? Is it possible to just build a trigger on the change in the payload? I guess I dont really need a sensor device change for this, I think what I really want to do is trigger a notification? Its unlikely that anyone is going to be watching the device as one of the actions occurs.

Cheers

Posted on
Thu Feb 20, 2020 3:11 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Aqara Vibration/Tilt sensor

siclark wrote:
Does this still expect boolean? Is it possible to just build a trigger on the change in the payload? I guess I dont really need a sensor device change for this, I think what I really want to do is trigger a notification? Its unlikely that anyone is going to be watching the device as one of the actions occurs.


For an OnOff sensor, it needs to be able to evaluate the payload to a boolean. If the On Value is blank, it assumes that the actual payload item will be a boolean in the JSON, if it's not, it does a comparison to get the boolean. So if you put "vibration" in the field (no quotes), it should turn off when it's any other value. If that's not happening, turn on debug logging and activate the sensor a couple times (different modes) and then post the log.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Feb 20, 2020 3:29 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Aqara Vibration/Tilt sensor

Ok, so that is half the way there. Its turning on, but not recognising that the action value goes to blank, and the device stays on. It only turns off when it receives a non null value that doesnt match tilt (in below example)

Code: Select all
   Trigger                         MQTT Aqara Tilt
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTilt## from MQTT local broker
   MQTT Shims Debug                Tilt Angle: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":110,"angle":78,"angle_x":0,"angle_y":-1,"angle_z":89,"angle_x_absolute":90,"angle_y_absolute":91,"strength":151,"action":"tilt"}
   MQTT Shims Debug                Tilt Angle: shimValueSensor, key = angle, data = {u'linkquality': 110, u'angle_x_absolute': 90, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 89, u'angle_y': -1, u'angle_x': 0, u'voltage': 3095, u'action': u'tilt', u'angle_y_absolute': 91}, value = 78
   MQTT Shims Debug                Tilt Angle: Updating state to 78.0
   MQTT Shims Debug                Tilt sensor tilt: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":110,"angle":78,"angle_x":0,"angle_y":-1,"angle_z":89,"angle_x_absolute":90,"angle_y_absolute":91,"strength":151,"action":"tilt"}
   MQTT Shims Debug                Tilt sensor tilt: shimOnOffSensor, state_key = action, data = {u'linkquality': 110, u'angle_x_absolute': 90, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 89, u'angle_y': -1, u'angle_x': 0, u'voltage': 3095, u'action': u'tilt', u'angle_y_absolute': 91}, value = tilt
   MQTT Shims Debug                Tilt sensor tilt: Updating state to True
   MQTT Shims Debug                Tilt test copy: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":110,"angle":78,"angle_x":0,"angle_y":-1,"angle_z":89,"angle_x_absolute":90,"angle_y_absolute":91,"strength":151,"action":"tilt"}
   MQTT Shims Debug                Tilt test copy: update address mismatch: TestTile != TestTilt
   Trigger                         MQTT Aqara Tilt
   MQTT Shims Debug                Tilt Angle: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":110,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151}
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTilt## from MQTT local broker
   MQTT Shims Debug                Tilt Angle: shimValueSensor, key = angle, data = {u'linkquality': 110, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'angle_y_absolute': 88}, value = 78
   MQTT Shims Debug                Tilt Angle: Updating state to 78.0
   MQTT Shims Debug                Tilt sensor tilt: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":110,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151}
   MQTT Shims Debug                Tilt sensor tilt: shimOnOffSensor, state_key = action, data = {u'linkquality': 110, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'angle_y_absolute': 88}, value = None
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 96, in runConcurrentThread
  File "plugin.py", line 121, in processMessages
  File "plugin.py", line 326, in update
UnboundLocalError: local variable 'key' referenced before assignment

   MQTT Shims Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)



When I then drop it, it sees change in action and turns off the tilt device.

Code: Select all
20 Feb 2020 at 21:28:11
   Trigger                         MQTT Aqara Tilt
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTilt## from MQTT local broker
   MQTT Shims Debug                Tilt Angle: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":73,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"vibration"}
   MQTT Shims Debug                Tilt Angle: shimValueSensor, key = angle, data = {u'linkquality': 73, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'action': u'vibration', u'angle_y_absolute': 88}, value = 78
   MQTT Shims Debug                Tilt Angle: Updating state to 78.0
   MQTT Shims Debug                Tilt sensor tilt: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":73,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"vibration"}
   MQTT Shims Debug                Tilt sensor tilt: shimOnOffSensor, state_key = action, data = {u'linkquality': 73, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'action': u'vibration', u'angle_y_absolute': 88}, value = vibration
   MQTT Shims Debug                Tilt sensor tilt: Updating state to False
   MQTT Shims Debug                Tilt test copy: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":73,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"vibration"}
   MQTT Shims Debug                Tilt test copy: update address mismatch: TestTile != TestTilt
   Trigger                         MQTT Aqara Tilt
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTilt## from MQTT local broker
   MQTT Shims Debug                Tilt Angle: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":70,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"drop"}
   MQTT Shims Debug                Tilt Angle: shimValueSensor, key = angle, data = {u'linkquality': 70, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'action': u'drop', u'angle_y_absolute': 88}, value = 78
   MQTT Shims Debug                Tilt Angle: Updating state to 78.0
   MQTT Shims Debug                Tilt sensor tilt: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":70,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"drop"}
   MQTT Shims Debug                Tilt sensor tilt: shimOnOffSensor, state_key = action, data = {u'linkquality': 70, u'angle_x_absolute': 11, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': 11, u'angle_y': 2, u'angle_x': 79, u'voltage': 3095, u'action': u'drop', u'angle_y_absolute': 88}, value = drop
   MQTT Shims Debug                Tilt sensor tilt: Updating state to False
   MQTT Shims Debug                Tilt test copy: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":70,"angle":78,"angle_x":79,"angle_y":2,"angle_z":11,"angle_x_absolute":11,"angle_y_absolute":88,"strength":151,"action":"drop"}
   MQTT Shims Debug                Tilt test copy: update address mismatch: TestTile != TestTilt
   Trigger                         MQTT Aqara Tilt
   MQTT Shims Debug                received notification of MQTT message type ##AqaraTilt## from MQTT local broker
   MQTT Shims Debug                Tilt Angle: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":78,"angle":78,"angle_x":6,"angle_y":1,"angle_z":-84,"angle_x_absolute":84,"angle_y_absolute":89,"strength":151}
   MQTT Shims Debug                Tilt Angle: shimValueSensor, key = angle, data = {u'linkquality': 78, u'angle_x_absolute': 84, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': -84, u'angle_y': 1, u'angle_x': 6, u'voltage': 3095, u'angle_y_absolute': 89}, value = 78
   MQTT Shims Debug                Tilt Angle: Updating state to 78.0
   MQTT Shims Debug                Tilt sensor tilt: processMessages: '##AqaraTilt##' zigbee2mqtt/AqaraTilt/TestTilt -> {"battery":100,"voltage":3095,"linkquality":78,"angle":78,"angle_x":6,"angle_y":1,"angle_z":-84,"angle_x_absolute":84,"angle_y_absolute":89,"strength":151}
   MQTT Shims Debug                Tilt sensor tilt: shimOnOffSensor, state_key = action, data = {u'linkquality': 78, u'angle_x_absolute': 84, u'strength': 151, u'angle': 78, u'battery': 100, u'angle_z': -84, u'angle_y': 1, u'angle_x': 6, u'voltage': 3095, u'angle_y_absolute': 89}, value = None
   MQTT Shims Error                Error in plugin execution runConcurrentThread:

Posted on
Thu Feb 20, 2020 3:37 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Aqara Vibration/Tilt sensor

Oh, that's ugly. When the sensor resets, it doesn't just return a blank for the "action" key, it doesn't include it at all. Which is why you got that error. I'm going to have to figure out how to handle that case.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Feb 20, 2020 3:45 pm
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Aqara Vibration/Tilt sensor

Yes, see my other post on the button. I guess I could do similar there but a neater solution would be better.

I am intrigued as to what I can use these for. Work for simple door opening etc, and maybe someone trying to break windows, but the reporting of specific tilt angle changes could be interesting.

Posted on
Thu Feb 20, 2020 3:46 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Aqara Vibration/Tilt sensor


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Sep 06, 2021 4:34 pm
tazswe offline
Posts: 211
Joined: Mar 13, 2017
Location: Sweden

Re: Aqara Vibration/Tilt sensor

Installed a zigbee2mqtt stick in the weekend and got it up an running.
Have some tradfri and Aqara devices connected to my MQTTserver.

Managed to get the Tradfri devices to work with the shims plugin.

Running into problems with the Aqaba vibration/tilt sensors.

Did you find a solution?
And if you did, what settings are you useing?


Sent from my iPad with Tapatalk

Posted on
Tue Sep 07, 2021 12:42 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: Aqara Vibration/Tilt sensor

Yes I got them working. Will have a look in a bit. Best thing is to watch them i an mqtt monitor as you move and tilt and deep them so you see what commands they issue.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest