desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return the name of the light.'
| @property
def name(self):
| return self._name
|
'Read back the color of the light.'
| @property
def rgb_color(self):
| return self._rgb_color
|
'Check whether any of the LEDs colors are non-zero.'
| @property
def is_on(self):
| return (sum(self._rgb_color) > 0)
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_BLINKSTICK
|
'Read back the device state.'
| def update(self):
| self._rgb_color = self._stick.get_color()
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| if (ATTR_RGB_COLOR in kwargs):
self._rgb_color = kwargs[ATTR_RGB_COLOR]
else:
self._rgb_color = [255, 255, 255]
self._stick.set_color(red=self._rgb_color[0], green=self._rgb_color[1], blue=self._rgb_color[2])
|
'Turn the device off.'
| def turn_off(self, **kwargs):
| self._stick.turn_off()
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_BRIGHTNESS
|
'Return the brightness of the light.'
| @property
def brightness(self):
| return to_hass_level(self._state['current_state'])
|
'Turn the light on.'
| def turn_on(self, **kwargs):
| if (ATTR_BRIGHTNESS in kwargs):
brightness = kwargs[ATTR_BRIGHTNESS]
else:
brightness = 255
self._smartbridge.set_value(self._device_id, to_lutron_level(brightness))
|
'Turn the light off.'
| def turn_off(self, **kwargs):
| self._smartbridge.set_value(self._device_id, 0)
|
'Return true if device is on.'
| @property
def is_on(self):
| return (self._state['current_state'] > 0)
|
'Call when forcing a refresh of the device.'
| def update(self):
| self._state = self._smartbridge.get_device_by_id(self._device_id)
_LOGGER.debug(self._state)
|
'Initialize the light.'
| def __init__(self, device):
| import zengge
self._name = device['name']
self._address = device['address']
self.is_valid = True
self._bulb = zengge.zengge(self._address)
self._white = 0
self._rgb = (0, 0, 0)
self._state = False
if (self._bulb.connect() is False):
self.is_valid = False
_LOGGER.error... |
'Return the ID of this light.'
| @property
def unique_id(self):
| return '{}.{}'.format(self.__class__, self._address)
|
'Return the name of the device if any.'
| @property
def name(self):
| return self._name
|
'Return true if device is on.'
| @property
def is_on(self):
| return self._state
|
'Return the color property.'
| @property
def rgb_color(self):
| return self._rgb
|
'Return the white property.'
| @property
def white_value(self):
| return self._white
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_ZENGGE_LED
|
'Feel free to poll.'
| @property
def should_poll(self):
| return True
|
'We can report the actual state.'
| @property
def assumed_state(self):
| return False
|
'Set the rgb state.'
| def set_rgb(self, red, green, blue):
| return self._bulb.set_rgb(red, green, blue)
|
'Set the white state.'
| def set_white(self, white):
| return self._bulb.set_white(white)
|
'Turn the specified light on.'
| def turn_on(self, **kwargs):
| self._state = True
self._bulb.on()
rgb = kwargs.get(ATTR_RGB_COLOR)
white = kwargs.get(ATTR_WHITE_VALUE)
if (white is not None):
self._white = white
self._rgb = (0, 0, 0)
if (rgb is not None):
self._white = 0
self._rgb = rgb
if (self._white != 0):
self... |
'Turn the specified light off.'
| def turn_off(self, **kwargs):
| self._state = False
self._bulb.off()
|
'Synchronise internal state with the actual light state.'
| def update(self):
| self._rgb = self._bulb.get_colour()
self._white = self._bulb.get_white()
self._state = self._bulb.get_on()
|
'Initialize a Mochad Light Device.'
| def __init__(self, hass, ctrl, dev):
| from pymochad import device
self._controller = ctrl
self._address = dev[CONF_ADDRESS]
self._name = dev.get(CONF_NAME, 'x10_light_dev_{}'.format(self._address))
self._comm_type = dev.get(mochad.CONF_COMM_TYPE, 'pl')
self.device = device.Device(ctrl, self._address, comm_type=self._comm_type)
s... |
'Return the birghtness of this light between 0..255.'
| @property
def brightness(self):
| return self._brightness
|
'Get the status of the light from mochad.'
| def _get_device_status(self):
| status = self.device.get_status().rstrip()
return (status == 'on')
|
'Return the display name of this light.'
| @property
def name(self):
| return self._name
|
'Return true if the light is on.'
| @property
def is_on(self):
| return self._state
|
'Return supported features.'
| @property
def supported_features(self):
| return SUPPORT_BRIGHTNESS
|
'X10 devices are normally 1-way so we have to assume the state.'
| @property
def assumed_state(self):
| return True
|
'Send the command to turn the light on.'
| def turn_on(self, **kwargs):
| self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
self.device.send_cmd('xdim {}'.format(self._brightness))
self._controller.read_data()
self._state = True
|
'Send the command to turn the light on.'
| def turn_off(self, **kwargs):
| self.device.send_cmd('off')
self._controller.read_data()
self._state = False
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self._brightness
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_RFXTRX
|
'Turn the light on.'
| def turn_on(self, **kwargs):
| brightness = kwargs.get(ATTR_BRIGHTNESS)
if (brightness is None):
self._brightness = 255
self._send_command('turn_on')
else:
self._brightness = brightness
_brightness = ((brightness * 100) // 255)
self._send_command('dim', _brightness)
|
'Initialize the light.'
| def __init__(self, add_devices_callback, server_addr=None, broadcast_addr=None):
| import liffylights
self._devices = []
self._add_devices_callback = add_devices_callback
self._liffylights = liffylights.LiffyLights(self.on_device, self.on_power, self.on_color, server_addr, broadcast_addr)
|
'Search for bulbs.'
| def find_bulb(self, ipaddr):
| bulb = None
for device in self._devices:
if (device.ipaddr == ipaddr):
bulb = device
break
return bulb
|
'Initialize the light.'
| def on_device(self, ipaddr, name, power, hue, sat, bri, kel):
| bulb = self.find_bulb(ipaddr)
if (bulb is None):
_LOGGER.debug('new bulb %s %s %d %d %d %d %d', ipaddr, name, power, hue, sat, bri, kel)
bulb = LIFXLight(self._liffylights, ipaddr, name, power, hue, sat, bri, kel)
self._devices.append(bulb)
self._add_devic... |
'Initialize the light.'
| def on_color(self, ipaddr, hue, sat, bri, kel):
| bulb = self.find_bulb(ipaddr)
if (bulb is not None):
bulb.set_color(hue, sat, bri, kel)
bulb.schedule_update_ha_state()
|
'Initialize the light.'
| def on_power(self, ipaddr, power):
| bulb = self.find_bulb(ipaddr)
if (bulb is not None):
bulb.set_power(power)
bulb.schedule_update_ha_state()
|
'Set up polling for the light.'
| def poll(self, now):
| self.probe()
|
'Probe the light.'
| def probe(self, address=None):
| self._liffylights.probe(address)
|
'Initialize the light.'
| def __init__(self, liffy, ipaddr, name, power, hue, saturation, brightness, kelvin):
| _LOGGER.debug('LIFXLight: %s %s', ipaddr, name)
self._liffylights = liffy
self._ip = ipaddr
self.set_name(name)
self.set_power(power)
self.set_color(hue, saturation, brightness, kelvin)
|
'No polling needed for LIFX light.'
| @property
def should_poll(self):
| return False
|
'Return the name of the device.'
| @property
def name(self):
| return self._name
|
'Return the IP address of the device.'
| @property
def ipaddr(self):
| return self._ip
|
'Return the RGB value.'
| @property
def rgb_color(self):
| _LOGGER.debug('rgb_color: [%d %d %d]', self._rgb[0], self._rgb[1], self._rgb[2])
return self._rgb
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| brightness = int((self._bri / (BYTE_MAX + 1)))
_LOGGER.debug('brightness: %d', brightness)
return brightness
|
'Return the color temperature.'
| @property
def color_temp(self):
| temperature = color_temperature_kelvin_to_mired(self._kel)
_LOGGER.debug('color_temp: %d', temperature)
return temperature
|
'Return true if device is on.'
| @property
def is_on(self):
| _LOGGER.debug('is_on: %d', self._power)
return (self._power != 0)
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_LIFX
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| if (ATTR_TRANSITION in kwargs):
fade = int((kwargs[ATTR_TRANSITION] * 1000))
else:
fade = 0
if (ATTR_RGB_COLOR in kwargs):
(hue, saturation, brightness) = convert_rgb_to_hsv(kwargs[ATTR_RGB_COLOR])
else:
hue = self._hue
saturation = self._sat
brightness = ... |
'Turn the device off.'
| def turn_off(self, **kwargs):
| if (ATTR_TRANSITION in kwargs):
fade = int((kwargs[ATTR_TRANSITION] * 1000))
else:
fade = 0
_LOGGER.debug('turn_off: %s %d', self._ip, fade)
self._liffylights.set_power(self._ip, 0, fade)
|
'Set name of the light.'
| def set_name(self, name):
| self._name = name
|
'Set power state value.'
| def set_power(self, power):
| _LOGGER.debug('set_power: %d', power)
self._power = (power != 0)
|
'Set color state values.'
| def set_color(self, hue, sat, bri, kel):
| self._hue = hue
self._sat = sat
self._bri = bri
self._kel = kel
(red, green, blue) = colorsys.hsv_to_rgb((hue / SHORT_MAX), (sat / SHORT_MAX), (bri / SHORT_MAX))
red = int((red * BYTE_MAX))
green = int((green * BYTE_MAX))
blue = int((blue * BYTE_MAX))
_LOGGER.debug('set_color: %d ... |
'Initialize the Tellstick Net light.'
| def __init__(self, hass, device_id):
| super().__init__(hass, device_id)
self._last_brightness = self.brightness
|
'Define a property of the device that might have changed.'
| def changed(self):
| self._last_brightness = self.brightness
super().changed()
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self.device.dim_level
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_BRIGHTNESS
|
'Return true if light is on.'
| @property
def is_on(self):
| return self.device.is_on
|
'Turn the light on.'
| def turn_on(self, **kwargs):
| brightness = kwargs.get(ATTR_BRIGHTNESS, self._last_brightness)
self.device.dim(level=brightness)
self.changed()
|
'Turn the light off.'
| def turn_off(self, **kwargs):
| self.device.turn_off()
self.changed()
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| if (self._state == 'LEVEL'):
return int((self._hm_get_state() * 255))
return None
|
'Return true if light is on.'
| @property
def is_on(self):
| try:
return (self._hm_get_state() > 0)
except TypeError:
return False
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_HOMEMATIC
|
'Turn the light on.'
| def turn_on(self, **kwargs):
| if ((ATTR_BRIGHTNESS in kwargs) and (self._state == 'LEVEL')):
percent_bright = (float(kwargs[ATTR_BRIGHTNESS]) / 255)
self._hmdevice.set_level(percent_bright, self._channel)
else:
self._hmdevice.on(self._channel)
|
'Turn the light off.'
| def turn_off(self, **kwargs):
| self._hmdevice.off(self._channel)
|
'Generate a data dict (self._data) from the Homematic metadata.'
| def _init_data_struct(self):
| self._state = 'LEVEL'
self._data.update({self._state: STATE_UNKNOWN})
|
'Initialize the light.'
| def __init__(self, device):
| import avion
self._name = device['name']
self._address = device['address']
self._key = device['key']
self._brightness = 255
self._state = False
self._switch = avion.avion(self._address, self._key)
|
'Return the ID of this light.'
| @property
def unique_id(self):
| return '{}.{}'.format(self.__class__, self._address)
|
'Return the name of the device if any.'
| @property
def name(self):
| return self._name
|
'Return true if device is on.'
| @property
def is_on(self):
| return self._state
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self._brightness
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_AVION_LED
|
'Don\'t poll.'
| @property
def should_poll(self):
| return False
|
'We can\'t read the actual state, so assume it matches.'
| @property
def assumed_state(self):
| return True
|
'Set the state of this lamp to the provided brightness.'
| def set_state(self, brightness):
| import avion
initial = time.monotonic()
while True:
if ((time.monotonic() - initial) >= 10):
return False
try:
self._switch.set_brightness(brightness)
break
except avion.avionException:
self._switch.connect()
return True
|
'Turn the specified or all lights on.'
| def turn_on(self, **kwargs):
| brightness = kwargs.get(ATTR_BRIGHTNESS)
if (brightness is not None):
self._brightness = brightness
self.set_state(self.brightness)
self._state = True
|
'Turn the specified or all lights off.'
| def turn_off(self, **kwargs):
| self.set_state(0)
self._state = False
|
'Initialize the light.'
| def __init__(self, name, host, port, default_color):
| self._host = host
self._port = port
self._name = name
self._default_color = default_color
self._rgb_color = [0, 0, 0]
|
'Return the name of the light.'
| @property
def name(self):
| return self._name
|
'Return last RGB color value set.'
| @property
def rgb_color(self):
| return self._rgb_color
|
'Return true if not black.'
| @property
def is_on(self):
| return (self._rgb_color != [0, 0, 0])
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_HYPERION
|
'Turn the lights on.'
| def turn_on(self, **kwargs):
| if (ATTR_RGB_COLOR in kwargs):
self._rgb_color = kwargs[ATTR_RGB_COLOR]
else:
self._rgb_color = self._default_color
self.json_request({'command': 'color', 'priority': 128, 'color': self._rgb_color})
|
'Disconnect all remotes.'
| def turn_off(self, **kwargs):
| self.json_request({'command': 'clearall'})
self._rgb_color = [0, 0, 0]
|
'Get the remote\'s active color.'
| def update(self):
| response = self.json_request({'command': 'serverinfo'})
if response:
if ('activeLedColor' not in response['info']):
self._rgb_color = self._default_color
return
if (response['info']['activeLedColor'] == []):
self._rgb_color = [0, 0, 0]
else:
... |
'Get the hostname of the remote.'
| def setup(self):
| response = self.json_request({'command': 'serverinfo'})
if response:
if (self._name == self._host):
self._name = response['info']['hostname']
return True
return False
|
'Communicate with the JSON server.'
| def json_request(self, request, wait_for_response=False):
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
try:
sock.connect((self._host, self._port))
except OSError:
sock.close()
return False
sock.send(bytearray((json.dumps(request) + '\n'), 'utf-8'))
try:
buf = sock.recv(4096)
except sock... |
'Initialize a MySensors Light.'
| def __init__(self, *args):
| mysensors.MySensorsDeviceEntity.__init__(self, *args)
self._state = None
self._brightness = None
self._rgb = None
self._white = None
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self._brightness
|
'Return the RGB color value [int, int, int].'
| @property
def rgb_color(self):
| return self._rgb
|
'Return the white value of this light between 0..255.'
| @property
def white_value(self):
| return self._white
|
'Return true if unable to access real state of entity.'
| @property
def assumed_state(self):
| return self.gateway.optimistic
|
'Return true if device is on.'
| @property
def is_on(self):
| return self._state
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.