Skip to content

Commit c144aec

Browse files
authored
Use shorthand attributes in opple light (home-assistant#163519)
1 parent 1cb44ae commit c144aec

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

homeassistant/components/opple/light.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ def __init__(self, name, host):
6262

6363
self._device = OppleLightDevice(host)
6464

65-
self._name = name
66-
self._is_on = None
67-
self._brightness = None
65+
self._attr_name = name
6866

6967
@property
7068
def available(self) -> bool:
@@ -76,21 +74,6 @@ def unique_id(self):
7674
"""Return unique ID for light."""
7775
return self._device.mac
7876

79-
@property
80-
def name(self):
81-
"""Return the display name of this light."""
82-
return self._name
83-
84-
@property
85-
def is_on(self):
86-
"""Return true if light is on."""
87-
return self._is_on
88-
89-
@property
90-
def brightness(self):
91-
"""Return the brightness of the light."""
92-
return self._brightness
93-
9477
def turn_on(self, **kwargs: Any) -> None:
9578
"""Instruct the light to turn on."""
9679
_LOGGER.debug("Turn on light %s %s", self._device.ip, kwargs)
@@ -118,8 +101,8 @@ def update(self) -> None:
118101

119102
if (
120103
prev_available == self.available
121-
and self._is_on == self._device.power_on
122-
and self._brightness == self._device.brightness
104+
and self._attr_is_on == self._device.power_on
105+
and self._attr_brightness == self._device.brightness
123106
and self._attr_color_temp_kelvin == self._device.color_temperature
124107
):
125108
return
@@ -128,8 +111,8 @@ def update(self) -> None:
128111
_LOGGER.debug("Light %s is offline", self._device.ip)
129112
return
130113

131-
self._is_on = self._device.power_on
132-
self._brightness = self._device.brightness
114+
self._attr_is_on = self._device.power_on
115+
self._attr_brightness = self._device.brightness
133116
self._attr_color_temp_kelvin = self._device.color_temperature
134117

135118
if not self.is_on:
@@ -138,6 +121,6 @@ def update(self) -> None:
138121
_LOGGER.debug(
139122
"Update light %s success: power on brightness %s color temperature %s",
140123
self._device.ip,
141-
self._brightness,
124+
self._attr_brightness,
142125
self._attr_color_temp_kelvin,
143126
)

0 commit comments

Comments
 (0)