Switch off event while already off?


#1

I have a Zipato switch, it basically is an RFID tag reader that has an “Away”/“Home” button on it. One turns the button on, the other turns it off. Works great in webCore.

However, I was hoping that I could repeat one of the buttons and have it perform an operation.

What I have setup in my piston to trigger when “zipato switch is on” and “zipato switch is off”.

I can watch in my ST logs and I see that an event was generated when I repeat one of the buttons. But I can’t seem to get my piston to fire again. It only seems to do anything when the state of the switch changes?

Thanks in advance!


#2

Can you share the pisto? And logs. That helps a lot more


#3

Code looks like:


In my ST logs I see:

And I do not see any logs in the WC Dashboard logs when the second event is fired.

Does that make sense?


#4

Still kind of vague what is really happening here. However, try changing the if statements from is on/off to changes to on/off


#5

I actually had changed it from that to what it is now thinking that was the cause.


#6

See if you can catch it with an on events from Zipato switch.


#7

Not sure how to do that exactly? I know how to create an if clause, select the physical device, then I get a few things to compare (switch is what I am using):


#8

One thing I don’t understand is when I select the statement for the switch there is a property on the upper right for “Subscription Method” Not sure if that is related to when this piston receives an event?


#9

While editing a piston, go to Options (top right), enable Show Advanced Statements if not already on.

This will be available…


#10

Oh cool, hadn’t seen that. So I am not seeing any event… Maybe this is an issue with the device handler?


#11

I haven’t written a device handler before, but I am a software engineer (just not a groovy one).

I poked around the code of the device handler to see if I could figure out why no events were getting sent when the switch command is given a second time. The code is here.

I am seeing a message in the log when the second event happens. it is basically the message you see here and

I put info statements in the on and off functions thinking those were getting called (and I see that they checked that state changed), but I don’t see those messages in the logs.

Any ideas? Thanks in advance!


#12

I wouldn’t expect to to be the handler since you’re seeing the events in your SmartThings log.

Did you change add an “on events from Zipato Switch” trigger like eibyer suggested? If you put your two conditions (on and off) inside the event trigger, in theory it should behave the way you would like it. If it doesn’t, there are other options left to try. I’d start with his suggestion though if you haven’t already.


#13

I added this to my piston:
image
I didn’t see anything appear in the dashboard logs when the second event was fired.


#14

Can you disable command optimization and try again, see if the second push generates anything in your log files? Command optimization prevents webCoRE from sending redundant commands to devices (if a switch is off and a piston encounters a ‘turn off’ command, it will skip that step). I’m not sure how/if it affects incoming triggers, but it’s worth a try.

To do this, go to the upper right corner of your Piston Edit screen and click options, then click the box that ‘Show piston settings’:
image

Click on the word ‘settings’ that will display in your piston, probably around line 11.

Click on the gear cog to expand options, and then disable command optimization:


#15

Just tried that, I see this in my piston:
image

Same behavior


#16

I’m afraid if you see it in your ST logs but nothing is recorded in webCoRE, I’ve run out of skills to help you out. :frowning:

Maybe @Robin has an idea, or can explain what’s happening here.


#17

I see some custom attributes in the DTH which may be of use, try one of the following:

on events from Zipato’s lastsetby
DO

or

on events from Zipato’s webCoREPush


#18

I added these:
image
But still nothing gets logged when I try to trigger a second time.


#19

perhaps tweak the handler to the following and try listening for events from ‘webCorePush’ again:

def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd) {
	// COMMAND_CLASS_ALARM_V2 0X71
	def dateStamp = getDateStamp()
    def userNumber = cmd.eventParameter.toString().substring(1,2).toInteger()
    def userName = [who1, who2, who3, who4, who5, who6, who7, who8, who9][userNumber - 1]
    if(userName == null){
    	userName = "User $userNumber"
    }
    def result = []
	if (cmd.zwaveAlarmType == 6) {	
       
       switch(cmd.zwaveAlarmEvent) {
			case 5:
            	// Recognised user pressed "Away"
				info "$userName set device to Away mode at $dateStamp"
                sendEvent(name:"user", value: "Away by $userName at $dateStamp")
                sendEvent(name:"webCoREPush", value: "I changed briefely")
                sendEvent(name:"webCoREPush", value: pushNotifications?"Yes":"No")
                sendEvent(name:"webCoRESMS", value: smsNotifications?"Yes":"No")
                sendEvent(name:"lastsetby", value: "$userName")
                result << createEvent(name:"switch", value: "on")
            	break
			case 6:
            	// Recognised user pressed "Home"				
                info "$userName set device to Home mode at $dateStamp"
                sendEvent(name:"user", value: "Home by $userName at $dateStamp")
                sendEvent(name:"webCoREPush", value: "I changed briefely")
                sendEvent(name:"webCoREPush", value: pushNotifications?"Yes":"No")
                sendEvent(name:"webCoRESMS", value: smsNotifications?"Yes":"No")
                sendEvent(name:"lastsetby", value: "$userName")
 			    result << createEvent(name:"switch", value: "off")                
                break
			default:
				log.warn "Received unrecognised alarm status: $cmd"
				break
		}
	}

#20

Yea so that worked, but I am getting two events for the webCoREPush. Is that because the value changed from one value to the next?