I’m trying to figure out how to add multiple Bayesian sensors. I’d like to track when I am home and when my wife is at home. This is the yaml code that I thought would work, but I get a duplicate key error:
binary_sensor:
# Bayesian sensor determining if I am home
- platform: bayesian
name: "Me_home"
prior: 0.75
probability_threshold: 0.75
observations:
- entity_id: "device_tracker.my_phone"
prob_given_true: 0.75
prob_given_false: 0.25
platform: "state"
to_state: "home"
binary_sensor:
# Bayesian sensor determining if Wife is home
- platform: bayesian
name: "Wife home"
prior: 0.60
probability_threshold: 0.75
observations:
- entity_id: "device_tracker.wifes_phone"
prob_given_true: 0.75
prob_given_false: 0.25
platform: "state"
to_state: "home"
I always have trouble getting my head around the Bayesian integration, and you may just be experimenting, but how did you work out your prob_given_false etc?
If I’ve understood correctly, when your phone’s home there’s a 75% chance that you are too; when your phone’s not home, there’s a 25% chance that you’re home. That suggests that you leave it behind a lot, and that it’s “unavailable” a lot of the time (I think…).
One of the great things about Bayesian in HA is that there’s lots of historical data to use. There’s an interactive spreadsheet here to save you racking your brain over the maths:
Also, the more observations you have, the better it works!