Best practices for Whole Home State Based Scene Control (Day/Night/Bedtime/Away)

In line with UI6/UI7, I’m moving all my scenes and PLEG logic to understand these 4 states.

I’m excited for making this change as it allows a low light level for the bedtime state.

  • My question is, what do you do with “state” of the time of day? Are there other states that folks should use?
  • Do you use PLEG state variables vs using sample virtual switches logic as I’ve shown below?

Thanks in advance for any ideas.

PS - I’ve accomplished this via the following PLEG logic:

Triggers

Name Description
Away_Switch Activated - Away Mode is set to away
Bedtime_Switch Activated - Bedtime Mode is turned on
Night_Switch Activated - Night Mode indicates Night time.

Schedules

Name Type Time Days Random On Delay Off After Type Off Time Off Days Random Off Delay
Weekday Weekly 00:00:00 1,2,3,4,5 None Weekly 23:59:59 1,2,3,4,5 None
Weekend Weekly 00:00:00 6,7 None Weekly 23:59:59 6,7 None
Time1159p Weekly 23:59:00 1,2,3,4,5,6,7 None None None
Time1259a Weekly 00:59:00 1,2,3,4,5,6,7 None None None
Wakeup_Alarm Weekly 07:00:00 1,2,3,4,5,6,7 None Interval 01:00:00 None
Sunset_Plus30 Weekly +00:30:00t 1,2,3,4,5,6,7 None None None

Conditions

Name Repeat Expression
Day No !Night_Switch and !Bedtime_Switch
Night No Night_Switch and !Bedtime_Switch
Dark No Sunset_Plus30
Bedtime No Night_Switch and Bedtime_Switch
Away No Away_Switch
Wakeup_Weekday No Weekday and !Away and Wakeup_Alarm
Wakeup_Weekend No Weekend and !Away and Wakeup_Alarm
TV_Auto_Off No Time1259a
Goodnight_Auto_Off No Time1159p and !Bedtime

I’ve attached the dashboard of the Day Night Plugin with Virtual Switches that make up the day/night/bedtime/away logic too. I use Nest for my Home/Away switch…but you could use a Virtual Switch.

I have added a LateNight virtual switch which will change the behaviour of outdoor lights and sensors after my exterior lighting is turned off. So, the latest light I have turning off is over the front door, that happens at 01:00 and that is when Late Night mode is on.

May I ask, what does “Late Night” do that “Bedtime” won’t?

It seems like my “Dark” condition for Sunset + 30 minutes which lower the Window Blinds…it’s not a core function of the home “state”. I could probably due this in PLEG condition for “Night;Now>1:00:00” vs have created anothers schedule trigger “Sunset_Plus30” to keep the least amount of states that are common to most folks.

The goal is to keep folks from going through my evolution as I did of in the following stages:

1 Oh, I made a light go on! Wohoo!

2 I want to make the light go on automatically. I have no time for light switches!

3 Darn, I really don’t want it to go on during the day…the wife just laughs at me for wasting money when HA was supposed to save money on HA.

4 Ok, got my night and day scene…but now my eyes hurt when I go to the bathroom at 2am :slight_smile: I’ll disarm the motion off at bedtime.

  1. Now, nobody knows how to use a light switch, none the less at 2am…so the light management should just have super dim light on motion. That’s what I’m working on now in moving lighting to PLEG. I used to use a lot of scenes and Luup filtering for day/night…plus disarming motion at night,turning on at the wakeup alarm.

  2. Future Problem to Avoid #1 - Why is the TV and lights come on when the cat sets the motion off 1% of the time when we’re able to afford a vacation after buying a new unfinished home + a new HA hobby? I’m assuming I’ll need an away scene. This could also be used to Arm the Alarm during the day.

Looking for others experience of future problems to maximize the evolution of the system. I think UI6 was a good start based on my experience of adding these core 4 Day/Night/Bedtime/Away states (even if you don’t need it at step #1 of your HA project).

Is anyone using PLEG states for this vs using virtual switches?

For example, the cycling through the state order:

1-Sunrise
2-Wake up
3-Get up
4-Low Light (pre-sunset or perhaps)
5-Sunset
6-Dark
7-Bedtime
8-Late Night

i’m using a combination of schedules and switches in PLEG to get what I want.

example, and I’ve posted the PLEG, my guesthouse is in vacation mode if the main house is and it remains there if it is unoccupied by a guest.

the A/C is on a schedule, but is affected by VacationMode and GuestPresent.

I find it difficult to believe your state sequence is the same as the day-length changes during the year.

You are mixing multiple potentially independent activities:
1) Sunrise/LowLight/Sunset/Dark
2) Your sleeping patterns: WakeUp/Getup Bedtime/ ??Late Night

Some might argue that it should be:
LowLight/Sunrise/Sunset/Dark

AgileHumor, looks like we’ve travelled through the same learning journey, however my wife laughs at me at every step of the evolution (and every time I think I’ve cracked something that will impress her she comes up with an even harder challenge!).

So, my current stage is 4 states within each day: Morning → Day → Evening → Night, with the logic being 6am to Sunrise = Morning, Sunrise to Sunset = Day, Sunset to 10pm = Evening and 10pm to 6am Night. However the logic does not work now that the days are getting longer (exactly as RichardTSchaefer points out!). When I created these I knew this would happen, but reckoned I would have improved it before it mattered, but guess how that went!

