Cycling my hotwater pump based on energy meter and motion


#21

Yes it is, I was careful to do that. I currently have you version running for 15 minute intervals, but the history on the switch it is running on 8 minute intervals before it stopped, motion just restarted it so I will see what it does.

So yours isnt ever turning the switch on for whatever reason, and yes I am using a different relay to test this one with.

11/3/2020, 4:56:52 PM +438ms
+1ms ╔Received event [Motion Living Room].motion = inactive with a delay of 33ms
+69ms ║RunTime Analysis CS > 14ms > PS > 38ms > PE > 16ms > CE
+71ms ║Runtime (38492 bytes) successfully initialized in 38ms (v0.3.110.20191009) (69ms)
+72ms ║╔Execution stage started
+79ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+80ms ║║Cancelling condition #2's schedules...
+81ms ║║Condition #2 evaluated false (5ms)
+82ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+84ms ║╚Execution stage complete. (12ms)
+85ms ╚Event processed successfully (85ms)
11/3/2020, 4:56:35 PM +443ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 32ms
+75ms ║RunTime Analysis CS > 19ms > PS > 37ms > PE > 19ms > CE
+78ms ║Runtime (38493 bytes) successfully initialized in 37ms (v0.3.110.20191009) (75ms)
+79ms ║╔Execution stage started
+86ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+88ms ║║Cancelling condition #2's schedules...
+89ms ║║Condition #2 evaluated true (6ms)
+93ms ║║Comparison (boolean) false is (boolean) true = false (2ms)
+94ms ║║Condition #13 evaluated false (4ms)
+95ms ║║Condition group #1 evaluated false (state did not change) (12ms)
+97ms ║╚Execution stage complete. (19ms)
+99ms ╚Event processed successfully (98ms)
11/3/2020, 4:56:10 PM +201ms
+0ms ╔Received event [Motion Living Room].motion = inactive with a delay of 36ms
+83ms ║RunTime Analysis CS > 21ms > PS > 45ms > PE > 18ms > CE
+85ms ║Runtime (38492 bytes) successfully initialized in 45ms (v0.3.110.20191009) (84ms)
+87ms ║╔Execution stage started
+94ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+96ms ║║Cancelling condition #2's schedules...
+97ms ║║Condition #2 evaluated false (5ms)
+98ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+100ms ║╚Execution stage complete. (13ms)
+101ms ╚Event processed successfully (101ms)
11/3/2020, 4:55:47 PM +697ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 33ms
+72ms ║RunTime Analysis CS > 15ms > PS > 42ms > PE > 16ms > CE
+75ms ║Runtime (38493 bytes) successfully initialized in 42ms (v0.3.110.20191009) (72ms)
+75ms ║╔Execution stage started
+83ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+84ms ║║Cancelling condition #2's schedules...
+85ms ║║Condition #2 evaluated true (5ms)
+89ms ║║Comparison (boolean) false is (boolean) true = false (2ms)
+90ms ║║Condition #13 evaluated false (4ms)
+91ms ║║Condition group #1 evaluated false (state did not change) (12ms)
+93ms ║╚Execution stage complete. (18ms)
+94ms ╚Event processed successfully (94ms)
11/3/2020, 4:55:15 PM +894ms
+1ms ╔Received event [Motion Living Room].motion = inactive with a delay of 35ms
+74ms ║RunTime Analysis CS > 13ms > PS > 46ms > PE > 15ms > CE
+76ms ║Runtime (38492 bytes) successfully initialized in 46ms (v0.3.110.20191009) (74ms)
+77ms ║╔Execution stage started
+84ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+86ms ║║Cancelling condition #2's schedules...
+86ms ║║Condition #2 evaluated false (5ms)
+87ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+89ms ║╚Execution stage complete. (12ms)
+90ms ╚Event processed successfully (90ms)
11/3/2020, 4:54:45 PM +351ms
+0ms ╔Received event [Motion Living Room].motion = active with a delay of 33ms
+61ms ║RunTime Analysis CS > 13ms > PS > 35ms > PE > 14ms > CE
+64ms ║Runtime (38493 bytes) successfully initialized in 35ms (v0.3.110.20191009) (62ms)
+65ms ║╔Execution stage started
+71ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+72ms ║║Cancelling condition #2's schedules...
+73ms ║║Condition #2 evaluated true (5ms)
+77ms ║║Comparison (boolean) false is (boolean) true = false (2ms)
+78ms ║║Condition #13 evaluated false (4ms)
+79ms ║║Condition group #1 evaluated false (state did not change) (11ms)
+81ms ║╚Execution stage complete. (16ms)
+82ms ╚Event processed successfully (81ms)
11/3/2020, 4:54:16 PM +501ms
+0ms ╔Received event [Motion Living Room].motion = inactive with a delay of 33ms
+73ms ║RunTime Analysis CS > 17ms > PS > 42ms > PE > 15ms > CE
+75ms ║Runtime (38492 bytes) successfully initialized in 42ms (v0.3.110.20191009) (74ms)
+76ms ║╔Execution stage started
+83ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+84ms ║║Cancelling condition #2's schedules...
+85ms ║║Condition #2 evaluated false (5ms)
+86ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+88ms ║╚Execution stage complete. (11ms)
+89ms ╚Event processed successfully (89ms)
11/3/2020, 4:52:31 PM +345ms
+2ms ╔Received event [Motion Living Room].motion = active with a delay of 38ms
+82ms ║RunTime Analysis CS > 17ms > PS > 50ms > PE > 15ms > CE
+85ms ║Runtime (38493 bytes) successfully initialized in 50ms (v0.3.110.20191009) (83ms)
+86ms ║╔Execution stage started
+94ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+95ms ║║Cancelling condition #2's schedules...
+96ms ║║Condition #2 evaluated true (6ms)
+101ms ║║Comparison (boolean) false is (boolean) true = false (1ms)
+102ms ║║Condition #13 evaluated false (5ms)
+103ms ║║Condition group #1 evaluated false (state did not change) (13ms)
+105ms ║╚Execution stage complete. (20ms)
+107ms ╚Event processed successfully (106ms)
11/3/2020, 4:02:47 PM +277ms
+1ms ╔Received event [Motion Living Room].motion = inactive with a delay of 35ms
+66ms ║RunTime Analysis CS > 13ms > PS > 39ms > PE > 14ms > CE
+68ms ║Runtime (38492 bytes) successfully initialized in 39ms (v0.3.110.20191009) (66ms)
+69ms ║╔Execution stage started
+76ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+77ms ║║Cancelling condition #2's schedules...
+78ms ║║Condition #2 evaluated false (5ms)
+79ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+81ms ║╚Execution stage complete. (12ms)
+82ms ╚Event processed successfully (82ms)
11/3/2020, 4:02:25 PM +869ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 38ms
+77ms ║RunTime Analysis CS > 17ms > PS > 46ms > PE > 13ms > CE
+79ms ║Runtime (38493 bytes) successfully initialized in 46ms (v0.3.110.20191009) (77ms)
+80ms ║╔Execution stage started
+204ms ║║Comparison (enum) active changes_to (string) active = true (118ms)
+206ms ║║Cancelling condition #2's schedules...
+207ms ║║Condition #2 evaluated true (123ms)
+211ms ║║Comparison (boolean) false is (boolean) true = false (2ms)
+212ms ║║Condition #13 evaluated false (4ms)
+213ms ║║Condition group #1 evaluated false (state did not change) (129ms)
+215ms ║╚Execution stage complete. (135ms)
+216ms ╚Event processed successfully (216ms)
11/3/2020, 4:02:19 PM +831ms
+0ms ╔Received event [Motion Living Room].motion = inactive with a delay of 36ms
+62ms ║RunTime Analysis CS > 13ms > PS > 36ms > PE > 13ms > CE
+64ms ║Runtime (38492 bytes) successfully initialized in 36ms (v0.3.110.20191009) (63ms)
+65ms ║╔Execution stage started
+72ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+74ms ║║Cancelling condition #2's schedules...
+75ms ║║Condition #2 evaluated false (6ms)
+76ms ║║Condition group #1 evaluated false (state did not change) (7ms)
+78ms ║╚Execution stage complete. (14ms)
+79ms ╚Event processed successfully (80ms)
11/3/2020, 4:02:01 PM +997ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 33ms
+146ms ║RunTime Analysis CS > 16ms > PS > 116ms > PE > 14ms > CE
+149ms ║Runtime (38496 bytes) successfully initialized in 116ms (v0.3.110.20191009) (146ms)
+149ms ║╔Execution stage started
+157ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+159ms ║║Cancelling condition #2's schedules...
+160ms ║║Condition #2 evaluated true (6ms)
+164ms ║║Comparison (boolean) false is (boolean) true = false (1ms)
+166ms ║║Condition #13 evaluated false (4ms)
+167ms ║║Condition group #1 evaluated false (state did not change) (12ms)
+169ms ║╚Execution stage complete. (19ms)
+170ms ╚Event processed successfully (170ms)
11/3/2020, 4:00:31 PM +521ms
+1ms ╔Received event [Motion Living Room].motion = inactive with a delay of 40ms
+76ms ║RunTime Analysis CS > 19ms > PS > 45ms > PE > 12ms > CE
+78ms ║Runtime (38492 bytes) successfully initialized in 45ms (v0.3.110.20191009) (76ms)
+79ms ║╔Execution stage started
+86ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+88ms ║║Cancelling condition #2's schedules...
+89ms ║║Condition #2 evaluated false (6ms)
+90ms ║║Condition group #1 evaluated false (state did not change) (7ms)
+92ms ║╚Execution stage complete. (12ms)
+93ms ╚Event processed successfully (92ms)
11/3/2020, 3:59:44 PM +10ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 29ms
+60ms ║RunTime Analysis CS > 12ms > PS > 37ms > PE > 10ms > CE
+62ms ║Runtime (38493 bytes) successfully initialized in 37ms (v0.3.110.20191009) (60ms)
+63ms ║╔Execution stage started
+69ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+71ms ║║Cancelling condition #2's schedules...
+72ms ║║Condition #2 evaluated true (5ms)
+75ms ║║Comparison (boolean) false is (boolean) true = false (1ms)
+77ms ║║Condition #13 evaluated false (4ms)
+78ms ║║Condition group #1 evaluated false (state did not change) (11ms)
+79ms ║╚Execution stage complete. (16ms)
+80ms ╚Event processed successfully (80ms)
11/3/2020, 3:58:22 PM +685ms
+1ms ╔Received event [Motion Living Room].motion = inactive with a delay of 35ms
+67ms ║RunTime Analysis CS > 15ms > PS > 41ms > PE > 11ms > CE
+70ms ║Runtime (38492 bytes) successfully initialized in 41ms (v0.3.110.20191009) (67ms)
+70ms ║╔Execution stage started
+77ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+79ms ║║Cancelling condition #2's schedules...
+79ms ║║Condition #2 evaluated false (5ms)
+80ms ║║Condition group #1 evaluated false (state did not change) (6ms)
+82ms ║╚Execution stage complete. (12ms)
+83ms ╚Event processed successfully (83ms)
11/3/2020, 3:57:33 PM +51ms
+1ms ╔Received event [Motion Living Room].motion = active with a delay of 36ms
+75ms ║RunTime Analysis CS > 17ms > PS > 42ms > PE > 15ms > CE
+77ms ║Runtime (38467 bytes) successfully initialized in 42ms (v0.3.110.20191009) (76ms)
+78ms ║╔Execution stage started
+84ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+86ms ║║Cancelling condition #2's schedules...
+87ms ║║Condition #2 evaluated true (4ms)
+90ms ║║Comparison (boolean) false is (boolean) true = false (1ms)
+91ms ║║Condition #13 evaluated false (4ms)
+92ms ║║Condition group #1 evaluated false (state did not change) (11ms)
+94ms ║╚Execution stage complete. (17ms)
+95ms ╚Event processed successfully (95ms)

