1 """The D-Link Power Plug integration."""
3 from __future__
import annotations
5 from pyW215.pyW215
import SmartPlug
12 from .const
import CONF_USE_LEGACY_PROTOCOL
13 from .data
import SmartPlugData
15 type DLinkConfigEntry = ConfigEntry[SmartPlugData]
17 PLATFORMS = [Platform.SWITCH]
21 """Set up D-Link Power Plug from a config entry."""
22 smartplug = await hass.async_add_executor_job(
24 entry.data[CONF_HOST],
25 entry.data[CONF_PASSWORD],
26 entry.data[CONF_USERNAME],
27 entry.data[CONF_USE_LEGACY_PROTOCOL],
29 if not smartplug.authenticated
and smartplug.use_legacy_protocol:
33 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
39 """Unload a config entry."""
40 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, DLinkConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, DLinkConfigEntry entry)