1 """Energenie Power-Sockets (EGPS) integration."""
3 from pyegps
import PowerStripUSB, get_device
4 from pyegps.exceptions
import MissingLibrary, UsbError
11 from .const
import CONF_DEVICE_API_ID, DOMAIN
13 PLATFORMS = [Platform.SWITCH]
17 """Set up Energenie Power Sockets."""
19 powerstrip: PowerStripUSB |
None =
get_device(entry.data[CONF_DEVICE_API_ID])
21 except (MissingLibrary, UsbError)
as ex:
24 if powerstrip
is None:
26 "Can't access Energenie Power Sockets, will retry later."
29 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = powerstrip
30 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
36 """Unload config entry."""
37 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
38 powerstrip = hass.data[DOMAIN].pop(entry.entry_id)
41 if not hass.data[DOMAIN]:
DeviceEntry get_device(HomeAssistant hass, str unique_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)