Feed the dog button


#1

1) Give a description of the problem
Hello webCoRE community! This is my first piston, so please be patient with me. I created this piston to help keep track of feeding the dog. Logs seem to show button presses, but my boolean variables don’t seem to be changing from “false” to “true” and I am getting notifications even though the button was pressed.

2) What is the expected behaviour?
Button press in the morning changes variable 1 from false to true. At 8AM if variable is false then send notification
Button press in the afternoon changes variable 2 from false to true. at 9PM if variable is false then send notification
Variables both reset to false at 12:01AM

3) What is happening/not happening?
Variables are not changing to true even though logs show button presses. As a result, notifications are being sent regardless of button press.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
|+0ms|╔Received event [Home].time = 1582639200000 with a delay of -857ms|
|+191ms|║Setting up scheduled job for Tue, Feb 25 2020 @ 9:00:00 PM CST (in 46800.666s), with 2 more jobs pending|
|+198ms|╚Event processed successfully (198ms)|
|2/25/2020, 7:14:18 AM +717ms|
|+5ms|╔Received event [Button].button = pushed with a delay of 99ms|
|+174ms|║Setting up scheduled job for Tue, Feb 25 2020 @ 8:00:00 AM CST (in 2741.11s), with 2 more jobs pending|
|+186ms|╚Event processed successfully (186ms)|
|2/25/2020, 12:00:59 AM +142ms|
|+1ms|╔Received event [Home].time = 1582610460000 with a delay of -858ms|
|+617ms|║Setting up scheduled job for Tue, Feb 25 2020 @ 8:00:00 AM CST (in 28740.242s), with 2 more jobs pending|
|+627ms|╚Event processed successfully (627ms)|
|2/24/2020, 8:59:59 PM +156ms|
|+0ms|╔Received event [Home].time = 1582599600000 with a delay of -845ms|
|+397ms|║Setting up scheduled job for Tue, Feb 25 2020 @ 12:01:00 AM CST (in 10860.448s), with 2 more jobs pending|
|+404ms|╚Event processed successfully (404ms)|
|2/24/2020, 7:45:16 PM +56ms|
|+2ms|╔Received event [Button].button = pushed with a delay of 119ms|
|+145ms|║Setting up scheduled job for Mon, Feb 24 2020 @ 9:00:00 PM CST (in 4483.8s), with 2 more jobs pending|
|+157ms|╚Event processed successfully (157ms)|


#2

Try this,
Don’t define the variables at the beggining of the piston - line 17-18
Each time the piston executes, your variables are assigned by the piston FALSE.

And instead of ONLY WHEN, use the button pressed as a single trigger and create your conditions as a nested IF

IF button 1 is pressed (Trigger)
then 
     IF Time is between X and Y
     Do this do that
     
     IF time is between A and B
     Do this do that

#3

Thanks, I’ll try the nested IF for the times, but I’m a bit confused on the variables. I understand what you mean by they’ll be defined as false, but where do I define them where they will change?


#4

let me understand this,

you want to make sure your dog/cat has eaten breakfast and dinner and IF NOT you want to get warning.
And you are pushing a button when he is fed.

am i correct?


#5

if my assumption is correct, it can be something like this:

boolean FOOD: unassigned

IF button is pushed 
and 
IF time is between 5.00am and 8.00am 
then 
set variable food = TRUE

Everyday at 12:00 noon 
Set variable food = FALSE

IF button is pushed 
and 
IF time is between 6.00pm and 11.00pm 
then 
set variable food = TRUE

Everyday at 11:59pm 
Set variable food = FALSE

(now checking the variable twice a day)

Everyday at 11.55am 
IF variable food is FALSE 
Then 
Send push notification

Everyday at 11.55pm
IF variable food is FALSE 
Then 
Send push notification

#6

Yes, you are correct. Two notifications per day. In your example, where does the boolean variable “FOOD” go? If in “DEFINE” wouldn’t the same thing happen as in my current piston?


#7

In the “define” section, when it shows (no value set) like this:

pic

then that variable will only change when code in the body of the piston changes it.

This is my preferred method for any variable that changes…


#8

Same place you have it before (Before the coding starts) Line 17
and as @WCmore stated, you don’t assign any value.


#9

Ok, so this makes sense then. I can just leave my piston the same and change the initial value to “Nothing selected” and should work. I’ll give that a shot. Thank you so much!


#10

Ok, I’ve made some changes to the piston, and it still does not seem to be working consistently. I think, for some reason, the boolean variable is not changing on button press. At least it didn’t this morning. The button was pressed. I can see that it was at 7:01AM on the device history in the app. (I’m using the new one.) But, I still received a text at 8AM that the dog was not fed. I am assuming the piston did not change to “true”. Here’s a updated green snapshot. Hopefully someone is still lurking on this post that can help. Thanks!!


#11

I personally stay away from Zwave butttons. They are not consistent in my experience.
My fish tank uses OPEN/CLOSED sensor.

But just to test it,
after both lines 29 and 34 add send SMSs,

But for the message line chose VARIABLE instead of value.
Or you can use expressions.

In this case you’ll see when/IF the variable is changing or not. The piston will send you the current variable state.

note: For some odd reason I always get confused using ELSE in Webcore (maybe some form of dislexia) I have well over 100 pistons and never needed ELSE. I would get rid of the ELSE parts and test it again.


#12

For testing purposes, I’m able to see the button press was received via the SmartThings app, but yeah, I guess I can add something to ensure webCoRE is getting it too.

Can you explain this more? I’m not sure how this works.

I feel like the ELSE parts are needed for the variable to reset to “false”. Therefore if the button is not pressed during the next scheduled event, it will react accordingly.
Thanks again for all your help.


#13

You need to reset the variable, that for sure but I was just saying, doing that without the ELSE.

Expression lets you write more comlex messages.
I was having a problem with a variable, it was not changing.
in expressions text box (same place as you choose what type of message you want to send)

I would write:
“The movie room variable should be TRUE and it is :” {@movieroom}

so the piston reads the real value of the variable and sends it to you.
When it’s only TRUE or FALSE you may not need expressions, but my room had 5 different phases.


#14

Here is a piston i’d recommend. Not the best way of doing it but very simple. You can download with the code and test it if you’d like to.

And the second one is what I’m using for my fish tank.
it keeps sending messages until the fish are fed. you might want to take a look at it.