Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions homeassistant/components/niko_home_control/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import voluptuous as vol

# Import the device class from the component that you want to support
from homeassistant.components.light import ATTR_BRIGHTNESS, PLATFORM_SCHEMA, LightEntity
from homeassistant.components.light import PLATFORM_SCHEMA, ColorMode, LightEntity
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady
Expand Down Expand Up @@ -51,14 +51,16 @@ async def async_setup_platform(
class NikoHomeControlLight(LightEntity):
"""Representation of an Niko Light."""

_attr_color_mode = ColorMode.ONOFF
_attr_supported_color_modes = {ColorMode.ONOFF}
Comment on lines +54 to +55
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not be ColorMode.BRIGHTNESS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to ONOFF will not change the behavior.

The non-working brightness code has been there since the integration was first added, @MartinHjelmare had review comments about it which were never addressed: #18019

Maybe @NoUseFreak or @legovaer could comment?


def __init__(self, light, data):
"""Set up the Niko Home Control light platform."""
self._data = data
self._light = light
self._unique_id = f"light-{light.id}"
self._name = light.name
self._state = light.is_on
self._brightness = None

@property
def unique_id(self):
Expand All @@ -70,19 +72,13 @@ def name(self):
"""Return the display name of this light."""
return self._name

@property
def brightness(self):
"""Return the brightness of the light."""
return self._brightness

@property
def is_on(self):
"""Return true if light is on."""
return self._state

def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
_LOGGER.debug("Turn on: %s", self.name)
self._light.turn_on()

Expand Down