Bayesian Integration - What do you use it for?

I am trying to use the Bayesian sensor for a novel user case. I have a large freshwater aquarium with a sump (basically a small tank below the aquarium) in which the recirculation pump, ph, temperature and ORP sensors are located. The aquarium has an automatic water changing system that on rare occasions has a failure in which the water drains out of the sump due to power outages or potentially other issues relating to the Reverse Osmosis intake.

This week, I had an event in which due to a small water leak in my RO unit, the sump water level started to decline. I realized that with a Bayesian sensor, I can monitor the PH and ORP sensors because the moment the water level drops below the probes, I can trigger an alarm or notification.

I need some help though because the YAML code isn’t working:

When I do a check code it gives me the following error:

Invalid config for [python_script]: expected dict for dictionary value @ data['python_script']. Got [OrderedDict([('platform', 'bayesian'), ('name', 'Sump Low'), ('prior', 0.6), ('probability_threshold', 0.8), ('observations', [OrderedDict([('platform', 'numeric_state'), ('entity_id', 'sensor.apex_ph'), ('prob_given_true', 0.7), ('prob_given_false', 0.1), ('below', 6.2)]), OrderedDict([('platform', 'numeric_state'), ('entity_id', 'sensor.apex_orp'), ('prob_given_true', 0.7), ('prob_given_false', 0.1), ('below', 400)])])])]. (See /config/configuration.yaml, line 50).

My config YAML is:

  - platform: "bayesian"
    name: "Sump Low"
    prior: 0.6
    probability_threshold: 0.8
    observations:
      - platform: numeric_state
        entity_id: sensor.apex_ph
        prob_given_true: 0.7
        prob_given_false: 0.1
        below: 6.2
      - platform: numeric_state
        entity_id: sensor.apex_orp
        prob_given_true: 0.7
        prob_given_false: 0.1
        below: 400

I haven’t done any refining of the probabilities yet.

Questions:

  1. Is bayesian part of the basic python installation or does one need to install anything else?
  2. What am I doing wrong in the YAML code?