[Deprecated] Xiaomi / Aqara / Opple Drivers with Presence!

Have you done a vibration sensor? Can't see it in hpm

Yes, but not yet published it to HPM. I have only 3 Zigbee drivers not yet published there, Aqara Vibration, Aqara Cube and the Xiaomi Smoke Detector. They can all be found through the links in the first post though.

1 Like

Since months I am using for my 21 battery powers Xiaomi devices the drivers from veeceeoh. All the connection problems disappeard the moment I added 5 Ikea plugs.
At this moment I am in holiday and geuss what, 2 devices are dropped :triumph:. I definitely going to try your drivers once back home.

Many of my Xiaomi contact sensors dropped overnight. I recently updated to the latest version via HPM (two days ago, was fine until then), and there was another update this morning. They're all still offline. Hope they come back.

Lost a couple of mine on the .123 update, but they're all still here after the .125. Must be mesh panic-shuffling when the coordinator disappears.

Hello
For one of my contact sensors few times per minute I see in log:
dev:2932020-07-21 23:19:10.946 infoRecovery feature ENABLED

dev:2932020-07-21 23:19:10.890 infogetDriverVersion() = v0.8.1.0720

dev:2932020-07-21 23:19:10.880 infoReset button pressed/message requested by hourly checkin - description:read attr - raw: 68D301000036050042166C756D692E73656E736F725F6D61676E65742E617132, dni: 68D3, endpoint: 01, cluster: 0000, size: 36, attrId: 0005, encoding: 42, command: 01, value: 166C756D692E73656E736F725F6D61676E65742E617132 | parseMap:[raw:68D301000036050042166C756D692E73656E736F725F6D61676E65742E617132, dni:68D3, endpoint:01, cluster:0000, size:36, attrId:0005, encoding:42, command:01, value:lumi.sensor_magnet.aq2, clusterInt:0, attrInt:5]

What does this mean?

Thanks

That doesn't make sense, are you sure it is the same device, and really a few times per minute? There is nothing in the driver that should cause that to happen. A screenshot of more than one time would be good to see, especially if there are other logs around/before/after it.
Which contact sensor model is it?

Yes, that was last night - same device 3, 4 times per minute. Now it stop, now is 2,3 times pe hour
which I suppose is good :slight_smile:

Yes, but that is still more frequent than normal, exactly which model is this?

this one: MCCGQ11LM

Ok, so the Aqara model, the normal frequency is about once every 50-55 minutes. But more frequent than that wouldn't be bad, it just isn't something I have ever seen from these.

ok, I can live with this now :), if you find something I will update the drivers
Thanks

I'd like to request a feature for the driver above. Could a date/time be added for the last Dry and the last wet? Like the last open and last close on the contact sensor driver...

Thanks!

1 Like

I am seeing an odd behavior with the Xiaomi contact sensors and HubConnect.

It will sometimes take a long, long time for the sensor state to be reported on the secondary hub. All the while, a Tasmota device using the latest driver (also from @markus) will immediately report its state on the other hub.

Not sure if this should go under this topic or the Hub Connect topic... I'm thinking this is the right topic since it only seems to impact the devices using the Xiaomi drivers.

I have tried rebooting both hubs and found that after they both have been rebooted, the devices state slowly transitions.

Not sure what the best approach would be to debug this issue...

Update: It seems that the problem may be with a custom driver I created with the HubConnect app that allows me to transfer all the states. When I change to the default driver, it registers the proper state. Unfortunately, I don't know enough about drivers to understand why one would work and the other wouldn't...

This is the HubConnect driver that work but doesn't provide Presence and other states:

HubConnect Contact Sensor

/*

  • Copyright 2019 Steve White
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not
  • use this file except in compliance with the License. You may obtain a copy
  • of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  • WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  • License for the specific language governing permissions and limitations
  • under the License.

*/
metadata
{
definition(name: "HubConnect Contact Sensor", namespace: "shackrat", author: "Steve White", importUrl: "https://raw.githubusercontent.com/HubitatCommunity/HubConnect/master/UniversalDrivers/HubConnect-Contact-Sensor.groovy")
{
capability "Contact Sensor"
capability "Temperature Measurement"
capability "Battery"
capability "Refresh"

	attribute "version", "string"
	
	command "sync"
}

}

/*
installed

Doesn't do much other than call initialize().

*/
def installed()
{
initialize()
}

/*
updated

Doesn't do much other than call initialize().

*/
def updated()
{
initialize()
}

/*
initialize

Doesn't do much other than call refresh().

*/
def initialize()
{
refresh()
}

/*
parse

In a virtual world this should never be called.

*/
def parse(String description)
{
log.trace "Msg: Description is $description"
}

/*
refresh

Refreshes the device by requesting an update from the client hub.

*/
def refresh()
{
// The server will update status
parent.sendDeviceEvent(device.deviceNetworkId, "refresh")
}

/*
sync

Synchronizes the device details with the parent.

*/
def sync()
{
// The server will respond with updated status and details
parent.syncDevice(device.deviceNetworkId, "contact")
sendEvent([name: "version", value: "v${driverVersion.major}.${driverVersion.minor}.${driverVersion.build}"])
}
def getDriverVersion() {[platform: "Universal", major: 1, minor: 2, build: 1]}

This is the custom driver I created within the app that gives me all the details, but doesn't always work...

HubConnect Xiaomi Window Sensor

