Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Aqara Smart Vibration Sensor DJT11LM #748

Open
Cavemanz opened this issue Aug 24, 2018 · 162 comments

Comments

@jo-me

This comment has been minimized.

Copy link

commented Aug 28, 2018

Cool, could be interesting for the classic washing machine use case..
Simpler as this:
https://community.home-assistant.io/t/laundry-sensors-with-nodemcu-and-home-assistant/42533

@sumo-89

This comment has been minimized.

Copy link

commented Aug 28, 2018

I've just ordered 3 of these, I also hope they will be supported in Deconz soon. :)

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Aug 28, 2018

I would expect these to be IAS devices, just as the Xiaomi leak sensor. In that case, adding support should be straightforward. Please post the usual deCONZ GUI screenshots:

  • Node, endpoints, and clusters;
  • Node info panel;
  • Cluster info panel for the Basic cluster after reading the attributes (press the button to wake the sensor while reading);
  • Cluster info panel for the IAS Zone cluster (assuming the sensor has one), again after reading the attributes.

Please also try to capture the Xiaomi special packet for this device from the dCONZ log.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

I've got mine today. It's my first time on deCONZ so please help me out getting the details 😊

Device:

3
4

Node info:

1
2

Cluster info (0000 Basic)

0000 basic

Cluster info (0101 Door lock)

0101 lock 1
0101 lock 2
0101 lock 3

Also, some pics of the device:

img_8486
img_8487

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2018

Door lock cluster ?! That doesn't make any sense to me, even for Xiaomi. Do any of the Door lock attributes change when the sensor detects vibration?

I wonder if deCONZ read it correctly. Could you please reset the device (hold the reset button/hole for 10 seconds), remove it from deCONZ, power down all your lights (ZigBee routers), move it close to the RaspBee/ConBee and re-pair it, while shaking it (to keep it awake)?

The leak sensor doesn't show an IAS Zone cluster either. I've copied the logic of that sensor to create a ZHAVibration sensor resource for the lumi.vibration.aq1, assuming a similar of Xiaomi magic packet.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

I can confirm. I've paired a brand new one, by standing next to the Conbee USB device. I have no lights on this network (totally separate from the Hue network I have, even the channel is different). The new device is still a door lock... how can I test your changes? Do I have to pull your branch and build?

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2018

I can confirm.

Thanks. I've seem some other strange, non-functional clusters reported by Xiaomi devices. Do you see any changes in the Door lock attributes when the sensor detects vibration?

Do I have to pull your branch and build?

Yes. Or wait for @manup to publish the next release. I see he just merged the open PRs.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

I'm tilting and shaking the sensor as the vibration detection might not be accurate (see https://community.home-assistant.io/t/new-aqara-vibration-shock-sensor/63211/8). The lock is in "not fully locked" and it does not change if I keep moving the sensor. Also, no changes in any of the other params.

@manup

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2018

Latest PRs are now available in 2.05.37, however please make a backup and read the changelog before updating, the release has some larger changes under the hood, hopefully nothing will break.

https://github.com/dresden-elektronik/deconz-rest-plugin/releases

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

Also, check this for reference too: Koenkk/zigbee2mqtt#295

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

I've deleted two comments. After upgrading the firmware too and deleting and repairing (several times), here's where i've got:

1 pairing after upgrading
2 after upgrading

I shake the sensor, the dot next to the sensor in the map on the GUI flashes blue but no changes in value. When I shake it I can see:

image

When I stop shaking I see:
image

@manup

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2018

Interesting, you may also try command line parameters --dbg-zcl=2 --dbg-aps=2 to get more details when receiving data.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 1, 2018

deconz.log

I've added some empty line before and after shaking the sensors (shaked first one sensor, added more empty lines, than the second one)

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2018

That means it does send attribute reports for the Door lock cluster (0x01). Currently deCONZ uses this cluster only for /lights resources (the door lock is exposed as a light), but it can be added to the /sensors logic as well.

