Skip to content

Commit

Permalink
Add airtouch5 (home-assistant#98136)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Resch <[email protected]>
  • Loading branch information
danzel and edenhaus authored Jan 23, 2024
1 parent 701404f commit e3a73c1
Show file tree
Hide file tree
Showing 18 changed files with 661 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ omit =
homeassistant/components/airtouch4/__init__.py
homeassistant/components/airtouch4/climate.py
homeassistant/components/airtouch4/coordinator.py
homeassistant/components/airtouch5/__init__.py
homeassistant/components/airtouch5/climate.py
homeassistant/components/airtouch5/entity.py
homeassistant/components/airvisual/__init__.py
homeassistant/components/airvisual/sensor.py
homeassistant/components/airvisual_pro/__init__.py
Expand Down
1 change: 1 addition & 0 deletions .strict-typing
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ homeassistant.components.airnow.*
homeassistant.components.airq.*
homeassistant.components.airthings.*
homeassistant.components.airthings_ble.*
homeassistant.components.airtouch5.*
homeassistant.components.airvisual.*
homeassistant.components.airvisual_pro.*
homeassistant.components.airzone.*
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ build.json @home-assistant/supervisor
/tests/components/airthings_ble/ @vincegio @LaStrada
/homeassistant/components/airtouch4/ @samsinnamon
/tests/components/airtouch4/ @samsinnamon
/homeassistant/components/airtouch5/ @danzel
/tests/components/airtouch5/ @danzel
/homeassistant/components/airvisual/ @bachya
/tests/components/airvisual/ @bachya
/homeassistant/components/airvisual_pro/ @bachya
Expand Down
50 changes: 50 additions & 0 deletions homeassistant/components/airtouch5/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""The Airtouch 5 integration."""
from __future__ import annotations

from airtouch5py.airtouch5_simple_client import Airtouch5SimpleClient

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .const import DOMAIN

PLATFORMS: list[Platform] = [Platform.CLIMATE]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Airtouch 5 from a config entry."""

hass.data.setdefault(DOMAIN, {})

# Create API instance
host = entry.data[CONF_HOST]
client = Airtouch5SimpleClient(host)

# Connect to the API
try:
await client.connect_and_stay_connected()
except TimeoutError as t:
raise ConfigEntryNotReady() from t

# Store an API object for your platforms to access
hass.data[DOMAIN][entry.entry_id] = client

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
client: Airtouch5SimpleClient = hass.data[DOMAIN][entry.entry_id]
await client.disconnect()
client.ac_status_callbacks.clear()
client.connection_state_callbacks.clear()
client.data_packet_callbacks.clear()
client.zone_status_callbacks.clear()
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok
Loading

0 comments on commit e3a73c1

Please sign in to comment.