Power Outlet Piston Design Help

piston

#1

1) Give a description of the problem
Aeotec Outlet 6 I- when it detects power for 1 hour

2) What is the expected behaviour?
I want the outlet to turn off, then turn back on.

3) What is happening/not happening?
Unsure how to create the piston

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)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Something along the lines of…

IF Outlet power is greater than 5W for 60 minutes
  Then
    With Outlet
      turn off
      wait 4 seconds
      turn on
END IF

#3

I did this, but i like your thought.


#4

I have a few observations.

  1. You have an empty if/then at line 32. You can remove that and just use the “with”
  2. Why are you using Toggle and off and on?
  3. I would insert a wait of a few seconds between the off and on commands to allow time for those actions to happen. Otherwise, network congestion may interfere with proper execution.

#5

added this but seems to be not working.


#6

Do you really need the boolean variable?


#7

how about this


#8

Why not just…

IF Outlet 1's power stays greater than 5W for 1 minute
  Then
    Do
      Send PUSH
      with Outlet 1
        turn off
        wait 4 seconds
        turn on
END IF

#9

I have tested the above code, and it works.


#10

Thank you. This is what I currently have and it turns off, but will not turn back on after 10 seconds. thoughts?


#11

Now that I look at it again, my suggested code above may not work. When I have time, I will dig a little further. One quick note…I am a fan of small, task specific pistons. I find them much easier to debug than larger, more complex pistons. I think you could break your task into two small pistons.

Piston 1
If Outlet 1 power stays greater than 425W for 60 minutes
  Then turn off Outlet 1

Piston 2
If Outlet 1 changes to off
  Then
    wait 10 seconds
    turn on Outlet 1

When I get free, I will put more thought into this.


#12

I also noticed that when my heater is plugged into my outlet, the usage in Watts varies often and that triggered my test piston every few seconds.



#13

You have turned off the switch so I’d imagine a new power reading will be sent and there is a good chance it will turn up in your wait. The if will return false and the default Task Cancellation Policy (TCP) will kill your scheduled task. If you edit either the with or the wait you’ll find a setting to change the TCP to ‘never cancel’. That’ll make sure the turn on still happens.


#14

I still struggle with my understanding of TCP.


#15

You are extremely helpful. That worked!!! for anyone else wanting to know where this is set, please see this url. How TCP is set to NEVER - when WAIT is not working in your piston

Anyone needing the piston here is the final image that works perfectly.


#16

I want to also say thank you as well for your help. You stopped and took the time to even read and try to help and get me going in the right direction. Thank you so much to you as well!!!


#17

You are welcome! Take a look at my last sample piston above. My power plug was spamming my network every few seconds because of the frequent power changes. The power level changed every few seconds. And since it was above 100W (my trigger), it triggered my piston every few seconds. Not desirable. I’m not sure how your outlet works, but you might consider using a different trigger, such as Outlet 1 stays on for XX minutes, or similar. Just food for thought.


#18

good thought!!! Thank you so much. Let me review as well and see if I can get it work based on the outlet versus power consumption.


#19

Oh dear, THAT thread. I’d have to correct a number of my comments in that thread as although I knew how things worked I’d got myself confused by the wake up behaviour after a period of not having been using webCoRE for a while.

The bottom line is that if you have a piston like:

if condition 1
then
    if condition 2
    then
        with a light
            wait 10 seconds
            turn off
        end with
    endif
endif

If the piston runs and conditions 1 and 2 evaluate as true the piston would start a task (with block) with a wait for ten seconds. As it is over five seconds the piston would create a scheduled task for ten seconds time - the task being the one it hasn’t finished yet, which involves turning off the light and going on to the rest of the piston - and it would exit. This scheduled task only exists because conditions 1 and 2 were true.

If something else (anything at all) causes the piston to run during the ten second wait it is quite possible that conditions 1 and/or 2 are no longer true. But hang on, there is this scheduled task that is only there because they were true. What to do about it? The default Task Cancellation Policy says to cancel any scheduled tasks that were created when the conditions evaluated differently. If you don’t want that to happen you can specify the TCP as ‘never cancel’ on an individual task basis.

Now if the new piston does evaluate as true for conditions 1 and 2, that is a whole new story. That is where the Task Execution Policy and Task Scheduling Policy sometimes come into play.