Sleepwalking detection / virtual entities

We’ve got an older kid who is a sleepwalker, and I’m trying to create automations which will let us know when they are up and around while not creating false positives for getting up and going to the bathroom.

I’ve got a collection of different sensors (several motion sensors with luminence) and have reasonably good algorithms for detecting individual things happening (kid is light’s out for the night, kid has left the room, etc…). I’m struggling to build logic that ties those things together to say things like “if they’ve gone to bed and they leave the room but don’t go into the bathroom, wake us up after 5 minutes”.

The specific issue is that I’m facing having to build a variety of automations with a lot of duplicate logic that I know I’m going to need to be tweaking and updating to address false positives and negatives. Things would be greatly simplified if I can build an automation for “Kid has gone to bed” and store that state somewhere where I can then reference it in conditions in other scripts.

Is there such a thing as a “virtual entity” that’s not tied to a hardware device, where I can control the state through automations / scripts? I’ve done some searching but the right way to do this hasn’t leapt out. I see template sensors, but all of the examples are for setting state based on the state of other things.

The virtual one would be a ‘helper’
6 New Home Assistant Input Helpers Explained! (

One could also think of presence (not motion) detection but my personal experiences are not good so far with a Aqara fp1

Though they can be a bit fussy to get set up, this may be a good place for a Bayesian Binary Sensor

1 Like

How about creating a dropdown helper and then using it to hold the current state, i.e. in bed, in the bathroom, on walkabout etc (input_select.select_option). Then you can have an automation that triggers after the state is walkabout for at least 5 minutes. Alternatively, if you want to try pyscript, you can use the state.set() function to create a sensor and save whatever sensor & state combination you want.