I mix these times with a Weekend or Bank Holiday switch (in fact any holiday, it looks for the word holiday in a google calendar to decide when not to annoy my wife by opening curtains at inappropriate times). Also, recently got a Nest Thermostat (finally released here in the UK, yah!) so have the concept of Away or Home to add complexity to the mix.

My most recent initiative is to move all of the virtual switches to a multiswitch as it removes complexity from the dashboard and makes the state simpler to see. Now I need to see if I should be using the PLEG state functions to improve it further.

But, I need to solve this logic issue with moving sunrise and sunset messing things up! I like the idea of having a LowLight/Sunrise/Sunset/Dark set of states (although I was thinking Dawn/Day/Dusk/Night which also gives me a low light option in the evening), and then combine this with a different set of states for acceptable hours for waking up or going to bed based on working day or non-working day.

It would be this combination of the two that should give me something useful (that is neither time of day or a fixed schedule) against which to drive decision logic for opening blinds, dimming lights for let night motion and so on. This would be a new independent set of states.

Any clever suggestions or comments greatly received ;D

Use the day night plugin for your day night scenes. I do this with an offset of 30 min late in the morning and 30 min early in the evening. Works very well at adjusting for the longer days. I also have a virtual switch that gets turned on when we go to bed that puts the house into sleep mode. I use this to have the lights really dim in the evening and really short cycles. That isn’t on a schedule to be turned on as we go to bed at random hours. I have it set to trigger off a pattern of events we do and then in the morning it does get shut off when the house goes back into day mode.

i use only 2 switches … where one could be replaced with a extra variable on the first one (iam just loo lazy to change all the luup in order to get rid of the switch)

  1. Away Mode
  2. Sleep Mode (this is the switch not really used to push at all)

everything is beeing triggerd via the away switch Or via a scene (usally via the scene)

if away is off and the sleep scene is triggered, the sleep button is turned on and the sleep script will run
the script runns for abot 15 minutes
if within the 15 minutes the car leaves (another virtual switch controlled via gps tracking in the car) the scene will turn off sleep and turn on away
this will trigger a few more actions … and turn off the before dimmed lights
if not the sleep button change state back to off (no action there)

by this way all away/sleep actions can be triggered with just one scene buttona nd the vera does decide based on other states how far it goes.
lock, dim or lock/off or all off …

well the combination with awayon and car cone also have some changes in the timebased scenes …
if not there the back light is also on in the late evening … and if a sensor triggers while this state i get push messages or calls (depend on which sensor)

as example if the front gate is open, car not there and away on, i get a push message to homewave and a email with the current picture from the camera seeing the gate.

if i come back home the yard and garage light are also turned on (only if night of course) and the garage light off after 30 minutes.

what i have not yet figured out is how to decide to remote start the airconditioners or not …
the fans in living room and unlock events for phones i use the arm/bypass functions of the virtual motion sensors.
but for extended preperation i have not yet come up with a good idea

[quote=“AgileHumor, post:4, topic:180088”]Is anyone using PLEG states for this vs using virtual switches?

For example, the cycling through the state order:

1-Sunrise
2-Wake up
3-Get up
4-Low Light (pre-sunset or perhaps)
5-Sunset
6-Dark
7-Bedtime
8-Late Night[/quote]

I am struggling to figure out how I am supposed to script time-of-day based logical arguments as well but I’m confident that this state sequence wouldn’t work for me for a few reasons:

  1. I live on the 54th Parallel, so sunrise/sunset changes from 09:00/16:20 on Dec 20 to 05:09/22:20 on June 20.

  2. I work shift work, so for a week out of the month, I work from 6 PM to 6 AM

  3. My missus has a normal job, so there are days that she’s waking up when I’m coming home, and vice-versa,

[quote=“RichardTSchaefer, post:6, topic:180088”]I find it difficult to believe your state sequence is the same as the day-length changes during the year.

You are mixing multiple potentially independent activities:
1) Sunrise/LowLight/Sunset/Dark
2) Your sleeping patterns: WakeUp/Getup Bedtime/ ??Late Night[/quote]

The Day/night arguments will work for me, but I don’t know how to script based on sleep patterns, as our household has 6 distinct schedule combos

I’m on day shift, missus at work(weekday)
I’m on day shift, missus at home(weekend)
I’m off shift, missus at work(weekday)
I’m off shift, missus at home(weekend)
I’m on night shift, missus at work(weekday)
I’m on day shift, missus at home(weekend)

I think proximity based triggers would work better using the iPhone locator (iViri won’t work due to lack of towers where I live) and ditch the schedule based triggers. There would only be 4 combos required:

Home,Home
Home,Away
Away,Home
Away,Away

Due to battery drain issues, that app poses its own set of logic challenges I am going to have to work thru which, ironically, will work on schedules :-\

you should seperate the house status with the persons in it.

i do this with a multiswitch (see attachment)
this is also all i really “change” on the vera … anything else is pretty much automated :wink:

this settings beeing respected on time based and action based triggers.
(as example … if my with works late and the car comes back home in the night the livingroom lights and kitchen will be triggered as well, if morning shift then not)

with that set and the time scenes tuned with that … you need to take care the sensing if someone home or not (and who that is)

for me this is simple, as only i do drive my car, so the car does trigger the away/home (with exeption if wife outside working time (based on the multiswitch setting) the away not goes off if i leave (this covers me going buy eggs) :wink:

the mobile sensor for my wife iphone uses the old ping sensor code which represents a motion sensor …
this one i can arm/bypass … in case she leave her phone at home.

works great so far.

if someone else at home (visitors guests) i set he multiswitch to “default” … this simply means no workingbased actions will be taken.