Bayesian Sensor not updating (always off and "probability" 0 no matter how the inputs change)

Hello,

I have several presence sensors (Aqara FP1E) and the iBeacon signal of my Android phone (using the companion app as a transmitter and my HA host, which is in the same room as the presence sensors, as the receiver) and now want to combine all of these with a Bayesian sensor to compensate false-negatives of the presence sensors (while I am sleeping) and false-positives of the BLE sensor (when I leave my phone in the room).
I currently have the following YAML:

binary_sensor:
- platform: bayesian
  name: "Anwesenheit Bayesian"
  prior: 0.5
  probability_threshold: 0.8
  unique_id: 9872abdc-8ca5-4d66-801d-4685f93126b7
  device_class: occupancy
  observations:
   - platform: template
     value_template: >
       {{states("binary_sensor.fpe1e_1_presence")=="on"}}
     prob_given_true: 0.9
     prob_given_false: 0.5
   - platform: template
     value_template: >
       {{states("binary_sensor.fpe1e_2_presence")=="on"}}
     prob_given_true: 0.9
     prob_given_false: 0.5
   - platform: template
     value_template: >
       {{states("binary_sensor.fpe1e_3_presence")=="on"}}
     prob_given_true: 0.9
     prob_given_false: 0.5
   - platform: template
     value_template: >
       {{states("device_tracker.handy_aaron_ble")=="home" and states("sensor.handy_aaron_distance")|float(11) < 8}}
     prob_given_true: 0.7
     prob_given_false: 0.4

However, the binary sensor stays ‘off’ all the time even if all 3 FP1Es are triggered and my phone is within BLE range, the probability atteibute also stays at 0 all the time.
What could be the cause of this issue?

Best regards
Aaron

Not sure why you’re using templates. It may not be the cause of the problem, but it complicates things. Why not…

    - platform: "state"
      entity_id: "binary_sensor.fpe1e_1_presence"
      to_state: "on"

I had it like that in the beginning but as it didn’t work I changed it. Now I changed it back to what you suggested and it still doesn’t work…

I’ve been having a look at my Bayesian sensors. It’s a while since I set them up, but I notice that in all of your observations prob_given_true and prob_given_false added together give a number > 1. In mine the sum of the two is always <= 1. Which sort of makes sense intuitively.

    # Phone in kitchen -------------------------------------------------------------

    - platform: "state"
      entity_id: "sensor.nokia_area"
      to_state: "Kitchen"

      # Phone often gets left elsewhere

      prob_given_true: 0.33
      prob_given_false: 0.02

Have you looked at this post? It’s quite old, but it provides spreadsheets for working out the observations.