From 6d5f00098a0ef4a941542cb84873909f494009f0 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Nov 2016 07:53:54 -0800 Subject: [PATCH 1/6] Move Honeywell I/O out of event loop (#4244) --- homeassistant/components/climate/honeywell.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/climate/honeywell.py b/homeassistant/components/climate/honeywell.py index 540a9a941d1..0d31cdd1387 100644 --- a/homeassistant/components/climate/honeywell.py +++ b/homeassistant/components/climate/honeywell.py @@ -223,7 +223,6 @@ class HoneywellUSThermostat(ClimateDevice): @property def current_temperature(self): """Return the current temperature.""" - self._device.refresh() return self._device.current_temperature @property @@ -274,3 +273,7 @@ class HoneywellUSThermostat(ClimateDevice): """Set the system mode (Cool, Heat, etc).""" if hasattr(self._device, ATTR_SYSTEM_MODE): self._device.system_mode = operation_mode + + def update(self): + """Update the state.""" + self._device.refresh() From faceb4c1dc0ac52212ef6fe9c9263cddc2fd9fa8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Nov 2016 23:12:20 -0800 Subject: [PATCH 2/6] Sequential updates for non-async entities --- homeassistant/helpers/entity_component.py | 36 ++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index a648de1d650..f4ca2f1274f 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -279,6 +279,7 @@ class EntityPlatform(object): self.entity_namespace = entity_namespace self.platform_entities = [] self._async_unsub_polling = None + self._process_updates = False def add_entities(self, new_entities, update_before_add=False): """Add entities for a single platform.""" @@ -335,14 +336,35 @@ class EntityPlatform(object): self._async_unsub_polling() self._async_unsub_polling = None - @callback + @asyncio.coroutine def _update_entity_states(self, now): """Update the states of all the polling entities. - + To protect from flooding the executor, we will update async entities + in parallel and other entities sequential. This method must be run in the event loop. """ - for entity in self.platform_entities: - if entity.should_poll: - self.component.hass.loop.create_task( - entity.async_update_ha_state(True) - ) + if self._process_updates: + return + self._process_updates = True + + try: + tasks = [] + to_update = [] + + for entity in self.platform_entities: + if not entity.should_poll: + continue + + update_coro = entity.async_update_ha_state(True) + if hasattr(entity, 'async_update'): + tasks.append(update_coro) + else: + to_update.append(update_coro) + + for update_coro in to_update: + yield from update_coro + + if tasks: + yield from asyncio.wait(tasks, loop=self.component.hass.loop) + finally: + self._process_updates = False From 6a92e27e2fc00ab31b5439e62fdfeba3208821c6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Nov 2016 23:12:37 -0800 Subject: [PATCH 3/6] Version bump to 0.32.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 299e437be3c..0eb2384517d 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 32 -PATCH_VERSION = '1' +PATCH_VERSION = '2' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) From 272899ec963ebef2f12ba2308f0e91bb06758383 Mon Sep 17 00:00:00 2001 From: andyat Date: Sun, 6 Nov 2016 23:18:06 -0800 Subject: [PATCH 4/6] Fix setting temperature in Celsius on radiotherm CT50 (#4270) --- homeassistant/components/climate/radiotherm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/climate/radiotherm.py b/homeassistant/components/climate/radiotherm.py index 5fa3f891aac..d06e148cfdd 100644 --- a/homeassistant/components/climate/radiotherm.py +++ b/homeassistant/components/climate/radiotherm.py @@ -135,9 +135,9 @@ class RadioThermostat(ClimateDevice): if temperature is None: return if self._current_operation == STATE_COOL: - self.device.t_cool = temperature + self.device.t_cool = round(temperature * 2.0) / 2.0 elif self._current_operation == STATE_HEAT: - self.device.t_heat = temperature + self.device.t_heat = round(temperature * 2.0) / 2.0 if self.hold_temp: self.device.hold = 1 else: @@ -159,6 +159,6 @@ class RadioThermostat(ClimateDevice): elif operation_mode == STATE_AUTO: self.device.tmode = 3 elif operation_mode == STATE_COOL: - self.device.t_cool = self._target_temperature + self.device.t_cool = round(self._target_temperature * 2.0) / 2.0 elif operation_mode == STATE_HEAT: - self.device.t_heat = self._target_temperature + self.device.t_heat = round(self._target_temperature * 2.0) / 2.0 From 0af1a96f14ef112acc9cf2f0212087aefd5353b9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Nov 2016 23:24:25 -0800 Subject: [PATCH 5/6] Lint --- homeassistant/helpers/entity_component.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index f4ca2f1274f..1144ee112e7 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -339,8 +339,10 @@ class EntityPlatform(object): @asyncio.coroutine def _update_entity_states(self, now): """Update the states of all the polling entities. + To protect from flooding the executor, we will update async entities in parallel and other entities sequential. + This method must be run in the event loop. """ if self._process_updates: From d129df93dd509d85798786f6cc01a6458435e538 Mon Sep 17 00:00:00 2001 From: David-Leon Pohl Date: Mon, 7 Nov 2016 08:34:32 +0100 Subject: [PATCH 6/6] Hotfix #4272 (#4273) --- homeassistant/components/switch/pilight.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/pilight.py b/homeassistant/components/switch/pilight.py index 1818372f1dc..f07d91ca9fb 100644 --- a/homeassistant/components/switch/pilight.py +++ b/homeassistant/components/switch/pilight.py @@ -37,8 +37,10 @@ SWITCHES_SCHEMA = vol.Schema({ vol.Required(CONF_ON_CODE): COMMAND_SCHEMA, vol.Required(CONF_OFF_CODE): COMMAND_SCHEMA, vol.Optional(CONF_NAME): cv.string, - vol.Optional(CONF_OFF_CODE_RECIEVE): COMMAND_SCHEMA, - vol.Optional(CONF_ON_CODE_RECIEVE): COMMAND_SCHEMA, + vol.Optional(CONF_OFF_CODE_RECIEVE, default=[]): vol.All(cv.ensure_list, + [COMMAND_SCHEMA]), + vol.Optional(CONF_ON_CODE_RECIEVE, default=[]): vol.All(cv.ensure_list, + [COMMAND_SCHEMA]) }) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({