I am out of replies apparently, but I did just add:
define
boolean Pump_Off = true;
end define;

I will test this

ya, I updated to your latest version, it did do that, unfortunately with the last version, it is still stopping the countdowns on new motion events, so I basically get one press every time it sees motion if I am occupying the space.

Well, I really wish I could reply, it says I have to wait 17 hours so see you on the otherside, but both of these are not working as intended.

Thanks for all the help

Ya, that is definitely the issue that is keeping this from being a simple IF THEN, its acting like a WHILE THEN. Equis script seems to be getting past that, since it runs and checks the time since the value changed, but for some reason that is triggering an ON command 2-3 times within a minute, and also firing at an odd interval like 8 minutes when its set to fire at 15 minutes.

I like the way this reads better too, but I did try doing that in one of the attempts it does get around needing to initialize the variable, I did find that in Equis script I had to add something to reset the pump state anyway, because it at one point got caught in Pumprunning = True, but outside of all the windows to trigger an ON it was running to nowhere.

Maybe I need to do this in a smartapp instead, I know enough of groovy to do it, but since they are retiring that its a waste of time I presume, and I haven’t played with Javascript


#22

I forgot to initialize the boolean variable.


#24

I don’t think it will work that way…Each time the motion sensor changes state, the piston will run from top to bottom and the Pump_Off will always be true.