According to the zigbee2mqtt thread, the sensor issues reports for attributes "85" (0x0055), "1283" (0x0503), and "1288" (0x0508) - that matches pl[0] of 55 and 8. I have no clue as to what these attributes mean, they're not defined for the Door lock cluster, but 0x0055 is Present value for many of the input and output clusters.
The Basic cluster report with pl[0] of 5 and 1 matches attributes 0x0005 (Model Identifier) and 0xff01 (Xiaomi special).
The Xiaomi special package also contains a lot of info. If I were a betting man, I'd place my money on tags 98, 99, and 9A. According to the gearbest page, the sensor detects vibration, tilt, and fall, so I'd expect different values for these three.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 2, 2018

@ebaauw here's the log after compiling and running your master branch (including f68d511):

new.log

I've tilted the sensor first, then pressed the button to capture the special packet

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2018

That doesn't look good - too many unsupported tag messages. I haven't actually compiled and tested the commit myself yet, still upgrading to v2.05.37 and new firmware.

The asdu message gives the raw package payload. Dissecting the magic package:

                                            1                       2                       3                      4
                     1 2  3 4  5 6  7  8 9  0 1  2 3  4 5  6 7  8 9 0 1 2  3 4  5 6  7 8  9 0  1 2  3 4  5 6  7 8  9 0  1 2 3 4 5 6
         attr tp  l   battery    temp         ?   RSSI dB             LQI         ?         ?         ?         ?                 ?
         ---- -- -- --------- ------- --------- --------- --------------- --------- --------- --------- --------- -----------------
         01ff 42 2e 0121 030c 0328 1f 0421 a813 0521 3b00 0624 0000000000 0821 0803 0a21 0000 9821 2800 9921 7400 9a25 8000fffbb300
vibration:       46    3.075V    31°C  u16       u16       u40              u16      u16       u16       u16       u48
@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2018

Ah there was an if in the original code which should have been an else if.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 2, 2018

new2.log
Pulled the new commit, recompiled, updated firmware

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2018

I'll add the tag 0x0A. Next step is to figure out how these values change for the various actions: tilt, shake/vibrate, and drop.

Looking at the reports for the Door lock cluster, it reports attributes 0x0055 and 0x0503, both u16. I'll add them to general.xml, so you should be able to monitor them in the deCONZ GUI. You need to copy this file to /usr/share/deCONZ/zcl (or create a symlink to where you download the git repository). I'm guessing the 0x0508 attribute is u48, just like the 9A tag. They showed it as two numbers in zigbee2mqtt, I'm guessing u16 and u32 to make up u48. Would be nice if you manage to capture the asdu for that as well.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 2, 2018

I think i've cracked the meaning of 0x0055:
Value "1": shake
Value "2": tilt
Value "3": drop

The value 0x0503 seems to be a number between 1 and 100 (but at some point I saw a value like 108, 169, 200 and 230). It doesn't seem to represent an angle. Might be the strength/intensity of the motion.

The value of 0x0508 is usually quite a long number (sometimes 20 digits like 18446744073707061293 or 18446744073708372031 but also 1507201 and 65339396).

The 0x0503 and 0x0508 might stay to the same value, even if the value of the 0x0055 changes.

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2018

I think i've cracked the meaning of 0x0055

Cool! I couldn’t have been more wrong assuming it would be an IAS zone device. Maybe best to expose the sensor as a switch, re-using the buttonevent values for shake, flip, and drop, from the cube.

Did you get the values from the deCONZ GUI or from the log? If from the log, could you post the asdu for the 0x0508?

20 digits is too long for a u48, more like a u64. In hex, the values are 0xFFFFFFFFFFDA002D and 0xFFFFFFFFFFEE003F.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 3, 2018

Cool! I couldn’t have been more wrong assuming it would be an IAS zone device. Maybe best to expose the sensor as a switch, re-using the buttonevent values for shake, flip, and drop, from the cube.

I think that is a good idea

Did you get the values from the deCONZ GUI or from the log? If from the log, could you post the asdu for the 0x0508?

From the UI. Is there a way to run deCONZ to log the output only of a single device? I usually get a stream of events and it's quite difficult to isolate the ones relating to the vibration sensor.

20 digits is too long for a u48, more like a u64. In hex, the values are 0xFFFFFFFFFFDA002D and 0xFFFFFFFFFFEE003F.

I'm really curious to find out what that number means :)

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2018

Is there a way to run deCONZ to log the output only of a single device?

