Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Random switch state #54

Open
RobinWinbourne opened this issue Oct 4, 2016 · 6 comments
Open

Feature Request: Random switch state #54

RobinWinbourne opened this issue Oct 4, 2016 · 6 comments

Comments

@RobinWinbourne
Copy link

Would you consider adding an option to randomly switch state?

I'm trying to setup a piston that simulates someone being home. It will trigger every 30 minutes whilst we're out (done) but the only options for switch states are on / off / toggle. I have included a 1-29 minute random wait before each device toggles but this still results in all lights being on at some point and all off at another (even if only for minimum 1 minute but up to 29 minutes) as the piston first activates at sunset with all devices in the off state.

The fact that switches are toggling (be it at random times) also leaves a noticeable pattern of On>Off>On>Off etc etc.

I would like to get something like this random example:

On>On>Off>On>Off>Off>Off>On>Off etc etc.

Thanks in advance!!

Robin

@ady624
Copy link
Owner

ady624 commented Oct 28, 2016

What I've done for that is, I added one action for each light. The living room lights have their own timeline wait random time, on, wait random time, off, etc. The dining room lights have their own timeline, with their own random times. So not all lights turn on at the same time and not all lights turn off at the same time. Would this fix your problem?

@RobinWinbourne
Copy link
Author

RobinWinbourne commented Oct 29, 2016

Hi Adrian,

Thanks for your reply!

I have it setup almost as you describe (separate randomly delayed actions for each light). This prevents all changes occurring at the same time.

The method you describe requires a long chain of individual random on and off actions. This could easily complete early if random delays are all short and would be further compounded in the long winter nights.

Using one random toggle action for each light, every 30 minutes, can run as long as needed without running out of pre-coded on/off's

The setup I have is:

  • Trigger = Every 30 minutes
  • Multiple Actions = Lights toggle with random delay between 5-25 minutes
  • Restrictions = Between Sunset and 11:00pm AND Alarm 'Armed'

I have a separate Piston that randomly turns everything off between 11:30 and 11:45 to simulate bedtime.

The problem with the above is that:

  • All lights are off at the start (Sunset)
  • So all lights are on max 54 minutes later
  • Then all lights are off max 30 minutes after that
  • Then all lights are on max 30 minutes after that
  • Etc etc

This shows an obvious pattern and also having all lights off at any point is unrealistic, as I need it to look like the house is occupied.

Having a 'change state to random On or Off' option will be a massive help. Some lights can then randomly stay on for multiple cycles, others can stay off.

Many Thanks and keep up the awesome work!!!

Robin

@Xtropy74
Copy link

Xtropy74 commented Dec 5, 2016

Suggestion - Add a wait after the trigger:

Result - Light randomly comes on 20-60 min after sunset and off between 10:30PM-11:00PM

Trigger happens at sunset
Wait 20-60 Min
Turn on
Wait for 10 PM
Wait 30-60 min
Turn off

@RobinWinbourne
Copy link
Author

Thanks for the input Xtropy74 but I'm looking for a more random on / off every 30 minutes (trigger every 3mins, random 5-25 min delay, change to random state).... Without the random state part all lights will be on at the hour and off at the half hour, even with separate delayed actions.

In the end I created my own random state variable via a separate piston, making use of the existing $randomlevel variable:

Trigger every minute...
If $RandomLevel IS greater than or equal to 51
THEN
@randomstate = true
ELSE
@randomstate = false

I then adapted each action in my 'away lights' piston to use the new @randomstate variable. Each light has a separate random delayed action and follow the following logic:

Trigger every 30 mins

Action:
With (for example) hallway light
Wait random 5-25mins
Begin IF Block (if @randomstate = true), Turn On,
End IF,
Begin ELSE IF Block (if @randomstate = false)
Turn Off
End IF

Would be great if CoRE could have a built in random state variable though... I could then just the 'load state from variable' option and save a lot of confusion.

@RobinWinbourne
Copy link
Author

@Xtropy74
Should say 30 minutes not 3 minutes in the 1st paragraph of my last comment.... :)

@ady624
Copy link
Owner

ady624 commented Dec 5, 2016

Looking into a more complex light cycle action with rotating colors et al.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants