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
@@ -261,6 +261,16 @@ class Throttle(object):
|
||||
|
||||
def __call__(self, method):
|
||||
"""Caller for the throttle."""
|
||||
# Make sure we return a coroutine if the method is async.
|
||||
if asyncio.iscoroutinefunction(method):
|
||||
async def throttled_value():
|
||||
"""Stand-in function for when real func is being throttled."""
|
||||
return None
|
||||
else:
|
||||
def throttled_value():
|
||||
"""Stand-in function for when real func is being throttled."""
|
||||
return None
|
||||
|
||||
if self.limit_no_throttle is not None:
|
||||
method = Throttle(self.limit_no_throttle)(method)
|
||||
|
||||
@@ -277,16 +287,6 @@ class Throttle(object):
|
||||
is_func = (not hasattr(method, '__self__') and
|
||||
'.' not in method.__qualname__.split('.<locals>.')[-1])
|
||||
|
||||
# Make sure we return a coroutine if the method is async.
|
||||
if asyncio.iscoroutinefunction(method):
|
||||
async def throttled_value():
|
||||
"""Stand-in function for when real func is being throttled."""
|
||||
return None
|
||||
else:
|
||||
def throttled_value():
|
||||
"""Stand-in function for when real func is being throttled."""
|
||||
return None
|
||||
|
||||
@wraps(method)
|
||||
def wrapper(*args, **kwargs):
|
||||
"""Wrap that allows wrapped to be called only once per min_time.
|
||||
|
||||
Reference in new issue
Block a user