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.""" 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/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.""" 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): 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)) 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/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) 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