Piston with global variable "does not change" as trigger, not triggering as expected


#1

1) Give a description of the problem
I have a piston with a global variable as a trigger. If the variable is not updated in the last 30 minutes (this variable tracks motions from an external device via IFTTT), the light should turn off. I did look around the forum and found similar posts on piston triggers. I also found this post by bangali, and based on that I feel that this should work. It actually did seem to work for a couple of hours after I set it up but then it simply stopped working. Can someone please help me figure out what I’m doing wrong?


2) What is the expected behaviour?
The light should turn off if the global variable has not been updated in the past 30 minutes AND if the light is currently on

3) What is happening/not happening?
The light is not turning off when the variable is not updated in the past 30 minutes.

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)


#2

Try forcing the subscription on the global variable. Edit the IF statement then click the cog icon on the bottom then in Subscription method, change to Always Subscribe.


#3

Would need to see logs.

The only thing that wakes this piston is the global variable changing, or the timer on the stays.

Once the timer on the stays fires, this piston will only run if the global changes.

Logs would help see this.


#4

Thanks @eibyer and @E_Sch, I am doing more testing and changed the wait time to 10 minutes. I also enabled “always subscribe” as suggested. In this morning’s test, it seems to work as expected. This is similar to the behavior I was seeing yesterday where it seems to work at first, but then stops working altogether. Below is a screenshot of the logs from this morning - where it worked. What would be the most reliable way to get this work consistently? A while loop that keeps checking the global variable every 10 minutes while the light is on?


#5

So it seems you want this piston to trigger if the global changes, or if the light switch changes

So lets look at some cases:

  • light is off - so you really don’t wan to do anything
  • light is on you do want to do something

What type of values are you putting in the global? is this a time, or active/inactive?

  • you really want to know if motion is active or inactive
  • the challenge with a global is that if you set it to active, and then set it to active again, it did not change.
  • this may not be an issue, but it is important to understand what type of data is coming in and at what frequency.
  • you could have your ifttt thing send ‘active:number’ and ‘inactive:number’ where number is changing each time you update.

I’m guessing you want if you get a motion inactive and the light is on, wait 20 mins and turn it off

if you get a motion active, wait for the inactive then wait 20 mins to turn it off.

There are many pistons both in this forum and HE that are simple motion active/inactive turn on off a light with or without a wait.

The challenge with changes, it seems you want to know how it changed, not only that it did change.

You also want to track the light being on or not. You now have to decide what you want to have happen if the light is turned off, and motion is still active. ie someone walks back in space, but you don’t know if you get another motion event (or if it changes), to know to turn the light back on if manually turned off).

also see:


#6

@E_Sch I appreciate the detailed answer. The IFTTT event is setting the global variable to the current time in epoch time. This guarantees that every time I get an event, the value will be different. While running some tests last night, the light did seem to turn off after no motion was detected (as I would expect). But it is still not consistent.

Today, I changed the timer to 15 minutes. I’ve captured an instance where it does not seem to work as shown in the logs. Please see the screenshot below:

Why would the event at 7:15pm not schedule a new timer 15 minutes later?


#7

I pushed an update, HPM repair to get it

Please try this again.


#8

Did not see this until now. I was a bit confused by the message. Are you one of the maintainers of webcore? I didn’t know. If yes, thanks for going the extra mile for this. Took me a while to decipher what HPM means (Hubitat Package Manager). I actually installed the version I have manually and HPM ended up installing another copy. I manually copied the code of the newly downloaded version into the old version and saved.

I just started testing the piston in question and will advise if I see any improvement.

Thanks for your help.