Jump to content

Please help with program


Recommended Posts

37 minutes ago, BobM99 said:

Hi,

I'm trying to write a simple program to reset the energy meter on a Zooz power switch every 30 minutes.

I attached a photo. This doesn't seem to be working. 

Please help. Thanks.

Bob

UD.jpg

You have a useless Repeat construct. The lines to be repeated are found indented under the repeat loop construct command.

To terminate the repeat loop use Repeat 1 times after the lines you want repeated.

Repeat every 30 minutes
.....do something in a loop
Repeat 1 times
do the rest only once.

 

If you want two condition you can use this construct

Repeat 20 times
....do something 20 times
....Wait 20 minutes
Repeat 1 times
Do more lines only once
Etc...

 

Move your Repeat line up one.

 

Link to comment

Am also wondering if in @BobM99 case, if he reversed the two program lines, will the program turn false during the reboot, which would stop the repeat, and then turn true again once on, causing a loop effect less than the 30 minutes. 

My suggestion would be to have the following, assuming he wants it running all the time:

Program 1:

IF time is 2am

Then run THEN of program 2

Program 2: 

THEN:

repeat every 30min

reset zoom.

This way, the program will always be running and if it were to stop due to reboot etc, it will start up again every day. 

Link to comment

I also tend to make loops like this occur at odd times, so that there is a less likely chance be data collisions.  That is, instead of happening every 30 minutes exactly on the half and and hour, I'll mix it up:

DoorOpenLight.Query - [ID 014C][Parent 0034]

If
        From     5:28:28AM
        To      11:59:59PM (same day)
 
Then
        Repeat Every  33 minutes and 33 seconds
           Set 'Garage Entryway+# / Door Open' Query
 
Else
   - No Actions - (To add one, press 'Action')
 

 

Link to comment

You could instead just alter your program to run every 30 minutes:

If       'ZW 016 On-Off Power Switch' Status is On
     And Time is Last Run Time for 'Reset kWh sump 2' + 30 minutes
Then
        Set 'ZW 016 Energy Meter Sump 2' Reset
Else
   - No Actions - (To add one, press 'Action')

Make sure "Run at Startup" is Enabled.

Link to comment
14 hours ago, MrBill said:

When does it jump out of "repeat every 30 minutes"?  What makes it jump to Repeat 1 times?

Good catch! Repeats usually need a terminator so that following lines don't repeat in a loop fashion also. In this case of an infinitely repeating time loop, there is "no out".

UDI needs to implement a Break on xxxxxx condition construct yet.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...