In room detection of Occupancy

Experts, quick question.

What equipment and rules do you need to setup in order to:

  • detect a person enter the room
  • detect a person leave the room
  • count total # of person in the room

basically I want to setup a rule so that whenever someone enter the room, turn the lights on, and turn lights off when exiting the room.



Magic technology that doesn’t really exist yet. They’re working on it. Ninja blocks that just went out of business was working on it using our radio interference.

1 Like

Fibaro shows this functionality on their website for their controller. - scroll down the page a bit

They use two motion sensors. Kind of makes sense, but it seems like it would be difficult to implement in practice. You would need a very narrow field of view to ensure that you are only getting people walking up to the door. You would also want to have a motion sensor in the room as a failsafe to correct when the system might think there are multiple people in the room but there is no motion for x minutes.

This would be better achieved with a beam sensor like on a garage door. Breaking a beam is probably more reliable than detecting motion.


iBeacons, RFID and NFC could achieve this but not solely on presence. I don’t mind requiring a BLE device to achieve my goal (not security related), so I’ve been following estimotes and related beacons for the past couple years.

1 Like

Not great for people that don’t carry their phones around everywhere. A podcast I listened to claimed that ladies tend not to carry their phones around like us guys, they did a survey which provided mixed results but I can attest to that claim in my house.

1 Like

[quote=“geek, post:1, topic:16735”]
whenever someone enter the room, turn the lights on, and turn lights off when exiting the room
[/quote]This is typically done with simple motion sensing - just like in offices, which turn off lights when the room is empty (and occasionally leave you in a dark conference room, waving your arms like a crazed monkey…)

To detect individual people, you need to tag the people (BTLE/beacons) and even then there is bleed, so you may detect people in the next room over. Alternately, you use something like the kinect sensor which is pretty darn good at detecting the number of people it can see - but would get pretty expensive for turning lights on and off.

Which gets us back to simple motion sensors for lights in rooms.

Thanks all, and Brian!

I didn’t think it would be difficult to do this at the beginning. I think two motion sensor would do right? Have the motion sensor mounted on both sides of the door, depending on which one triggered first, we will have direction, and the rest is the easy part, no?


I am quadriparetic, wheelchair dependent with limited and function, so I pay a lot of attention to the various hands-free control options.


That said, in my own house I never use inactivity from motion detectors to turn lights off. They always fail at the wrong time. It’s true there’s a lot of different scheduling tricks you can use to try to make them work well. But it’s just such an annoyance when the lights turn off when someone is in the room that I don’t even go there.

There’s also the issue if you have anybody who is potentially subject to falling, seizures, heart problems, that if you just use motion sensors the person might fall to the floor, pass out, and wake up in the dark.


When people are talking about multiple motion detectors, they aren’t talking about one for on and one for off. Instead, they are talking about the “zone detection” where the lights turn on because there is motion on multiple sensors, or turn off because there is inactivity on multiple sensors. All designed to reduce problems from the inherent unreliability of motion sensor technology.


I personally do use motion detectors as touchless switches. But the detector is in a box that someone waves a hand over as they go past. An intentional gesture.


Back to these case you described. This is called “microlocation.” Everybody wants it, nobody has it now, at least not for less than many thousand dollars per room.

The Kinect is a really good device for knowing that there is more than one person present, but only in a range of 6 to 8 feet. There are actually hospitals using this for patient detection in some wards. But it’s a cost of several hundred dollars per device. And it’s only for this limited range. Great for knowing if an Alzheimer’s patient has gotten out of bed, but not really suited for the room light scenario.

Sometime in the next 10 years we’ll have exactly what you asked for at a lower cost, probably by a device that listens for heartbeats.


I beacons are another option, particularly for those with iOS devices, but as others have mentioned you have to have a device with you.

It’s possible to put a plug-in tablet in each room and use that as the beacon detector, and then give each person a beacon to carry around with them. Perhaps even worn with a belt loop or a bracelet band.

This has some interesting possibilities, and it keeps the Beacon detection from
Burning through The battery life on your phone, but it does mean each person has to remember to have the device with them. Including your guests. That can get tricky.

