1 """The Hisense AEH-W4A1 integration."""
6 from pyaehw4a1.aehw4a1
import AehW4a1
7 import pyaehw4a1.exceptions
8 import voluptuous
as vol
10 from homeassistant
import config_entries
18 from .const
import DOMAIN
20 _LOGGER = logging.getLogger(__name__)
22 PLATFORMS = [Platform.CLIMATE]
26 """Validate that provided value is a valid IP address."""
28 raise vol.Invalid(
"Must define an IP address")
30 ipaddress.IPv4Network(value)
31 except ValueError
as err:
32 raise vol.Invalid(
"Not a valid IP address")
from err
36 CONFIG_SCHEMA = vol.Schema(
39 CLIMATE_DOMAIN: vol.Schema(
41 vol.Optional(CONF_IP_ADDRESS, default=[]): vol.All(
42 cv.ensure_list, [vol.All(cv.string, coerce_ip)]
48 extra=vol.ALLOW_EXTRA,
52 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
53 """Set up the Hisense AEH-W4A1 integration."""
54 conf = config.get(DOMAIN)
55 hass.data[DOMAIN] = {}
58 devices = conf[CONF_IP_ADDRESS][:]
59 for device
in devices:
61 await AehW4a1(device).
check()
62 except pyaehw4a1.exceptions.ConnectionError:
63 conf[CONF_IP_ADDRESS].
remove(device)
64 _LOGGER.warning(
"Hisense AEH-W4A1 at %s not found", device)
65 if conf[CONF_IP_ADDRESS]:
66 hass.data[DOMAIN] = conf
67 hass.async_create_task(
68 hass.config_entries.flow.async_init(
70 context={
"source": config_entries.SOURCE_IMPORT},
78 """Set up a config entry for Hisense AEH-W4A1."""
79 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
84 """Unload a config entry."""
85 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool remove(self, _T matcher)
bool async_setup(HomeAssistant hass, ConfigType config)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
def check(config_dir, secrets=False)