Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active October 7, 2022 13:22
Show Gist options
  • Save HarvsG/fa3a943ff47ce7b55bd06fe60842271b to your computer and use it in GitHub Desktop.
Save HarvsG/fa3a943ff47ce7b55bd06fe60842271b to your computer and use it in GitHub Desktop.
example configs.

The hacky, not-reccomended, may break in future solution would be this

platform: bayesian
prior: 0.6
name: occupancy_livingroom_0
probability_threshold: 0.87
observations:
  - entity_id: "input_boolean.occupancy_override_livingroom_0"
    prob_given_true: 0.9
    prob_given_false: 0.1
    platform: "state"
    to_state: "on"
  - entity_id: "input_boolean.occupancy_override_livingroom_0"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "off"
  - entity_id: "binary_sensor.pir_sensor_livingroom_0"
    prob_given_true: 0.45
    prob_given_false: 0.2
    platform: "state"
    to_state: "on"
  - entity_id: "binary_sensor.pir_sensor_livingroom_0"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "off"
  - entity_id: "binary_sensor.dop_sensor_livingroom_0"
    prob_given_true: 0.45
    prob_given_false: 0.2
    platform: "state"
    to_state: "on"
  - entity_id: "binary_sensor.dop_sensor_livingroom_0"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "off"

platform: oldbayesian
prior: 0.6
name: home_precense_ben
probability_threshold: 0.85
observations:
  - entity_id: "device_tracker.ben"
    prob_given_true: 0.9
    prob_given_false: 0.2
    platform: "state"
    to_state: "home"
  - entity_id: "device_tracker.ben"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "not_home"
  - entity_id: "input_boolean.home_precense_homekit_ben"
    prob_given_true: 0.9
    prob_given_false: 0.2
    platform: "state"
    to_state: "on"
  - entity_id: "input_boolean.home_precense_homekit_ben"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "off"

The hacky, not-reccomended, may break in future solution would be this

  - name: 'family'
    platform: bayesian
    prior: 0.83
    probability_threshold: 0.86
    observations:
      - entity_id: 'device_tracker.nmap_person1'
        prob_given_true: 0.95
        prob_given_false: 0.125
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.nmap_person1' # this duplicate entry for not_home is uninformative so bayesian effectively ingores it.
        prob_given_true: 0.5
        prob_given_false: 0.5
        platform: 'state'
        to_state: 'not_home'
      - entity_id: 'device_tracker.person1phoneapp'
        prob_given_true: 0.8
        prob_given_false: 0.5
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.person1phoneapp'
        prob_given_true: 0.5
        prob_given_false: 0.5
        platform: 'state'
        to_state: 'not_home'
      - entity_id: 'device_tracker.life360_person1'
        prob_given_true: 0.6
        prob_given_false: 0.5
        platform: 'state'
        to_state: 'home'
      - entity_id: 'device_tracker.life360_person1'
        prob_given_true: 0.5
        prob_given_false: 0.5
        platform: 'state'
        to_state: 'not_home'

And so on

@HarvsG
Copy link
Author

HarvsG commented Oct 7, 2022

@Altycoder, Note how there are 2 entries for each entity? Configuring an uninformative entry for the off to_state for every entity is the difference. This is essentially what the old logic was (incorrectly) doing in the background before. It makes zero sense mathematically but if it works on your config....

- entity_id: "input_boolean.occupancy_override_livingroom_0"
    prob_given_true: 0.5
    prob_given_false: 0.5
    platform: "state"
    to_state: "off"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment