Bayesian use cases, examples and how it works. I need some input! :)

I read a lot about the Bayesian integration lately. I am very interested but I also don’t understand Bayesian statistics. So I want some input.

Bayesian vs ‘dumb’ sensors
Why or better: when will a Bayesian sensor be better above a single sensor. I understand that my motion sensor and light in the basement (where only I come) is not useful.

Useful ideas?
I am struggling with a few things that normal automations can’t handle, thinking of

  • motion sensors activated by my cat
  • heating turns on at 17:00 in the living room while I am not planning on going there

Limitations
Bayesian is not AI or a learning thing. So I can imagine that heating things are more difficult, because they need time to heat (the room).

(Your) use cases
Do you have good or interesting use cases? I’d like to get inspired!

Have you read this?

1 Like

Indeed a must read for Bayes.

Shortest way to think about it is with this perspective…

You want to act on stuff but that stuff is kinda fuzzy…

Thibk of it this way. You want to automatically set the house in sleep mode at night when your So goes to bed. But once a week you have poker night. And you don’t want sleep mode to happen when that’s going on. So what sensors denote activity in the rest of the home so when whatever you’re using to detect SO in bed activates you can also gather data to determine should I set the home asleep.

Complex stats happen and resolve to an answer. Yes I should or no I should not. Then you act in that result.

No magic. Just stats. Read the post above in it’s entirety

The post @echopage links to is very good. It’s quite old, but it includes some spreadsheets for working out probabilities.

I have two use cases at the moment:

Probably Home

The aim is to allow HA to recover into an appropriate state after a restart - most restarts only last a few seconds, but after a power cut you don’t know how how long it will have been down, and one thing you need to establish is whether anyone’s in the house. This runs shortly after a restart and looks at time of day, movement, presence of devices and a few other things to decide whether to turn the heating on etc. It will also turn on presence simulation (lights going on and off) if I go out without setting the alarm.

It has another rather macabre use - if there is probably someone home but no movement for 24 hours HA sends a text to a neighbour.

Most likely room

My voice assistant responds over my Sonos speakers, but it has a single server (not a bunch of Alexas, in other words), so HA has to decide which room I’m in before it can reply. This takes device tracker data and adds information about movement, whether things like the TV are on or off, time of day etc. to work out which is the most likely room. It could be used for all sorts of room presence applications (like heating) and usually filters out my dog’s movements quite well (she doesn’t have a mobile phone). It also smooths out the “bounce” you sometimes get from room presence applications.

I built both of these for fun initially and was a bit dubious about how reliable they’d be. It took a bit of fine tuning, but it turns out they’re remarkably accurate, and, yes, better than relying on single sensors. You need quite a lot of kit, though - motion sensors and device trackers in every room. Fortunately things like Bluetooth proxies are not expensive.

2 Likes

Yes!

That still makes it fuzzy to me!

As this topic seems to be forgotten and I’m still looking for inspiration. I’ve came up with an idea: is it possible to use bayesian to determine if I am a short time or a long time from home?
Short time: running some errands. Long time: work or vacation, etc.

Old thread but still interest me. What I’ve done is; My example, occupancy and motion. A convoluted presence detection.

Devices, all Aqara entry T1s? and P1 motion sensors, about 7. More evidence “may” be best. And Reolink person detected and a convoluted cloud trick for Wyze cameras for person seen.

How an Aqara motion sensor works from factory. Motion triggers, clears in 30 seconds.
Occupancy also triggers at the same time as motion.

Occupancy takes 10 minutes to clear and if new motion occurs within that 10 minutes, it resets and starts the count down at 10 minutes, continuously with new motion. Can hold my Bayesians thresholds for 10 minutes or more.

Retirement fun, lol, :thinking: I created several mini Bayesians.
Computer room, bedroom, basement, trash day, garden, outside. Etc.

Computer room is used heavily in the morning. Path of travel concepts.

Hallway motion sensor see someone coming, ok, going to bedroom or computer room? So hallway some evidence but not a big spike.

Computer room motion detects, occupancy fires on, while there, unless absolutely still, motion will continuously trigger occupancy.

For my sensors, it’s safe to assume someone is in the computer room, so motion and occupancy are both in the observations. Holds Bayesian above the threshold.

Leaves computer room? Motion clears in 30 seconds, occupancy clears in 10 minutes.
(These Aqara motion device settings for at least motion are adjustable) occupancy? I’d have to look.

I have gauge’s for each Bayesian to show probability, template a sensor helpers to display probability on the gauges.

History graphs show room occupancy, and motion sensors display on another entities card.

Trash day;
Pulls Trash keyword in Google calendar events, automation to remind me, take trash down, two reminders, 11AM & 3PM.

Only on Tuesday. Ignored holidays and snow days for now. Wednesday also looked at in events, but manual entry of keyword (for now).

If completed, another automation sends notification that trash bin moved at so and so time. Etc.

So the Trash Bayesion is looking at on Tuesdays, during 11AM_5PM, has inner garage door opened, has Wyze V3 seen a person, has right outer garage door opened.

Has driveway Wyze V4 camera seen a person, walks down trash can, checks mail box, did my phone exit the home zone? Should have. Being seen by cameras coming back, right garage door closes, entry goes to off. Big spike trash has been completed. All observations in the Bayesian.

This would become a tedious post if I continued much further.

In case someone reads it and doesn’t know, visit the HA Bayesian page, it has a GUI integration for easier GUI building of the Bayesian sensors.

Read the document above, build a small Bayesian, think thru travel paths of family, time, for us old folks, it’s just two people.

While looking to load the integration, look at the sample Bayesians on the webpage and read it thoroughly.

It’ll take some time, effort and frustration, maybe some Ai assistance. Use Ai with a grain salt, trust but verify.

Good luck, I’m still tweaking Bayesians.:thinking::grimacing::grin: But, understanding Bayesians more & more every day. Have to build some more.

1 Like

There are three choices for Bayesian now, presumably YAML version still available.

And a developer brought it into gui, Bayesian - Home Assistant

What I consider easiest and now use. A WIP, GitHub - Hankanman/Area-Occupancy-Detection: A Home Assistant integration to accurately and intelligently track occupancy of an area