diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 9517971b16d..76a768385f8 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -24,7 +24,7 @@ from .const import ( CONF_USER_POOL_ID, DOMAIN, MODE_DEV, MODE_PROD) from .prefs import CloudPreferences -REQUIREMENTS = ['hass-nabucasa==0.10'] +REQUIREMENTS = ['hass-nabucasa==0.11'] DEPENDENCIES = ['http'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/cloud/binary_sensor.py b/homeassistant/components/cloud/binary_sensor.py index 874c3420c58..19a6528e321 100644 --- a/homeassistant/components/cloud/binary_sensor.py +++ b/homeassistant/components/cloud/binary_sensor.py @@ -1,6 +1,7 @@ """Support for Home Assistant Cloud binary sensors.""" +import asyncio + from homeassistant.components.binary_sensor import BinarySensorDevice -from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN @@ -8,6 +9,9 @@ from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN DEPENDENCIES = ['cloud'] +WAIT_UNTIL_CHANGE = 3 + + async def async_setup_platform( hass, config, async_add_entities, discovery_info=None): """Set up the cloud binary sensors.""" @@ -58,10 +62,10 @@ class CloudRemoteBinary(BinarySensorDevice): async def async_added_to_hass(self): """Register update dispatcher.""" - @callback - def async_state_update(data): + async def async_state_update(data): """Update callback.""" - self.async_write_ha_state() + await asyncio.sleep(WAIT_UNTIL_CHANGE) + self.async_schedule_update_ha_state() self._unsub_dispatcher = async_dispatcher_connect( self.hass, DISPATCHER_REMOTE_UPDATE, async_state_update) diff --git a/requirements_all.txt b/requirements_all.txt index 8603d7a91de..020ed3248a5 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -521,7 +521,7 @@ habitipy==0.2.0 hangups==0.4.6 # homeassistant.components.cloud -hass-nabucasa==0.10 +hass-nabucasa==0.11 # homeassistant.components.mqtt.server hbmqtt==0.9.4 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 1a8298d196b..4bd50b713e2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -120,7 +120,7 @@ ha-ffmpeg==1.11 hangups==0.4.6 # homeassistant.components.cloud -hass-nabucasa==0.10 +hass-nabucasa==0.11 # homeassistant.components.mqtt.server hbmqtt==0.9.4 diff --git a/tests/components/cloud/test_binary_sensor.py b/tests/components/cloud/test_binary_sensor.py index 938829b809b..f6d8783a609 100644 --- a/tests/components/cloud/test_binary_sensor.py +++ b/tests/components/cloud/test_binary_sensor.py @@ -7,6 +7,9 @@ from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE async def test_remote_connection_sensor(hass): """Test the remote connection sensor.""" + from homeassistant.components.cloud import binary_sensor as bin_sensor + bin_sensor.WAIT_UNTIL_CHANGE = 0 + assert await async_setup_component(hass, 'cloud', {'cloud': {}}) cloud = hass.data['cloud'] = Mock() cloud.remote.certificate = None