def __init__(self, name, code, username, password, url): """Initialize the iAlarm status.""" self._name = name self._code = str(code) if code else None self._username = username self._password = password self._url = url self._state = None self._client = IAlarm(username, password, url)
def __init__(self, name, username, password, url): """Initialize the iAlarm status.""" from pyialarm import IAlarm self._name = name self._username = username self._password = password self._url = url self._state = None self._client = IAlarm(username, password, url)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up iAlarm config.""" host = entry.data[CONF_HOST] port = entry.data[CONF_PORT] ialarm = IAlarm(host, port) try: async with timeout(10): mac = await hass.async_add_executor_job(ialarm.get_mac) except (asyncio.TimeoutError, ConnectionError) as ex: raise ConfigEntryNotReady from ex coordinator = IAlarmDataUpdateCoordinator(hass, ialarm, mac) await coordinator.async_config_entry_first_refresh() hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.entry_id] = { DATA_COORDINATOR: coordinator, } hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True
async def _get_device_mac(hass: core.HomeAssistant, host, port): ialarm = IAlarm(host, port) return await hass.async_add_executor_job(ialarm.get_mac)