2.2.5.131 [C7]
I'm getting system errors trying to send a simple message to a Zigbee device. I thought it worked in the past but now thinking back I'm not 100% sure. However I do know I wasn't originally getting this error message.
the error seems to be the command:
sendHubCommand(new HubAction(sendtodevice(msg), Protocol.ZIGBEE))
The device is a Haas TI CC2530 board. has worked in the past but now either something changed or I damaged the code.
In troubleshooting I replaced the msg to be sent to a simple string.
Anybody have suggestions.
/**
* Furnace Lockout Monitor
* This is version two. The version one used the iharyadi board. It worked fine but was too chatty.
* Version two is a CC2530 board with the Haas firmware.
* The lockout switch (open when OK) connects the D1 input (P0.6) to ground when there is a lockout
* at the same time the switch turns monitor mounted LED on. The LED is controlled only by
* the switch and does not need a Hubitat connection to illuminate.
* Code is largely based on the Dan Ogorchock code for the Haas board
*
* Log entries from manually switching inputs:
*
* dev:28932021-01-16 17:12:34.173 infocontact set to open
* dev:28922021-01-16 17:12:34.164 info parsing 'Button1 not. '
*
* dev:28932021-01-16 17:12:25.702 infocontact set to closed
* dev:28922021-01-16 17:12:25.682 info parsing 'Button1 yes. '
*
*
* 2021-01-16 - v01 -
* 2021-01-20 - v02 - restructured Parse
* 2021-01-21 - v05 - moved "ping" under the if(read Attr) statement structure.
* v05c Full function validated, at ping_360 the ping would occur once an hour.
* Config doesn't do much.
*
*
*/
import hubitat.device.HubAction
import hubitat.device.HubMultiAction
import hubitat.device.Protocol
metadata {
definition (name: "Furnace Lockout Monitor", namespace: "johnrob", author: "various") {
capability "Actuator" // our device has commands...
capability "Sensor" // our device has attributes...
capability "Configuration" // capability "Configuration" commands: configure()
command "sendCommand", ["string"] //allows arbitrary comm
attribute "lastActivity", "String"
attribute "FurnaceStatus", "string"
}
preferences {
input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
input name: "txtEnable", type: "bool", title: "Enable description logging", defaultValue: true
}
}
// Parse incoming device messages to generate events
def parse(String description) {
if (logEnable) log.debug " description is $description"
state.lastRan = now()
Map map = [:]
def event = zigbee.getEvent(description)
if (event) {
sendEvent(event)
}
else if (description?.startsWith("catchall:")) {
if (logEnable) log.debug "catchall is $description"
}
else if (description?.startsWith("read attr -")) {
def descMap = zigbee.parseDescriptionAsMap(description)
log.info "$descMap"
if (descMap.clusterInt == 0) {
def text = descMap.value
if(text.startsWith("ping")) return
if (text?.startsWith("Button1 yes")) {
sendEvent(name: "FurnaceStatus", value: "LockedOut", isStateChange: true)
}
if (text?.startsWith("Button1 not")) {
sendEvent(name: "FurnaceStatus", value: "running", isStateChange: true)
}
}
else {
log.warn "Not an attribute we can decode"
}
}
else {
log.warn "DID NOT PARSE MESSAGE for description : $description"
if (logEnable) log.debug zigbee.parseDescriptionAsMap(description)
}
} // --- parse ---
// However, once a condition is satisfied, the appropriate statements are executed and the remaining conditions are not evaluated.
def sendtodevice(String mystr){
if (txtEnable) log.info "sending '${mystr}'"
mystr=mystr.padRight(16,".") // mystr should be 16 bytes!
def packed = hubitat.helper.HexUtils.byteArrayToHexString(mystr.getBytes())
if (logEnable) log.info "sending '${mystr}', packed is ${packed}"
def commandtosend = "HE w/attr 0x${device.deviceNetworkId} 8 0x000 0x010 0x42 {10"+packed+"}" // SAMPLELIGHT_ENDPOINT is defined as 8 in device code // the 10 on the end means 16 bytes length
if (logEnable) log.debug "$commandtosend"
return commandtosend
}
def sendCommand(String msg) {
msg = "hello"
//if (txtEnable)
log.info "sendCommand - ${msg}"
sendHubCommand(new HubAction(sendtodevice(msg), Protocol.ZIGBEE)) // "new" Creates a new HubAction object
}
def configure() {
if (txtEnable) log.info "Configuring Reporting and Bindings."
zigbee.onOffRefresh() + zigbee.onOffConfig()
}
def installed() {
if (txtEnable) log.info "Executing 'installed()'"
updated()
}
def initialize() {
if (txtEnable) log.info "Executing 'initialize()'"
}
def updated() {
if (txtEnable) log.info "Executing 'updated()'"
if (logEnable) {
log.info "Enabling Debug Logging for 30 minutes"
runIn(1800,logsOff)
} else {
unschedule(logsoff)
}
}
def now() {
if(location.timeZone)
now = new Date().format("yyyy MMM dd EEE h:mm:ss a", location.timeZone)
else
now = new Date().format("yyyy MMM dd EEE h:mm:ss a")
sendEvent(name: "lastActivity", value: now, displayed:false)
result
}
// --- eof ---