[BETA] v0.7b of Aqara Vibration Sensor Device Driver
The new beta device driver code can be found here .
Although the main functionality of the driver remains the same, I've made significant changes "under the hood", especially in terms of how events are reported as well as adding control over the volume of custom events that are reported. This is a change I am planning to make to all of the Xiaomi/Aqara device drivers moving forward.
Beyond this, there are some new preference settings that can be accessed in the device details page, and probably the most important change is that I am now very very close to getting the sensitivity level change function working.
Major Changes
-
Changing the sensitivity level
As mentioned in my previous post, I realized that the sensor's reset button must be short-pressed before the command to change the sensitivity level is sent. So the "button" in the device details page has been removed, and now the only way to send the sensitivity level change command is by short-pressing the reset button.
The setting will cycle through the 3 levels on each press: low -> medium -> high -> low, etc. However, in my testing, the sensitivity level still does not seem to be changing and the only way I can troubleshoot at this point is by using a ZigBee network sniffer. I have ordered one and will post my findings here as soon as I've received it and got it working. If you happen to have a ZigBee sniffer and an Aqara Vibration sensor, please let me know if you'd like to try to help before my sniffer arrives. -
Time/Date stamp events are now optional (default = disabled)
There are a number of custom time/date attributes I included in the device driver for users that would like to use either for displaying the time/date of the last instance of a particular event, or to use with WebCoRE (if you dare) or other automation apps that may need the (UNIX) Epoch-based date format.
All of the custom attributes begin withlast
and the human-readable time/date stamp ones end withTime
and the Epoch-based ones end withEpoch
. So for example if you want to display the time/date stamp of the last time the hub received any message from the sensor in a Hubitat Dashboard, you'd want to use the attributelastCheckinTime
.
However, these custom attributes add a good number of extra events that some people would rather not clutter up their events list. So starting with this beta device driver, I am adding preference settings to enable/disablelastCheckin
events, and another setting for all of the otherlast_____
events. The default for these settings is disabled so if you've been making use of any of them, you'll need to go to the device details page for the sensor and enable them, like this:
-
New setting: Margin of error for open/close position
The open/close contact feature of this driver uses some "complex" math to convert the accelerometer XYZ data to a position in 3D space, but since doors and things don't always open or close in exactly the same position, there needs to be some way to adjust how far off from the originally set open/close positions the sensor can be in order to be considered in the open or closed positions.
That margin of error value is now opened up to users to adjust as seen in the above screenshot. The default is 10.0, and larger numbers will increase the range of positions that will be considered open/closed. Don't ask me how many inches there are to a change of 1.0 in the value, because it doesn't work that way! It's based on the XYZ angles, so this is a setting that needs to be tested for each particular use case/installation. -
Repeat/redundant events are not posted anymore
Another thing I am changing in the Xiaomi/Aqara device drivers to reduce "clutter" in the events lists is to stop posting events that are redundant or repeats of the same information. This is a really important thing to be aware of if you have been looking at battery percentage reports as an indication of "device" health. With this change, battery events will only occur when the percentage changes from the previous value. There is one exception to this, which isTiltAngle
events, because it is entirely possible for the sensor position to change with the same change in tilt angle as the last time the sensor was tilted.
Note that this change to the way events are posted does not changeinfo
anddebug
log output (if it has been enabled in the preference settings). -
Other Changes
See the Detailed Change List, below.
IMPORTANT: For detailed information on the features / functionality of this device driver, please see my post from the initial beta release. For quick reference, here's a chart of the available functions taken from that post:
Sensor Function | Hubitat event | Notes |
---|---|---|
Movement/Shock Detected | motion = active | motion inactive is timer-based |
Tilt Detected | acceleration = active | acceleration inactive is timer-based |
Tilt Angle | tiltAngle = value | custom attribute (see notes here) |
Drop Detected | button 1 = pushed | |
XYZ accelerometer values | contact = open/closed | (see notes here) |
Activity Report values | Custom attribute | (see notes here) |
Change sensitivity level | n/a | not yet working |
Detailed Change List
- Changed method of changing sensitivity level - the sensor's reset button must be short-pressed to cycle through levels (low > medium > high > low, etc.)
- Renamed custom attributes
lastCheckin
,lastDrop
,lastStationary
,lastTilt
andlastVibration
tolastCheckinEpoch
,lastDropEpoch
,lastStationaryEpoch
,lastTiltEpoch
, andlastVibrationEpoch
, respectively - Removed all references to WebCoRE for use of Epoch-time/date stamp custom attribute events and replaced with "Apps that can use Epoch time/date stamps"
- Added Preference Settings to enable/disable all events that use 1) custom attributes
lastCheckinEpoch
andlastCheckinTime
, and 2) all custom time/date stamp attributes (e.g., lastDropEpoch, lastDropTime, etc.) with a default of DISABLED for both settings - Added Preference Setting to change the "Margin of Error" range value used when determining whether the sensor's position matches either of the user-set open / close positions
- Changed method of storing current XYZ angle values (
angleX
,angleY
,angleZ
) tostate
objects (currentAngleX
,currentAngleY
,currentAngleZ
) instead of custom attribute events - Removed
Three Axis
capability and recording ofthreeAxis
events - Removed
isStateChange: true
parameter from all events exceptTiltAngle
to avoid any redundant repeat events being posted - Removed unnecessary
displayed: true
&false
parameter from all events - Removed redundant vibration/movement, tilt, and drop detection description text from
motion active
,acceleration active
, andbutton pushed
events - Fixed reset battery replaced date command function
- Change date formate used for battery replaced date to MMM dd yyyy (e.g., "Jan 17 2019")
- Improved initialization and configuration when sensor is first paired
- Reorganized code (order of functions, some refactoring)
- Added more (hopefully) helpful comments to code
- Edited and cleaned up log and event description output
- Other minor code formatting cleanup and fixes