mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00

* Add Tailscale integration * Use DeviceEntryType * Fix tests * Adjust to new Pylint version * Use enums for device classes * Update homeassistant/components/tailscale/config_flow.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Pass empty string as default Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""The Tailscale integration."""
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import TailscaleDataUpdateCoordinator
|
|
|
|
PLATFORMS = (BINARY_SENSOR_DOMAIN,)
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up Tailscale from a config entry."""
|
|
coordinator = TailscaleDataUpdateCoordinator(hass, entry)
|
|
await coordinator.async_config_entry_first_refresh()
|
|
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
|
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload Tailscale config entry."""
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
if unload_ok:
|
|
del hass.data[DOMAIN][entry.entry_id]
|
|
return unload_ok
|