Add missing conext preservation to bayesian and universal (#40178)

We already do this for template sensors, but it was
missing for bayesian and universal
This commit is contained in:
J. Nick Koston 2020-09-17 09:47:23 -05:00 committed by GitHub
parent 95e998d25a
commit 44952a94cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 3 deletions

View file

@ -182,6 +182,7 @@ class BayesianBinarySensor(BinarySensorEntity):
entity = event.data.get("entity_id")
self.current_observations.update(self._record_entity_observations(entity))
self.async_set_context(event.context)
self._recalculate_and_write_state()
self.async_on_remove(
@ -220,6 +221,8 @@ class BayesianBinarySensor(BinarySensorEntity):
obs_entry = None
self.current_observations[obs["id"]] = obs_entry
if event:
self.async_set_context(event.context)
self._recalculate_and_write_state()
for template in self.observations_by_template: