bayesian binary sensor platform observes the state from multiple sensors and uses Bayes’ rule to estimate the probability that an event has occurred given the state of the observed sensors. If the estimated posterior probability is above the
probability_threshold, the sensor is
on otherwise it is
This allows for the detection of complex events that may not be readily observable, e.g., cooking, showering, in bed, the start of a morning routine, etc. It can also be used to gain greater confidence about events that are directly observable, but for which the sensors can be unreliable, e.g., presence.
To enable the Bayesian sensor, add the following lines to your
# Example configuration.yaml entry binary_sensor: - platform: bayesian prior: 0.1 observations: - entity_id: 'switch.kitchen_lights' prob_given_true: 0.6 prob_given_false: 0.2 platform: 'state' to_state: 'on'
(float)(Required)The prior probability of the event. At any point in time (ignoring all external influences) how likely is this event to occur?
(float)(Optional)The probability at which the sensor should trigger to
Default value: 0.5
(string)(Optional)Name of the sensor to use in the frontend.
Default value: Bayesian Binary Sensor
(list)(Required)The observations which should influence the likelihood that the given event has occurred.
(string)(Required)Name of the entity to monitor.
(float)(Required)The probability of the observation occurring, given the event is
(float)(Optional)The probability of the observation occurring, given the event is
falsecan be set as well.
1 - prob_given_trueif
prob_given_falseis not set
(string)(Required)The only supported observation platforms are
numeric_state, which are modeled after their corresponding triggers for automations, requiring
(string)(Required)The target state.
The following is an example for the
state observation platform.
# Example configuration.yaml entry binary_sensor: name: 'in_bed' platform: 'bayesian' prior: 0.25 probability_threshold: 0.95 observations: - entity_id: 'sensor.living_room_motion' prob_given_true: 0.4 prob_given_false: 0.2 platform: 'state' to_state: 'off' - entity_id: 'sensor.basement_motion' prob_given_true: 0.5 prob_given_false: 0.4 platform: 'state' to_state: 'off' - entity_id: 'sensor.bedroom_motion' prob_given_true: 0.5 platform: 'state' to_state: 'on' - entity_id: 'sun.sun' prob_given_true: 0.7 platform: 'state' to_state: 'below_horizon'
Next up an example which targets the
numeric_state observation platform,
as seen in the configuration it requires
above instead of
# Example configuration.yaml entry binary_sensor: name: 'Heat On' platform: 'bayesian' prior: 0.2 probability_threshold: 0.9 observations: - entity_id: 'sensor.outside_air_temperature_fahrenheit' prob_given_true: 0.95 platform: 'numeric_state' below: 50