From 4e848f60c4b17859f12f2d7ff6c2d8a47d15e292 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Wed, 7 Jul 2021 22:12:17 -0400 Subject: [PATCH] Use entity class attributes for anel_pwrctrl (#52594) * Use entity class attributes for anel_pwrctrl * Tweak --- .../components/anel_pwrctrl/switch.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/anel_pwrctrl/switch.py b/homeassistant/components/anel_pwrctrl/switch.py index 0669a3bb6c6..2f4ce0ee7db 100644 --- a/homeassistant/components/anel_pwrctrl/switch.py +++ b/homeassistant/components/anel_pwrctrl/switch.py @@ -65,25 +65,13 @@ class PwrCtrlSwitch(SwitchEntity): """Initialize the PwrCtrl switch.""" self._port = port self._parent_device = parent_device - - @property - 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() + self._attr_unique_id = f"{port.device.host}-{port.get_index()}" + self._attr_name = port.label def update(self): """Trigger update for all switches on the parent device.""" self._parent_device.update() + self._attr_is_on = self._port.get_state() def turn_on(self, **kwargs): """Turn the switch on."""