Update hass-nabucasa & fix state (#22385)

* Update hass-nabucasa & fix state

* Fix lint
This commit is contained in:
Pascal Vizeli 2019-03-25 17:43:15 +01:00 committed by Paulus Schoutsen
parent f997957054
commit b57d809dad
5 changed files with 14 additions and 7 deletions

View File

@ -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__)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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