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

[Aqara Motion Sensor] Version 0.8.0 #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Xiaomi Aqara Motion Sensor - model RTCGQ11LM
* Device Driver for Hubitat Elevation hub
* Version 0.7.2
* Version 0.8.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -173,17 +173,23 @@ private parseBattery(description) {

// If currently in 'active' motion detected state, resetToMotionInactive() resets to 'inactive' state and displays 'no motion'
def resetToMotionInactive() {
def seconds = motionreset ? motionreset : 61
def timediff = ((now() - device.currentState('lastMotion')?.value.toLong()) / 1000).intValue()
if (device.currentState('motion')?.value == "active") {
def seconds = motionreset ? motionreset : 61
def descText = "Reset to motion inactive after ${seconds} seconds"
sendEvent(
name:'motion',
value:'inactive',
isStateChange: true,
descriptionText: descText
)
sendEvent(name: "lastInactive", value: now())
displayInfoLog(descText)
if(timediff < seconds) {
runIn(seconds - timediff, resetToMotionInactive)
}
else {
def descText = "Reset to motion inactive after ${seconds} seconds"
sendEvent(
name:'motion',
value:'inactive',
isStateChange: true,
descriptionText: descText
)
sendEvent(name: "lastInactive", value: now())
displayInfoLog(descText)
}
}
}

Expand Down