I'm struggling to get the below (connectCheck) method able to send a command to my device. Specificaly basicGet() The method is triggered by a schedule.
I would then in the parse code update some part of the data like last time active or perhaps toggle a state variable. Simply to make a daily activity that can be used by one of he apps that watches code for missing reports. Mine is set for daily;
I'm hoping there is some conceptual relationship I am completely missing because right now I an garbing things from the air.
My Current code:
There are 3 different methods to send the command guess for a command report two are disabled but each has been run and provides similar errors in the logs. I keep on feeling there must be an addational action I need to make this function work. Maybe somewhere in the metada.
/**
* 2020-02-16 v00 WaterCop Z-Wave Driver
* v03 removed Health Check and checkInterval as they are not supported by Hubitat.
* v04c cleaning up code and changing On Off to Open Closed
* v04d (open) Change Lucy to Configuration
* 2021-03-16 v04f tried multple configurations for checkConnect finally found the correct option for our code.
*
* 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.
*
*/
// ______________________________________________________________________________________
metadata {
definition (name: "WaterCopValveV4f", namespace: "hubitat", author: "various") {
capability "Configuration"
capability "Refresh"
capability "Actuator"
capability "Sensor"
capability "Valve"
attribute "lastCheckin", "String"
fingerprint deviceId: "0xAA08", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70"
fingerprint mfr:"0132", deviceJoinName: "WaterCop Valve"
}
} //
// ______________________________________________________________________________________
def parse(String description) {
log.trace description
def cmd = zwave.parse(description)
log.trace "cmd=$description"
if (cmd) {
log.trace zwaveEvent(cmd)
return zwaveEvent(cmd)
}
state.lastActivity = new Date().time
return null
}
def configure() {
log.debug "Configuration"
updated()
// zwave.basicV1.basicGet().format()
// zwave.switchBinaryV1.switchBinaryGet().format()
}
def installed(){
response(refresh())
}
def updated(){
schedule("0 0 6 * * ?", connectCheck) // once every day at 6 AM
log.debug " connectCheck schedule 0 0 6 * * ? initiated"
}
def initialize(){
updated()
}
def refresh() {
log.debug " refresh performed"
connectCheck()
//return zwave.switchBinaryV1.switchBinaryGet().format()
//zwave.basicV1.basicGet().format()
}
//_________________________________________________________________________________________________
//________________________________________________________________________________________________
//________________________________________________________________________________________________
void connectCheck(){
List<hubitat.zwave.Command> cmds=[]
cmds.add(zwave.switchBinaryV1.switchBinaryGet())
cmds.add(zwave.basicV1.basicGet())
sendToDevice(cmds)
}
def yyyconnectCheck(){
// updates lastactivity so App "Device Activity Check App" will know its still communicating.
//return zwave.basicV1.basicGet().format() //should code as 2002
return hubitat.zwave.commands.basicv1.BasicGet() //.format
// response should be from 2003
}
void xxxxconnectCheck(){
// updates lastactivity so App "Device Activity Check App" will know its still communicating.
sendToDevice(zwave.basicV1.basicGet()) //.format() //should code as 2002
// response should be from 2003
}
//________________________________________________________________________________________________
//________________________________________________________________________________________________
//________________________________________________________________________________________________
def zwaveEvent(hubitat.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
def value = cmd.value ? "closed" : "open"
def event = createEvent([name: "valve", value: value, descriptionText: "$device.displayName valve is $value"])
return event
}
def zwaveEvent(hubitat.zwave.Command cmd) {
return createEvent([:]) // Handles all Z-Wave commands we aren't interested in
}
def open() {
delayBetween([
zwave.switchBinaryV1.switchBinarySet(switchValue: 0x00).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 500)
}
def close() {
delayBetween([
zwave.switchBinaryV1.switchBinarySet(switchValue: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 500)
}
// --- eof ---
/**
* 2020-02-16 v00 WaterCop Z-Wave Driver
* v03 removed Health Check and checkInterval as they are not supported by Hubitat.
* v04c cleaning up code and changing On Off to Open Closed
* v04d (open) Change Lucy to Configuration
* 2021-03-16 v04f tried multple configurations for checkConnect finally found the correct option for our code.
*
* 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.
*
*/
// ______________________________________________________________________________________
metadata {
definition (name: "WaterCopValveV4f", namespace: "hubitat", author: "various") {
capability "Configuration"
capability "Refresh"
capability "Actuator"
capability "Sensor"
capability "Valve"
attribute "lastCheckin", "String"
fingerprint deviceId: "0xAA08", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70"
fingerprint mfr:"0132", deviceJoinName: "WaterCop Valve"
}
} //
// ______________________________________________________________________________________
def parse(String description) {
log.trace description
def cmd = zwave.parse(description)
log.trace "cmd=$description"
if (cmd) {
log.trace zwaveEvent(cmd)
return zwaveEvent(cmd)
}
state.lastActivity = new Date().time
return null
}
def configure() {
log.debug "Configuration"
updated()
// zwave.basicV1.basicGet().format()
// zwave.switchBinaryV1.switchBinaryGet().format()
}
def installed(){
response(refresh())
}
def updated(){
schedule("0 0 6 * * ?", connectCheck) // once every day at 6 AM
log.debug " connectCheck schedule 0 0 6 * * ? initiated"
}
def initialize(){
updated()
}
def refresh() {
log.debug " refresh performed"
connectCheck()
//return zwave.switchBinaryV1.switchBinaryGet().format()
//zwave.basicV1.basicGet().format()
}
//_________________________________________________________________________________________________
//________________________________________________________________________________________________
//________________________________________________________________________________________________
void connectCheck(){
List<hubitat.zwave.Command> cmds=[]
cmds.add(zwave.switchBinaryV1.switchBinaryGet())
cmds.add(zwave.basicV1.basicGet())
sendToDevice(cmds)
}
def yyyconnectCheck(){
// updates lastactivity so App "Device Activity Check App" will know its still communicating.
//return zwave.basicV1.basicGet().format() //should code as 2002
return hubitat.zwave.commands.basicv1.BasicGet() //.format
// response should be from 2003
}
void xxxxconnectCheck(){
// updates lastactivity so App "Device Activity Check App" will know its still communicating.
sendToDevice(zwave.basicV1.basicGet()) //.format() //should code as 2002
// response should be from 2003
}
//________________________________________________________________________________________________
//________________________________________________________________________________________________
//________________________________________________________________________________________________
def zwaveEvent(hubitat.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
def value = cmd.value ? "closed" : "open"
def event = createEvent([name: "valve", value: value, descriptionText: "$device.displayName valve is $value"])
return event
}
def zwaveEvent(hubitat.zwave.Command cmd) {
return createEvent([:]) // Handles all Z-Wave commands we aren't interested in
}
def open() {
delayBetween([
zwave.switchBinaryV1.switchBinarySet(switchValue: 0x00).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 500)
}
def close() {
delayBetween([
zwave.switchBinaryV1.switchBinarySet(switchValue: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 500)
}
// --- eof ---