In version 108, I started to get a lot of problems with the bayesian sensors in combinations with inputs based on templates. In fact, my HA system get totally unresponsive when a template evaluates to true.
Here is the bayesian sensor config:
- platform: bayesian
name: 'Panelovner stue'
prior: 0.35
probability_threshold: 0.5
observations:
- entity_id: input_boolean.travel_enabled
prob_given_true: 0.001
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.vindu_2_etg_a
prob_given_true: 0.001
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.vindu_2_etg_b
prob_given_true: 0.001
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.noen_er_hjemme
prob_given_true: 0.7
platform: 'state'
to_state: 'on'
- entity_id: input_boolean.sleeptime
prob_given_true: 0.32
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.soonsleeptime
prob_given_true: 0.32
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.preheat_day
prob_given_true: 0.66
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.preheat_night_weekend
prob_given_true: 0.64
platform: 'state'
to_state: 'on'
- entity_id: binary_sensor.heatlimit_morning
prob_given_true: 0.4
platform: 'state'
to_state: 'on'
- entity_id: input_boolean.soonhome
prob_given_true: 0.66
platform: 'state'
to_state: 'on'
- entity_id: input_boolean.visitors_comfort_temp
prob_given_true: 0.64
platform: 'state'
to_state: 'on'
- entity_id: sensor.pricelevel
prob_given_true: 0.3
platform: 'state'
to_state: 'VERY_EXPENSIVE'
- prob_given_true: 0.64
platform: 'template'
value_template: >-
{{ states('binary_sensor.preheat_night') == 'on' and states('input_boolean.home_office') == 'on' }}
And here is the error in the log. The template used as input, evaluates to true at 03:10
2020-04-14 03:10:01 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2755669936] Unable to serialize to JSON: Object of type Template is not JSON serializable
{'id': 85, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'binary_sensor.panelovner_stue', 'old_state': <state binary_sensor.panelovner_stue=off; observations=[None, None, None, {'entity_id': 'binary_sensor.noen_er_hjemme', 'prob_given_true': 0.7, 'platform': 'state', 'to_state': 'on', 'id': 3}, {'entity_id': 'input_boolean.sleeptime', 'prob_given_true': 0.32, 'platform': 'state', 'to_state': 'on', 'id': 4}, None, None, None, None, None, None, None, None], occurred_observation_entities=['input_boolean.sleeptime', 'binary_sensor.noen_er_hjemme'], probability=0.37, probability_threshold=0.5, friendly_name=Panelovner stue @ 2020-04-13T20:00:01.123377+02:00>, 'new_state': <state binary_sensor.panelovner_stue=on; observations=[None, None, None, {'entity_id': 'binary_sensor.noen_er_hjemme', 'prob_given_true': 0.7, 'platform': 'state', 'to_state': 'on', 'id': 3}, {'entity_id': 'input_boolean.sleeptime', 'prob_given_true': 0.32, 'platform': 'state', 'to_state': 'on', 'id': 4}, None, None, None, None, None, None, None, {'entity_id': 'binary_sensor.preheat_night', 'prob_given_true': 0.64, 'platform': 'template', 'value_template': Template("{{ states('binary_sensor.preheat_night') == 'on' and states('input_boolean.home_office') == 'on' }}"), 'id': 12}], occurred_observation_entities=['input_boolean.sleeptime', 'binary_sensor.noen_er_hjemme', 'binary_sensor.preheat_night'], probability=0.51, probability_threshold=0.5, friendly_name=Panelovner stue @ 2020-04-14T03:10:01.114390+02:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2020, 4, 14, 1, 10, 1, 114451, tzinfo=<UTC>), 'context': {'id': 'b93ee2ccd5dc4e65b726fe917fbbd62f', 'parent_id': None, 'user_id': None}}}
The home-assistant.log grows to 200-300MB within minutes and are filled up with these “Unable to serialize to JSON: Object of type Template is not JSON serializable” messages. Does someone know what is causing this?