Piston Trouble: Expression Variable not Triggering Actions


#1

1) Give a description of the problem
Help with a piston that’s not triggering push notifications. I suspect something in my expression is wrong.

2) What is the expected behaviour?
At noon, I want this piston to check the duration value of each of the segments. If any meet the prescribed criteria, send push

3) What is happening/not happening?
The dates/duration of the variable values are calculating correctly, I just can’t make it trigger based on the final calculation comparison. The expression is format duration($now-@variable). It calculates and displays in 23d 17h 21min format. I’ve tried making the comparison “30”, “30d”, and “30 days” and haven’t been able to get it to trigger at all. I’m sure I’m just not giving it the input it wants. None of the conditions are triggering so I know it’s something equally wrong across the board.

**4) Post a Green Snapshot of the piston

5) Attach logs after turning logging level to Full
I don’t think this applies here but if I must, I’ll either need to wait till noon tomorrow or reconfigure it for a time when I can capture logs.


#2

I didn’t really look into the piston in detail but if you’re going to make comparison, you might have to extract the days part of formatDuration() from the result so you can make a proper comparison between integers.

Rough expression, test with your data, should be able to compare with integer 30 or 14 (no ’ days’).

replace(formatDuration([email protected]_Robot_Vacuum_Filter_Change_Rosie,true,'d'),' days','')

Substitute your correct global variable


#3

Thank you! I’m not new to WebCore but I AM new to the use of expressions and this was one of the first I tried on my own. Everything you suggested worked perfectly and I can ‘understand’ it well enough. This teachable moment will benefit me in future work.

I knew there was more complex logic in expressions and honestly that’s why I never tried to tackle it. This was a great learning experience for me.