Why can't I get this simple piston to work?


#1

1) Give a description of the problem
I get notifications for the device that started to the piston, whether it was on or off. Then I get x amount of notifications for the incorrect light.

2) What is the expected behavior?
If a light is on for more than 10s, I want a PUSH notification for that device and only that device.
I do not want a repeat notification until that light turns off, then stays on again for 15s.

3) What is happening/not happening?

  1. It works at first, if all switches are off and Switch #1 turns on for 15s, I get the notification.
  2. After is the problem, so if Switch #2 turns on for 15s, I get two notifications saying Switch #2 has been on.
  3. If Switch #3 turns on for 15s, I get three notifications saying Switch #3 has been on.
  4. If Switch #1 turns off for 15s, I get two notifications saying Switch #1 has been on.

So the currentEventDevice is always the light that changed or caused the piston to check, then I receive x number of notifications for each light.
Is there an easier way to do this besides making 10+ different pistons - one for each light.
Basically, If Light #1 is On for 15s, then PUSH.

**4) Post a Green Snapshot of the piston


#2

I’m not sure I fully understand the application, but you might try saving the devices to a list variable, and then sending the output of that variable as a push message.

For instance at the beginning:

define:

device: “deviceList” (empty)

And in the body:

IF any of “your lights” says on for 10 seconds
—In the same menu selection, select the gear icon at the bottom gear and select "Store the list of matching devices into variable “deviceList”.

THEN
with Location
do
Send PUSH notification: {“The following lights have been on for 10s: {deviceList}.”}


#3

I think the way webCoRE determines “stays on for 10 seconds” is by setting a wake-up timer for itself 10 seconds after an ‘On’ event to see if the device is still on. As you’ve found, this works great for the first one. The problem is when a second device in your list turns on, the piston sets a wake-up event for 10 seconds later and now you have TWO devices that meet your criteria.

You could work around this by adding in an age criteria. Try adding another condition to your IF statement (using AND), select expression, and type this in the box:

age([$currentEventDevice : switch])

What this will do is determine how long the switch has been in a given position in milliseconds (so 11,000 is 11 seconds). This will only evaluate true for devices that changed less than 11 seconds ago, eliminating messages for devices you’ve already been notified about (but not filtering out items that just hit the 10 second criteria).


#4

I am still getting the same behavior when turning the lights off.


#5

Can you post your latest snapshot and a log file? Can’t picture how it’s doing that but can fix it one we can see in the logs.


#6

I’ve read in some other threads where the Minions have responded that this is indeed how the “stays” feature works. It’s starts a timer.


#7

The problem with my original piston is that turning a switch off will trigger the On timer for the other Switches.

I’ve changed it around but still not getting the results I want.
The problem with the piston below is if a switch turns on during the wait period.


#8

Waiting 15 seconds is not going to filter the results of the IF condition like the expression I posted in post 3.

Have you tried adding that?


#9

That works but turning a switch off triggers the piston too.
How do I make it not trigger when a switch is turned off?

1/2/2018, 10:58:38 PM +230ms
+0ms ╔Received event [Home].time = 1514951919021 with a delay of -792ms
+84ms ║Runtime (40224 bytes) successfully initialized in 36ms (v0.2.101.20171227) (83ms)
+86ms ║╔Execution stage started
+135ms ║║Executed virtual command sendPushNotification (9ms)
+830ms ║║Executed virtual command sendPushNotification (7ms)
+877ms ║║Executed virtual command sendPushNotification (7ms)
+879ms ║╚Execution stage complete. (794ms)
+881ms ╚Event processed successfully (880ms)
1/2/2018, 10:58:28 PM +911ms
+1ms ╔Received event [Kitchen Bar Light].switch = on with a delay of 127ms
+82ms ║Runtime (40223 bytes) successfully initialized in 38ms (v0.2.101.20171227) (80ms)
+83ms ║╔Execution stage started
+119ms ║╚Execution stage complete. (36ms)
+121ms ║Setting up scheduled job for Tue, Jan 2 2018 @ 10:58:39 PM EST (in 9.99s), with 2 more jobs pending
+128ms ╚Event processed successfully (128ms)

My old piston in CoRE worked perfect:


#10

I’m new here and likely to be wrong, but would it be “and $currentEventDevice’s switch is off”?


#11

Is that full logging? I can’t see where it evaluated the age expression to understand why it sent 3 push messages.


#12

I just tested it aga and it isn’t pushing multiple notifications now.
The problem is that it triggers when a light switches off.


#13

But does the expression evaluate true? The piston will trigger on switch events (on or off) for everything in your list… There’s no changing that.

You could add a restriction to see if that limits the amount of processing but the piston will still be triggered.


#14

it is true but it repeats when the trigger goes off.
This seems like a simple piston, is this really the easiest way to do it?


#15

I’m not sure I follow. You’re getting repeat messages when something else opens or closes?