From 078a7e446dabf92e7838f34ee2b12cff46ec2863 Mon Sep 17 00:00:00 2001 From: sophof Date: Tue, 26 Nov 2019 20:26:40 +0100 Subject: [PATCH] Fix all entities triggering all observations in bayesian sensor (#28979) * change fromkeys to dict comprehension to prevent append working on a list by reference. Now each entity id has its own seperate list * change fromkeys to dict comprehension to prevent append working on a list by reference. Now each entity id has its own seperate list * use get instead of direct keys for dict * change fromkeys to dict comprehension to prevent append working on a list by reference. Now each entity id has its own seperate list * use get instead of direct keys for dict * changed get back to [] --- homeassistant/components/bayesian/binary_sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/bayesian/binary_sensor.py b/homeassistant/components/bayesian/binary_sensor.py index ffa13a6288c..1d3720f6723 100644 --- a/homeassistant/components/bayesian/binary_sensor.py +++ b/homeassistant/components/bayesian/binary_sensor.py @@ -133,7 +133,7 @@ class BayesianBinarySensor(BinarySensorDevice): to_observe.update(set([obs.get("entity_id")])) if "value_template" in obs: to_observe.update(set(obs.get(CONF_VALUE_TEMPLATE).extract_entities())) - self.entity_obs = dict.fromkeys(to_observe, []) + self.entity_obs = {key: [] for key in to_observe} for ind, obs in enumerate(self._observations): obs["id"] = ind