The code originally was this:
def switchOn(node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, On$node</FONT>"
def cmds = []
cmds << new hubitat.device.HubAction(command(encap(zwave.basicV1.basicSet(value: 0xFF), node)))
cmds << new hubitat.device.HubAction(command(encap(zwave.switchBinaryV1.switchBinaryGet(), node)))
sendHubCommand(cmds)
}
Which is close to being correct, we do not support sending a List of HubActions from sendHubCommand, you must use HubMultiAction if you want to send a list of actions and you must send a hub command from a parent device. In the code you posted above you are returning the commands to the child device and the child device is returning them to system.
your parent device:
def switchOn(Integer node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, ${device.deviceNetworkId-ep}</FONT>"
def cmds = []
cmds << new hubitat.device.HubAction(command(encap(zwave.basicV1.basicSet(value: 0xFF), node)), hubitat.device.Protocol.ZWAVE)
cmds << new hubitat.device.HubAction(command(encap(zwave.switchBinaryV1.switchBinaryGet(), node)), hubitat.device.Protocol.ZWAVE)
cmds
}
which is the same as this (with the explicit return):
def switchOn(Integer node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, ${device.deviceNetworkId-ep}</FONT>"
def cmds = []
cmds << new hubitat.device.HubAction(command(encap(zwave.basicV1.basicSet(value: 0xFF), node)), hubitat.device.Protocol.ZWAVE)
cmds << new hubitat.device.HubAction(command(encap(zwave.switchBinaryV1.switchBinaryGet(), node)), hubitat.device.Protocol.ZWAVE)
return cmds
}
Then in your child device you have this:
def on() {
log.debug "Switching on $device.label, $device.deviceNetworkId"
parent.switchOn(splitChannel(device.deviceNetworkId))
}
which is the same as this:
def on() {
log.debug "Switching on $device.label, $device.deviceNetworkId"
return parent.switchOn(splitChannel(device.deviceNetworkId))
}
So in order to fix this, there are a bunch of different ways (Note that the "def" was changed to "void" since your method is not returning anything)
this:
void switchOn(Integer node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, ${device.deviceNetworkId-ep}</FONT>"
sendHubCommand(new hubitat.device.HubAction(command(encap(zwave.basicV1.basicSet(value: 0xFF), node)), hubitat.device.Protocol.ZWAVE))
sendHubCommand(new hubitat.device.HubAction(command(encap(zwave.switchBinaryV1.switchBinaryGet(), node)), hubitat.device.Protocol.ZWAVE))
}
or do this:
void switchOn(Integer node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, ${device.deviceNetworkId-ep}</FONT>"
def cmds = new hubitat.device.HubMultiAction()
cmds.add(new hubitat.device.HubAction(command(encap(zwave.basicV1.basicSet(value: 0xFF), node)), hubitat.device.Protocol.ZWAVE))
cmds.add(new hubitat.device.HubAction(command(encap(zwave.switchBinaryV1.switchBinaryGet(), node)), hubitat.device.Protocol.ZWAVE))
sendHubCommand(cmds)
}
or this:
void switchOn(Integer node) {
log.debug "<FONT COLOR=RED>Turning on Powerstrip - ${device.deviceNetworkId} node ${node}, ${device.deviceNetworkId-ep}</FONT>"
def cmds = []
cmds << command(encap(zwave.basicV1.basicSet(value: 0xFF), node))
cmds << command(encap(zwave.switchBinaryV1.switchBinaryGet(), node))
sendHubCommand(new hubitat.device.HubMultiAction(cmds, hubitat.device.Protocol.ZWAVE))
}