1 """Switch implementation for Energenie-Power-Sockets Platform."""
5 from pyegps
import __version__
as PYEGPS_VERSION
6 from pyegps.exceptions
import EgpsException
7 from pyegps.powerstrip
import PowerStrip
16 from .const
import DOMAIN
21 config_entry: ConfigEntry,
22 async_add_entities: AddEntitiesCallback,
24 """Add EGPS sockets for passed config_entry in HA."""
25 powerstrip: PowerStrip = hass.data[DOMAIN][config_entry.entry_id]
30 for socket
in range(powerstrip.numberOfSockets)
32 update_before_add=
True,
37 """Represents a socket of an Energenie-Socket-Strip."""
39 _attr_device_class = SwitchDeviceClass.OUTLET
40 _attr_has_entity_name =
True
41 _attr_translation_key =
"socket"
43 def __init__(self, dev: PowerStrip, socket: int) ->
None:
44 """Initiate a new socket."""
51 identifiers={(DOMAIN, dev.device_id)},
53 manufacturer=dev.manufacturer,
55 sw_version=PYEGPS_VERSION,
59 """Switch the socket on."""
62 except EgpsException
as err:
66 """Switch the socket off."""
69 except EgpsException
as err:
73 """Read the current state from the device."""
76 except EgpsException
as err:
_attr_translation_placeholders
None turn_on(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None __init__(self, PowerStrip dev, int socket)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
def get_status(hass, host, port)