Just for the record…I hate WAITS…ugh.


#25

I think you are having issues with the value of the local variable. Might I suggest that you try flipping the logic. Instead of checking if Pump_off is true, try checking if Pump_on is false. An unitialised variable will evaluate as false, so that will let get you up and running, and then the piston is explicitly setting the values from then on.

@Qwertypo, if you haven’t realised, the ‘define’ section is evaluated every time the piston runs. So as you want to use the variable to maintain state you can’t intitialise it there.


#26

One problem that I cannot solve is the re-activation of the motion sensor during the waits.


#27

could you not have two pistons, one that is triggered by the motion sensor that only calls the 2nd piston when it has been x amount of time since the last motion, IE set the time of the last motion to a variable and then only call the 2nd piston if it has been x time since that variable. Then have the 2nd piston execute the cycling of the water heater??


#28

I’ve tried simplifying things to see if I can sort out why its doubling up events, or getting stuck. Not much progress towards that.

I am using line 57 to try to catch when it happens to miss a turn on and it gets stuck out of sequence. It doesn’t work.

And even with setting it to only one IF to turn ON at line 45 I am still getting multiple ON events in one minute, or early ON events. A bit baffled. Even if it runs the button twice, the cycle count isn’t reflecting that…


#29

I think part of the problem is the motion sensor. This piston triggers when the motion sensor turns active. But when the motion sensor goes inactive 30 seconds later, that is a change of state for the trigger and this piston fires again and executes from top to bottom again.


