a4refillpad / xiaomi Goto Github PK
View Code? Open in Web Editor NEWmy Xiaomi Device Handlers for Smartthings
License: Apache License 2.0
my Xiaomi Device Handlers for Smartthings
License: Apache License 2.0
Hi,
I have the following error, maybe since the last ST hub upgrade:
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug Parse returned Guest room Temp & Humidity humidity is 35%
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug Evencreated: humidity, 35, %
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug Parsevalue: 35
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug Parsename: humidity
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug RAW: humidity: 35.1%
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.math.BigDecimal#plus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class java.lang.Character]
[class java.lang.String]
[class java.lang.Number]
[class java.math.MathContext]
f3dff9ae-9346-4e28-8ed5-10:46:47 AM: debug Parsename: temperature
f3dff9ae-9346-4e28-8ed5- 10:46:47 AM: debug RAW: temperature: 20.42
f3dff9ae-9346-4e28-8ed5- 10:19:04 AM: debug Sending enroll response
f3dff9ae-9346-4e28-8ed5-10:19:04 AM: debug refresh called
I have the latest A4refillpad Xiaomi Temperature Humidity Sensor. I see one call to BigData:
private String parseValue(String description) {
if (description?.startsWith("temperature: ")) {
def value = ((description - "temperature: ").trim()) as Float
if (getTemperatureScale() == "C") {
if (tempOffset) {
return (Math.round(value * 10))/ 10 + tempOffset as Float
} else {
return (Math.round(value * 10))/ 10 as Float
}
} else {
if (tempOffset) {
return (Math.round(value * 90/5))/10 + 32 + offset as Float
} else {
return (Math.round(value * 90/5))/10 + 32 as Float
}
}
} else if (description?.startsWith("humidity: ")) {
def pct = (description - "humidity: " - "%").trim()
if (pct.isNumber()) {
return Math.round(new BigDecimal(pct)).toString()
}
} else if (description?.startsWith("catchall: ")) {
return parseCatchAllMessage(description)
} else {
log.debug "unknown: $description"
sendEvent(name: "unknown", value: description)
}
null
}
Any idea?
Hi, hooked everything up yesterday. 1 Temp sensor, 2 buttons.
today batt level says 1% on all of them.
Hello,
Xiaomi has four wall mount switches that would be an awesome addition to this device handler.
there has been some work done but it seems to be dead right now.
https://community.smartthings.com/t/xiaomi-aqara-zigbee-switch-dth-help-needed/82072
Do you think that you will add support for theese switches?
Hi ,
I successfully paired xiaomi button with my hub using your DH. But after complete SmartApp rule, button press doesnt do anything. I just setup simple rule saying if button pressed, send me push notification. But nothing showed in notification after pressed the button.
I propose the following addition to support Xiaomi Outlet temperature offset:
metadata {
<snip>
preferences {
section {
input title: "Temperature Offset", description: "This feature allows you to correct any temperature variations by selecting an offset. Ex: If your sensor consistently reports a temp that's 5 degrees too warm, you'd enter '-5'. If 3 degrees too cold, enter '+3'. Please note, any changes will take effect only on the NEXT temperature change.", displayDuringSetup: false, type: "paragraph", element: "paragraph"
input "tempOffset", "number", title: "Degrees", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
}
}
<snip>
private Map parseReportAttributeMessage(String description) {
Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
//log.debug "Desc Map: $descMap"
Map resultMap = [:]
if (descMap.cluster == "0001" && descMap.attrId == "0020") {
resultMap = getBatteryResult(convertHexToInt(descMap.value / 2))
}
if (descMap.cluster == "0002" && descMap.attrId == "0000") {
def value = zigbee.parseHATemperatureValue("temperature: " + (convertHexToInt(descMap.value) / 2), "temperature: ", getTemperatureScale()) as Float
log.debug "Value is $value, tempOffset is $tempOffset"
def correctedtemp
if (getTemperatureScale() == "C") {
if (tempOffset) {
correctedtemp= (Math.round(value * 10))/ 10 + tempOffset as Float
} else {
correctedtemp= (Math.round(value * 10))/ 10 as Float
}
} else {
if (tempOffset) {
correctedtemp= (Math.round(value * 90/5))/10 + 32 + tempOffset as Float
} else {
correctedtemp= (Math.round(value * 90/5))/10 + 32 as Float
}
}
log.debug "Corrected temp is $correctedtemp"
resultMap = createEvent(name: "temperature", value: correctedtemp, unit: getTemperatureScale())
log.debug "Temperature Hex convert to ${resultMap.value}%"
}
else if (descMap.cluster == "0008" && descMap.attrId == "0000") {
resultMap = createEvent(name: "switch", value: "off")
}
return resultMap
}
Can you help with aqara water leak sensors.
Hi @a4refillpad , Thanks so much for creating such robust device handlers for the Xiaomi products. I am loving it and have found them to be extremely reliable.
I use and love the buttons capability to control so much via single / hold options, plus even more utilising CoRe to add the time dimension.
I had a feature enhancement request: double tap for the Zigbee Buttons.
I've never written Groovy - I have had a thought as to logically how it could be added (no clue if what I wrote would even compile), but it seems the code could support a "double tap" type feature. I am not sure how to update the rest of the code to enable it be used across CoRe etc.
attribute "previousPress" "string" //I am unsure if this is possible / how to get it (given I can see this in SmartThings history, I am assuming this could be obtained through some mechanism)
private createButtonEvent(button) {
def currentTime = now()
def startOfPress = device.latestState('lastPress').date.getTime()
def timeDif = currentTime - startOfPress
def holdTimeMillisec = (settings.holdTime?:3).toInteger() * 1000
// my additional various
def previousPress = device.latestState('previousPress').date.getTime()
def timeDifPreviousPress = currentTime - previousPress
if (timeDif < 0)
return [] //likely a message sequence issue. Drop this press and wait for another. Probably won't happen...
//my simple logic to check if the last two presses occurred in the hold time
else if (timeDif <holdTimeMillisec & timeDifPreviousPress < holdTimeMillisec)
return createEvent(name: "button", value: "double tap", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was double tapped", isStateChange: true)
else if (timeDif < holdTimeMillisec)
if (
return createEvent(name: "button", value: "pushed", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was pushed", isStateChange: true)
else
return createEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
}
I would test it myself, but I have no idea how to get the Previous Press time.
In the Farenheight section of parsing values there is a typo:
if (tempOffset) {
return (Math.round(value * 90/5))/10 + 32 + offset as Float
}
should be
if (tempOffset) {
return (Math.round(value * 90/5))/10 + 32 + tempOffset as Float
}
the original phrase results in a null issue because "offset" doesn't exist. The Celsius path looks correct.
I have used the DH for the temp and Humidty, when it is registered with ST hub it is detected as ‘Thing’ but as type ‘unknown’. So I assume Thsi is a new sensor from them and not the one you created the DH for. It is the 9x9x3 cm version. Any chance create one for this or give some guidance how I can?
Hi, hooked up the temp sensor and am getting an error message:
unknown read attr - raw: c6810 dni: c681 endpoint 01 cluster 0403 size 1c attrid 0000 encoding 29 value 2740290010f28001403c
Hello, this is an open question, have someone tested new aqara sensors with this scripts? I need to get more equipment and I'm considering buying a few. Cheers
when temperature below 0 oC
the system read 100 oC
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.