As to other examples.. they are all over this forum. There's a Category here called Code Share.. for just that purpose, to make community created code available to the community. https://community.hubitat.com/c/basics/codeshare
Same here, I'm using Amazon IOT buttons but theres around a 8 second delay to connect to wifi, send the message, and hit my local network. Would love something with a quicker response time.
I keep the amazon button in the car, so a battery and a small form factor are a must. The new button meets both of those and the price isn't bad, my only worry is range as my zigbee sensor in my mailbox is already at the edge of my network. I only have zigbee battery powered sensors so it would probably help to get some kind of repeater.
My SmartThings "2018" Button (IM6001-BTP01 on the device; GP-U999SJVLEAA on the website) arrived today! I was able to heavily pare down modify the SmartThingsPublic "ZigBee Button" DTH to work with this device on Hubitat. It supports push, doubleTap, and hold, just as it does on ST (does not appear to register separate release event, and by "on "ST I mean that the button model is completely different but this these are the effective capabilities of the device on both).
This will probably become a moot point after Mike gets his hand on one and supports it as part of the stock Hubitat driver store, but for now this is working for me:
/**
* SmartThings Button IM6001-BTP01
*
* Loosely based on SmartThingsPublic ZigBee Button DTH copyright 2015 Mitch Pond
* Modified for SmartThings Button and adapted for Hubitat by Robert Morris
*
* 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.
*
*/
import groovy.json.JsonOutput
import com.hubitat.zigbee.DataType
metadata {
definition (name: "SmartThings Button", namespace: "RMoRobert", author: "Robert Morris, Mitch Pond") {
capability "Actuator"
capability "Battery"
capability "PushableButton"
capability "HoldableButton"
capability "DoubleTapableButton"
capability "Configuration"
capability "Refresh"
capability "Sensor"
command "enrollResponse"
fingerprint inClusters: "0000, 0001, 0003, 0020, 0402, 0500", outClusters: "0003, 0019", manufacturer: "Samjin", model: "button"
}
}
def parse(String description) {
log.debug "Running 'parse'; 'description' is: $description"
def event = zigbee.getEvent(description)
if (event) {
sendEvent(event)
}
else {
if ((description?.startsWith("catchall:")) || (description?.startsWith("read attr -"))) {
def descMap = zigbee.parseDescriptionAsMap(description)
if (descMap.clusterInt == 0x0001 && descMap.attrInt == 0x0020) {
event = getBatteryResult(zigbee.convertHexToInt(descMap.value))
}
else if (descMap.clusterInt == 0x0006 || descMap.clusterInt == 0x0008) {
// Not handled
}
}
else if (description?.startsWith('zone status')) {
event = parseIasButtonMessage(description)
}
log.debug "Parse returned $event"
def result = event ? createEvent(event) : []
if (description?.startsWith('enroll request')) {
List cmds = zigbee.enrollResponse()
result = cmds?.collect { new hubitat.device.HubAction(it) }
}
return result
}
}
private Map parseIasButtonMessage(String description) {
def zs = zigbee.parseZoneStatus(description)
def eventType = "unknown"
if (zs.isAlarm1Set()) { eventType = "pushed" }
if (zs.isAlarm2Set()) { eventType = "doubleTapped" }
if (zs.isAlarm1Set() && zs.isAlarm2Set()) { eventType = "held" }
def descriptionText = "$device.displayName: $eventType"
if (eventType != "unknown") {
return createEvent(
name: eventType,
value: 1,
isStateChange: true,
descriptionText: "Button 1 was $eventType"
)
}
}
private Map getBatteryResult(rawValue) {
log.debug 'Battery'
def volts = rawValue / 10
if (volts > 3.0 || volts == 0 || rawValue == 0xFF) {
return [:]
}
else {
def result = [
name: 'battery'
]
def minVolts = 2.1
def maxVolts = 3.0
def pct = (volts - minVolts) / (maxVolts - minVolts)
result.value = Math.min(100, (int) pct * 100)
def linkText = getLinkText(device)
result.descriptionText = "${linkText} battery was ${result.value}%"
return result
}
}
def refresh() {
log.debug "Refreshing Battery"
return zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x20) +
zigbee.enrollResponse()
}
def configure() {
log.debug "Configuring Reporting, IAS CIE, and Bindings."
def cmds = []
return zigbee.onOffConfig() +
zigbee.levelConfig() +
zigbee.configureReporting(zigbee.POWER_CONFIGURATION_CLUSTER, 0x20, DataType.UINT8, 30, 21600, 0x01) +
zigbee.enrollResponse() +
zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x20) +
cmds
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 1)
}
Thanks! I was so concerned with just the button pressed that I didn't even know it reported temperature and just kept the code for the battery from the ST buttons (which did not include this one, nor did I know how this one reported the values). I see you can also get rid of the imports at the top since they aren't needed with this simplified driver. Thanks again!
Finally got my 2018 ST Multisensor in the mail today. I can get it to report open/close, temperature, and (I think) battery with the SmartSense Multi driver. What I can't get working is vibration/movement with any of the stock drivers I tried. I did hastily port the SmartThingPublic multi driver (or everything I could--commented out a few parts where I wasn't sure), and it does work for acceleration and axis reporting now, too! I would share that code but it's in very poor shape, having been cobbled together embarassingly hastily. Again, I'm sure these will be officially supported with native drivers as staff gets their hands on them and has time.
EDIT: Updated the above post to indicate I was eventually able to get movement/vibration/acceleration and axis reporting working (funny what happens when you start with a motion sensor driver but really wanted the multi sensor...).
Thanks for creating the driver for the SmartThings buttons! I just received three of them today (ordered from Amazon a week ago). They seem to be working well with this driver.
2018 Water Sensors work fine with generic zigbee driver, not sure if @mike.maxwell has added the fingerprint data to the driver so that it is setup properly during pairing yet. I posted the fingerprint a while back so it's possible that he has.
both the motion sensor and the moisture sensor fingerprints are in 1.1.4, the multipurpose sensor works with the generic zigbee contact sensor driver, that fingerprint will be in 1.1.5, still waiting for my button...