Bayesian binary sensor does not seem to work


#1

I was super excited to see the Bayesian binary sensor by @jlmcgehee21 and implemented it right away for presence detection. Here’s the config:

  - platform: 'bayesian'
    prior: 0.25
    name: 'Rashmi Home'
    probability_threshold: 0.95
    observations:
      - entity_id: 'device_tracker.pi_rashmiphone'
        prob_given_true: 0.8
        prob_given_false: 0.6
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.rashmiappiphone'
        prob_given_true: 0.99
        prob_given_false: 0.99
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.rashmisiphone'
        prob_given_true: 0.9
        prob_given_false: 0.6
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.sonu_sonu'
        prob_given_true: 0.99
        prob_given_false: 0.99
        platform: 'state'
        to_state: 'home'

However, despite all the trackers being home, I am not seeing the right value for binary_sensor.rashmi_home. The probability is only 0.4

image

Not sure what am I missing.


The new Bayesian Binary Sensor - Any additional examples?
Best Implementation Strategy for Bayesian Binary Sensor
#2

Posted a response here: https://github.com/home-assistant/home-assistant/issues/9347


#3

Just to complete the loop, here is the updated sensor

  - platform: 'bayesian'
    prior: 0.75
    name: 'Rashmi Home'
    probability_threshold: 0.95
    observations:
      - entity_id: 'device_tracker.pi_rashmiphone'
        prob_given_true: 0.8
        prob_given_false: 0.2
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.rashmiappiphone'
        prob_given_true: 0.99
        prob_given_false: 0.10
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.rashmisiphone'
        prob_given_true: 0.95
        prob_given_false: 0.4
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.sonu_sonu'
        prob_given_true: 0.99
        prob_given_false: 0.1
        platform: 'state'
        to_state: 'home'

#4

I works also here, thank you for your contribution.