Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 26 additions & 21 deletions homeassistant/components/light/iglo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import voluptuous as vol

from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, Light)
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_RGB_COLOR,
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_EFFECT,
PLATFORM_SCHEMA, Light)
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util

REQUIREMENTS = ['iglo==1.1.3']
REQUIREMENTS = ['iglo==1.2.5']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,10 +47,6 @@ def __init__(self, name, host, port):
from iglo import Lamp
self._name = name
self._lamp = Lamp(0, host, port)
self._on = True
self._brightness = 255
self._rgb = (0, 0, 0)
self._color_temp = 0

@property
def name(self):
Expand All @@ -59,12 +56,12 @@ def name(self):
@property
def brightness(self):
"""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
def color_temp(self):
"""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'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (86 > 79 characters)


@property
def min_mireds(self):
Expand All @@ -81,21 +78,32 @@ def max_mireds(self):
@property
def rgb_color(self):
"""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
def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR
return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
SUPPORT_RGB_COLOR | SUPPORT_EFFECT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent


@property
def is_on(self):
"""Return true if light is on."""
return self._on
return self._lamp.state['on']

def turn_on(self, **kwargs):
"""Turn the light on."""
if not self._on:
if not self.is_on:
self._lamp.switch(True)
if ATTR_BRIGHTNESS in kwargs:
brightness = int((kwargs[ATTR_BRIGHTNESS] / 255.0) * 200.0)
Expand All @@ -113,14 +121,11 @@ def turn_on(self, **kwargs):
self._lamp.white(kelvin)
return

if ATTR_EFFECT in kwargs:
effect = kwargs[ATTR_EFFECT]
self._lamp.effect(effect)
return

def turn_off(self, **kwargs):
"""Turn the light off."""
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']
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ https://github.com/wokar/pylgnetcast/archive/v0.2.0.zip#pylgnetcast==0.2.0
# i2csense==0.0.4

# homeassistant.components.light.iglo
iglo==1.1.3
iglo==1.2.5

# homeassistant.components.ihc
ihcsdk==2.1.1
Expand Down