desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Instruct the group lights to turn on, or dim.'
def turn_on(self, **kwargs):
if (ATTR_BRIGHTNESS in kwargs): self._group.set_dimmer(kwargs[ATTR_BRIGHTNESS]) else: self._group.set_state(1)
'Fetch new state data for this group.'
def update(self):
from pytradfri import RequestTimeout try: self._group.update() except RequestTimeout: _LOGGER.warning('Tradfri update request timed out')
'Initialize a Light.'
def __init__(self, light):
self._light = light self._light_control = light.light_control self._light_data = light.light_control.lights[0] self._name = light.name self._rgb_color = None self._features = SUPPORT_BRIGHTNESS if (self._light_data.hex_color is not None): if (self._light.device_info.manufacturer == I...
'Flag supported features.'
@property def supported_features(self):
return self._features
'Return the display name of this light.'
@property def name(self):
return self._name
'Return true if light is on.'
@property def is_on(self):
return self._light_data.state
'Return the brightness of the light.'
@property def brightness(self):
return self._light_data.dimmer
'Return the CT color value in mireds.'
@property def color_temp(self):
if ((self._light_data.hex_color is None) or ((self.supported_features & SUPPORT_COLOR_TEMP) == 0) or (not self._ok_temps)): return None kelvin = next((kelvin for (kelvin, hex_color) in self._ok_temps.items() if (hex_color == self._light_data.hex_color)), None) if (kelvin is None): _LOGGER.er...
'RGB color of the light.'
@property def rgb_color(self):
return self._rgb_color
'Instruct the light to turn off.'
def turn_off(self, **kwargs):
self._light_control.set_state(False)
'Instruct the light to turn on. After adding "self._light_data.hexcolor is not None" for ATTR_RGB_COLOR, this also supports Philips Hue bulbs.'
def turn_on(self, **kwargs):
if (ATTR_BRIGHTNESS in kwargs): self._light_control.set_dimmer(kwargs[ATTR_BRIGHTNESS]) else: self._light_control.set_state(True) if ((ATTR_RGB_COLOR in kwargs) and (self._light_data.hex_color is not None)): self._light.light_control.set_hex_color(color_util.color_rgb_to_hex(*kwargs[...
'Fetch new state data for this light.'
def update(self):
from pytradfri import RequestTimeout try: self._light.update() except RequestTimeout: _LOGGER.warning('Tradfri update request timed out') if (self._light_data.hex_color not in (None, '0')): self._rgb_color = color_util.rgb_hex_to_rgb_list(self._light_data.hex_color)
'Initialize the light.'
def __init__(self, hass, plm, address, name, dimmable):
self._hass = hass self._plm = plm.protocol self._address = address self._name = name self._dimmable = dimmable self._plm.add_update_callback(self.async_light_update, {'address': self._address})
'No polling needed.'
@property def should_poll(self):
return False
'Return the the address of the node.'
@property def address(self):
return self._address
'Return the the name of the node.'
@property def name(self):
return self._name
'Return the brightness of this light between 0..255.'
@property def brightness(self):
onlevel = self._plm.get_device_attr(self._address, 'onlevel') _LOGGER.debug('on level for %s is %s', self._address, onlevel) return int(onlevel)
'Return the boolean response if the node is on.'
@property def is_on(self):
onlevel = self._plm.get_device_attr(self._address, 'onlevel') _LOGGER.debug('on level for %s is %s', self._address, onlevel) return bool(onlevel)
'Flag supported features.'
@property def supported_features(self):
if self._dimmable: return SUPPORT_BRIGHTNESS
'Provide attributes for display on device card.'
@property def device_state_attributes(self):
insteon_plm = get_component('insteon_plm') return insteon_plm.common_attributes(self)
'Return specified attribute for this device.'
def get_attr(self, key):
return self._plm.get_device_attr(self.address, key)
'Receive notification from transport that new data exists.'
@callback def async_light_update(self, message):
_LOGGER.info('Received update calback from PLM for %s', self._address) self._hass.async_add_job(self.async_update_ha_state())
'Turn device on.'
@asyncio.coroutine def async_turn_on(self, **kwargs):
if (ATTR_BRIGHTNESS in kwargs): brightness = int(kwargs[ATTR_BRIGHTNESS]) else: brightness = MAX_BRIGHTNESS self._plm.turn_on(self._address, brightness=brightness)
'Turn device off.'
@asyncio.coroutine def async_turn_off(self, **kwargs):
self._plm.turn_off(self._address)
'Initialize the switch.'
def __init__(self, switch):
self._switch = switch
'Return supported features.'
@property def supported_features(self):
if self._switch.canSetLevel: return (SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION) else: return 0
'Return the display name of this switch.'
@property def name(self):
return self._switch.name
'Return the brightness of the dimmer switch.'
@property def brightness(self):
return int(((self._switch.brightness * 255) / 100))
'Return true if switch is on.'
@property def is_on(self):
return (self._switch.power == 'ON')
'Instruct the switch to turn on & adjust brightness.'
def turn_on(self, **kwargs):
attribs = {'power': 'ON'} if (ATTR_BRIGHTNESS in kwargs): min_level = self._switch.get('minLevel', 0) max_level = self._switch.get('maxLevel', 100) brightness = int(((kwargs[ATTR_BRIGHTNESS] * max_level) / 255)) brightness = max(brightness, min_level) attribs['brightness'...
'Instruct the switch to turn off.'
def turn_off(self, **kwargs):
attribs = {'power': 'OFF'} try: self._switch.update_attributes(attribs) except ValueError: _LOGGER.error('Failed to turn off myLeviton switch.')
'Fetch new state data for this switch.'
def update(self):
try: self._switch.refresh() except ValueError: _LOGGER.error('Failed to update myLeviton switch data.')
'Initialize the light.'
def __init__(self, area_name, lutron_device, controller):
self._prev_brightness = None LutronDevice.__init__(self, area_name, lutron_device, controller)
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_BRIGHTNESS
'Return the brightness of the light.'
@property def brightness(self):
new_brightness = to_hass_level(self._lutron_device.last_level()) if (new_brightness != 0): self._prev_brightness = new_brightness return new_brightness
'Turn the light on.'
def turn_on(self, **kwargs):
if ((ATTR_BRIGHTNESS in kwargs) and self._lutron_device.is_dimmable): brightness = kwargs[ATTR_BRIGHTNESS] elif (self._prev_brightness == 0): brightness = (255 / 2) else: brightness = self._prev_brightness self._prev_brightness = brightness self._lutron_device.level = to_lutr...
'Turn the light off.'
def turn_off(self, **kwargs):
self._lutron_device.level = 0
'Return the state attributes.'
@property def device_state_attributes(self):
attr = {} attr['Lutron Integration ID'] = self._lutron_device.id return attr
'Return true if device is on.'
@property def is_on(self):
return (self._lutron_device.last_level() > 0)
'Call when forcing a refresh of the device.'
def update(self):
if (self._prev_brightness is None): self._prev_brightness = to_hass_level(self._lutron_device.level)
'Initialize the cover.'
def __init__(self, hass, config):
KNXMultiAddressDevice.__init__(self, hass, config, [], optional=['state', 'brightness', 'brightness_state']) self._hass = hass self._supported_features = 0 if (CONF_BRIGHTNESS_ADDRESS in config.config): _LOGGER.debug('%s is dimmable', self.name) self._supported_features = (self._su...
'Turn the switch on. This sends a value 1 to the group address of the device'
def turn_on(self, **kwargs):
_LOGGER.debug('%s: turn on', self.name) self.set_value('base', [1]) self._state = 1 if (ATTR_BRIGHTNESS in kwargs): self._brightness = kwargs[ATTR_BRIGHTNESS] _LOGGER.debug('turn_on requested brightness for light: %s is: %s ', self.name, self._brightness) ...
'Turn the switch off. This sends a value 1 to the group address of the device'
def turn_off(self, **kwargs):
_LOGGER.debug('%s: turn off', self.name) self.set_value('base', [0]) self._state = 0 if (not self.should_poll): self.schedule_update_ha_state()
'Return True if the value is not 0 is on, else False.'
@property def is_on(self):
return (self._state != 0)
'Flag supported features.'
@property def supported_features(self):
return self._supported_features
'Update device state.'
def update(self):
super().update() if self.has_attribute('brightness_state'): value = self.value('brightness_state') if (value is not None): self._brightness = int.from_bytes(value, byteorder='little') _LOGGER.debug('%s: brightness = %d', self.name, self._brightness) if self.h...
'No polling needed for a KNX light.'
def should_poll(self):
return False
'Initialize a LiteJet light.'
def __init__(self, hass, lj, i, name):
self._hass = hass self._lj = lj self._index = i self._brightness = 0 self._name = name lj.on_load_activated(i, self._on_load_changed) lj.on_load_deactivated(i, self._on_load_changed)
'Handle state changes.'
def _on_load_changed(self):
_LOGGER.debug('Updating due to notification for %s', self._name) self.schedule_update_ha_state(True)
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_BRIGHTNESS
'Return the light\'s name.'
@property def name(self):
return self._name
'Return the light\'s brightness.'
@property def brightness(self):
return self._brightness
'Return if the light is on.'
@property def is_on(self):
return (self._brightness != 0)
'Return that lights do not require polling.'
@property def should_poll(self):
return False
'Return the device state attributes.'
@property def device_state_attributes(self):
return {ATTR_NUMBER: self._index}
'Turn on the light.'
def turn_on(self, **kwargs):
if (ATTR_BRIGHTNESS in kwargs): brightness = int(((kwargs[ATTR_BRIGHTNESS] / 255) * 99)) self._lj.activate_load_at(self._index, brightness, 0) else: self._lj.activate_load(self._index)
'Turn off the light.'
def turn_off(self, **kwargs):
self._lj.deactivate_load(self._index)
'Retrieve the light\'s brightness from the LiteJet system.'
def update(self):
self._brightness = ((self._lj.get_load_level(self._index) / 99) * 255)
'Initialize a group.'
def __init__(self, group, config):
self.group = group self.repeating = False self._is_on = False self._brightness = None self.config = config
'Produce LimitlessLEDGroup objects.'
@staticmethod def factory(group, config):
from limitlessled.group.rgbw import RgbwGroup from limitlessled.group.white import WhiteGroup from limitlessled.group.rgbww import RgbwwGroup if isinstance(group, WhiteGroup): return LimitlessLEDWhiteGroup(group, config) elif isinstance(group, RgbwGroup): return LimitlessLEDRGBWGroup...
'No polling needed.'
@property def should_poll(self):
return False
'Return the name of the group.'
@property def name(self):
return self.group.name
'Return true if device is on.'
@property def is_on(self):
return self._is_on
'Return the brightness property.'
@property def brightness(self):
return self._brightness
'Turn off a group.'
@state(False) def turn_off(self, transition_time, pipeline, **kwargs):
if self.is_on: if self.config[CONF_FADE]: pipeline.transition(transition_time, brightness=0.0) pipeline.off()
'Initialize White group.'
def __init__(self, group, config):
super().__init__(group, config) self.group.on = True self.group.temperature = 1.0 self.group.brightness = 0.0 self._brightness = _to_hass_brightness(1.0) self._temperature = _to_hass_temperature(self.group.temperature) self.group.on = False
'Return the temperature property.'
@property def color_temp(self):
return self._temperature
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_LIMITLESSLED_WHITE
'Turn on (or adjust property of) a group.'
@state(True) def turn_on(self, transition_time, pipeline, **kwargs):
if (ATTR_BRIGHTNESS in kwargs): self._brightness = kwargs[ATTR_BRIGHTNESS] if (ATTR_COLOR_TEMP in kwargs): self._temperature = kwargs[ATTR_COLOR_TEMP] pipeline.transition(transition_time, brightness=_from_hass_brightness(self._brightness), temperature=_from_hass_temperature(self._temperature...
'Initialize RGBW group.'
def __init__(self, group, config):
super().__init__(group, config) self.group.on = True self.group.white() self._color = WHITE self.group.brightness = 0.0 self._brightness = _to_hass_brightness(1.0) self.group.on = False
'Return the color property.'
@property def rgb_color(self):
return self._color
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_LIMITLESSLED_RGB
'Turn on (or adjust property of) a group.'
@state(True) def turn_on(self, transition_time, pipeline, **kwargs):
from limitlessled.presets import COLORLOOP if (ATTR_BRIGHTNESS in kwargs): self._brightness = kwargs[ATTR_BRIGHTNESS] if (ATTR_RGB_COLOR in kwargs): self._color = kwargs[ATTR_RGB_COLOR] if (min(self._color) > (256 - RGB_BOUNDARY)): pipeline.white() self._color = WHITE ...
'Initialize RGBWW group.'
def __init__(self, group, config):
super().__init__(group, config) self.group.on = True self.group.white() self.group.temperature = 0.0 self._color = WHITE self.group.brightness = 0.0 self._brightness = _to_hass_brightness(1.0) self._temperature = _to_hass_temperature(self.group.temperature) self.group.on = False
'Return the color property.'
@property def rgb_color(self):
return self._color
'Return the temperature property.'
@property def color_temp(self):
return self._temperature
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_LIMITLESSLED_RGBWW
'Turn on (or adjust property of) a group.'
@state(True) def turn_on(self, transition_time, pipeline, **kwargs):
from limitlessled.presets import COLORLOOP if (ATTR_BRIGHTNESS in kwargs): self._brightness = kwargs[ATTR_BRIGHTNESS] if (ATTR_RGB_COLOR in kwargs): self._color = kwargs[ATTR_RGB_COLOR] elif (ATTR_COLOR_TEMP in kwargs): self._temperature = kwargs[ATTR_COLOR_TEMP] if (min(self...
'Callback when entity is added to hass.'
@asyncio.coroutine def async_added_to_hass(self):
self.hass.data[DOMAIN]['entities']['light'].append(self)
'Return true if light is on.'
@property def is_on(self):
return self.wink.state()
'Return the brightness of the light.'
@property def brightness(self):
if (self.wink.brightness() is not None): return int((self.wink.brightness() * 255)) return None
'Define current bulb color in RGB.'
@property def rgb_color(self):
if (not self.wink.supports_hue_saturation()): return None else: hue = self.wink.color_hue() saturation = self.wink.color_saturation() value = int((self.wink.brightness() * 255)) if ((hue is None) or (saturation is None) or (value is None)): return None ...
'Define current bulb color in CIE 1931 (XY) color space.'
@property def xy_color(self):
if (not self.wink.supports_xy_color()): return None return self.wink.color_xy()
'Define current bulb color in degrees Kelvin.'
@property def color_temp(self):
if (not self.wink.supports_temperature()): return None return color_util.color_temperature_kelvin_to_mired(self.wink.color_temperature_kelvin())
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_WINK
'Turn the switch on.'
def turn_on(self, **kwargs):
brightness = kwargs.get(ATTR_BRIGHTNESS) rgb_color = kwargs.get(ATTR_RGB_COLOR) color_temp_mired = kwargs.get(ATTR_COLOR_TEMP) state_kwargs = {} if rgb_color: if self.wink.supports_xy_color(): xyb = color_util.color_RGB_to_xy(*rgb_color) state_kwargs['color_xy'] = (xy...
'Turn the switch off.'
def turn_off(self):
self.wink.set_state(False)
'Initialize the WeMo light.'
def __init__(self, device, update_lights):
self.light_id = device.name self.device = device self.update_lights = update_lights
'Return the ID of this light.'
@property def unique_id(self):
deviceid = self.device.uniqueID return '{}.{}'.format(self.__class__, deviceid)
'Return the name of the light.'
@property def name(self):
return self.device.name
'Return the brightness of this light between 0..255.'
@property def brightness(self):
return self.device.state.get('level', 255)
'Return the XY color values of this light.'
@property def xy_color(self):
return self.device.state.get('color_xy')
'Return the color temperature of this light in mireds.'
@property def color_temp(self):
return self.device.state.get('temperature_mireds')
'Return true if device is on.'
@property def is_on(self):
return (self.device.state['onoff'] != 0)
'Flag supported features.'
@property def supported_features(self):
return SUPPORT_WEMO
'Turn the light on.'
def turn_on(self, **kwargs):
transitiontime = int(kwargs.get(ATTR_TRANSITION, 0)) if (ATTR_XY_COLOR in kwargs): xycolor = kwargs[ATTR_XY_COLOR] elif (ATTR_RGB_COLOR in kwargs): xycolor = color_util.color_RGB_to_xy(*(int(val) for val in kwargs[ATTR_RGB_COLOR])) kwargs.setdefault(ATTR_BRIGHTNESS, xycolor[2]) e...
'Turn the light off.'
def turn_off(self, **kwargs):
transitiontime = int(kwargs.get(ATTR_TRANSITION, 0)) self.device.turn_off(transition=transitiontime)
'Synchronize state with bridge.'
def update(self):
self.update_lights(no_throttle=True)
'Initialize the Tellstick light.'
def __init__(self, tellcore_id, tellcore_registry, signal_repetitions):
super().__init__(tellcore_id, tellcore_registry, signal_repetitions) self._brightness = 255
'Return the brightness of this light between 0..255.'
@property def brightness(self):
return self._brightness