Use entity class attributes for anel_pwrctrl (#52594)
* Use entity class attributes for anel_pwrctrl * Tweakpull/52701/head
parent
b5a6d05778
commit
4e848f60c4
|
@ -65,25 +65,13 @@ class PwrCtrlSwitch(SwitchEntity):
|
||||||
"""Initialize the PwrCtrl switch."""
|
"""Initialize the PwrCtrl switch."""
|
||||||
self._port = port
|
self._port = port
|
||||||
self._parent_device = parent_device
|
self._parent_device = parent_device
|
||||||
|
self._attr_unique_id = f"{port.device.host}-{port.get_index()}"
|
||||||
@property
|
self._attr_name = port.label
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID of the device."""
|
|
||||||
return f"{self._port.device.host}-{self._port.get_index()}"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._port.label
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self):
|
|
||||||
"""Return true if the device is on."""
|
|
||||||
return self._port.get_state()
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Trigger update for all switches on the parent device."""
|
"""Trigger update for all switches on the parent device."""
|
||||||
self._parent_device.update()
|
self._parent_device.update()
|
||||||
|
self._attr_is_on = self._port.get_state()
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
|
|
Loading…
Reference in New Issue