mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Move airtouch4 coordinator to its own file (#100424)
This commit is contained in:
parent
a8013836e1
commit
7723a9b36b
@ -45,6 +45,7 @@ omit =
|
|||||||
homeassistant/components/airthings_ble/sensor.py
|
homeassistant/components/airthings_ble/sensor.py
|
||||||
homeassistant/components/airtouch4/__init__.py
|
homeassistant/components/airtouch4/__init__.py
|
||||||
homeassistant/components/airtouch4/climate.py
|
homeassistant/components/airtouch4/climate.py
|
||||||
|
homeassistant/components/airtouch4/coordinator.py
|
||||||
homeassistant/components/airvisual/__init__.py
|
homeassistant/components/airvisual/__init__.py
|
||||||
homeassistant/components/airvisual/sensor.py
|
homeassistant/components/airvisual/sensor.py
|
||||||
homeassistant/components/airvisual_pro/__init__.py
|
homeassistant/components/airvisual_pro/__init__.py
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
"""The AirTouch4 integration."""
|
"""The AirTouch4 integration."""
|
||||||
import logging
|
|
||||||
|
|
||||||
from airtouch4pyapi import AirTouch
|
from airtouch4pyapi import AirTouch
|
||||||
from airtouch4pyapi.airtouch import AirTouchStatus
|
|
||||||
|
|
||||||
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, Platform
|
from homeassistant.const import CONF_HOST, 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 DOMAIN
|
from .const import DOMAIN
|
||||||
|
from .coordinator import AirtouchDataUpdateCoordinator
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
PLATFORMS = [Platform.CLIMATE]
|
PLATFORMS = [Platform.CLIMATE]
|
||||||
|
|
||||||
@ -44,38 +38,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class AirtouchDataUpdateCoordinator(DataUpdateCoordinator):
|
|
||||||
"""Class to manage fetching Airtouch data."""
|
|
||||||
|
|
||||||
def __init__(self, hass, airtouch):
|
|
||||||
"""Initialize global Airtouch data updater."""
|
|
||||||
self.airtouch = airtouch
|
|
||||||
|
|
||||||
super().__init__(
|
|
||||||
hass,
|
|
||||||
_LOGGER,
|
|
||||||
name=DOMAIN,
|
|
||||||
update_interval=SCAN_INTERVAL,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def _async_update_data(self):
|
|
||||||
"""Fetch data from Airtouch."""
|
|
||||||
await self.airtouch.UpdateInfo()
|
|
||||||
if self.airtouch.Status != AirTouchStatus.OK:
|
|
||||||
raise UpdateFailed("Airtouch connection issue")
|
|
||||||
return {
|
|
||||||
"acs": [
|
|
||||||
{"ac_number": ac.AcNumber, "is_on": ac.IsOn}
|
|
||||||
for ac in self.airtouch.GetAcs()
|
|
||||||
],
|
|
||||||
"groups": [
|
|
||||||
{
|
|
||||||
"group_number": group.GroupNumber,
|
|
||||||
"group_name": group.GroupName,
|
|
||||||
"is_on": group.IsOn,
|
|
||||||
}
|
|
||||||
for group in self.airtouch.GetGroups()
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
46
homeassistant/components/airtouch4/coordinator.py
Normal file
46
homeassistant/components/airtouch4/coordinator.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
"""DataUpdateCoordinator for the airtouch integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from airtouch4pyapi.airtouch import AirTouchStatus
|
||||||
|
|
||||||
|
from homeassistant.components.climate import SCAN_INTERVAL
|
||||||
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class AirtouchDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
"""Class to manage fetching Airtouch data."""
|
||||||
|
|
||||||
|
def __init__(self, hass, airtouch):
|
||||||
|
"""Initialize global Airtouch data updater."""
|
||||||
|
self.airtouch = airtouch
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
hass,
|
||||||
|
_LOGGER,
|
||||||
|
name=DOMAIN,
|
||||||
|
update_interval=SCAN_INTERVAL,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def _async_update_data(self):
|
||||||
|
"""Fetch data from Airtouch."""
|
||||||
|
await self.airtouch.UpdateInfo()
|
||||||
|
if self.airtouch.Status != AirTouchStatus.OK:
|
||||||
|
raise UpdateFailed("Airtouch connection issue")
|
||||||
|
return {
|
||||||
|
"acs": [
|
||||||
|
{"ac_number": ac.AcNumber, "is_on": ac.IsOn}
|
||||||
|
for ac in self.airtouch.GetAcs()
|
||||||
|
],
|
||||||
|
"groups": [
|
||||||
|
{
|
||||||
|
"group_number": group.GroupNumber,
|
||||||
|
"group_name": group.GroupName,
|
||||||
|
"is_on": group.IsOn,
|
||||||
|
}
|
||||||
|
for group in self.airtouch.GetGroups()
|
||||||
|
],
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user