This commit is contained in:
Fabian Affolter 2017-02-25 13:24:43 +01:00 committed by GitHub
parent c5a8372f13
commit a80fd2f243
3 changed files with 7 additions and 14 deletions

View File

@ -2,9 +2,7 @@
Support for Yeelight Sunflower color bulbs (not Yeelight Blue or WiFi). Support for Yeelight Sunflower color bulbs (not Yeelight Blue or WiFi).
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.yeelight-sunflower https://home-assistant.io/components/light.yeelightsunflower
Uses the yeelightsunflower library:
https://github.com/lindsaymarkward/python-yeelight-sunflower
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol
@ -18,33 +16,28 @@ from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['yeelightsunflower==0.0.6'] REQUIREMENTS = ['yeelightsunflower==0.0.6']
SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
# Validate the user's configuration
SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string vol.Required(CONF_HOST): cv.string
}) })
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Yeelight Sunflower Light platform.""" """Set up the Yeelight Sunflower Light platform."""
import yeelightsunflower import yeelightsunflower
# Assign configuration variables.
# The configuration check takes care they are present.
host = config.get(CONF_HOST) host = config.get(CONF_HOST)
# Setup connection with Yeelight Sunflower hub
hub = yeelightsunflower.Hub(host) hub = yeelightsunflower.Hub(host)
# Verify that hub is responsive
if not hub.available: if not hub.available:
_LOGGER.error('Could not connect to Yeelight Sunflower hub') _LOGGER.error('Could not connect to Yeelight Sunflower hub')
return False return False
# Add devices
add_devices(SunflowerBulb(light) for light in hub.get_lights()) add_devices(SunflowerBulb(light) for light in hub.get_lights())

View File

@ -2,7 +2,7 @@
Sensor for Fedex packages. Sensor for Fedex packages.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.usps/ https://home-assistant.io/components/sensor.fedex/
""" """
from collections import defaultdict from collections import defaultdict
import logging import logging

View File

@ -2,7 +2,7 @@
Sensor for UPS packages. Sensor for UPS packages.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.usps/ https://home-assistant.io/components/sensor.ups/
""" """
from collections import defaultdict from collections import defaultdict
import logging import logging