[Migrated to Custom Capabilities] Rooms Manager: Smarter Rooms: Personalized rules based home automation with rooms Occupancy sensing from devices you already have in your home

I guess you are thinking about a pressure pad or contact sensor under a seat… that would indeed work for some rooms but not all.

I was thinking simpler, basically leaving the current mechanism intact but changing the subscribed event.
So I tried this (after creating a list of room devices for adj rooms - granted this doesn’t take the previous state into account yet):
subscribe(adjRoomList, “occupancy.occupied”, adjMotionActiveEventHandler)
subscribe(adjRoomList, “occupancy.vacant”, adjMotionInactiveEventHandler)

…but the handlers don’t seem to fire.

nothing that esoteric :slight_smile: just contact sensor on doors or music player playing in room or TV being on in room or … etc.

since occupancy is a custom capability that event subscription will not work.

if I change the subscribed event from motion to occupancy changing to occupied it will break things for other users. so can’t just change that.

I am happy to create an option in settings to use occupancy change instead of motion to trigger adjacent room checking state. but before implementIng that need to understand if that would actually work as you are thinking it should and would it work consistent with how other users might expect it to.

unfortunately right now I am missing something. I know you have something in mind with this change that would make things work better for your usage pattern. but I am not able to see it yet. sorry.

will give it some more thought and see if I can figure it out.

thanks.

Sure thing, I understand. I’d like to test it myself first :slight_smile: I’ll fix up that subscription and see if it helps things.

1 Like

@bangali now that there is a screen for locked settings, would you Consider adding an (optional) setting for locked timeout (similar to the asleep timeout) so we can avoid having a room accidentally forgot in locked mode?

1 Like

the original thinking was no automation for locked state. now i am drawing the line at no automation rules in locked state.

so why not? :slight_smile:

1 Like

After I made occupancy into an enum, it worked fine. Also stuffed the previous state in there:

