Jump to content

Endless Loop in program


ketchup318

Recommended Posts

Hi

 

I'm trying to use my harmony remote to toggle on and off a scene for watching TV... here's the script. I don't know what's going wrong, but the "Toggle Watch TV" program is stuck looping over and over again and the lights turn on and off, until I disable the script...

 

Any thoughts?

 

 

 

(name:Watch_TV)

--------------------------------------------------

If

IR 'IR_001' is Released

 

Then

Run Program 'Toggle Watch TV' (If)

 

Else

- No Actions - (To add one, press 'Action')

 

--------------------------------------------------

 

(name:Toggle Watch TV)

--------------------------------------------------

If

Status 'TV Light' is Off

 

Then

Set Scene 'Button B -Watch TV' On

 

Else

Set Scene 'Button B -Watch TV' Off

Link to comment

How about something like this instead:

 

WATCH TV ON

 
If
       IR 'IR_001' is Pressed
   And Status  'TV Light' is Off

Then
       Set Scene 'Button B - Watch TV' On

Else
  - No Actions - (To add one, press 'Action')

 

 

WATCH TV OFF

 
If
       IR 'IR_001' is Pressed
   And Status  'TV Light' is On

Then
       Set Scene 'Button B - Watch TV' Off

Else
  - No Actions - (To add one, press 'Action')

Link to comment

Hello ketchup,

 

In your original programs, simply clear the Enabled checkbox for the Toggle Watch TV program, so that it only runs when called from another program. This should prevent the oscillation.

 

However, Mike's approach will actually be a tab bit faster, since it doesn't have one program calling another program, which adds some latency. Whether the difference would be noticeable, would need to be tested.

 

In Mike's Watch TV Off program, I would change the line:

 

 
   And Status  'TV Light' is On

to:

 

 
   And Status  'TV Light' is Not Off

in case the light happened to be between 99% and 1% (not On, and not Off).

Link to comment

thanks for the replies

 

coming from a programming background, it feels a bit constrained with the fixed format of the IF Loops, but it seems to work fine now. I'm using Mike's version with two if loops, one button though...

 

press once = on

hold = off

 

I'm really starting to like the IR option and I'm really glad to have bought it.

Link to comment

Archived

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


×
×
  • Create New...