Also since Ibeacons use Bluetooth, they are not stopped by walls which means even if you have a pretty small region, say 6 feet, it might pick you up on both sides of the same wall.

This is actually the approach that I am currently experimenting with, but again I’m in a personal situation where it’s worth investing more in touchless solutions. Although to be honest it looks more and more like voice control will be the solution for my case. But that does require someone remembering at some point to say “lights off.” I am successfully using a Beacon on my wheelchair to trigger a tablet at home so that it picks me up just as I reach the base of the ramp to my front door and it knows the difference between me and my roommate coming home.


If you could tell us a little more about the use case details you’re considering, we might be able to make some practical suggestions.

For example, if your household includes someone with Alzheimer’s or on the autism spectrum and you really need things to happen even though the person doesn’t intentionally ask for them, that’s one situation.

If your entire house is set up with solar power and you need to take extreme energy saving measures, that would be a different situation.

Or if you have a light in a closet that people always forget to turn off.

Or, if you just think it would be cool and convenient to have the lights come on when someone walks in the livingroom, that’s different yet again.

There are technical solutions for the base case you described, but it’s a question of cost and priorities. When it comes to meeting the budget for a typical household case then there’s no one single approach right now, but there are some options that might fit depending on the details.


Thanks JDRoberts.The use case is simply convenience. After all, that’s what smart things are for, to me.

Can you elaborate on motion sensor have lots false alerts? Is it that the motion sensor itself throw out false alert? Or it would be hard to implement logic like:

if motion sensor 1 “active” + motion sensor 2 “active” -> do something

And we don’t need to wait 10 years for this solution. I know there are people counting cameras out there (which can be mounted on any ceiling) that can be triggered via Event (i.e. 2 person in room) and do something with it (i.e. send a text to ifttt to trigger action).

Typically cameras are connected by WiFi and home automation motion sensors are connected by a mesh protocol like zigbee or zwave.


Mesh has the advantage that it’s cheap in both dollars per device and energy draw per device. However, with a mesh network the messages are allowed to bounce around the network, which means there can be a delay and the messages can even arrive out of order. That’s usually very surprising to people whose past experience has only been with WiFi devices, which typically use a star topology where every device has a direct connection to the hub and forced sequencing is possible.

As for the camera solution, sure–but those cameras cost a lot more money per device than the typical motion sensor. And since they’re using WiFi they have forced sequencing.


Also, I’m pretty sure those cameras are hardwired, not battery powered. Battery powered sensors, particularly on a mesh nextwork where low costs are a high priority, tend to “sleep” for long periods of type, often arriving with a default of 3 minutes. (That is, they only report once every 3 minutes.) That may be fine for catching a burglar, but tends to be terrible at catching people moving in and out of the living room during a tv show, so either the counts are always off or you’re changing batteries way more often than you’d like.

So that’s a perfect example of what I meant by there might well be options available now, but they’re options that are likely to cost a lot more than the $25 motion sensors commonly used with SmartThings.

The “next ten year” solution (and more likely 3 or 4) is for a CHEAP “count the people in the room” system that would be a better fit to a typical room lighting case.


As I mentioned, there are people in this community who are doing a lot with motion sensors and lighting ( @bravenel is one ) who could likely make some recommendations.

I still wouldn’t recommend them for really critical situations, like, say, for a person who might become agitated if the lights went off unexpectedly.

But if it’s just a convenience case and you’re OK with an occasional miss, there’s a lot you can play around with. :smile:

As a wheelchair-dependent person, I can’t easily feel my way to the switch, or turn it on when I get there for that matter, so I take misses a lot more seriously than many people do. “All home automation is local.”


Not sure if this is what you are looking for but it sounds kind of like a “Wasp in a box” type of use.

Wasp in a Box Implementation - Virtual Occupancy by @Kristopher



BTW, if you are serious about this and you are the home owner (not just renting) it can be done very nicely with a double set of trip beams at about shoulder height.

(Think of the alarm systems in movies like Mission Impossible. Or for that matter the “obstruction detected” sensor for a garage door.)

