1 """The Vogel's MotionMount integration."""
3 from __future__
import annotations
15 from .const
import DOMAIN, EMPTY_MAC
17 PLATFORMS: list[Platform] = [
18 Platform.BINARY_SENSOR,
26 """Set up Vogel's MotionMount from a config entry."""
28 host = entry.data[CONF_HOST]
31 mm = motionmount.MotionMount(host, entry.data[CONF_PORT])
36 except (ConnectionError, TimeoutError, socket.gaierror)
as ex:
40 if found_mac
not in (EMPTY_MAC, entry.unique_id):
48 f
"Unexpected device found at {host}; expected {entry.unique_id}, found {found_mac}"
52 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = mm
54 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
60 """Unload a config entry."""
61 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
62 mm: motionmount.MotionMount = hass.data[DOMAIN].pop(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)