mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move coolmaster coordinator to its own file (#100425)
This commit is contained in:
parent
c170babba6
commit
a08b74c550
@ -182,6 +182,7 @@ omit =
|
|||||||
homeassistant/components/control4/__init__.py
|
homeassistant/components/control4/__init__.py
|
||||||
homeassistant/components/control4/director_utils.py
|
homeassistant/components/control4/director_utils.py
|
||||||
homeassistant/components/control4/light.py
|
homeassistant/components/control4/light.py
|
||||||
|
homeassistant/components/coolmaster/coordinator.py
|
||||||
homeassistant/components/cppm_tracker/device_tracker.py
|
homeassistant/components/cppm_tracker/device_tracker.py
|
||||||
homeassistant/components/crownstone/__init__.py
|
homeassistant/components/crownstone/__init__.py
|
||||||
homeassistant/components/crownstone/devices.py
|
homeassistant/components/crownstone/devices.py
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
"""The Coolmaster integration."""
|
"""The Coolmaster integration."""
|
||||||
import logging
|
|
||||||
|
|
||||||
from pycoolmasternet_async import CoolMasterNet
|
from pycoolmasternet_async import CoolMasterNet
|
||||||
|
|
||||||
from homeassistant.components.climate import SCAN_INTERVAL
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT, Platform
|
from homeassistant.const import CONF_HOST, CONF_PORT, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
|
||||||
|
|
||||||
from .const import CONF_SWING_SUPPORT, DATA_COORDINATOR, DATA_INFO, DOMAIN
|
from .const import CONF_SWING_SUPPORT, DATA_COORDINATOR, DATA_INFO, DOMAIN
|
||||||
|
from .coordinator import CoolmasterDataUpdateCoordinator
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
PLATFORMS = [Platform.CLIMATE, Platform.BINARY_SENSOR, Platform.BUTTON, Platform.SENSOR]
|
PLATFORMS = [Platform.CLIMATE, Platform.BINARY_SENSOR, Platform.BUTTON, Platform.SENSOR]
|
||||||
|
|
||||||
@ -60,25 +55,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class CoolmasterDataUpdateCoordinator(DataUpdateCoordinator):
|
|
||||||
"""Class to manage fetching Coolmaster data."""
|
|
||||||
|
|
||||||
def __init__(self, hass, coolmaster):
|
|
||||||
"""Initialize global Coolmaster data updater."""
|
|
||||||
self._coolmaster = coolmaster
|
|
||||||
|
|
||||||
super().__init__(
|
|
||||||
hass,
|
|
||||||
_LOGGER,
|
|
||||||
name=DOMAIN,
|
|
||||||
update_interval=SCAN_INTERVAL,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def _async_update_data(self):
|
|
||||||
"""Fetch data from Coolmaster."""
|
|
||||||
try:
|
|
||||||
return await self._coolmaster.status()
|
|
||||||
except OSError as error:
|
|
||||||
raise UpdateFailed from error
|
|
||||||
|
31
homeassistant/components/coolmaster/coordinator.py
Normal file
31
homeassistant/components/coolmaster/coordinator.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"""DataUpdateCoordinator for coolmaster integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.climate import SCAN_INTERVAL
|
||||||
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class CoolmasterDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
"""Class to manage fetching Coolmaster data."""
|
||||||
|
|
||||||
|
def __init__(self, hass, coolmaster):
|
||||||
|
"""Initialize global Coolmaster data updater."""
|
||||||
|
self._coolmaster = coolmaster
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
hass,
|
||||||
|
_LOGGER,
|
||||||
|
name=DOMAIN,
|
||||||
|
update_interval=SCAN_INTERVAL,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def _async_update_data(self):
|
||||||
|
"""Fetch data from Coolmaster."""
|
||||||
|
try:
|
||||||
|
return await self._coolmaster.status()
|
||||||
|
except OSError as error:
|
||||||
|
raise UpdateFailed from error
|
Loading…
x
Reference in New Issue
Block a user