Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Ledenet protocol support to flux_led #5097

Merged
merged 2 commits into from Dec 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions homeassistant/components/light/flux_led.py
Expand Up @@ -10,15 +10,15 @@

import voluptuous as vol

from homeassistant.const import CONF_DEVICES, CONF_NAME
from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_PROTOCOL
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_EFFECT, EFFECT_RANDOM,
SUPPORT_BRIGHTNESS, SUPPORT_EFFECT, SUPPORT_RGB_COLOR, Light,
PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.10.zip'
'#flux_led==0.10']
REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.11.zip'
'#flux_led==0.11']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -34,6 +34,8 @@
vol.Optional(CONF_NAME): cv.string,
vol.Optional(ATTR_MODE, default='rgbw'):
vol.All(cv.string, vol.In(['rgbw', 'rgb'])),
Copy link
Member

Choose a reason for hiding this comment

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

If the changes to add LEDENET protocol to flux_led pypi package allow for controlling all five channels (RGBWW), we need to consider adding RGBWW as a mode in the near future. For now, let's just get LEDENET added in working condition and stable for all users.

Copy link
Author

Choose a reason for hiding this comment

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

I agree. I need to get a true RGBWW light to test it with though. Most are just RGB(warm)W and not actually a 5th channel for the fancy white hue changing leds.

vol.Optional(CONF_PROTOCOL, default=None):
vol.All(cv.string, vol.In(['ledenet'])),
Copy link
Member

Choose a reason for hiding this comment

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

@bah2830 : You have to change the library to support lower case. https://github.com/Danielhiversen/flux_led/blob/master/flux_led/__init__.py#L642

Copy link
Author

Choose a reason for hiding this comment

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

The setprotocol method of the library uppers everything so this will work

Copy link
Member

Choose a reason for hiding this comment

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

Ok, i see

})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
Expand All @@ -51,6 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
device = {}
device['name'] = device_config[CONF_NAME]
device['ipaddr'] = ipaddr
device[CONF_PROTOCOL] = device_config[CONF_PROTOCOL]
device[ATTR_MODE] = device_config[ATTR_MODE]
light = FluxLight(device)
if light.is_valid:
Expand Down Expand Up @@ -87,11 +90,14 @@ def __init__(self, device):

self._name = device['name']
self._ipaddr = device['ipaddr']
self._protocol = device[CONF_PROTOCOL]
self._mode = device[ATTR_MODE]
self.is_valid = True
self._bulb = None
try:
self._bulb = flux_led.WifiLedBulb(self._ipaddr)
if self._protocol:
self._bulb.setProtocol(self._protocol)
except socket.error:
self.is_valid = False
_LOGGER.error(
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -178,7 +178,7 @@ hikvision==0.4
http://github.com/technicalpickles/python-nest/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip#python-nest==3.0.3

# homeassistant.components.light.flux_led
https://github.com/Danielhiversen/flux_led/archive/0.10.zip#flux_led==0.10
https://github.com/Danielhiversen/flux_led/archive/0.11.zip#flux_led==0.11

# homeassistant.components.switch.tplink
https://github.com/GadgetReactor/pyHS100/archive/45fc3548882628bcde3e3d365db341849457bef2.zip#pyHS100==0.2.2
Expand Down