Auto Home/Night Mode - How to use Time and Sunrise together?

So I was thinking of how to set house mode to Home/Away daily based on motion sensors and GPS.
I’d like it to change to night mode between 11pm and 30mins after sunrise… And home home after 30 mins after sunrise, as long as either me or my wife are home.

This is the way ive built it, but the time conditions are not true when I expect them to be true.

What is the actual function on the time conditions? After sunrise, for example, could mean anytime after sunrise up to a certain time… so is it up to midnight?

I have it setup as such:

  • Group: (AND) Is Night Mode

    • Time is after 2300h
    • Time is before sunrise +30 mins
    • Group: (OR) GPS are home - Night, Sustained for 600 seconds.
      • RJ is Home
      • MJ is Home
    • Group: (AND) No Motion, sustained for 600 seconds.
      • Motion detectors have no motion
  • Group: (AND) Is Home Mode

    • Group (OR) GPS are home - home
      • RJ is Home
      • MJ is Home
    • After sunrise + 30 mins

Activites:

  • When Is Night Mode is true, Change House mode to Night.
  • When Is Home Mode is true, Change House mode to Home.

Any better ways to structure this?
Any other triggers that could be used to make a more reliable Home/Night mode automation?

Thanks in advance!

Here is the code incase it is more helpful:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.5 config 20017 cdata 20045 ui 20045 pluginDevice 8 LuaXP not loaded
    System: Vera version 1.7.4832 (7.30) on Sercomm NA301 ID 35 (Vera Edge); loadtime 1582002282; systemReady 1582002302; Lua 5.1; JSON dkjson 1.2; UnsafeLua=nil
Local time: 2020-02-18T00:06:26-0500; DST=0; Oakville, Ontario Canada; formats %Y-%m-%d %H:%M:%S
House mode: plugin 4; system 4; tracking on
  Sun data: { "source": "int", "civdawn": 1582026260, "nautdawn": 1582024258, "sunset": 1582066327, "nautdusk": 1582070084, "stamp": 2020049, "latitude": 43.4501, "astrodusk": 1582072070, "longitude": -79.6829, "civdusk": 1582068082, "astrodawn": 1582022272, "sunrise": 1582028015 }
  Geofence: not running
