From a987cad973e41f7d9a64fb9ebd93d513ec16ed2e Mon Sep 17 00:00:00 2001
From: epenet <6771947+epenet@users.noreply.github.com>
Date: Thu, 4 Aug 2022 23:10:27 +0200
Subject: [PATCH] Use attributes in unifiled light (#76019)

---
 homeassistant/components/unifiled/light.py | 52 ++++++----------------
 1 file changed, 14 insertions(+), 38 deletions(-)

diff --git a/homeassistant/components/unifiled/light.py b/homeassistant/components/unifiled/light.py
index 8ba9fc2b6f9..f1d3ad15a02 100644
--- a/homeassistant/components/unifiled/light.py
+++ b/homeassistant/components/unifiled/light.py
@@ -63,58 +63,34 @@ class UnifiLedLight(LightEntity):
     _attr_color_mode = ColorMode.BRIGHTNESS
     _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
 
-    def __init__(self, light, api):
+    def __init__(self, light: dict[str, Any], api: unifiled) -> None:
         """Init Unifi LED Light."""
 
         self._api = api
         self._light = light
-        self._name = light["name"]
-        self._unique_id = light["id"]
-        self._state = light["status"]["output"]
-        self._available = light["isOnline"]
-        self._brightness = self._api.convertfrom100to255(light["status"]["led"])
-
-    @property
-    def name(self):
-        """Return the display name of this light."""
-        return self._name
-
-    @property
-    def available(self):
-        """Return the available state of this light."""
-        return self._available
-
-    @property
-    def brightness(self):
-        """Return the brightness name of this light."""
-        return self._brightness
-
-    @property
-    def unique_id(self):
-        """Return the unique id of this light."""
-        return self._unique_id
-
-    @property
-    def is_on(self):
-        """Return true if light is on."""
-        return self._state
+        self._attr_name = light["name"]
+        self._light_id = light["id"]
+        self._attr_unique_id = light["id"]
+        self._attr_is_on = light["status"]["output"]
+        self._attr_available = light["isOnline"]
+        self._attr_brightness = self._api.convertfrom100to255(light["status"]["led"])
 
     def turn_on(self, **kwargs: Any) -> None:
         """Instruct the light to turn on."""
         self._api.setdevicebrightness(
-            self._unique_id,
+            self._light_id,
             str(self._api.convertfrom255to100(kwargs.get(ATTR_BRIGHTNESS, 255))),
         )
-        self._api.setdeviceoutput(self._unique_id, 1)
+        self._api.setdeviceoutput(self._light_id, 1)
 
     def turn_off(self, **kwargs: Any) -> None:
         """Instruct the light to turn off."""
-        self._api.setdeviceoutput(self._unique_id, 0)
+        self._api.setdeviceoutput(self._light_id, 0)
 
     def update(self) -> None:
         """Update the light states."""
-        self._state = self._api.getlightstate(self._unique_id)
-        self._brightness = self._api.convertfrom100to255(
-            self._api.getlightbrightness(self._unique_id)
+        self._attr_is_on = self._api.getlightstate(self._light_id)
+        self._attr_brightness = self._api.convertfrom100to255(
+            self._api.getlightbrightness(self._light_id)
         )
-        self._available = self._api.getlightavailable(self._unique_id)
+        self._attr_available = self._api.getlightavailable(self._light_id)