[BETA UPDATE] Xiaomi Aqara Vibration Sensor (Model DJR11LM) SmartThings DTH v0.9b
This version finally adds a open/close capability to the DTH, using code graciously shared by GitHub user @_Oltman. His code calculates the angle position of the sensor based on its XYZ accelerometer reports, and allows the user to set and store open/close positions that are then linked to SmartThings
contact sensor capability, with
The new DTH code can be grabbed from here.
Changes & Fixes
- Added NEW FEATURE: Open/Close position, which links to the Contact Sensor capability. Using code kindly shared by GitHub user @_Oltman, custom open and close positions can be stored by pressing the Set Open and Set Closed UI tile buttons while the sensor is in your desired open & closed positions. Once set, the DTH will generate
contact - openand
contact - closedevents when the sensor is in nearly the same positions.
- Added two new UI tiles to display current
- Changed “Vibration Level” UI tile to more representative name “Recent Activity Level”
- Removed icon displayed in main sensor status tile
- Added “refresh” tile that can be used to initialize blank UI tiles if needed
- Changed the 3-Axis tile to display the calculated position angles instead of the raw accelerometer values
- Reorganized UI tiles
- Changed the method to initially set and display hardware Sensitivity level when the sensor is paired (If the sensor is already installed, either press the new “refresh” tile (bottom right) or open preferences and press “save” to set up the Sensitivity level UI button
- Added code to initialize Recent Activity Level and Last Angle Change UI tiles to display “–” if no reported values have been received yet when the sensor is paired. If this doesn’t work, they can be manually initialized either by pressing the new “refresh” tile (bottom right) or opening preferences and pressing “save”
- Improved the code that cycles through the 3 levels when Sensitivity level UI button is pushed
- Fixed mapSensorEvent to correctly set a status reset timer of 2 seconds for Tilt or Drop events
- Changed the timer reset code for Tilt/Drop events: If a Vibration/Shock event is followed by any Tilt or Drop events, the main UI tile will display “Tilt” or “Drop” for approximately 2 seconds, and then change back to display the “Vibration/Shock” status until the Vibration/Shock reset timer is finished (or until another different event occurs.)
- Moved code to reset to Stationary status from
configure()so that that status isn’t reset to Stationary when preference settings are saved, instead only resetting it when the sensor is first paired
- Added info log messages to report open/close/unknown position
- Added info log messages to report successfully set open/close positions
- Various code cleanup/reorganization and formatting fixes
Screenshots of updated User Interface
(A vibration event results in
motion - active state)
(A tilt event results in
acceleration - active state)
(The open/close/unknown status is displayed in a separate small tile,
because other events can happen simultaneously.)
(Here are the rest of the UI tiles)
- After updating to this new DTH code, I recommend opening preferences and pressing save. That should fix any issues that some users have been reporting about the Sensitivity Level UI button not working.
- I still cannot confirm that the command to change the hardware sensitivity is working. On the SmartThings platform, no confirmation message is received from the sensor.
contact - openor
contact - closedevents will be sent until both the open and closed positions are set. If the open and closed are set for the same position, then it that position will only report
contact - closed.
- Although not officially supported by the
contact sensorcapability, when the sensor is in any position outside the set open and closed positions, a
contact - unknownevent will be sent and the tile will display “unknown”.
- The open/close position algorithm uses a margin of error value to allow for some variance from the stored open/closed positions set by the user. This is not user adjustable yet, but may be added to the preference settings in a future release.