Jump to content

random command execution


smiley73

Recommended Posts

Posted

Hi,

 

I'm trying to write a program which simulates a TV being on, using a dimmer (as part of my vacation programs).

This is what I currently have:

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' 50%
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' 75%
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' On

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

 

I was hoping that the "Repeat 1 times (Random)" would work to randomly execute certain statements, but that didn't work so well. I guess the 'randomness' is between 1 and the value specified (was hoping it's 0).

Is there another way to randomly execute statements?

 

Thanks

Heiko

Posted

Hi Heiko,

 

Repeating random (in your case) means that it would either repeat the block or not execute at all.

 

I think what you need is to use the Random function on Wait instead of repeat. This way, the amount of time waited for the next statement will be random.

 

With kind regards,

Michel

Hi,

 

I'm trying to write a program which simulates a TV being on, using a dimmer (as part of my vacation programs).

This is what I currently have:

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' 50%
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' 75%
       Repeat 1 times (Random)
          Wait  3 seconds
          Wait  3 seconds (Random)
          Set 'LR LampLinc TV' On

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

 

I was hoping that the "Repeat 1 times (Random)" would work to randomly execute certain statements, but that didn't work so well. I guess the 'randomness' is between 1 and the value specified (was hoping it's 0).

Is there another way to randomly execute statements?

 

Thanks

Heiko

Posted
Repeating random (in your case) means that it would either repeat the block or not execute at all.

That's exactly what I want, randomly executing the block (or not). Unfortunately it doesn't seem to work, it always executes all the blocks.

 

I think what you need is to use the Random function on Wait instead of repeat. This way, the amount of time waited for the next statement will be random.

Using Wait is my backup solution, but this would cause my TV simulation not to be random. It would always go from 50%, to 75%, to 100%. I could probably make the code a bit more extensive, so it looks more random.

 

Heiko

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...