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

Added tags to test compatibility with the new SmartThings app #126

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Expand Up @@ -13,16 +13,16 @@
* for the specific language governing permissions and limitations under the License.
*
* Original device handler code by a4refillpad, adapted for use with Aqara model by bspranger
* Additional contributions to code by alecm, alixjg, bspranger, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Additional contributions to code by alecm, alixjg, bspranger, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Known issues:
* Xiaomi sensors do not seem to respond to refresh requests
* Inconsistent rendering of user interface text/graphics between iOS and Android devices - This is due to SmartThings, not this device handler
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
*
*/
metadata {
definition (name: "Xiaomi Aqara Door/Window Sensor", namespace: "bspranger", author: "bspranger") {
definition (name: "Xiaomi Aqara Door/Window Sensor", namespace: "bspranger", author: "bspranger", mnmn: "Xiaomi", vid: "generic-contact-2") {
capability "Configuration"
capability "Sensor"
capability "Contact Sensor"
Expand Down Expand Up @@ -86,7 +86,7 @@ metadata {
}
preferences {
//Date & Time Config
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input name: "dateformat", type: "enum", title: "Set Date Format\n US (MDY) - UK (DMY) - Other (YMD)", description: "Date Format", options:["US","UK","Other"]
input name: "clockformat", type: "bool", title: "Use 24 hour clock?"
//Battery Reset Config
Expand All @@ -96,15 +96,15 @@ metadata {
input description: "Only change the settings below if you know what you're doing.", type: "paragraph", element: "paragraph", title: "ADVANCED SETTINGS"
input name: "voltsmax", title: "Max Volts\nA battery is at 100% at __ volts\nRange 2.8 to 3.4", type: "decimal", range: "2.8..3.4", defaultValue: 3, required: false
input name: "voltsmin", title: "Min Volts\nA battery is at 0% (needs replacing) at __ volts\nRange 2.0 to 2.7", type: "decimal", range: "2..2.7", defaultValue: 2.5, required: false
}
}
}

// Parse incoming device messages to generate events
def parse(String description) {
def result = zigbee.getEvent(description)

// Determine current time and date in the user-selected date format and clock style
def now = formatDate()
def now = formatDate()
def nowDate = new Date(now).getTime()
// Any report - contact sensor & Battery - results in a lastCheckin event and update to Last Checkin tile
// However, only a non-parseable report results in lastCheckin being displayed in events log
Expand All @@ -113,7 +113,7 @@ def parse(String description) {

Map map = [:]

// Send message data to appropriate parsing function based on the type of report
// Send message data to appropriate parsing function based on the type of report
if (result) {
log.debug "${device.displayName} Event: ${result}"
map = getContactResult(result)
Expand All @@ -135,7 +135,7 @@ def parse(String description) {
// Convert raw 4 digit integer voltage value into percentage based on minVolts/maxVolts range
private Map getBatteryResult(rawValue) {
// raw voltage is normally supplied as a 4 digit integer that needs to be divided by 1000
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
def rawVolts = rawValue / 1000

def minVolts
Expand All @@ -145,12 +145,12 @@ private Map getBatteryResult(rawValue) {
minVolts = 2.5
else
minVolts = voltsmin

if(voltsmax == null || voltsmax == "")
maxVolts = 3.0
else
maxVolts = voltsmax

def pct = (rawVolts - minVolts) / (maxVolts - minVolts)
def roundedPct = Math.min(100, Math.round(pct * 100))

Expand Down Expand Up @@ -230,13 +230,13 @@ private Map getContactResult(result) {

def resetClosed() {
sendEvent(name: "contact", value: "closed", descriptionText: "${device.displayName} was manually reset to closed")
}
}

def resetOpen() {
def now = formatDate()
def nowDate = new Date(now).getTime()
sendEvent(name: "lastOpened", value: now, displayed: false)
sendEvent(name: "lastOpenedDate", value: nowDate, displayed: false)
sendEvent(name: "lastOpenedDate", value: nowDate, displayed: false)
sendEvent(name: "contact", value: "open", descriptionText: "${device.displayName} was manually reset to open")
}

Expand Down Expand Up @@ -288,7 +288,7 @@ def formatDate(batteryReset) {
correctedTimezone = TimeZone.getTimeZone("GMT")
log.error "${device.displayName}: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app."
sendEvent(name: "error", value: "", descriptionText: "ERROR: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app.")
}
}
else {
correctedTimezone = location.timeZone
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* for the specific language governing permissions and limitations under the License.
*
* Original device handler code by a4refillpad, adapted for use with Aqara model by bspranger
* Additional contributions to code by alecm, alixjg, bspranger, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Additional contributions to code by alecm, alixjg, bspranger, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Known issues:
* Xiaomi sensors do not seem to respond to refresh requests
* Inconsistent rendering of user interface text/graphics between iOS and Android devices - This is due to SmartThings, not this device handler
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
*
*/

metadata {
definition (name: "Xiaomi Aqara Motion Sensor", namespace: "bspranger", author: "bspranger") {
definition (name: "Xiaomi Aqara Motion Sensor", namespace: "bspranger", author: "bspranger", mnmn: "Xiaomi", vid: "generic-motion") {
capability "Motion Sensor"
capability "Illuminance Measurement"
capability "Configuration"
Expand Down Expand Up @@ -81,7 +81,7 @@ metadata {
[value:500, color:"#51b8e1"],
[value:750, color:"#66c1e5"],
[value:1000, color:"#7ccae9"],
[value:1500, color: "#92d3ed"]
[value:1500, color: "#92d3ed"]
]
}
standardTile("reset", "device.reset", inactiveLabel: false, decoration:"flat", width: 2, height: 2) {
Expand All @@ -102,7 +102,7 @@ metadata {
input description: "This setting only changes how long MOTION DETECTED is reported in SmartThings. The sensor hardware always remains blind to motion for 60 seconds after any activity.", type: "paragraph", element: "paragraph", title: "MOTION RESET"
input "motionreset", "number", title: "", description: "Enter number of seconds (default = 60)", range: "1..7200"
//Date & Time Config
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input name: "dateformat", type: "enum", title: "Set Date Format\n US (MDY) - UK (DMY) - Other (YMD)", description: "Date Format", options:["US","UK","Other"]
input name: "clockformat", type: "bool", title: "Use 24 hour clock?"
//Battery Reset Config
Expand All @@ -112,15 +112,15 @@ metadata {
input description: "Only change the settings below if you know what you're doing.", type: "paragraph", element: "paragraph", title: "ADVANCED SETTINGS"
input name: "voltsmax", title: "Max Volts\nA battery is at 100% at __ volts\nRange 2.8 to 3.4", type: "decimal", range: "2.8..3.4", defaultValue: 3
input name: "voltsmin", title: "Min Volts\nA battery is at 0% (needs replacing) at __ volts\nRange 2.0 to 2.7", type: "decimal", range: "2..2.7", defaultValue: 2.5
}
}
}

// Parse incoming device messages to generate events
def parse(String description) {
log.debug "${device.displayName} parsing: $description"

// Determine current time and date in the user-selected date format and clock style
def now = formatDate()
def now = formatDate()
def nowDate = new Date(now).getTime()

// Any report - motion, lux & Battery - results in a lastCheckin event and update to Last Event tile
Expand All @@ -129,8 +129,8 @@ def parse(String description) {
sendEvent(name: "lastCheckinDate", value: nowDate, displayed: false)

Map map = [:]
// Send message data to appropriate parsing function based on the type of report

// Send message data to appropriate parsing function based on the type of report
if (description?.startsWith('illuminance:')) {
map = parseIlluminance(description)
}
Expand Down Expand Up @@ -219,7 +219,7 @@ private Map parseCatchAllMessage(String description) {
// Convert raw 4 digit integer voltage value into percentage based on minVolts/maxVolts range
private Map getBatteryResult(rawValue) {
// raw voltage is normally supplied as a 4 digit integer that needs to be divided by 1000
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
def rawVolts = rawValue / 1000
def minVolts
def maxVolts
Expand All @@ -228,12 +228,12 @@ private Map getBatteryResult(rawValue) {
minVolts = 2.5
else
minVolts = voltsmin

if (voltsmax == null || voltsmax == "")
maxVolts = 3.0
else
maxVolts = voltsmax

def pct = (rawVolts - minVolts) / (maxVolts - minVolts)
def roundedPct = Math.min(100, Math.round(pct * 100))

Expand Down Expand Up @@ -305,7 +305,7 @@ def formatDate(batteryReset) {
correctedTimezone = TimeZone.getTimeZone("GMT")
log.error "${device.displayName}: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app."
sendEvent(name: "error", value: "", descriptionText: "ERROR: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app.")
}
}
else {
correctedTimezone = location.timeZone
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* for the specific language governing permissions and limitations under the License.
*
* Original device handler code by a4refillpad, adapted for use with Aqara model by bspranger
* Additional contributions to code by alecm, alixjg, bspranger, cscheiene, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Additional contributions to code by alecm, alixjg, bspranger, cscheiene, gn0st1c, foz333, jmagnuson, rinkek, ronvandegraaf, snalee, tmleafs, twonk, & veeceeoh
*
* Known issues:
* Xiaomi sensors do not seem to respond to refresh requests
* Inconsistent rendering of user interface text/graphics between iOS and Android devices - This is due to SmartThings, not this device handler
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
* Pairing Xiaomi sensors can be difficult as they were not designed to use with a SmartThings hub. See
*
*/

metadata {
definition (name: "Xiaomi Aqara Temperature Humidity Sensor", namespace: "bspranger", author: "bspranger") {
definition (name: "Xiaomi Aqara Temperature Humidity Sensor", namespace: "bspranger", author: "bspranger", ocfDeviceType: "x.com.st.d.sensor.multifunction") {
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
capability "Sensor"
Expand Down Expand Up @@ -138,7 +138,7 @@ metadata {
input name:"PressureUnits", type:"enum", title:"Pressure Units", options:["mbar", "kPa", "inHg", "mmHg"], description:"Sets the unit in which pressure will be reported"
input description: "NOTE: The temperature unit (C / F) can be changed in the location settings for your hub.", type: "paragraph", element: "paragraph", title: ""
//Date & Time Config
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input description: "", type: "paragraph", element: "paragraph", title: "DATE & CLOCK"
input name: "dateformat", type: "enum", title: "Set Date Format\nUS (MDY) - UK (DMY) - Other (YMD)", description: "Date Format", options:["US","UK","Other"]
input name: "clockformat", type: "bool", title: "Use 24 hour clock?"
//Battery Reset Config
Expand All @@ -156,7 +156,7 @@ def parse(String description) {
log.debug "${device.displayName}: Parsing description: ${description}"

// Determine current time and date in the user-selected date format and clock style
def now = formatDate()
def now = formatDate()
def nowDate = new Date(now).getTime()

// Any report - temp, humidity, pressure, & battery - results in a lastCheckin event and update to Last Checkin tile
Expand Down Expand Up @@ -186,7 +186,7 @@ def parse(String description) {
map = parseReadAttr(description)
} else {
log.debug "${device.displayName}: was unable to parse ${description}"
sendEvent(name: "lastCheckin", value: now)
sendEvent(name: "lastCheckin", value: now)
}

if (map) {
Expand Down Expand Up @@ -245,7 +245,7 @@ private Map parseReadAttr(String description) {
settings.PressureUnits = "mbar"
}
// log.debug "${device.displayName}: Converting ${pressureval} to ${PressureUnits}"

switch (PressureUnits) {
case "mbar":
pressureval = (pressureval/10) as Float
Expand Down Expand Up @@ -284,7 +284,7 @@ private Map parseReadAttr(String description) {
]
} else if (cluster == "0000" && attrId == "0005") {
def modelName = ""

// Parsing the model name
for (int i = 0; i < value.length(); i+=2) {
def str = value.substring(i, i+2);
Expand All @@ -299,7 +299,7 @@ private Map parseReadAttr(String description) {
// Convert raw 4 digit integer voltage value into percentage based on minVolts/maxVolts range
private Map getBatteryResult(rawValue) {
// raw voltage is normally supplied as a 4 digit integer that needs to be divided by 1000
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
// but in the case the final zero is dropped then divide by 100 to get actual voltage value
def rawVolts = rawValue / 1000
def minVolts
def maxVolts
Expand All @@ -308,12 +308,12 @@ private Map getBatteryResult(rawValue) {
minVolts = 2.5
else
minVolts = voltsmin

if(voltsmax == null || voltsmax == "")
maxVolts = 3.0
else
maxVolts = voltsmax

def pct = (rawVolts - minVolts) / (maxVolts - minVolts)
def roundedPct = Math.min(100, Math.round(pct * 100))

Expand Down Expand Up @@ -355,7 +355,7 @@ def resetMinMax() {
def updateMinMaxTemps(temp) {
temp = temp ? (int) temp : temp
if ((temp > device.currentValue('maxTemp')) || (device.currentValue('maxTemp') == null))
sendEvent(name: "maxTemp", value: temp, displayed: false)
sendEvent(name: "maxTemp", value: temp, displayed: false)
if ((temp < device.currentValue('minTemp')) || (device.currentValue('minTemp') == null))
sendEvent(name: "minTemp", value: temp, displayed: false)
refreshMultiAttributes()
Expand Down Expand Up @@ -425,7 +425,7 @@ def formatDate(batteryReset) {
correctedTimezone = TimeZone.getTimeZone("GMT")
log.error "${device.displayName}: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app."
sendEvent(name: "error", value: "", descriptionText: "ERROR: Time Zone not set, so GMT was used. Please set up your location in the SmartThings mobile app.")
}
}
else {
correctedTimezone = location.timeZone
}
Expand Down
Loading