By having two sets a few inches apart, you can detect whether someone is entering the room or leaving based on which one tripped first.

However, people have to enter the room single file–if they break the beams at the same time, it will only count one person.

And if you are carrying something shiny, you can confuse the detectors.

Also, height can be tricky if you have large dogs and small children.

Anyway…this can be done at a cost of about $800 per door way, less if you do everything yourself and know exactly what you’re doing.

But it’s hardwired (not battery powered), and uses WiFi or direct line connection, not zigbee/zwave. And getting the information into SmartThings would be another story altogether.

But definitely doable with current technology. :smile: And less creepy than pointing cameras at everybody.

If I ever lose hand function all together, I will likely use something like this.

1 Like

Accurate Occupancy sensing is an area with tremendous potential uses. Perhaps a few of us “geniuses” :wink: should get together and design a system?

One use case not reported, for example, is for fire safety. The first thing that firefighters do when arriving at a scene is determining if all occupants have been safely evacuated. They probably ask persons on the scene (other family members, etc.) what rooms need to be checked, and so on.

Having the latest “room occupancy” data could save lives if it directed rescuers to the highest priority locations to search.

there is an interesting PIR type called “curtain” sensor, which reads two pretty-flat planes a couple degrees-angle apart. The planes are only 1-2 degrees wide. So by noting which plane is broken/hot first, you can get an indication of “moving left/into-the-room” or “moving right/out-of-the-room” in one device. It may be two sensors inside, I dunno.

like this device "Visonic CLIP MCW"
I love these things. They can still be falsed by a big bug on the face, but it hasn’t happened in 6-7 years I’ve been using them. The original battery has lasted the entire time. Probably wouldn’t last so long on a busy border

Until this curtain PIR is adapted to Zwave direction-indication, I think a pair of ST Zigbee motions masked appropriately, can do the same thing, and their battery life seems pretty good too.


If you’re trying to catch “going in” vs “going out” with two detectors most mesh based protocols (zigbee or zwave) may have a high failure rate because there’s no guaranteed sequencing in a mesh network. You can’t be absolutely certain which message will arrive first. Star topology is generally better for this reason.

1 Like

good to know about the mesh network (I’m not familiar with zigbee). I guess if I setup “zone” occupancy it’ll still work that is, motion sensor at the bottom of the stair and another motion sensor at the top of the stair (takes approx 2-3 sec to walk up, should be enough time)

That could work very well, although it may take a modest amount of custom code to work. I’m sure there will be community members happy to help, they love those kinds of chalenges. :smile:

Just wanted to mention that since this thread was started, @mike_maxwell has written a very nice custom smart app to do zone detection using multiple motion sensors. It’s becoming very popular. It doesn’t detect a specific person, but it significantly reduces false positives because all of the sensors assigned to the zone have to trigger at the same time or it doesn’t count as an event.


Also wanted to mention that estimotes, who make one of the most popular Ibeacons, now have a model specifically for zone mapping called “location beacons.” But this requires four devices per zone, so it gets pretty expensive. It’s intended for commercial use such as a department store that wants to present one set of options when a customer is standing in sportswear, and then a different set if they have moved to the jewelry department. But the cost is going to be around $160 per room.

In my case I want ST to detect if I am in the room. The challenge is that it is a media room, and it is fairly common to sit in one spot, reclined, and not move hardly at all for a couple hours. Possibly even fall asleep. :blush: So motion detection cannot be relied on.

Since I always sit in the same spot, which is in a recliner, I’m wondering if I can do it based on detecting my butt in the seat…? One possible solution is to use a MultiSensor with a open/close contact, and set it so that when the recliner is closed it thinks I’m not in the room, and when open it assumes I’m in the room.

That would be pretty accurate. Except that often times I keep it reclined and then just hop in and out of the seat without closing the reclined position, since it is motorized and a bit slow to open/close. Otherwise it becomes a bit of a pain to close it every time I jump up for something and then recline again when I return.

Is there any way to rig something at the seat that could detect my butt in the seat or my back against the back part of the chair or my head on the headrest? Without it being an eyesore or uncomfortable (such as physically sitting on a contact mat)?