Refactor Hue: phue -> aiohue (#13043)
* phue -> aiohue * Clean up * Fix config * Address comments * Typo * Fix rebase error * Mark light as unavailable when bridge is disconnected * Tests * Make Throttle work with double delay and async * Rework update logic * Don't resolve host to IP * Clarify comment * No longer do unnecessary updates * Add more doc * Another comment update * Wrap up tests * Lint * Fix tests * PyLint does not like mix 'n match async and coroutine * Lint * Update aiohue to 1.2 * Lint * Fix await MagicMock
This commit is contained in:
1 parent
d78e75db66
commit
5a9013cda5
20 files changed
+1289
-1485
No files matched your search
@@ -203,8 +203,8 @@ def get_config_value(node, value_index, tries=5):
|
||||
return None
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the Z-Wave platform (generic part)."""
|
||||
if discovery_info is None or DATA_NETWORK not in hass.data:
|
||||
return False
|
||||
@@ -504,8 +504,7 @@ def setup(hass, config):
|
||||
"target node:%s, instance=%s", node_id, group,
|
||||
target_node_id, instance)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_refresh_entity(service):
|
||||
async def async_refresh_entity(service):
|
||||
"""Refresh values that specific entity depends on."""
|
||||
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||
async_dispatcher_send(
|
||||
@@ -559,8 +558,7 @@ def setup(hass, config):
|
||||
network.start()
|
||||
hass.bus.fire(const.EVENT_NETWORK_START)
|
||||
|
||||
@asyncio.coroutine
|
||||
def _check_awaked():
|
||||
async def _check_awaked():
|
||||
"""Wait for Z-wave awaked state (or timeout) and finalize start."""
|
||||
_LOGGER.debug(
|
||||
"network state: %d %s", network.state,
|
||||
@@ -585,7 +583,7 @@ def setup(hass, config):
|
||||
network.state_str)
|
||||
break
|
||||
else:
|
||||
yield from asyncio.sleep(1, loop=hass.loop)
|
||||
await asyncio.sleep(1, loop=hass.loop)
|
||||
|
||||
hass.async_add_job(_finalize_start)
|
||||
|
||||
@@ -798,11 +796,10 @@ class ZWaveDeviceEntityValues():
|
||||
|
||||
dict_id = id(self)
|
||||
|
||||
@asyncio.coroutine
|
||||
def discover_device(component, device, dict_id):
|
||||
async def discover_device(component, device, dict_id):
|
||||
"""Put device in a dictionary and call discovery on it."""
|
||||
self._hass.data[DATA_DEVICES][dict_id] = device
|
||||
yield from discovery.async_load_platform(
|
||||
await discovery.async_load_platform(
|
||||
self._hass, component, DOMAIN,
|
||||
{const.DISCOVERY_DEVICE: dict_id}, self._zwave_config)
|
||||
self._hass.add_job(discover_device, component, device, dict_id)
|
||||
@@ -844,8 +841,7 @@ class ZWaveDeviceEntity(ZWaveBaseEntity):
|
||||
self.update_properties()
|
||||
self.maybe_schedule_update()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self):
|
||||
"""Add device to dict."""
|
||||
async_dispatcher_connect(
|
||||
self.hass,
|
||||
|
||||
Reference in new issue
Block a user