Fix mysensors light supported features (#13512)
* Different types of light should have different supported features.pull/12899/merge
parent
f391cbae27
commit
0a0b33af03
|
@ -12,8 +12,7 @@ from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.util.color import rgb_hex_to_rgb_list
|
from homeassistant.util.color import rgb_hex_to_rgb_list
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
SUPPORT_MYSENSORS = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR |
|
SUPPORT_MYSENSORS_RGBW = SUPPORT_COLOR | SUPPORT_WHITE_VALUE
|
||||||
SUPPORT_WHITE_VALUE)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
@ -64,11 +63,6 @@ class MySensorsLight(mysensors.MySensorsEntity, Light):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_MYSENSORS
|
|
||||||
|
|
||||||
def _turn_on_light(self):
|
def _turn_on_light(self):
|
||||||
"""Turn on light child device."""
|
"""Turn on light child device."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
|
@ -171,6 +165,11 @@ class MySensorsLight(mysensors.MySensorsEntity, Light):
|
||||||
class MySensorsLightDimmer(MySensorsLight):
|
class MySensorsLightDimmer(MySensorsLight):
|
||||||
"""Dimmer child class to MySensorsLight."""
|
"""Dimmer child class to MySensorsLight."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
|
@ -188,6 +187,14 @@ class MySensorsLightDimmer(MySensorsLight):
|
||||||
class MySensorsLightRGB(MySensorsLight):
|
class MySensorsLightRGB(MySensorsLight):
|
||||||
"""RGB child class to MySensorsLight."""
|
"""RGB child class to MySensorsLight."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
set_req = self.gateway.const.SetReq
|
||||||
|
if set_req.V_DIMMER in self._values:
|
||||||
|
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
|
||||||
|
return SUPPORT_COLOR
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
|
@ -209,6 +216,14 @@ class MySensorsLightRGBW(MySensorsLightRGB):
|
||||||
|
|
||||||
# pylint: disable=too-many-ancestors
|
# pylint: disable=too-many-ancestors
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
set_req = self.gateway.const.SetReq
|
||||||
|
if set_req.V_DIMMER in self._values:
|
||||||
|
return SUPPORT_BRIGHTNESS | SUPPORT_MYSENSORS_RGBW
|
||||||
|
return SUPPORT_MYSENSORS_RGBW
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
|
|
Loading…
Reference in New Issue