mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 21:10:25 +00:00
Update hass-nabucasa & fix state (#22385)
* Update hass-nabucasa & fix state * Fix lint
This commit is contained in:
committed by
Paulus Schoutsen
parent
f997957054
commit
b57d809dad
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user