From 3e6cf8f59f5d673a002d675850cfd89bce7140ab Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Wed, 26 Sep 2018 15:38:13 -0700 Subject: [PATCH 1/6] Optimize Ring Sensors platform setup (#16886) --- homeassistant/components/binary_sensor/ring.py | 7 ++++--- homeassistant/components/sensor/ring.py | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/binary_sensor/ring.py b/homeassistant/components/binary_sensor/ring.py index 102e22cbe2d..3945eb5c926 100644 --- a/homeassistant/components/binary_sensor/ring.py +++ b/homeassistant/components/binary_sensor/ring.py @@ -44,14 +44,15 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ring = hass.data[DATA_RING] sensors = [] - for sensor_type in config.get(CONF_MONITORED_CONDITIONS): - for device in ring.doorbells: + for device in ring.doorbells: # ring.doorbells is doing I/O + for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'doorbell' in SENSOR_TYPES[sensor_type][1]: sensors.append(RingBinarySensor(hass, device, sensor_type)) - for device in ring.stickup_cams: + for device in ring.stickup_cams: # ring.stickup_cams is doing I/O + for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'stickup_cams' in SENSOR_TYPES[sensor_type][1]: sensors.append(RingBinarySensor(hass, device, diff --git a/homeassistant/components/sensor/ring.py b/homeassistant/components/sensor/ring.py index 31c0360cc23..408971c60e1 100644 --- a/homeassistant/components/sensor/ring.py +++ b/homeassistant/components/sensor/ring.py @@ -66,16 +66,18 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ring = hass.data[DATA_RING] sensors = [] - for sensor_type in config.get(CONF_MONITORED_CONDITIONS): - for device in ring.chimes: + for device in ring.chimes: # ring.chimes is doing I/O + for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'chime' in SENSOR_TYPES[sensor_type][1]: sensors.append(RingSensor(hass, device, sensor_type)) - for device in ring.doorbells: + for device in ring.doorbells: # ring.doorbells is doing I/O + for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'doorbell' in SENSOR_TYPES[sensor_type][1]: sensors.append(RingSensor(hass, device, sensor_type)) - for device in ring.stickup_cams: + for device in ring.stickup_cams: # ring.stickup_cams is doing I/O + for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'stickup_cams' in SENSOR_TYPES[sensor_type][1]: sensors.append(RingSensor(hass, device, sensor_type)) From 3528f8e647ccb13a4c940bfe8053a9fb4a321e7c Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Sat, 29 Sep 2018 21:22:24 +0200 Subject: [PATCH 2/6] Fix exception during history_stats startup (#16932) * Fix exception during history_stats startup * Do not track changes during startup * Ignore args --- .../components/sensor/history_stats.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/sensor/history_stats.py b/homeassistant/components/sensor/history_stats.py index c76d2cefca0..a8d9276edc8 100644 --- a/homeassistant/components/sensor/history_stats.py +++ b/homeassistant/components/sensor/history_stats.py @@ -10,6 +10,7 @@ import math import voluptuous as vol +from homeassistant.core import callback from homeassistant.components import history import homeassistant.helpers.config_validation as cv import homeassistant.util.dt as dt_util @@ -19,7 +20,7 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_START) from homeassistant.exceptions import TemplateError from homeassistant.helpers.entity import Entity -from homeassistant.helpers.event import track_state_change +from homeassistant.helpers.event import async_track_state_change _LOGGER = logging.getLogger(__name__) @@ -94,8 +95,6 @@ class HistoryStatsSensor(Entity): self, hass, entity_id, entity_state, start, end, duration, sensor_type, name): """Initialize the HistoryStats sensor.""" - self._hass = hass - self._entity_id = entity_id self._entity_state = entity_state self._duration = duration @@ -109,15 +108,19 @@ class HistoryStatsSensor(Entity): self.value = None self.count = None - def force_refresh(*args): - """Force the component to refresh.""" - self.schedule_update_ha_state(True) + @callback + def start_refresh(*args): + """Register state tracking.""" + @callback + def force_refresh(*args): + """Force the component to refresh.""" + self.async_schedule_update_ha_state(True) - # Update value when home assistant starts - hass.bus.listen_once(EVENT_HOMEASSISTANT_START, force_refresh) + force_refresh() + async_track_state_change(self.hass, self._entity_id, force_refresh) - # Update value when tracked entity changes its state - track_state_change(hass, entity_id, force_refresh) + # Delay first refresh to keep startup fast + hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_refresh) @property def name(self): From 32d652884bbdf22bc5727efd057e3f77b1557c75 Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Sat, 29 Sep 2018 11:53:02 -0700 Subject: [PATCH 3/6] Override unique_id of NestActivityZoneSensor (#16961) --- homeassistant/components/binary_sensor/nest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/components/binary_sensor/nest.py b/homeassistant/components/binary_sensor/nest.py index c60463a8663..7f7278d9789 100644 --- a/homeassistant/components/binary_sensor/nest.py +++ b/homeassistant/components/binary_sensor/nest.py @@ -147,6 +147,11 @@ class NestActivityZoneSensor(NestBinarySensor): self.zone = zone self._name = "{} {} activity".format(self._name, self.zone.name) + @property + def unique_id(self): + """Return unique id based on camera serial and zone id.""" + return "{}-{}".format(self.device.serial, self.zone.zone_id) + @property def device_class(self): """Return the device class of the binary sensor.""" From c45b240026ef04adaa264055c8d3e404f78d380c Mon Sep 17 00:00:00 2001 From: Greg Laabs Date: Sun, 30 Sep 2018 00:21:27 -0700 Subject: [PATCH 4/6] Fix ISY blocking bug (#16978) This fix results in `is_on` returning False if the state is unknown (which was a bug in 0.79). --- homeassistant/components/light/isy994.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/light/isy994.py b/homeassistant/components/light/isy994.py index 4349bfa1467..d54aa3cd4ce 100644 --- a/homeassistant/components/light/isy994.py +++ b/homeassistant/components/light/isy994.py @@ -31,12 +31,14 @@ class ISYLightDevice(ISYDevice, Light): @property def is_on(self) -> bool: """Get whether the ISY994 light is on.""" + if self.is_unknown(): + return False return self.value != 0 @property def brightness(self) -> float: """Get the brightness of the ISY994 light.""" - return self.value + return None if self.is_unknown() else self.value def turn_off(self, **kwargs) -> None: """Send the turn off command to the ISY994 light device.""" From e2aadc3227f7356d21541b514744e9d6626da395 Mon Sep 17 00:00:00 2001 From: Rohan Kapoor Date: Sun, 30 Sep 2018 00:21:07 -0700 Subject: [PATCH 5/6] Bump zm-py to 0.0.4 (#16979) --- homeassistant/components/zoneminder.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zoneminder.py b/homeassistant/components/zoneminder.py index 53d6d8b2536..b7f43177200 100644 --- a/homeassistant/components/zoneminder.py +++ b/homeassistant/components/zoneminder.py @@ -15,7 +15,7 @@ import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['zm-py==0.0.3'] +REQUIREMENTS = ['zm-py==0.0.4'] CONF_PATH_ZMS = 'path_zms' diff --git a/requirements_all.txt b/requirements_all.txt index 61a412951f9..cdcab14d81c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1567,4 +1567,4 @@ zigpy-xbee==0.1.1 zigpy==0.2.0 # homeassistant.components.zoneminder -zm-py==0.0.3 +zm-py==0.0.4 From 677714ecab4ef7e358c6b014a49a37d43827ae21 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 30 Sep 2018 10:22:49 +0200 Subject: [PATCH 6/6] Bumped version to 0.79.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index d3888d2651e..31e05c2c86b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 79 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)