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

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

Well, it seems it was a Hub Connect issue. (You were right yet again!)

After trying a few things, I found that there was an issue with the connection. (Maybe caused by my incorrectly programmed drivers?) It works after it is reset. I'm just hoping it continues working.

That is the one thing that bugs me about having to have those sensors on a second hub, if there are issues, it can take quite a bit of time to figure out the source (device, hub connect, something else...). It does make it more interesting though! :slight_smile:

Great you got it working! :slight_smile:

Yes, it doesn't really make things easier. I have multiple hubs, but keep most rules/automations local to where the device is. I don't use HubConnect or the like.

I'm surprised you're able to do that. You must be a really good architect/planner...

I find that I have too many devices that need to cross over from one hub to another... Echo Speaks being a big one! I have automations that tell us to close the windows if AC is on, or to keep an eye on the weather if certain windows are open and the weather is predicting rain, etc... And a lot of the time it needs to poll devices status on both hubs.

Not so much, I don't live in a house and don't use any voice assistants, if I did either I don't think it would be possible. For Tasmota devices I can control them from all hubs, just not get instant status updates on more than one. For the rest it can be separated.

1 Like

@markus, When will you be showing some mercy to LLKZMK11LM Relay?
Regards,

I don't have one of those and wasn't even aware people used it? I've also never seen it in my local Aqara store nor from any of the online stores I buy from. As such it is not really on my list of drivers to write, but if someone finds a way to have one sent to me here in China I'll write a driver. Shouldn't take more than 1 hour or so. I currently only have the Xiaomi Gas Sensor left on my list of Xiaomi/Aqara devices to write a driver for.

1 Like

Does this help- link to an existing driver? The relay seems to share properties with the wall switch.

If my guess is correct, you prefer to observe the device directly? or does it not matter?

Huge Thank You for all you do, much appreciated.

1 Like

Try my Aqara Wall Switch driver, they might work with these. Didn't realize it, but went through debug logs for that device a while back, test it and see if it works as expected, otherwise some minor tweaks might be needed.

1 Like