Switchbot bump Dependency 0.14.0 (#74001)
* Bump requirement. * Switchbot depenacy update, full async. * Update tests, remove redundant config entry check. * Update requirements_test_all.txt * Update requirements_all.txt * Remove asyncio lock. Not required anymore with bleak. * Update requirements_all.txt * Update requirements_test_all.txt * pyswitchbot no longer uses bluepy
This commit is contained in:
parent
b185de0ac0
commit
10ea88e0ea
13 changed files with 59 additions and 88 deletions
|
@ -1,11 +1,10 @@
|
|||
"""Provides the switchbot DataUpdateCoordinator."""
|
||||
from __future__ import annotations
|
||||
|
||||
from asyncio import Lock
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import switchbot # pylint: disable=import-error
|
||||
import switchbot
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -26,7 +25,6 @@ class SwitchbotDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
api: switchbot,
|
||||
retry_count: int,
|
||||
scan_timeout: int,
|
||||
api_lock: Lock,
|
||||
) -> None:
|
||||
"""Initialize global switchbot data updater."""
|
||||
self.switchbot_api = api
|
||||
|
@ -39,20 +37,12 @@ class SwitchbotDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
hass, _LOGGER, name=DOMAIN, update_interval=self.update_interval
|
||||
)
|
||||
|
||||
self.api_lock = api_lock
|
||||
|
||||
def _update_data(self) -> dict | None:
|
||||
"""Fetch device states from switchbot api."""
|
||||
|
||||
return self.switchbot_data.discover(
|
||||
retry=self.retry_count, scan_timeout=self.scan_timeout
|
||||
)
|
||||
|
||||
async def _async_update_data(self) -> dict | None:
|
||||
"""Fetch data from switchbot."""
|
||||
|
||||
async with self.api_lock:
|
||||
switchbot_data = await self.hass.async_add_executor_job(self._update_data)
|
||||
switchbot_data = await self.switchbot_data.discover(
|
||||
retry=self.retry_count, scan_timeout=self.scan_timeout
|
||||
)
|
||||
|
||||
if not switchbot_data:
|
||||
raise UpdateFailed("Unable to fetch switchbot services data")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue