Fridge door open loop


#1

1) Give a description of the problem
Got a new Samsung smart fridge. I want the fridge to notify me every minute that the door is left open. It’s been while since I’ve programmed a loop.

2) What is the expected behaviour?
The piston should notify me every minute (The piston is currently set for 10 seconds for testing.

3) What is happening/not happening?
I’m guessing that Webcore is counting past 10 secs after the first announcement, so it’s not doing anything at 20, 30, 40 secs, etc. How do I reset the count? Or designate the past 10 secs?

**4) Post a Green Snapshot of the piston!


#2

I am walking out the door at the moment, but I would recommend doing your testing using 12+ seconds. The 10 seconds is borderline, so testing with that number will not give you consistent results.


Pro Tip:

You can keep your cold air in the fridge during testing by only opening the door a single inch.
(or sometimes, simply inserting a pencil to keep the magnets apart)

Alternatively, you can do testing with a different sensor.
(after temporarily pausing it’s current pistons)


#3

Also, this will only get you one notification. I would suggest:

If contact stays open for 15 seconds
then
    log "Fridge is open"
end if
while contact is open
    message "Fridge is open"
    wait 15 seconds
 end while

Just update the 15 seconds to 60 seconds when you have it working.


#4

Cool…that looks like the right idea. I’ll try it out.

[EDIT] It worked. I couldn’t remember how to get into and out of loops. I’d forgotten that I had to turn on Advanced Statements.