Jump to content

What is wrong with this program


AnthemAVM

Recommended Posts

This lights turn off, but not off?

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' Off

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

I suspect you meant "This lights turn on, but not off?", and that your program actually is:

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' On

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

 

If that is so, then the reason the lights don't turn off is because when the lights turn on the If becomes False, and when the Wait is reached, the program stops executing the Then and begins executing the Else.

 

The solution is to break it into two programs:

 

Program 'Garage Motion'

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Run Program 'Garage Lights' (Then Path)

 

Program 'Garage Lights'

If

 

Then

• Set 'Garage - Can Lights' On[/n]

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

 

See our wiki article on motion sensors.

Link to comment
This lights turn off, but not off?

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' Off

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

I suspect you meant "This lights turn on, but not off?", and that your program actually is:

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' On

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

 

If that is so, then the reason the lights don't turn off is because when the lights turn on the If becomes False, and when the Wait is reached, the program stops executing the Then and begins executing the Else.

 

The solution is to break it into two programs:

 

Program 'Garage Motion'

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Run Program 'Garage Lights' (Then Path)

 

Program 'Garage Lights'

If

 

Then

• Set 'Garage - Can Lights' On[/n]

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

 

See our wiki article on motion sensors.

 

Thanks Darryl,

 

If after the wait, it goes the the Else statement, could I move the set garage lights off in the else state?

 

Michael

Link to comment
Thanks Darryl,

 

If after the wait, it goes the the Else statement, could I move the set garage lights off in the else state?

 

Michael

Hello Michael,

 

Good question. The program will switch from the Then to the Else as soon as it encounters the Wait, so the Wait will not be executed. However, you could put the Wait in the Else, like this:

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' On

• Wait 10 minutes

 

Else

• Wait 10 minutes

• Set 'Garage - Can Lights' Off

 

I haven't tested this. The Wait in the Then may still be required, or may not be; try it both ways, and let us know how it works.

Link to comment
Good news, the below program works.

 

If

• Status '0A.43.29-Sensor' is On

• And Status 'Garage - Can Lights' is not On

 

Then

• Set 'Garage - Can Lights' Off

• Wait 1 minutes

 

Else

• Wait 5 minutes

• Set 'Garage - Can Lights' Off

Michael, thanks for the update, and for the idea--I never thought of doing it that way before. It should aid organization by keeping the code together in one program rather than two.

 

Did the Wait in the Then turn out to be necessary?

Link to comment
MikeB, possibly to trigger a re-evaluation of the program's conditions as per this thread: http://forum.universal-devices.com/viewtopic.php?t=1757 , but if I understand the way the Then statements should operate, they should simply complete and then the program's conditions would be automatically re-evaluated without the need to be triggered by a Wait statement.

Dave, well stated, thanks so much. Yes, that is exactly what I had in mind, and you are correct that without any Wait or Repeat statements, the entire Then (or Else) clause should be atomic, and therefore should complete before the If conditions are reevaluated. My suggestion was merely to test this.

Link to comment

Archived

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


×
×
  • Create New...