mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add effects to iGlo Lights (#12365)
* Add effects to iGlo Lights Simplify state variables to library * Fix lint issues
This commit is contained in:
parent
facd833e6d
commit
8d48272cbd
@ -10,13 +10,14 @@ import math
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, PLATFORM_SCHEMA,
|
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_RGB_COLOR,
|
||||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, Light)
|
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_EFFECT,
|
||||||
|
PLATFORM_SCHEMA, Light)
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
REQUIREMENTS = ['iglo==1.1.3']
|
REQUIREMENTS = ['iglo==1.2.5']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -46,10 +47,6 @@ class IGloLamp(Light):
|
|||||||
from iglo import Lamp
|
from iglo import Lamp
|
||||||
self._name = name
|
self._name = name
|
||||||
self._lamp = Lamp(0, host, port)
|
self._lamp = Lamp(0, host, port)
|
||||||
self._on = True
|
|
||||||
self._brightness = 255
|
|
||||||
self._rgb = (0, 0, 0)
|
|
||||||
self._color_temp = 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -59,12 +56,13 @@ class IGloLamp(Light):
|
|||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return int((self._brightness / 200.0) * 255)
|
return int((self._lamp.state['brightness'] / 200.0) * 255)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the color temperature."""
|
"""Return the color temperature."""
|
||||||
return color_util.color_temperature_kelvin_to_mired(self._color_temp)
|
return color_util.color_temperature_kelvin_to_mired(
|
||||||
|
self._lamp.state['white'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_mireds(self):
|
def min_mireds(self):
|
||||||
@ -81,21 +79,32 @@ class IGloLamp(Light):
|
|||||||
@property
|
@property
|
||||||
def rgb_color(self):
|
def rgb_color(self):
|
||||||
"""Return the RGB value."""
|
"""Return the RGB value."""
|
||||||
return self._rgb
|
return self._lamp.state['rgb']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def effect(self):
|
||||||
|
"""Return the current effect."""
|
||||||
|
return self._lamp.state['effect']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def effect_list(self):
|
||||||
|
"""Return the list of supported effects."""
|
||||||
|
return self._lamp.effect_list
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
|
return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
|
||||||
|
SUPPORT_RGB_COLOR | SUPPORT_EFFECT)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if light is on."""
|
"""Return true if light is on."""
|
||||||
return self._on
|
return self._lamp.state['on']
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
if not self._on:
|
if not self.is_on:
|
||||||
self._lamp.switch(True)
|
self._lamp.switch(True)
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
brightness = int((kwargs[ATTR_BRIGHTNESS] / 255.0) * 200.0)
|
brightness = int((kwargs[ATTR_BRIGHTNESS] / 255.0) * 200.0)
|
||||||
@ -113,14 +122,11 @@ class IGloLamp(Light):
|
|||||||
self._lamp.white(kelvin)
|
self._lamp.white(kelvin)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if ATTR_EFFECT in kwargs:
|
||||||
|
effect = kwargs[ATTR_EFFECT]
|
||||||
|
self._lamp.effect(effect)
|
||||||
|
return
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
self._lamp.switch(False)
|
self._lamp.switch(False)
|
||||||
|
|
||||||
def update(self):
|
|
||||||
"""Update light status."""
|
|
||||||
state = self._lamp.state()
|
|
||||||
self._on = state['on']
|
|
||||||
self._brightness = state['brightness']
|
|
||||||
self._rgb = state['rgb']
|
|
||||||
self._color_temp = state['white']
|
|
||||||
|
@ -394,7 +394,7 @@ https://github.com/wokar/pylgnetcast/archive/v0.2.0.zip#pylgnetcast==0.2.0
|
|||||||
# i2csense==0.0.4
|
# i2csense==0.0.4
|
||||||
|
|
||||||
# homeassistant.components.light.iglo
|
# homeassistant.components.light.iglo
|
||||||
iglo==1.1.3
|
iglo==1.2.5
|
||||||
|
|
||||||
# homeassistant.components.ihc
|
# homeassistant.components.ihc
|
||||||
ihcsdk==2.1.1
|
ihcsdk==2.1.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user