************************************************************************************************************************************
Home/Night AutoChang (#91)
    Version 20045.9 02/18/20 00:06:21
    Message/status: Not tripped
    Condition group "Home/Night - NULL" (AND)  false as of 23:35:45 <root>
      &-F-group "Is Night Mode" (AND)  false as of 23:35:45 <grpo7klfs6>
      |     &-F-trange after ,,,23,0,,,,, [1582002299 => 1582002381 at 00:06:21; F/F as of 00:00:00/00:00:00] <condo7kqine>
      |     &-T-sun before sunrise+30, [1582002299 => 1582002381 at 00:06:21; T/T as of 00:00:00/00:00:00] <condo7lsa1m>
      |     &-T-group "GPS are home - Night" (OR)  for ge 600s TRUE as of 23:26:11 <grpo7kz0lt>
      |     |     |-T-service HomeMJ (36) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 at 23:16:11; T/T as of 23:16:11/23:16:11] <condo7l03m5>
      |     |     |-T-service HomeRJ (37) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 at 23:16:11; T/T as of 23:16:11/23:16:11] <condo7l047l>
      |     &-T-group "Sensors No Motion" (AND)  for ge 600s TRUE as of 23:47:05 <grpo7kpo2a>
      |     |     &-T-service Back Door Sensor (13) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 0 [0 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7kq496>
      |     |     &-T-service Front Door Sensor (14) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 0 [0 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7kq5nw>
      |     |     &-T-service Kitchen Motion (56) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 0 [0 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7kq3l8>
      |     |     &-T-service Office Motion Sensor (84) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 0 [1 => 0 at 23:37:05; T/T as of 23:37:05/23:37:05] <condo7kq2xe>
      |     |     &-T-service Front Hall Motion (53) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 0 [0 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7kq6bk>
      &-F-group "Is Home Mode" (AND)  false as of 00:00:00 <grpo7klgla>
      |     &-F-sun after sunrise+30, [1582002299 => 1582002381 at 00:06:21; F/F as of 00:00:00/00:00:00] <condo7ko1kq>
      |     &-T-group "GPS are Home - Home" (OR)  TRUE as of 00:06:21 <grpo7ms1tr>
      |     |     |-T-service HomeMJ (36) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7knatl>
      |     |     |-T-service HomeRJ (37) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 at 23:14:03; T/T as of 23:14:03/23:14:03] <condo7knjr0>
    Activity grpo7klgla.true
        Change house mode to 1
    Activity grpo7klfs6.true
        Change house mode to 3
    Events
        2020-02-18 00:04:57: Reactor startup (Luup reload)
        2020-02-18 00:04:58: Starting (Luup Startup/Reload)
        2020-02-18 00:04:59: Group grpo7kz0lt successfully sustained for at least 600 seconds (actual 2928)
        2020-02-18 00:04:59: Group Sensors No Motion successfully sustained for at least 600 seconds (actual 1674)
        2020-02-18 00:06:21: Configuration changed!
        2020-02-18 00:06:21: Group GPS are home - Night successfully sustained for at least 600 seconds (actual 3010)
        2020-02-18 00:06:21: Group Sensors No Motion successfully sustained for at least 600 seconds (actual 1756)
        2020-02-18 00:06:21: Group GPS are Home - Home test state changed from (nil) to true
        2020-02-18 00:06:21: Group GPS are Home - Home evaluation state changed from (nil) to true
    Devices
        ZWave (1) urn:schemas-micasaverde-com:device:ZWaveNetwork:1 (19/0); parent 0; plugin -; mfg  model ; dev D_ZWaveNetwork.xml impl 
        Office Motion Sensor (84) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg NEO Coolcam model NAS-PD01Z; dev D_MotionSensor1.xml impl 
        HomeMJ (36) urn:schemas-micasaverde-com:device:DoorSensor:1 (4/1); parent 35; plugin -; mfg  model ; dev D_DoorSensor1.xml impl 
        HomeRJ (37) urn:schemas-micasaverde-com:device:DoorSensor:1 (4/1); parent 35; plugin -; mfg  model ; dev D_DoorSensor1.xml impl 
        Kitchen Motion (56) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg NEO Coolcam model NAS-PD01Z; dev D_MotionSensor1.xml impl 
        Lobo GeofenceBeta (35) urn:schemas-toggledbits-com:device:Lobo:1 (1/-1); parent 0; plugin -; mfg  model ; dev D_Lobo1.xml impl I_Lobo1.xml
        Front Door Sensor (14) urn:schemas-micasaverde-com:device:DoorSensor:1 (4/1); parent 1; plugin -; mfg Linear model WADWAZ-1; dev D_DoorSensor1.xml impl 
        Back Door Sensor (13) urn:schemas-micasaverde-com:device:DoorSensor:1 (4/1); parent 1; plugin -; mfg Linear model WADWAZ-1; dev D_DoorSensor1.xml impl 
        Front Hall Motion (53) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg NEO Coolcam model NAS-PD01Z; dev D_MotionSensor1.xml impl 
    Watches
        Device #36 HomeMJ service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #37 HomeRJ service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #84 Office Motion Sensor service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #53 Front Hall Motion service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #91 Home/Night AutoChang service urn:toggledbits-com:serviceId:ReactorSensor variable TestHouseMode
        Device #91 Home/Night AutoChang service urn:toggledbits-com:serviceId:ReactorSensor variable TestTime
        Device #91 Home/Night AutoChang service urn:toggledbits-com:serviceId:ReactorSensor variable cdata
        Device #56 Kitchen Motion service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #13 Back Door Sensor service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #14 Front Door Sensor service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
    Special Configuration
        UseReactorScenes = 1
        LogEventsToFile = 0
        Retrigger = 0
        FailOnTrouble = 0
        ContinuousTimer = 0

What you might do is structure the “GPS are home” groups as a single utility group outside the main groups, and then just use a “Group State” condition to check in inside the night and home mode groups. This will also push you further into thinking of your logic as modular groups–rules you build up using other rules you’ve built. Many benefits there I won’t go into here.

Also the 2300-sunrise test won’t work in an AND–when you split a time test across two conditions, you have to provide the midnight crossing logic yourself. So what I recommend is another group “Overnight” (OR) for >2300 and <sunrise. If it’s not clear why, example: the time is 2am… that’s 7200 seconds after midnight. Your >2300h test checks to see if time > 82,800 seconds after midnight, which 7200 is not, so the test fails, even though 2am is clearly between 11pm and sunrise conceptually.

Recommended:

Root group (NUL)

  • GPS are home, OR
    • RJ is Home
    • MJ is Home
  • Overnight, OR
    • Time is after 2300h
    • Time is before sunrise + 30 mins
  • Group: (AND) Is Night Mode
    • Group state “Overnight” is TRUE
    • Group state “GPS are home” is TRUE, sustained for 600 seconds
    • Group: (AND) No Motion, sustained for 600 seconds
      • Motion detectors have no motion
  • Group (AND) is Home Mode
    • Group State “Overnight” is FALSE
    • Group State “GPS are home” IS TRUE

Hint: if you have other ReactorSensors that would use similar or identical “GPS are home” or “Overnight” groups, use a Group State condition across ReactorSensors rather than duplicating the logic.

Perfect thanks!

Yes I have thought about starting to build group state conditions to use accross multiple reactor sensor. Probably saves vera resources?

I have lights turned off, devices turned off, and doors locked when vera is changed to night mode. The doors beep to lock (even if they are already locked) when this occurs because I believe vera actions all commands on the My Modes page, instead of checking current state of each device, then doing the action ONLY IF needed.

If I pulse the 'Is night mode" every half hour, I think its going to make the locks beep every every half hour because it would re-action the night pre-set mode.

Do you have an idea of how I can periodically recheck all conditions in the “is night mode” and only do the night mode activities which disagree with the ‘My Modes’ if the state changes during night mode?

Use Reactor to do it with an overarching when nightmode is true condition.

Possibly going to take some time to set up, depending on how many actions you have.

Or just bite the bullet and do them all only if one is out of synch as it were.

There’s probably better ways

C