#30

So maybe what millsjq said above about making it two seperate pistons is the answer.


#31

Also, it appears that scheduled events get cancelled even though we have “Never Cancel” switched on? I have struggled to understand this one for quite some time.

I think we would also have the same problems with two (or more) pistons.


#32

I have been a bit tied up lately, but I believe this should do the trick:


Note:

This piston runs top to bottom each time the sensor goes active or inactive… but the sequence of events should only run when the room is first entered. (the extra logs will help to confirm this)

Also, I would turn Trace on, and set logging level to Full during testing.


#33

Thanks @WCmore. I think that works. I knew you could throw this together in your sleep. I think we had an iteration close to your suggestion, but it did not work.


#34

Ya this definitely works. I’d really like to modify it to make it easy to set the cycle period and how many cycles, so I can fine tune it to my needs once I’ve seen how it goes.

Is it possible to use a loop with this to have it cycle a set amount of times instead of repeating the code?

Thanks for pulling this together everyone.

These defined variables is basically what I am hoping to achieve for easy adjustment:


#35

I try to avoid looping whenever possible, but here is your first request:

(the top two variables can be adjusted)


Copying code via Drag & Drop is the easiest way to do this.


Note:

Your “3cv0u” piston only runs when the motion sensor changes…
(as seen by the lightning bolt in the left margin)


#36

I guess I am missing something, since I see a lightning bolt in yours as well. Just for the sake of learning, what is different about yours that allows it to keep running despite the motion events?

Thanks


#37

The motion events will still keep coming in… each and every time the sensor turns active, as well as each time it turns inactive.

So my logic does not prevent the piston from running.

The only time the sequence of events takes place is when first entering the room. At that point, the TCP forces that block to continue thru to the end… regardless of what else changes.

At the end of the sequence, the variable is reset, to prepare itself for the next cycle.


Basically, the lightning bolts represent what kicks off (or begins) the piston.


#38

Gotcha, so what is preventing us for doing the same with a LOOP versus a DO?

Sorry, not trying to needlessly complicate it, but I was actually hoping once I had this portion working to progress it to - Motion Laundry Room - 3 or 4 cycles, Motion Bathroom - 1 cycles


#39

Nothing is stopping you from trying…

I have just learned from experience to avoid looping whenever possible.


We all have our own techniques, but for reliability & smooth logic, I try to limit each piston to a single trigger.
(and making sure that each event only triggers a single piston)


#40

So is it then if I have two motions sensors, both with the function to call for the pump, can they both share the same Pump_On Variable, so no need to run it if the other one already made the call?


#41

Yes, if you use a @global variable… Although it will not update until the first WAIT happens.