/*

  • 2020 Sébastien Viel.
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not
  • use this file except in compliance with the License. You may obtain a copy
  • of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  • WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  • License for the specific language governing permissions and limitations
  • under the License.

*/
def getDriverVersion() {[platform: "Universal", major: 2, minor: 0, build: 0]}

metadata
{
definition(name: "HubConnect Xiaomi Window Sensor", namespace: "shackrat", author: "Steve White")
{
capability "ContactSensor"
capability "Actuator"
capability "Battery"
capability "Initialize"
capability "Sensor"

	// Autogenerated attributes
	attribute "battery", "string"
	attribute "batteryLastReplaced", "string"
	attribute "driver", "string"
	attribute "lastCheckin", "string"
	attribute "lastClosed", "string"
	attribute "lastOpened", "string"
	attribute "notPresentCounter", "string"
	attribute "presence", "string"
	attribute "restoredCounter", "string"

	attribute "version", "string"

	command "sync"
}

}

/*
installed
*/
def installed()
{
initialize()
}

/*
updated
*/
def updated()
{
initialize()
}

/*
initialize
*/
def initialize()
{
refresh()
}

/*
uninstalled

Reports to the remote that this device is being uninstalled.

*/
def uninstalled()
{
// Report
parent?.sendDeviceEvent(device.deviceNetworkId, "uninstalled")
}

/*
refresh
*/
def refresh()
{
// The server will update status
parent.sendDeviceEvent(device.deviceNetworkId, "refresh")
}

/*
sync
*/
def sync()
{
// The server will respond with updated status and details
parent.syncDevice(device.deviceNetworkId, "xiaomiWindowSensor")
sendEvent([name: "version", value: "v${driverVersion.major}.${driverVersion.minor}.${driverVersion.build}"])
}

Update 2: Well, I have just taken the HubConnect Contact Sensor and added the Attributes I was looking for and it seems to have worked. Now to see how long it will stick...

Update 3: After further investigation, I noticed that a couple of other new custom drivers I had generated from the app had the same value in the "parent.syncDevice(device.deviceNetworkId, "xiaomiWindowSensor")" parameter (Value that I think should have been different in italics...) I wonder if it makes a difference that the value was the same in 3 different drivers... I have changed it in the newer drivers, but have not yet seen an impact. Will reboot the hubs and keep an eye on this...

It will be there in the next release as an optional extra set of attributes. :slight_smile: :slight_smile:

The only important difference I can see is that you were missing the Refresh capability. Presence should not be added as an attribute, it should be a capability.

2 Likes

I tried changing it, but I get a "Metadata Error: Capability 'presence' not found. on line 28"

I suspect there is something else I missed? :thinking:

HubConnect Xiaomi Window Sensor

/*

  • 2020-07-22 Sébastien Viel.
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not
  • use this file except in compliance with the License. You may obtain a copy
  • of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  • WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  • License for the specific language governing permissions and limitations
  • under the License.

*/
def getDriverVersion() {[platform: "Universal", major: 2, minor: 0, build: 0]}

metadata
{
definition(name: "HubConnect Xiaomi Water Sensor", namespace: "shackrat", author: "Steve White")
{
capability "WaterSensor"
capability "Actuator"
capability "Battery"
capability "Initialize"
capability "Sensor"
capability "presence"

	// Autogenerated attributes
	attribute "battery", "string"
	attribute "batteryLastReplaced", "string"
	attribute "driver", "string"
	attribute "lastCheckin", "string"
	attribute "notPresentCounter", "string"
	attribute "restoredCounter", "string"
	attribute "version", "string"

	command "sync"
}

}

/*
installed
*/
def installed()
{
initialize()
}

/*
updated
*/
def updated()
{
initialize()
}

/*
initialize
*/
def initialize()
{
refresh()
}

/*
uninstalled

Reports to the remote that this device is being uninstalled.

*/
def uninstalled()
{
// Report
parent?.sendDeviceEvent(device.deviceNetworkId, "uninstalled")
}

/*
refresh
*/
def refresh()
{
// The server will update status
parent.sendDeviceEvent(device.deviceNetworkId, "refresh")
}

/*
sync
*/
def sync()
{
// The server will respond with updated status and details
parent.syncDevice(device.deviceNetworkId, "xiaomiWaterSensor")
sendEvent([name: "version", value: "v${driverVersion.major}.${driverVersion.minor}.${driverVersion.build}"])
}

I should have mentioned it is called:
capability "PresenceSensor"

Here are all capabilities:
https://docs.hubitat.com/index.php?title=Driver_Capability_List

1 Like

Ah! That worked. So much to learn! Thanks for the link!

1 Like

It seems that even though I can now save the updated driver, there is something with the extra attributes or capability that is causing issues. (I suspect in the Hub Connect app.)

When I use the default driver with the addition of the PresenceSensor Capability and the other Xiaomi driver attributes, the window sensor's state will not refresh automatically. When I open or close a window that uses one of the Xiaomi contact sensors shared between hubs, the hub on which it is connected immediately sees the change, but the "client" hub only sees it if the "Sync" button is pressed on the client hub. :frowning_face:

@csteele, any idea what I may be doing wrong here? I suspect there is a small detail that I am not paying attention to, most likely due to my not having any idea what I am doing when making driver changes... Right now, I feel I just know enough to be dangerous... :smirk:

I can take this discussion to the Hub Connect thread if it makes more sense at this point...

Probably best, I don't use Hubconnect so can't help any more with this topic.

1 Like