Detecting movement around the house - rules based sensor?

Hi all,

Here is a use case I want to implement and I am looking for your ideas on how to best implement it.

Want to be able to detect person’s direction of movement around the house. Say as a person moves from living room to family room to office, they will trigger the “living room motion sensor” followed by triggering “family room motion sensor” and quickly following by triggering “office motion sensor” .

And as they continue moving around, they will continue trigger sensors in the corresponding room.

What I want to be able to do is have a template or some other sensor, which state would be as continuesly updated as follows: (corresponding to person’s movement )
LRFM -? Moved from Living Room to Family Room
FMSR - Moved from Family room to study.
FRBR - moved from Family Room to Bedroom

Basically state of the sensor constantly reflects the direction of movement in the house. How would one go about implementing it?

It almost feels we need some sort of real time rules engine, that will interpret the events on the bus an determine the state to set on a sensor and keep updating it. Did anybody implement such real time rules based sensor? It could be useful for many other things other than just detecting of house movement. For example one could continuouslycollect multiple types of events and send those to external rules engine via new MQTT plugin and the rules engine could detect various things happening in the house…

Say: if time is late eve + TV off, followed by motion directed from Living Room to bedroom, following by + lights off in the house, followed by no motion for 20 minutes , the rules engine may decide that you are sleeping and set sensor state to “sleeping” . Which can in-turn turn the alarm system on.

But in my particular case of just detecting direction of movement in the house… Can it be done within the realm of already available facilities we have in HA ?



Happy Bubbles from memory would be a good place to start with this. It uses BLE beacons to locate you in a given space.

Check this vid out.

1 Like

Should be possible via several if conditions and time Based rules.
However, this only works if there is only 1 Person in the Home

Yes, will only work for one person. This is the intent.
I want to build an automation which detects only one person in the house and switches lights mode operation to follow that person around the house.

Ie : follow-me-lights. as you move around the house, light turns on in the room where you are with immediate turn off in all other rooms.

I think the problem is how are you going to keep the state information. You could possible you use the last change attribute, input select or sensor.

An over kill idea would be to create a state table with the devices you want to monitor for these automation. If it was TV room, kitchen and bedroom, then when no motion anywhere would be


and if you went from TV room to kitchen to bedroom then state change would be


then if you create 10 sensors for the past say 10 state changes, you can automate based on rules. On a state change of the sensor, the 10 created sensors would have to pass their information to the next sensor and update with new state.

I have been thinking of this approach to allow for machine learning so after time, we might not have to program automation.

1 Like

Thinking about it more, you could even make this somehow work for more than 1 person if you have 2 motion sensors on each door. 1x outside, 1x inside. Then you can even track how many people are in each room.
Alternatively two light barriers per door should be relatively cost effective to do this :slight_smile:

I am considering use of sonic sensor

if sonic sensor angled in room face doorway you can judge object direction (moving toward/moving away) and room occupancy. Im not familiar with sonic sensor spec but if it has coverage similar to PIR motion this could work. If sonic is very directional not so much.

There is another technology available. Tomography.

Click me :slight_smile: I really like the concept, but its a bit expensive

1 Like

Out of curiosity couldn’t this be achieved without keeping track of the space that was just left (assuming single user)? If a sensor is triggered it can be assumed that the person is no longer in the presence of the other sensors right? Then simply turn lights on for the triggered space and turn lights off everywhere else. Maybe I’m missing something?

For this portion it seems like it would be pretty easy to configure with current triggers/actions. What I’m not clear on is what part of this is manual and what part is automated.

Tried almost all these methods before

  • Installed motion detectors inside and outside of the door
    It has a 5-20 seconds delay between activation. If a person enters the room and leaves immediately the counter will be in wrong state.

  • Had two sets of ir senders and receivers(Light curtain)
    Too hard to keep track of kids of varying heights and body width(Tracking the delay between entry and exit to determine if the person moved in or out)
    Was thinking to combine ir, motion detectors and the Ultrasound sensors(To determine the height of person to identify kids), then it became too much.
    The easiest is to get everyone to wear Xiaomi Band 2(Presented as a fitness tracker and an everyday step counter challenge for kids) and track the position in the house through HappyBubbles, which is the way I am going at the moment.

1 Like

YEs. you are right. I am taking exactly this approach now as it is easier.
I will just loop through all the lights and turn them off. I guess I could also check if the said light is ON before trying to turn them off to save traffic on the bus.

Yes, what you are proposing is working within the realm of what is possible in HA. I think it can get very complicated very soon as more sensors are involved. I agree some sort of ML or external rules engine would probably make things easier and just deliver some computed state back to HA to consume.

I think external Rules Engine would be good enough for this as ML is more complicated.
I can think of this approach:

Just send every event from the bus over an MQTT message to an external rules engine. There you are no longer limited by HA limitations. Can create complicated rules. …
Once rules engine determines a particular state based on the messages it’s receiving from HA bus, it would send an MQTT message back to HA… And that “set state” message can be consumed by a template sensor.

This way, all my automations would have to do is be triggered by that sensor and perform an appropriate action.

What do you think?

I think that is a good approach to create a new rule service, it might add more functions than just using HA automation. I would like a cloud service where we don’t have to create rules but instead it suggest automation based on past events. It will be coming I bet as more IoT come alive.

1 Like

How about this: ?
Never really tried it in practice, because I live in a small flat, but planing to make the lawn mover drived by this.
Does not need any extra hardware and is not as unsafe as bluetooth…


I am definitely getting this! Just need to figure out 220V option for it. That tech is really cool. But it will need to be integrated into HA as it is NOT at the moment. Maybe a cool development project for me…

Is there a Open Source version project that uses Tomography and uses of the shelve mesh wi-fi routers, so I would not need to buy Xandem in addition to Wi-Fi mesh routers?