2019-03-24 12:01:12 +00:00
|
|
|
"""Light platform support for yeelight."""
|
2016-10-30 00:03:26 +00:00
|
|
|
import logging
|
|
|
|
|
2019-03-25 07:50:47 +00:00
|
|
|
import voluptuous as vol
|
2019-03-24 12:01:12 +00:00
|
|
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
2019-03-25 07:50:47 +00:00
|
|
|
from homeassistant.helpers.service import extract_entity_ids
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
from homeassistant.util.color import (
|
|
|
|
color_temperature_mired_to_kelvin as mired_to_kelvin,
|
2018-03-18 22:00:29 +00:00
|
|
|
color_temperature_kelvin_to_mired as kelvin_to_mired)
|
2019-04-05 11:32:46 +00:00
|
|
|
from homeassistant.const import CONF_HOST, ATTR_ENTITY_ID, CONF_NAME
|
2019-03-24 12:01:12 +00:00
|
|
|
from homeassistant.core import callback
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
from homeassistant.components.light import (
|
2018-03-18 22:00:29 +00:00
|
|
|
ATTR_BRIGHTNESS, ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_COLOR_TEMP,
|
|
|
|
ATTR_FLASH, FLASH_SHORT, FLASH_LONG, ATTR_EFFECT, SUPPORT_BRIGHTNESS,
|
|
|
|
SUPPORT_COLOR, SUPPORT_TRANSITION, SUPPORT_COLOR_TEMP, SUPPORT_FLASH,
|
2019-03-24 12:01:12 +00:00
|
|
|
SUPPORT_EFFECT, Light)
|
2018-03-18 22:00:29 +00:00
|
|
|
import homeassistant.util.color as color_util
|
2019-04-07 14:07:15 +00:00
|
|
|
from . import (
|
2019-03-24 12:01:12 +00:00
|
|
|
CONF_TRANSITION, DATA_YEELIGHT, CONF_MODE_MUSIC,
|
2019-03-25 07:50:47 +00:00
|
|
|
CONF_SAVE_ON_CHANGE, CONF_CUSTOM_EFFECTS, DATA_UPDATED,
|
|
|
|
YEELIGHT_SERVICE_SCHEMA, DOMAIN, ATTR_TRANSITIONS,
|
2019-04-05 11:32:46 +00:00
|
|
|
YEELIGHT_FLOW_TRANSITION_SCHEMA, ACTION_RECOVER, CONF_FLOW_PARAMS,
|
|
|
|
ATTR_ACTION, ATTR_COUNT)
|
2016-10-30 00:03:26 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
SUPPORT_YEELIGHT = (SUPPORT_BRIGHTNESS |
|
|
|
|
SUPPORT_TRANSITION |
|
|
|
|
SUPPORT_FLASH)
|
|
|
|
|
2018-10-12 09:35:33 +00:00
|
|
|
SUPPORT_YEELIGHT_WHITE_TEMP = (SUPPORT_YEELIGHT |
|
|
|
|
SUPPORT_COLOR_TEMP)
|
|
|
|
|
2017-03-28 15:26:43 +00:00
|
|
|
SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT |
|
2018-03-18 22:00:29 +00:00
|
|
|
SUPPORT_COLOR |
|
2017-06-03 04:35:32 +00:00
|
|
|
SUPPORT_EFFECT |
|
2017-03-28 15:26:43 +00:00
|
|
|
SUPPORT_COLOR_TEMP)
|
|
|
|
|
2019-03-25 07:50:47 +00:00
|
|
|
ATTR_MODE = 'mode'
|
|
|
|
|
|
|
|
SERVICE_SET_MODE = 'set_mode'
|
|
|
|
SERVICE_START_FLOW = 'start_flow'
|
|
|
|
|
2017-06-03 04:35:32 +00:00
|
|
|
EFFECT_DISCO = "Disco"
|
|
|
|
EFFECT_TEMP = "Slow Temp"
|
|
|
|
EFFECT_STROBE = "Strobe epilepsy!"
|
|
|
|
EFFECT_STROBE_COLOR = "Strobe color"
|
|
|
|
EFFECT_ALARM = "Alarm"
|
|
|
|
EFFECT_POLICE = "Police"
|
|
|
|
EFFECT_POLICE2 = "Police2"
|
|
|
|
EFFECT_CHRISTMAS = "Christmas"
|
|
|
|
EFFECT_RGB = "RGB"
|
|
|
|
EFFECT_RANDOM_LOOP = "Random Loop"
|
|
|
|
EFFECT_FAST_RANDOM_LOOP = "Fast Random Loop"
|
2018-11-23 22:53:33 +00:00
|
|
|
EFFECT_LSD = "LSD"
|
2017-06-03 04:35:32 +00:00
|
|
|
EFFECT_SLOWDOWN = "Slowdown"
|
|
|
|
EFFECT_WHATSAPP = "WhatsApp"
|
|
|
|
EFFECT_FACEBOOK = "Facebook"
|
|
|
|
EFFECT_TWITTER = "Twitter"
|
|
|
|
EFFECT_STOP = "Stop"
|
|
|
|
|
|
|
|
YEELIGHT_EFFECT_LIST = [
|
|
|
|
EFFECT_DISCO,
|
|
|
|
EFFECT_TEMP,
|
|
|
|
EFFECT_STROBE,
|
|
|
|
EFFECT_STROBE_COLOR,
|
|
|
|
EFFECT_ALARM,
|
|
|
|
EFFECT_POLICE,
|
|
|
|
EFFECT_POLICE2,
|
|
|
|
EFFECT_CHRISTMAS,
|
|
|
|
EFFECT_RGB,
|
|
|
|
EFFECT_RANDOM_LOOP,
|
|
|
|
EFFECT_FAST_RANDOM_LOOP,
|
2018-11-23 22:53:33 +00:00
|
|
|
EFFECT_LSD,
|
2017-06-03 04:35:32 +00:00
|
|
|
EFFECT_SLOWDOWN,
|
|
|
|
EFFECT_WHATSAPP,
|
|
|
|
EFFECT_FACEBOOK,
|
|
|
|
EFFECT_TWITTER,
|
|
|
|
EFFECT_STOP]
|
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2019-04-05 11:32:46 +00:00
|
|
|
def _transitions_config_parser(transitions):
|
|
|
|
"""Parse transitions config into initialized objects."""
|
|
|
|
import yeelight
|
|
|
|
|
|
|
|
transition_objects = []
|
|
|
|
for transition_config in transitions:
|
|
|
|
transition, params = list(transition_config.items())[0]
|
|
|
|
transition_objects.append(getattr(yeelight, transition)(*params))
|
|
|
|
|
|
|
|
return transition_objects
|
|
|
|
|
|
|
|
|
|
|
|
def _parse_custom_effects(effects_config):
|
2019-04-17 20:05:49 +00:00
|
|
|
from yeelight import Flow
|
2019-04-05 11:32:46 +00:00
|
|
|
|
|
|
|
effects = {}
|
|
|
|
for config in effects_config:
|
|
|
|
params = config[CONF_FLOW_PARAMS]
|
2019-04-17 20:05:49 +00:00
|
|
|
action = Flow.actions[params[ATTR_ACTION]]
|
2019-04-05 11:32:46 +00:00
|
|
|
transitions = _transitions_config_parser(
|
|
|
|
params[ATTR_TRANSITIONS])
|
|
|
|
|
|
|
|
effects[config[CONF_NAME]] = {
|
|
|
|
ATTR_COUNT: params[ATTR_COUNT],
|
|
|
|
ATTR_ACTION: action,
|
|
|
|
ATTR_TRANSITIONS: transitions
|
|
|
|
}
|
|
|
|
|
|
|
|
return effects
|
|
|
|
|
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def _cmd(func):
|
2017-05-01 03:10:08 +00:00
|
|
|
"""Define a wrapper to catch exceptions from the bulb."""
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def _wrap(self, *args, **kwargs):
|
2019-04-17 20:05:49 +00:00
|
|
|
from yeelight import BulbException
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
try:
|
|
|
|
_LOGGER.debug("Calling %s with %s %s", func, args, kwargs)
|
|
|
|
return func(self, *args, **kwargs)
|
2019-04-17 20:05:49 +00:00
|
|
|
except BulbException as ex:
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
_LOGGER.error("Error when calling %s: %s", func, ex)
|
|
|
|
|
|
|
|
return _wrap
|
|
|
|
|
2016-10-30 00:03:26 +00:00
|
|
|
|
2018-08-24 14:37:30 +00:00
|
|
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
2017-05-02 16:18:47 +00:00
|
|
|
"""Set up the Yeelight bulbs."""
|
2019-03-25 07:50:47 +00:00
|
|
|
from yeelight.enums import PowerMode
|
|
|
|
|
|
|
|
data_key = '{}_lights'.format(DATA_YEELIGHT)
|
|
|
|
|
2019-03-24 12:01:12 +00:00
|
|
|
if not discovery_info:
|
|
|
|
return
|
2018-03-27 18:29:18 +00:00
|
|
|
|
2019-03-25 07:50:47 +00:00
|
|
|
if data_key not in hass.data:
|
|
|
|
hass.data[data_key] = []
|
|
|
|
|
|
|
|
device = hass.data[DATA_YEELIGHT][discovery_info[CONF_HOST]]
|
2019-03-24 12:01:12 +00:00
|
|
|
_LOGGER.debug("Adding %s", device.name)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2019-04-05 11:32:46 +00:00
|
|
|
custom_effects = _parse_custom_effects(discovery_info[CONF_CUSTOM_EFFECTS])
|
2018-04-08 20:00:47 +00:00
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
lights = [YeelightLight(device, custom_effects=custom_effects)]
|
|
|
|
|
|
|
|
if device.is_ambilight_supported:
|
|
|
|
lights.append(
|
|
|
|
YeelightAmbientLight(device, custom_effects=custom_effects))
|
|
|
|
|
|
|
|
hass.data[data_key] += lights
|
|
|
|
add_entities(lights, True)
|
2019-01-24 16:41:07 +00:00
|
|
|
|
2019-03-25 07:50:47 +00:00
|
|
|
def service_handler(service):
|
|
|
|
"""Dispatch service calls to target entities."""
|
|
|
|
params = {key: value for key, value in service.data.items()
|
|
|
|
if key != ATTR_ENTITY_ID}
|
|
|
|
|
|
|
|
entity_ids = extract_entity_ids(hass, service)
|
|
|
|
target_devices = [light for light in hass.data[data_key]
|
|
|
|
if light.entity_id in entity_ids]
|
|
|
|
|
|
|
|
for target_device in target_devices:
|
|
|
|
if service.service == SERVICE_SET_MODE:
|
|
|
|
target_device.set_mode(**params)
|
|
|
|
elif service.service == SERVICE_START_FLOW:
|
|
|
|
params[ATTR_TRANSITIONS] = \
|
|
|
|
_transitions_config_parser(params[ATTR_TRANSITIONS])
|
|
|
|
target_device.start_flow(**params)
|
|
|
|
|
|
|
|
service_schema_set_mode = YEELIGHT_SERVICE_SCHEMA.extend({
|
|
|
|
vol.Required(ATTR_MODE):
|
|
|
|
vol.In([mode.name.lower() for mode in PowerMode])
|
|
|
|
})
|
|
|
|
hass.services.register(
|
|
|
|
DOMAIN, SERVICE_SET_MODE, service_handler,
|
|
|
|
schema=service_schema_set_mode)
|
|
|
|
|
|
|
|
service_schema_start_flow = YEELIGHT_SERVICE_SCHEMA.extend(
|
|
|
|
YEELIGHT_FLOW_TRANSITION_SCHEMA
|
|
|
|
)
|
|
|
|
hass.services.register(
|
|
|
|
DOMAIN, SERVICE_START_FLOW, service_handler,
|
|
|
|
schema=service_schema_start_flow)
|
|
|
|
|
2016-10-30 00:03:26 +00:00
|
|
|
|
|
|
|
class YeelightLight(Light):
|
|
|
|
"""Representation of a Yeelight light."""
|
|
|
|
|
2019-03-24 12:01:12 +00:00
|
|
|
def __init__(self, device, custom_effects=None):
|
2017-05-02 16:18:47 +00:00
|
|
|
"""Initialize the Yeelight light."""
|
2019-04-07 14:07:34 +00:00
|
|
|
from yeelight.enums import LightType
|
|
|
|
|
2019-03-24 12:01:12 +00:00
|
|
|
self.config = device.config
|
|
|
|
self._device = device
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
self._supported_features = SUPPORT_YEELIGHT
|
|
|
|
|
|
|
|
self._brightness = None
|
|
|
|
self._color_temp = None
|
|
|
|
self._is_on = None
|
2018-03-18 22:00:29 +00:00
|
|
|
self._hs = None
|
2016-10-30 00:03:26 +00:00
|
|
|
|
2018-10-12 09:35:33 +00:00
|
|
|
self._min_mireds = None
|
|
|
|
self._max_mireds = None
|
|
|
|
|
2019-04-07 14:07:34 +00:00
|
|
|
self._light_type = LightType.Main
|
|
|
|
|
2019-01-24 16:41:07 +00:00
|
|
|
if custom_effects:
|
|
|
|
self._custom_effects = custom_effects
|
|
|
|
else:
|
|
|
|
self._custom_effects = {}
|
|
|
|
|
2019-03-24 12:01:12 +00:00
|
|
|
@callback
|
2019-04-07 14:07:50 +00:00
|
|
|
def _schedule_immediate_update(self):
|
|
|
|
self.async_schedule_update_ha_state(True)
|
2019-03-24 12:01:12 +00:00
|
|
|
|
|
|
|
async def async_added_to_hass(self):
|
|
|
|
"""Handle entity which will be added."""
|
|
|
|
async_dispatcher_connect(
|
2019-04-07 14:07:50 +00:00
|
|
|
self.hass,
|
|
|
|
DATA_UPDATED.format(self._device.ipaddr),
|
|
|
|
self._schedule_immediate_update
|
2019-03-24 12:01:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self):
|
|
|
|
"""No polling needed."""
|
|
|
|
return False
|
|
|
|
|
2016-10-30 00:03:26 +00:00
|
|
|
@property
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def available(self) -> bool:
|
|
|
|
"""Return if bulb is available."""
|
2019-03-29 17:43:29 +00:00
|
|
|
return self.device.available
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def supported_features(self) -> int:
|
|
|
|
"""Flag supported features."""
|
|
|
|
return self._supported_features
|
|
|
|
|
2017-06-03 04:35:32 +00:00
|
|
|
@property
|
|
|
|
def effect_list(self):
|
|
|
|
"""Return the list of supported effects."""
|
2019-01-24 16:41:07 +00:00
|
|
|
return YEELIGHT_EFFECT_LIST + self.custom_effects_names
|
2017-06-03 04:35:32 +00:00
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
@property
|
|
|
|
def color_temp(self) -> int:
|
|
|
|
"""Return the color temperature."""
|
|
|
|
return self._color_temp
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
2016-10-30 00:03:26 +00:00
|
|
|
"""Return the name of the device if any."""
|
2019-03-24 12:01:12 +00:00
|
|
|
return self.device.name
|
2016-10-30 00:03:26 +00:00
|
|
|
|
|
|
|
@property
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def is_on(self) -> bool:
|
2016-10-30 00:03:26 +00:00
|
|
|
"""Return true if device is on."""
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
return self._is_on
|
2016-10-30 00:03:26 +00:00
|
|
|
|
|
|
|
@property
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def brightness(self) -> int:
|
2016-10-30 00:03:26 +00:00
|
|
|
"""Return the brightness of this light between 1..255."""
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
return self._brightness
|
|
|
|
|
2017-10-09 04:05:49 +00:00
|
|
|
@property
|
|
|
|
def min_mireds(self):
|
|
|
|
"""Return minimum supported color temperature."""
|
2018-10-12 09:35:33 +00:00
|
|
|
return self._min_mireds
|
2017-10-09 04:05:49 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def max_mireds(self):
|
|
|
|
"""Return maximum supported color temperature."""
|
2018-10-12 09:35:33 +00:00
|
|
|
return self._max_mireds
|
2017-10-09 04:05:49 +00:00
|
|
|
|
2019-01-24 16:41:07 +00:00
|
|
|
@property
|
|
|
|
def custom_effects(self):
|
|
|
|
"""Return dict with custom effects."""
|
|
|
|
return self._custom_effects
|
|
|
|
|
|
|
|
@property
|
|
|
|
def custom_effects_names(self):
|
|
|
|
"""Return list with custom effects names."""
|
|
|
|
return list(self.custom_effects.keys())
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
@property
|
|
|
|
def light_type(self):
|
|
|
|
"""Return light type."""
|
2019-04-07 14:07:34 +00:00
|
|
|
return self._light_type
|
2019-03-27 12:39:55 +00:00
|
|
|
|
2018-03-18 22:00:29 +00:00
|
|
|
def _get_hs_from_properties(self):
|
2019-03-27 12:39:55 +00:00
|
|
|
rgb = self._get_property('rgb')
|
|
|
|
color_mode = self._get_property('color_mode')
|
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
if not rgb or not color_mode:
|
2018-03-18 22:00:29 +00:00
|
|
|
return None
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
color_mode = int(color_mode)
|
|
|
|
if color_mode == 2: # color temperature
|
2017-11-28 04:54:56 +00:00
|
|
|
temp_in_k = mired_to_kelvin(self._color_temp)
|
2018-03-18 22:00:29 +00:00
|
|
|
return color_util.color_temperature_to_hs(temp_in_k)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
if color_mode == 3: # hsv
|
2019-03-27 12:39:55 +00:00
|
|
|
hue = int(self._get_property('hue'))
|
|
|
|
sat = int(self._get_property('sat'))
|
|
|
|
|
2018-03-18 22:00:29 +00:00
|
|
|
return (hue / 360 * 65536, sat / 100 * 255)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
rgb = int(rgb)
|
|
|
|
blue = rgb & 0xff
|
|
|
|
green = (rgb >> 8) & 0xff
|
|
|
|
red = (rgb >> 16) & 0xff
|
|
|
|
|
2018-03-18 22:00:29 +00:00
|
|
|
return color_util.color_RGB_to_hs(red, green, blue)
|
2016-10-30 00:03:26 +00:00
|
|
|
|
|
|
|
@property
|
2018-03-18 22:00:29 +00:00
|
|
|
def hs_color(self) -> tuple:
|
2016-10-30 00:03:26 +00:00
|
|
|
"""Return the color property."""
|
2018-03-18 22:00:29 +00:00
|
|
|
return self._hs
|
2017-10-22 00:59:55 +00:00
|
|
|
|
2017-01-05 22:39:28 +00:00
|
|
|
@property
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def _properties(self) -> dict:
|
2019-03-24 12:01:12 +00:00
|
|
|
if self._bulb is None:
|
2018-10-29 07:07:57 +00:00
|
|
|
return {}
|
2019-03-24 12:01:12 +00:00
|
|
|
return self._bulb.last_properties
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
def _get_property(self, prop, default=None):
|
|
|
|
return self._properties.get(prop, default)
|
|
|
|
|
2019-03-24 12:01:12 +00:00
|
|
|
@property
|
|
|
|
def device(self):
|
|
|
|
"""Return yeelight device."""
|
|
|
|
return self._device
|
2017-01-05 22:39:28 +00:00
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
@property
|
|
|
|
def _is_nightlight_enabled(self):
|
|
|
|
return self.device.is_nightlight_enabled
|
|
|
|
|
2018-10-25 20:15:20 +00:00
|
|
|
# F821: https://github.com/PyCQA/pyflakes/issues/373
|
2016-10-30 00:03:26 +00:00
|
|
|
@property
|
2018-10-25 20:15:20 +00:00
|
|
|
def _bulb(self) -> 'yeelight.Bulb': # noqa: F821
|
2019-03-29 17:43:29 +00:00
|
|
|
return self.device.bulb
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
def set_music_mode(self, mode) -> None:
|
|
|
|
"""Set the music mode on or off."""
|
|
|
|
if mode:
|
|
|
|
self._bulb.start_music()
|
2016-10-30 00:03:26 +00:00
|
|
|
else:
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
self._bulb.stop_music()
|
|
|
|
|
|
|
|
def update(self) -> None:
|
|
|
|
"""Update properties from the bulb."""
|
2019-04-17 20:05:49 +00:00
|
|
|
from yeelight import BulbType, enums
|
2019-03-29 17:43:29 +00:00
|
|
|
bulb_type = self._bulb.bulb_type
|
|
|
|
|
2019-04-17 20:05:49 +00:00
|
|
|
if bulb_type == BulbType.Color:
|
2019-03-29 17:43:29 +00:00
|
|
|
self._supported_features = SUPPORT_YEELIGHT_RGB
|
2019-04-17 20:05:49 +00:00
|
|
|
elif self.light_type == enums.LightType.Ambient:
|
2019-03-29 17:43:29 +00:00
|
|
|
self._supported_features = SUPPORT_YEELIGHT_RGB
|
2019-04-17 20:05:49 +00:00
|
|
|
elif bulb_type in (BulbType.WhiteTemp, BulbType.WhiteTempMood):
|
2019-03-27 12:39:55 +00:00
|
|
|
if self._is_nightlight_enabled:
|
2019-03-29 17:43:29 +00:00
|
|
|
self._supported_features = SUPPORT_YEELIGHT
|
2019-03-24 12:01:12 +00:00
|
|
|
else:
|
2019-03-29 17:43:29 +00:00
|
|
|
self._supported_features = SUPPORT_YEELIGHT_WHITE_TEMP
|
2019-03-24 12:01:12 +00:00
|
|
|
|
2019-03-29 17:43:29 +00:00
|
|
|
if self.min_mireds is None:
|
|
|
|
model_specs = self._bulb.get_model_specs()
|
|
|
|
self._min_mireds = \
|
|
|
|
kelvin_to_mired(model_specs['color_temp']['max'])
|
|
|
|
self._max_mireds = \
|
|
|
|
kelvin_to_mired(model_specs['color_temp']['min'])
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2019-04-17 20:05:49 +00:00
|
|
|
if bulb_type == BulbType.WhiteTempMood:
|
2019-03-29 17:43:29 +00:00
|
|
|
self._is_on = self._get_property('main_power') == 'on'
|
|
|
|
else:
|
|
|
|
self._is_on = self._get_property('power') == 'on'
|
2019-03-27 12:39:55 +00:00
|
|
|
|
2019-03-29 17:43:29 +00:00
|
|
|
if self._is_nightlight_enabled:
|
|
|
|
bright = self._get_property('nl_br')
|
|
|
|
else:
|
|
|
|
bright = self._get_property('bright')
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2019-03-29 17:43:29 +00:00
|
|
|
if bright:
|
|
|
|
self._brightness = round(255 * (int(bright) / 100))
|
2017-10-22 00:59:55 +00:00
|
|
|
|
2019-03-29 17:43:29 +00:00
|
|
|
temp_in_k = self._get_property('ct')
|
|
|
|
|
|
|
|
if temp_in_k:
|
|
|
|
self._color_temp = kelvin_to_mired(int(temp_in_k))
|
|
|
|
|
|
|
|
self._hs = self._get_hs_from_properties()
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
@_cmd
|
|
|
|
def set_brightness(self, brightness, duration) -> None:
|
|
|
|
"""Set bulb brightness."""
|
|
|
|
if brightness:
|
|
|
|
_LOGGER.debug("Setting brightness: %s", brightness)
|
|
|
|
self._bulb.set_brightness(brightness / 255 * 100,
|
2019-03-27 12:39:55 +00:00
|
|
|
duration=duration,
|
|
|
|
light_type=self.light_type)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
@_cmd
|
|
|
|
def set_rgb(self, rgb, duration) -> None:
|
|
|
|
"""Set bulb's color."""
|
2018-03-18 22:00:29 +00:00
|
|
|
if rgb and self.supported_features & SUPPORT_COLOR:
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
_LOGGER.debug("Setting RGB: %s", rgb)
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.set_rgb(rgb[0], rgb[1], rgb[2], duration=duration,
|
|
|
|
light_type=self.light_type)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
@_cmd
|
|
|
|
def set_colortemp(self, colortemp, duration) -> None:
|
|
|
|
"""Set bulb's color temperature."""
|
|
|
|
if colortemp and self.supported_features & SUPPORT_COLOR_TEMP:
|
|
|
|
temp_in_k = mired_to_kelvin(colortemp)
|
|
|
|
_LOGGER.debug("Setting color temp: %s K", temp_in_k)
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.set_color_temp(temp_in_k, duration=duration,
|
|
|
|
light_type=self.light_type)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
@_cmd
|
|
|
|
def set_default(self) -> None:
|
|
|
|
"""Set current options as default."""
|
|
|
|
self._bulb.set_default()
|
|
|
|
|
|
|
|
@_cmd
|
|
|
|
def set_flash(self, flash) -> None:
|
|
|
|
"""Activate flash."""
|
|
|
|
if flash:
|
2017-04-07 05:41:47 +00:00
|
|
|
from yeelight import (RGBTransition, SleepTransition, Flow,
|
|
|
|
BulbException)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
if self._bulb.last_properties["color_mode"] != 1:
|
|
|
|
_LOGGER.error("Flash supported currently only in RGB mode.")
|
|
|
|
return
|
|
|
|
|
2017-02-27 05:21:12 +00:00
|
|
|
transition = int(self.config[CONF_TRANSITION])
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
if flash == FLASH_LONG:
|
|
|
|
count = 1
|
|
|
|
duration = transition * 5
|
|
|
|
if flash == FLASH_SHORT:
|
|
|
|
count = 1
|
|
|
|
duration = transition * 2
|
|
|
|
|
2018-03-18 22:00:29 +00:00
|
|
|
red, green, blue = color_util.color_hs_to_RGB(*self._hs)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
transitions = list()
|
|
|
|
transitions.append(
|
|
|
|
RGBTransition(255, 0, 0, brightness=10, duration=duration))
|
|
|
|
transitions.append(SleepTransition(
|
|
|
|
duration=transition))
|
|
|
|
transitions.append(
|
|
|
|
RGBTransition(red, green, blue, brightness=self.brightness,
|
|
|
|
duration=duration))
|
|
|
|
|
|
|
|
flow = Flow(count=count, transitions=transitions)
|
2017-04-07 05:41:47 +00:00
|
|
|
try:
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.start_flow(flow, light_type=self.light_type)
|
2017-04-07 05:41:47 +00:00
|
|
|
except BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set flash: %s", ex)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2017-06-03 04:35:32 +00:00
|
|
|
@_cmd
|
|
|
|
def set_effect(self, effect) -> None:
|
|
|
|
"""Activate effect."""
|
|
|
|
if effect:
|
|
|
|
from yeelight import (Flow, BulbException)
|
|
|
|
from yeelight.transitions import (disco, temp, strobe, pulse,
|
|
|
|
strobe_color, alarm, police,
|
|
|
|
police2, christmas, rgb,
|
2018-11-23 22:53:33 +00:00
|
|
|
randomloop, lsd, slowdown)
|
2017-06-03 04:35:32 +00:00
|
|
|
if effect == EFFECT_STOP:
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.stop_flow(light_type=self.light_type)
|
2017-06-03 04:35:32 +00:00
|
|
|
return
|
2018-11-23 22:53:33 +00:00
|
|
|
|
|
|
|
effects_map = {
|
|
|
|
EFFECT_DISCO: disco,
|
|
|
|
EFFECT_TEMP: temp,
|
|
|
|
EFFECT_STROBE: strobe,
|
|
|
|
EFFECT_STROBE_COLOR: strobe_color,
|
|
|
|
EFFECT_ALARM: alarm,
|
|
|
|
EFFECT_POLICE: police,
|
|
|
|
EFFECT_POLICE2: police2,
|
|
|
|
EFFECT_CHRISTMAS: christmas,
|
|
|
|
EFFECT_RGB: rgb,
|
|
|
|
EFFECT_RANDOM_LOOP: randomloop,
|
|
|
|
EFFECT_LSD: lsd,
|
|
|
|
EFFECT_SLOWDOWN: slowdown,
|
|
|
|
}
|
|
|
|
|
2019-01-24 16:41:07 +00:00
|
|
|
if effect in self.custom_effects_names:
|
|
|
|
flow = Flow(**self.custom_effects[effect])
|
|
|
|
elif effect in effects_map:
|
2018-11-23 22:53:33 +00:00
|
|
|
flow = Flow(count=0, transitions=effects_map[effect]())
|
2019-01-24 16:41:07 +00:00
|
|
|
elif effect == EFFECT_FAST_RANDOM_LOOP:
|
2017-06-03 04:35:32 +00:00
|
|
|
flow = Flow(count=0, transitions=randomloop(duration=250))
|
2019-01-24 16:41:07 +00:00
|
|
|
elif effect == EFFECT_WHATSAPP:
|
2017-06-03 04:35:32 +00:00
|
|
|
flow = Flow(count=2, transitions=pulse(37, 211, 102))
|
2019-01-24 16:41:07 +00:00
|
|
|
elif effect == EFFECT_FACEBOOK:
|
2017-06-03 04:35:32 +00:00
|
|
|
flow = Flow(count=2, transitions=pulse(59, 89, 152))
|
2019-01-24 16:41:07 +00:00
|
|
|
elif effect == EFFECT_TWITTER:
|
2017-06-03 04:35:32 +00:00
|
|
|
flow = Flow(count=2, transitions=pulse(0, 172, 237))
|
|
|
|
|
|
|
|
try:
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.start_flow(flow, light_type=self.light_type)
|
2017-06-03 04:35:32 +00:00
|
|
|
except BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set effect: %s", ex)
|
|
|
|
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
def turn_on(self, **kwargs) -> None:
|
|
|
|
"""Turn the bulb on."""
|
2017-04-07 05:41:47 +00:00
|
|
|
import yeelight
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
|
|
|
colortemp = kwargs.get(ATTR_COLOR_TEMP)
|
2018-03-18 22:00:29 +00:00
|
|
|
hs_color = kwargs.get(ATTR_HS_COLOR)
|
|
|
|
rgb = color_util.color_hs_to_RGB(*hs_color) if hs_color else None
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
flash = kwargs.get(ATTR_FLASH)
|
2017-06-03 04:35:32 +00:00
|
|
|
effect = kwargs.get(ATTR_EFFECT)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2017-02-27 05:21:12 +00:00
|
|
|
duration = int(self.config[CONF_TRANSITION]) # in ms
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
if ATTR_TRANSITION in kwargs: # passed kwarg overrides config
|
2017-02-27 05:21:12 +00:00
|
|
|
duration = int(kwargs.get(ATTR_TRANSITION) * 1000) # kwarg in s
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
self.device.turn_on(duration=duration, light_type=self.light_type)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
if self.config[CONF_MODE_MUSIC] and not self._bulb.music_mode:
|
2017-04-07 05:41:47 +00:00
|
|
|
try:
|
|
|
|
self.set_music_mode(self.config[CONF_MODE_MUSIC])
|
|
|
|
except yeelight.BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to turn on music mode,"
|
|
|
|
"consider disabling it: %s", ex)
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
2017-04-07 05:41:47 +00:00
|
|
|
try:
|
|
|
|
# values checked for none in methods
|
|
|
|
self.set_rgb(rgb, duration)
|
|
|
|
self.set_colortemp(colortemp, duration)
|
|
|
|
self.set_brightness(brightness, duration)
|
|
|
|
self.set_flash(flash)
|
2017-06-03 04:35:32 +00:00
|
|
|
self.set_effect(effect)
|
2017-04-07 05:41:47 +00:00
|
|
|
except yeelight.BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set bulb properties: %s", ex)
|
|
|
|
return
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
# save the current state if we had a manual change.
|
2017-04-07 05:41:47 +00:00
|
|
|
if self.config[CONF_SAVE_ON_CHANGE] and (brightness
|
|
|
|
or colortemp
|
|
|
|
or rgb):
|
|
|
|
try:
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
self.set_default()
|
2017-04-07 05:41:47 +00:00
|
|
|
except yeelight.BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set the defaults: %s", ex)
|
|
|
|
return
|
2019-03-26 13:18:53 +00:00
|
|
|
self.device.update()
|
new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight
* adapt yeelight's discovery code & suppress exceptions on set_default
* Support flash & code cleanups
Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.
* cleanup code, adjust default transition to 350
* bump required version to 0.0.13
* Cleaning up and marking todos, ready to be reviewed
* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.
* Fix a typo in rgb calculation
* yeelight_<bulbtype>_<mac> for autodetected bulbs
hostname from mdns seems to vary
* Lint fixes, add music mode, fix flash
* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.
* remove unused mode logging, move set_mode to turn_on
* Add save_on_change configuration variable
* yeelight: check if music mode is on before enabling it.
* Fix linting, bump required python-yeelight version
* More linting fixes, use import when needed instead of saving the module handle
* Use OR instead of + for features assignment
* Fix color temperature support, convert non-rgb values to rgb values in rgb()
* Fix typo on duration, thanks @qzapwy for noticing
* yeelight: fix issues from review, behave when not available
* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods
* yeelight: kwarg-given transition overrides config, slight cleanups
* change settings back to optional, request update when calling add_devices
* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.
* bump yeelight library version
* Remove unused import
* set the default only when settings are changed and not, e.g., when turned on by automation
* update comment & fix linting
2017-01-31 09:01:11 +00:00
|
|
|
|
|
|
|
def turn_off(self, **kwargs) -> None:
|
|
|
|
"""Turn off."""
|
2017-09-29 10:04:22 +00:00
|
|
|
duration = int(self.config[CONF_TRANSITION]) # in ms
|
|
|
|
if ATTR_TRANSITION in kwargs: # passed kwarg overrides config
|
|
|
|
duration = int(kwargs.get(ATTR_TRANSITION) * 1000) # kwarg in s
|
2019-01-24 16:41:07 +00:00
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
self.device.turn_off(duration=duration, light_type=self.light_type)
|
2019-03-26 13:18:53 +00:00
|
|
|
self.device.update()
|
2019-03-25 07:50:47 +00:00
|
|
|
|
|
|
|
def set_mode(self, mode: str):
|
|
|
|
"""Set a power mode."""
|
|
|
|
import yeelight
|
|
|
|
|
|
|
|
try:
|
|
|
|
self._bulb.set_power_mode(yeelight.enums.PowerMode[mode.upper()])
|
2019-03-26 13:18:53 +00:00
|
|
|
self.device.update()
|
2019-03-25 07:50:47 +00:00
|
|
|
except yeelight.BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set the power mode: %s", ex)
|
|
|
|
|
|
|
|
def start_flow(self, transitions, count=0, action=ACTION_RECOVER):
|
|
|
|
"""Start flow."""
|
|
|
|
import yeelight
|
|
|
|
|
|
|
|
try:
|
|
|
|
flow = yeelight.Flow(
|
|
|
|
count=count,
|
|
|
|
action=yeelight.Flow.actions[action],
|
|
|
|
transitions=transitions)
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
self._bulb.start_flow(flow, light_type=self.light_type)
|
2019-03-25 07:50:47 +00:00
|
|
|
self.device.update()
|
|
|
|
except yeelight.BulbException as ex:
|
|
|
|
_LOGGER.error("Unable to set effect: %s", ex)
|
2019-03-27 12:39:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
class YeelightAmbientLight(YeelightLight):
|
|
|
|
"""Representation of a Yeelight ambient light."""
|
|
|
|
|
|
|
|
PROPERTIES_MAPPING = {
|
|
|
|
"color_mode": "bg_lmode",
|
|
|
|
"main_power": "bg_power",
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
"""Initialize the Yeelight Ambient light."""
|
2019-04-07 14:07:34 +00:00
|
|
|
from yeelight.enums import LightType
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self._min_mireds = kelvin_to_mired(6500)
|
|
|
|
self._max_mireds = kelvin_to_mired(1700)
|
|
|
|
|
2019-04-07 14:07:34 +00:00
|
|
|
self._light_type = LightType.Ambient
|
|
|
|
|
2019-03-27 12:39:55 +00:00
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
"""Return the name of the device if any."""
|
|
|
|
return "{} ambilight".format(self.device.name)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _is_nightlight_enabled(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _get_property(self, prop, default=None):
|
|
|
|
bg_prop = self.PROPERTIES_MAPPING.get(prop)
|
|
|
|
|
|
|
|
if not bg_prop:
|
|
|
|
bg_prop = "bg_" + prop
|
|
|
|
|
|
|
|
return self._properties.get(bg_prop, default)
|