Not really. I usually just grep -i for the mac address, but that doesn’t match the asdu nor Xiaomi special messages. It does provide the time of the preceding message, so I use that to search the log in an editor.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 3, 2018

Ok, will dump a larger set of logs on Wed once I'm back home.

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Sep 4, 2018

@paolotremadio, my latest commit (ebaauw@bca9cf2) should support the lumi.vibration.aq1 as ZHASwitch sensor. The values for state.buttonevent are:

  • 1007 - shake (cf. lumi.cube's 7007 for shake);
  • 1008 - drop (cf. lumi.cube's 7008 for drop);
  • 1009 - tilt (new).

@manup, I kept the code for ZHAVibration and CLIPVibration, even though currently we don't support any IAS_Zone vibration sensors. I suppose it won't do any harm and it might come in handy later.

@paolotremadio

This comment has been minimized.

Copy link

commented Sep 4, 2018

I've been digging into GitHub and I've found this comment:

Danielhiversen/PyXiaomiGateway#86 (comment)

Also, here's a detail of the clusters (translated from French): https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Ffaire-ca-soi-meme.fr%2Fdomotique%2F2018%2F09%2F03%2Ftest-xiaomi-aqara-vibration-sensor%2F%23Compatibilite_ZiGate&edit-text=&act=url

To recap

0x0055 is clear:
Value "1": shake / vibrate
Value "2": tilt
Value "3": drop / free fall

0x0503 should be the bed activity:

bed_activity: this reports a number. It seems to be related to vibration. It might correspond to how much movement was seen during the last reporting period. When sitting on my clothes dryer while it was running, it reported the same number for many reports which seem to come about one minute apart. The numbers reported from 72 to 214. Often the same number would report for multiple minutes. A 0 is never reported.

0x0508 is still a mystery. According to the french article:

This frame makes it possible to avoid flooding of actions. As long as this frame is not started, you can not start any other actions.

but according to the GitHub comment:

coordination: this is three numbers separated by commas. It is reported without any regularity. When in the same spot on my running dryer, it reported different sets of numbers that were fairly close to one another: "51,-24,1207" and "47,-31,1233". When I then walked it to another room and placed it on my desk it reported "-935,40,220", but also, at another time, while near my desk, "5,46,1233"

Implementation

The device continues to report "vibrate" every minute or so when it is on a vibrating surface. However, there is no report when it stops vibrating. There is not a "no_motion" report like we see with the PIR sensors. This means that reporting when vibration stops will require a timer of slightly over 1 minute, most likely implemented in the sensor/xiaomi_aqara Entity code.

Shall we go ahead and implement it as a switch with buttonevent? The problem will be: the sensor doesn't report any "no action" so we have to start a timer and stop the "button pressed" after 1 minute or so (unless more changes have been sent over ZigBee). Would be nice to surface the other data in the rest API.. but not a deal breaker

Screenshot from app

image

@manup

This comment has been minimized.

Copy link
Contributor

commented Sep 4, 2018

@manup, I kept the code for ZHAVibration and CLIPVibration, even though currently we don't support any IAS_Zone vibration sensors. I suppose it won't do any harm and it might come in handy later.

Yes I guess sooner or later more these sensors will be available, so It's wise to keep the code :)

@chimpy

This comment has been minimized.

Copy link

commented Apr 4, 2019

HA 0.91 is out with @Kane610 's PR. Is the orientation (e.g. "orientation":[0,84,6]) now working correctly?

@AndySzr

This comment has been minimized.

Copy link

commented Apr 4, 2019

HA 0.91 is out with @Kane610 's PR. Is the orientation (e.g. "orientation":[0,84,6]) now working correctly?

here it isn't. the sensor values aren't updated in HA except the tiltangle value: this value is working. didn't have time find the bug yet.

it looks like HA is getting (reading) all the values at the start but is not updating the values (except tiltange).

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Apr 4, 2019

00:15:8d:00:02:af:94:1b-01-0101 I am referring to changing the last part?

So 01 is the Zigbee endpoint, 0101 the Zigbee cluster.

seems to depend on type or switch possibilities

It depends on how the device exposes itself over Zigbee, not on the resource type. This shows how (not) standard Zigbee is, and why we need to whitelist each sensor and switch explicitly.

@AndySzr

This comment has been minimized.

Copy link

commented Apr 5, 2019

@ebaauw
The websocket api is using a different data format than the REST api. I think that's the reason HomeAssistant is not updating the values. The REST API is sending the angles in an Array and the WS API using 3 different values.

Websocket:
"state":{"lastupdated":"2019-04-05T17:20:36","orientation_x":5,"orientation_y":-1,"orientation_z":85,"tiltangle":86,"vibration":true,"vibrationstrength":9},

REST:
"state": {
"lastupdated": "2019-04-05T17:21:21",
"orientation": [
5,
-1,
85
],
"tiltangle": 86,
"vibration": false,
"vibrationstrength": 9
},

@Kane610

This comment has been minimized.

Copy link

commented Apr 5, 2019

That will change with next release of deconz so I didn't bother supporting the earlier behavior

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2019

Indeed, changed in PR #1357.

@Smanar

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2019

I have a question again :).
"tiltangle" is a value that depend of mouvement ?
So if I just make vibration, vibration is set to true but why "tiltangle" is not set to 0, It keep the last value.

Still version version V2.05.60

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2019

So if I just make vibration, vibration is set to true but why "tiltangle" is not set to 0, It keep the last value.

Yes. The REST API plugin does the following when receiving attribute reports for the vibration sensor:

Attribute Value Action
0x0055 0 (vibration) Set state.vibration to true. It reverts to false automatically after 65 seconds (unless another vibration event is received).
0x0055 1 (tilt) Ignored, as this is always accompanied by a 0x0503.
0x0055 2 (drop) Set state.tiltangle to 360.
0x0503 n Set state.tiltangle to n.
0x0505 n Set state.vibrationstrength to n.
0x0508 0xzzzzyyyyxxxx Set state.orientation to [x, y, z].
@Smanar

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2019

But if I make only vibration without mouvement. The gateway doesn't receive 0x503, why in this case tiltangle isn't set to 0 and keep the last value ?

@ebaauw

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2019

Yes. I suppose we could change that to set state.tiltangle to 0 on vibration.

@Smanar

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2019

I haven't check the c++ code but in my mind without 0x503 message tiltangle need to be as defaut value : 0, but only in this case.

Nothing : vibration 0 tiltangle 0
Vibration only : vibration true tiltangle 0
Mouvement only : vibration 0 tiltangle n
Drop or big tilt : vibration true tiltangle n

@Smanar

This comment has been minimized.

Copy link
Contributor

commented Apr 14, 2019

I m trying to edit the code. I have make that to try

                            if (i->modelId().startsWith(QLatin1String("lumi.vibration")) && i->type() == QLatin1String("ZHAVibration"))
                            {
                                if (ia->id() == 0x0055) // u16: event type
                                {
                                    if (updateType != NodeValue::UpdateInvalid)
                                    {
                                        i->setZclValue(updateType, event.clusterId(), ia->id(), ia->numericValue());
                                        pushZclValueDb(event.node()->address().ext(), event.endpoint(), event.clusterId(), ia->id(), ia->numericValue().u16);
                                    }
                                    const quint16 value = ia->numericValue().u16;
                                    DBG_Printf(DBG_INFO, "0x%016llX: 0x0101/0x0055: event: %d\n", event.node()->address().ext(), value);
                                    
                                    //Set tiltangle to 0 by defaut
                                    ResourceItem *item = i->item(RStateTiltAngle);
                                    if (item)
                                    {
                                        item->setValue(0);
                                    }

It works, if you touch nothing, the next time you will make vibration only, tiltangle will be 0.
But when the time duration is up for vibration, the tiltangle will not be reset. And I can't add a second "timer" in same time than the vibration one because it will produce 2 notifications.

There is a way to set tiltangle to 0 in same time than vibration to false ?

But, I think it's not a solution.
Will not be better to make tiltangle notification ONLY when there is 0x0503 attribute ?

@volschin

This comment has been minimized.

Copy link

commented Jul 30, 2019

Mine arrived today. In Phoscon 2.05.66 it is correctly recognized as vibration sensor but only temperature is shown with XX °C. No vibration, tilt or drop information.

@SAOPP

This comment has been minimized.

Copy link

commented Aug 26, 2019

Guys, I just start to using my device at entry door, but, don;t understood, this sensor is not showed any events via deconz_event right? But 1007, 1008 and 1009 events didnt work for me, in HA and Phoscon I see the action, but my automation for gateway notify is not working, what I do wrong? Can someone show me a trigger action from working scene? Thanks.

@holdestmade

This comment has been minimized.

Copy link

commented Sep 11, 2019

Guys, I just start to using my device at entry door, but, don;t understood, this sensor is not showed any events via deconz_event right? But 1007, 1008 and 1009 events didnt work for me, in HA and Phoscon I see the action, but my automation for gateway notify is not working, what I do wrong? Can someone show me a trigger action from working scene? Thanks.

This is a working trigger I use in an automation:

- alias: Dog Food Bin
  trigger:
    - platform: event
      event_type: deconz_event
      event_data:
        id: dog_food_bin
        event: 1009
@SAOPP

This comment has been minimized.

Copy link

commented Sep 12, 2019

And u can see the events at deconz_events?

@holdestmade

This comment has been minimized.

Copy link

commented Sep 12, 2019

Yes sure do

@SAOPP

This comment has been minimized.

Copy link

commented Sep 13, 2019

Oh :( I didn't see any deconz events of my sensor, I tap it, drop it, close open ed door, nothing in deconz events, any action is here :( I can't understood how I can start this sensor.

@dxxxm

This comment has been minimized.

Copy link

commented Sep 13, 2019

deconz_ev works fine for Vibration Sensor:

2019-09-13 13:49:49.970211 INFO deconz_helper: EventName: deconz_event Deconz event received from: "vibration_sensor". Event was: 1007
2019-09-13 13:49:49.974848 INFO deconz_helper: ev_data: {'id': 'vibration_sensor', 'event': 1007}
2019-09-13 13:49:49.979323 INFO deconz_helper: kwargs: {}
2019-09-13 13:49:52.017012 INFO deconz_helper: EventName: deconz_event Deconz event received from: "vibration_sensor". Event was: 1008
2019-09-13 13:49:52.021886 INFO deconz_helper: ev_data: {'id': 'vibration_sensor', 'event': 1008}

@SAOPP

This comment has been minimized.

Copy link

commented Sep 13, 2019

If u use Home-Assistant, could u listen the deconz_events service for that sensor?

@dxxxm

This comment has been minimized.

Copy link

commented Sep 13, 2019

The log snippet posted was taken from home-assistant logs. appdaemon application. But the latter doesn't matter. HA definitely receive the deconz-evs.

@holdestmade

This comment has been minimized.

Copy link

commented Sep 13, 2019

If u use Home-Assistant, could u listen the deconz_events service for that sensor?

{
"event_type": "deconz_event",
"data": {
"id": "dog_food_bin",
"event": 1009
},
"origin": "REMOTE",
"time_fired": "2019-09-13T11:17:44.550644+00:00",
"context": {
"id": "34c2f85e488344e69e43e7db4e0f1350",
"parent_id": null,
"user_id": null
}
}

{
"event_type": "deconz_event",
"data": {
"id": "dog_food_bin",
"event": 1008
},
"origin": "REMOTE",
"time_fired": "2019-09-13T11:18:43.577640+00:00",
"context": {
"id": "24f420c66ceb407fb4b4a6fe15567fa2",
"parent_id": null,
"user_id": null
}
}

{
"event_type": "deconz_event",
"data": {
"id": "dog_food_bin",
"event": 1007
},
"origin": "REMOTE",
"time_fired": "2019-09-13T11:19:18.815475+00:00",
"context": {
"id": "a91e98c646b54ac6abead2f2a176e510",
"parent_id": null,
"user_id": null
}
}

@dxxxm

This comment has been minimized.

Copy link

commented Sep 13, 2019

from HA-GUI:
image

@SAOPP

This comment has been minimized.

Copy link

commented Sep 13, 2019

I don't have this in events via my raspbee :(

@Kane610

This comment has been minimized.

Copy link

commented Sep 13, 2019

@SAOPP maybe you have the vibration sensor entity instead?

@Kane610

This comment has been minimized.

Copy link

commented Sep 13, 2019

@holdestmade are you still getting deconz events for vibration sensor?

@holdestmade

This comment has been minimized.

Copy link

commented Sep 13, 2019

Yes I've posted them.above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.