attribute "occupancy", "enum", ['occupied','locked', 'vacant', 'reserved', 'checking', 'kaput', 'donotdisturb', 'asleep', 'engaged']
...
command "updateOccupancy", ["string", "string"]
...
updateOccupancy(newState, oldState)
...
sendEvent(name: "occupancy", value: occupancy, data: ["previous": oldOccupancy]...

in the event handler:

def data = parseJson(evt.data)
    if (data.previous != "vacant")
    	return;

and the subscriptions:

if (adjRoomsList && (adjRoomsMotion || adjRoomsPathway))   {
        subscribe(adjRoomsList, "occupancy.engaged", adjMotionActiveEventHandler)
        subscribe(adjRoomsList, "occupancy.occupied", adjMotionActiveEventHandler)
        subscribe(adjRoomsList, "occupancy.vacant", adjMotionInactiveEventHandler)

Works fine at a first pass. I don’t use adjRoomsPathway, so didn’t even think about that :stuck_out_tongue: but it’s easy to leave that subscribed to motion sensors. One glitch is if I leave the room and come right back, it won’t turn off the newly occupied room, so ‘infinite timeouts’ won’t work. For now I have just long timeouts but need to think about that one…

1 Like

cool.

that was what i pointing to in my email -1. figured once you went through it you would figure it out soon enough. :slight_smile:

wondering if you would be willing to try an experiment with one room setup with adjacent room and another room setup with an engaged sensor and see which one works better for you?

thanks.

@bangali I have been having some strange behavior from engaged contact sensor and am not sure if this is expected or not.

Here is the scenario:
Room starts vacant, I enter and it becomes occupied with motion. I close the door and it is engaged
Then I go out and the room goes into checking when the door opens. All good so far…
Then I return and close the door. If the checking timer expired while I was out, the room goes to vacant and the process starts over and all works as expected.

However, if I come back (and close the door) while the room is in checking state, it doesn’t change back to engaged. Is this expected or a bug?

1 Like

checking … :wink:

EDIT: sorry it was only considering occupied when setting room to engaged with contact closure. fixed. will be in next release likely tomorrow.

thanks for finding the bug.

2 Likes

Problem is I really don’t have anything I can use as an engaged sensor. No doors get opened or closed, TV is hardly on and computer is on 24/7 :slight_smile:

Here’s what I did to tweak it a bit more, and it’s awesome when there is 1 occupant per room (which happens pretty often apparently). I used the Welcome Home presence sensors with the idea that 1 presence sensor = 1 person. (with multiple presence sensors per person, you’d need to combine them with Reliable Presence or similar)

def getHomePopulation()
{
	def population = 0
    presenceSensors.each 	{ sensor -> 
    	if (sensor.currentPresence.contains('present'))
        {
        	population++
        }
    }
    return population
}

def getNumberOfRoomsOccupied()
{
	
    def occupants = 0
    childApps.each { child ->
         if (['engaged', 'occupied', 'checking'].contains(child?.getChildRoomDevice()?.currentOccupancy))
        {
        	occupants++
        }
    }
    return occupants
} 

Then modified the handler, moving the previous state check after the population check:

   if (adjRoomsMotion && roomState == 'occupied')      {
        if (parent.getNumberOfRoomsOccupied() > parent.getHomePopulation())
        {
            child.generateEvent('vacant')
            return
        }
        if (data.previous != "vacant")
    		return
        child.generateEvent('checking')
        return

Net result is lights turn on and off instantly as I move around, and the usual check and long timeouts functions as a fallback when per room population > 1

Happy!:star_struck:

1 Like

glad you are happy. :slight_smile:

btw, you want to continue maintaining this in your local copy or send me a PR?

thanks.

@bangali:

Bug report: Cannot set asleep button to toggle asleep to another room’s occupancy state button:

Create Room 1
Create Room 2
In room 2 go to Asleep settings
Button to toggle ASLEEP MODE
Select another Room Occupancy Object
Generates Error
Back out,
Subsequent returns to the settings screen shows an error screen Something’s wrong We cannot load your screen right now:

Room Log:
07b7ee4f-cf74-4dbc-9755-991d066f659f ‎10‎:‎47‎:‎19‎ ‎PM: error groovy.lang.MissingPropertyException: No such property: buttonNames for class: script_app_rooms_chil_a530bbb9_5b9b_4363_8fc5_a33ef77ce0a7_ver_1_5
07b7ee4f-cf74-4dbc-9755-991d066f659f ‎10‎:‎47‎:‎15‎ ‎PM: debug childCreated
07b7ee4f-cf74-4dbc-9755-991d066f659f ‎10‎:‎47‎:‎15‎ ‎PM: debug childCreated

In this case my rooms were Master Bedroom and Master Bathroom. I was trying to tie the asleep state of the master bathroom to follow the master bedroom and set asleep when the master bedroom went to ASLEEP mode. 07b7ee4f-cf74-4dbc-9755-991d066f659f is my Master Bathroom…

-nac

1 Like

fixed.

thanks for reporting the bug.

1 Like

@bangali, hi. This is my set up Engaged Room A :

  • Power value to set room to ENGAGED : 10
  • Power stay below … to reset ENGAGED state : 30
  • Require motion … when room is ENGAGED : 300

When I turn on my desktop, power meter : 45 to 65. Room A is MOTION > OCCUPIED > ENGAGED ( 5 minutes ) > CHECKING > VACANT ( light turn off ) . Everything run good .
But after VACANT state, when motion detect again , it’s only OCCUPIED , no ENGAGED ( power meter : 25 to 65 ) . If I turn off, then turn on my desktop ( power meter : 0 to 65 ) , now the app go to ENGAGED.
Am I missing something or the app did not check power value for next process ?

the app does not check power value on motion rather only when it gets a new power notification which is why its going to engaged when you restart the desktop but not when there is motion and the desktop is already on.

i will add the check.

thanks.

1 Like

I’d be happy to send you a PR asap. Need to make both parts optional and also not clobber adjRoomsPathway. Doesn’t look like the DTH changes messed up anything but I’ll keep checking the logs too. (Note to self: add a semi-automatic visitor mode)

btw, what’s the reason for this?
if (mV && mD > evt.date) return
I’m reading it as if there is further motion activity after the event, don’t do anything?

1 Like

sure checking logs is good. if you want try it for a couple more days to make sure you are happy with the behavior. i will probably apply it locally first and check out the behavior before applying.

right.

OK, but why should further motion stop us from vacating the room?

this is checking the in room motion sensor not the adjacent motion sensor. so if there was in room motion after the adjacent room motion you dont want the room to be vacated.

1 Like

Played with AL a little bit, settled on a four-zone approach
Sleep: min level, min kelvin
Morning (wake up time + 2 hours) reduced level, max kelvin
Daytime: max level, max kelvin
Night: (after sunset) reduced level, min or interpolated kelvin (interpolated is sexier probably :stuck_out_tongue: )
Sleep: min level, min kelvin

Maybe this could be a second AL option like “Auto - Interpolated” & “Auto - Threshold” or “Auto - Quad Zone”?

Also just setting up temperature maintenance, and I totally misunderstood offset - it sounds like it’s a setting to compensate for different readings from different sensors. I think “Temp Range” would be better in the UI.

And rules page title says “Maintain Lighting Rules” still even though temperature rules have been added.

1 Like