nineismine
(Chad Torkkola)
October 23, 2015, 2:43am
1
Ok I am sure I am missing some newbie element here but I have a device with two physical switches. When a switch is toggled by hand the following event is triggered:
def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCapabilityReport cmd)
{}
In the data sent from the switch I can see which of the two physical switches were toggled but not the current state of the light.
How can I ask Smartthings the current state of the switch on the hub?
Thanks so much!
sidjohn1
(sidjohn1)
October 23, 2015, 3:24am
2
nineismine
(Chad Torkkola)
October 23, 2015, 3:29am
3
I’ve looked at that a couple times but so far haven’t got it to work. Theres clearly a bunch I dont understand about Groovy and variable scope.
nineismine
(Chad Torkkola)
October 23, 2015, 3:30am
4
Here is what gets passed back to my event handler when I toggle a physical switch
multichannelv3.MultiChannelCapabilityReport MultiChannelCapabilityReport(commandClass: [32, 37], dynamic: false, endPoint: 1, genericDeviceClass: 16, specificDeviceClass: 1)
I’m not sure what
“dynamic: false” tells me and I think the two device classes arent useful for what I am trying to do. The end point is useful though!
Ive been reading through the user guide tonight (and im going to read the WHOLE thing through) but I from what it says about command classes that is also confusing to me.
Any idea what this means in the event?
commandClass: [32, 37],
sidjohn1
(sidjohn1)
October 23, 2015, 3:37am
5
hold on are you building a device or a smartapp?
nineismine
(Chad Torkkola)
October 23, 2015, 3:40am
6
This is a device. I am trying to improve the dual relay device type thats floating around because currently when you toggle the physical switch, there is no code to update the hub to let it know the state has changed.
sidjohn1
(sidjohn1)
October 23, 2015, 3:41am
7
nineismine
(Chad Torkkola)
October 23, 2015, 3:49am
8
So that works kinda if I use it like this:
if (cmd.endPoint == 1 )
{
sendEvent(name: “switch1”, value: “on”, isStateChange: true, display: false)
}
Only I need to know if it is on or off before so I can send the proper value :
Im not sure I understand isStateChange but I was hoping that might be part of it.
nineismine
(Chad Torkkola)
October 23, 2015, 5:27am
9
Just solved this!
def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCapabilityReport cmd)
{
log.debug "multichannelv3.MultiChannelCapabilityReport $cmd"
if (cmd.endPoint == 2 )
{
def currstate = device.currentState(“switch2”).getValue()
// log.debug “$currstate”;
if (currstate == “on”)
sendEvent(name: “switch2”, value: “off”, isStateChange: true, display: false)
else if (currstate == “off”)
sendEvent(name: “switch2”, value: “on”, isStateChange: true, display: false)
}
else if (cmd.endPoint == 1 )
{
def currstate = device.currentState(“switch1”).getValue()
// log.debug “$currstate”;
if (currstate == “on”)
sendEvent(name: “switch1”, value: “off”, isStateChange: true, display: false)
else if (currstate == “off”)
sendEvent(name: “switch1”, value: “on”, isStateChange: true, display: false)
}
}
Thanks for the nudge in the right direction!
1 Like