desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_MYSENSORS
|
'Turn on light child device.'
| def _turn_on_light(self):
| set_req = self.gateway.const.SetReq
if (self._state or (set_req.V_LIGHT not in self._values)):
return
self.gateway.set_child_value(self.node_id, self.child_id, set_req.V_LIGHT, 1)
if self.gateway.optimistic:
self._state = True
self._values[set_req.V_LIGHT] = STATE_ON
self... |
'Turn on dimmer child device.'
| def _turn_on_dimmer(self, **kwargs):
| set_req = self.gateway.const.SetReq
brightness = self._brightness
if ((ATTR_BRIGHTNESS not in kwargs) or (kwargs[ATTR_BRIGHTNESS] == self._brightness) or (set_req.V_DIMMER not in self._values)):
return
brightness = kwargs[ATTR_BRIGHTNESS]
percent = round(((100 * brightness) / 255))
self.... |
'Turn on RGB or RGBW child device.'
| def _turn_on_rgb_and_w(self, hex_template, **kwargs):
| rgb = self._rgb
white = self._white
hex_color = self._values.get(self.value_type)
new_rgb = kwargs.get(ATTR_RGB_COLOR)
new_white = kwargs.get(ATTR_WHITE_VALUE)
if ((new_rgb is None) and (new_white is None)):
return
if (new_rgb is not None):
rgb = list(new_rgb)
if (rgb is ... |
'Turn off light child device.'
| def _turn_off_light(self, value_type=None, value=None):
| set_req = self.gateway.const.SetReq
value_type = (set_req.V_LIGHT if (set_req.V_LIGHT in self._values) else value_type)
value = (0 if (set_req.V_LIGHT in self._values) else value)
return {ATTR_VALUE_TYPE: value_type, ATTR_VALUE: value}
|
'Turn off dimmer child device.'
| def _turn_off_dimmer(self, value_type=None, value=None):
| set_req = self.gateway.const.SetReq
value_type = (set_req.V_DIMMER if (set_req.V_DIMMER in self._values) else value_type)
value = (0 if (set_req.V_DIMMER in self._values) else value)
return {ATTR_VALUE_TYPE: value_type, ATTR_VALUE: value}
|
'Turn off RGB or RGBW child device.'
| def _turn_off_rgb_or_w(self, value_type=None, value=None):
| if (float(self.gateway.protocol_version) >= 1.5):
set_req = self.gateway.const.SetReq
if (self.value_type == set_req.V_RGB):
value = '000000'
elif (self.value_type == set_req.V_RGBW):
value = '00000000'
return {ATTR_VALUE_TYPE: self.value_type, ATTR_VALUE: value}
|
'Turn the device off.'
| def _turn_off_main(self, value_type=None, value=None):
| set_req = self.gateway.const.SetReq
if ((value_type is None) or (value is None)):
_LOGGER.warning('%s: value_type %s, value = %s, None is not valid argument when setting child value', self._name, value_type, value)
return
self.gateway.set_child_value... |
'Update the controller with values from light child.'
| def _update_light(self):
| value_type = self.gateway.const.SetReq.V_LIGHT
if (value_type in self._values):
self._values[value_type] = (STATE_ON if (int(self._values[value_type]) == 1) else STATE_OFF)
self._state = (self._values[value_type] == STATE_ON)
|
'Update the controller with values from dimmer child.'
| def _update_dimmer(self):
| set_req = self.gateway.const.SetReq
value_type = set_req.V_DIMMER
if (value_type in self._values):
self._brightness = round(((255 * int(self._values[value_type])) / 100))
if (self._brightness == 0):
self._state = False
if (set_req.V_LIGHT not in self._values):
... |
'Update the controller with values from RGB or RGBW child.'
| def _update_rgb_or_w(self):
| set_req = self.gateway.const.SetReq
value = self._values[self.value_type]
if ((len(value) != 6) and (len(value) != 8)):
_LOGGER.error('Wrong value %s for %s', value, set_req(self.value_type).name)
return
color_list = rgb_hex_to_rgb_list(value)
if ((set_req.V_LIGHT not in ... |
'Update the controller with the latest value from a sensor.'
| def _update_main(self):
| node = self.gateway.sensors[self.node_id]
child = node.children[self.child_id]
for (value_type, value) in child.values.items():
_LOGGER.debug('%s: value_type %s, value = %s', self._name, value_type, value)
self._values[value_type] = value
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| self._turn_on_light()
self._turn_on_dimmer(**kwargs)
|
'Turn the device off.'
| def turn_off(self, **kwargs):
| ret = self._turn_off_dimmer()
ret = self._turn_off_light(value_type=ret[ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
self._turn_off_main(value_type=ret[ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
|
'Update the controller with the latest value from a sensor.'
| def update(self):
| self._update_main()
self._update_light()
self._update_dimmer()
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| self._turn_on_light()
self._turn_on_dimmer(**kwargs)
self._turn_on_rgb_and_w('%02x%02x%02x', **kwargs)
|
'Turn the device off.'
| def turn_off(self, **kwargs):
| ret = self._turn_off_rgb_or_w()
ret = self._turn_off_dimmer(value_type=ret[ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
ret = self._turn_off_light(value_type=ret[ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
self._turn_off_main(value_type=ret[ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
|
'Update the controller with the latest value from a sensor.'
| def update(self):
| self._update_main()
self._update_light()
self._update_dimmer()
self._update_rgb_or_w()
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| self._turn_on_light()
self._turn_on_dimmer(**kwargs)
self._turn_on_rgb_and_w('%02x%02x%02x%02x', **kwargs)
|
'Initialize the light.'
| def __init__(self, values, refresh, delay):
| zwave.ZWaveDeviceEntity.__init__(self, values, DOMAIN)
self._brightness = None
self._state = None
self._supported_features = None
self._delay = delay
self._refresh_value = refresh
self._zw098 = None
if (self.node.manufacturer_id.strip() and self.node.product_id.strip()):
specific... |
'Update internal properties based on zwave values.'
| def update_properties(self):
| (self._brightness, self._state) = brightness_state(self.values.primary)
|
'Call when a new value is added to this entity.'
| def value_added(self):
| self._supported_features = SUPPORT_BRIGHTNESS
if (self.values.dimming_duration is not None):
self._supported_features |= SUPPORT_TRANSITION
|
'Call when a value for this entity\'s node has changed.'
| def value_changed(self):
| if self._refresh_value:
if self._refreshing:
self._refreshing = False
else:
def _refresh_value():
'Use timer callback for delayed value refresh.'
self._refreshing = True
self.values.primary.refresh()
... |
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self._brightness
|
'Return true if device is on.'
| @property
def is_on(self):
| return (self._state == STATE_ON)
|
'Flag supported features.'
| @property
def supported_features(self):
| return self._supported_features
|
'Set the transition time for the brightness value.
Zwave Dimming Duration values:
0x00 = instant
0x01-0x7F = 1 second to 127 seconds
0x80-0xFE = 1 minute to 127 minutes
0xFF = factory default'
| def _set_duration(self, **kwargs):
| if (self.values.dimming_duration is None):
if (ATTR_TRANSITION in kwargs):
_LOGGER.debug('Dimming not supported by %s.', self.entity_id)
return
if (ATTR_TRANSITION not in kwargs):
self.values.dimming_duration.data = 255
return
transition = kwargs[ATTR_... |
'Turn the device on.'
| def turn_on(self, **kwargs):
| self._set_duration(**kwargs)
if (ATTR_BRIGHTNESS in kwargs):
self._brightness = kwargs[ATTR_BRIGHTNESS]
brightness = int(((self._brightness / 255) * 99))
else:
brightness = 255
if self.node.set_dimmer(self.values.primary.value_id, brightness):
self._state = STATE_ON
|
'Turn the device off.'
| def turn_off(self, **kwargs):
| self._set_duration(**kwargs)
if self.node.set_dimmer(self.values.primary.value_id, 0):
self._state = STATE_OFF
|
'Initialize the light.'
| def __init__(self, values, refresh, delay):
| self._color_channels = None
self._rgb = None
self._ct = None
super().__init__(values, refresh, delay)
|
'Call when a new value is added to this entity.'
| def value_added(self):
| super().value_added()
self._supported_features |= SUPPORT_RGB_COLOR
if self._zw098:
self._supported_features |= SUPPORT_COLOR_TEMP
|
'Update internal properties based on zwave values.'
| def update_properties(self):
| super().update_properties()
if (self.values.color is None):
return
if (self.values.color_channels is None):
return
self._color_channels = self.values.color_channels.data
data = self.values.color.data
self._rgb = [int(data[1:3], 16), int(data[3:5], 16), int(data[5:7], 16)]
ind... |
'Return the rgb color.'
| @property
def rgb_color(self):
| return self._rgb
|
'Return the color temperature.'
| @property
def color_temp(self):
| return self._ct
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| rgbw = None
if (ATTR_COLOR_TEMP in kwargs):
if self._zw098:
if (kwargs[ATTR_COLOR_TEMP] > TEMP_MID_HASS):
self._ct = TEMP_WARM_HASS
rgbw = '#000000ff00'
else:
self._ct = TEMP_COLD_HASS
rgbw = '#00000000ff'
elif (... |
'Initialize the light.'
| def __init__(self, device):
| import tikteck
self._name = device['name']
self._address = device['address']
self._password = device['password']
self._brightness = 255
self._rgb = [255, 255, 255]
self._state = False
self.is_valid = True
self._bulb = tikteck.tikteck(self._address, 'Smart Light', self._password)
... |
'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
|
'Return the color property.'
| @property
def rgb_color(self):
| return self._rgb
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_TIKTECK_LED
|
'Return the polling state.'
| @property
def should_poll(self):
| return False
|
'Return the assumed state.'
| @property
def assumed_state(self):
| return True
|
'Set the bulb state.'
| def set_state(self, red, green, blue, brightness):
| return self._bulb.set_state(red, green, blue, brightness)
|
'Turn the specified light on.'
| def turn_on(self, **kwargs):
| self._state = True
rgb = kwargs.get(ATTR_RGB_COLOR)
brightness = kwargs.get(ATTR_BRIGHTNESS)
if (rgb is not None):
self._rgb = rgb
if (brightness is not None):
self._brightness = brightness
self.set_state(self._rgb[0], self._rgb[1], self._rgb[2], self.brightness)
self.schedul... |
'Turn the specified light off.'
| def turn_off(self, **kwargs):
| self._state = False
self.set_state(0, 0, 0, 0)
self.schedule_update_ha_state()
|
'Initialize the light.'
| def __init__(self, scs_id, name, logger):
| self._name = name
self._scs_id = scs_id
self._toggled = False
self._logger = logger
|
'Return the SCS ID.'
| @property
def scs_id(self):
| return self._scs_id
|
'No polling needed for a SCSGate light.'
| @property
def should_poll(self):
| return False
|
'Return the name of the device if any.'
| @property
def name(self):
| return self._name
|
'Return true if light is on.'
| @property
def is_on(self):
| return self._toggled
|
'Turn the device on.'
| def turn_on(self, **kwargs):
| from scsgate.tasks import ToggleStatusTask
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
self._toggled = True
self.schedule_update_ha_state()
|
'Turn the device off.'
| def turn_off(self, **kwargs):
| from scsgate.tasks import ToggleStatusTask
scsgate.SCSGATE.append_task(ToggleStatusTask(target=self._scs_id, toggled=False))
self._toggled = False
self.schedule_update_ha_state()
|
'Handle a SCSGate message related with this light.'
| def process_event(self, message):
| if (self._toggled == message.toggled):
self._logger.info('Light %s, ignoring message %s because state already active', self._scs_id, message)
return
self._toggled = message.toggled
self.schedule_update_ha_state()
command = 'off'
if self._toggled:
comma... |
'Initialize the device.'
| def __init__(self, node, name):
| self.node = node
self.node.deviceName = name
self._value = 0
|
'Return the the name of the node.'
| @property
def name(self):
| return self.node.deviceName
|
'Return the ID of this Insteon node.'
| @property
def unique_id(self):
| return 'insteon_local_{}'.format(self.node.device_id)
|
'Return the brightness of this light between 0..255.'
| @property
def brightness(self):
| return self._value
|
'Update state of the light.'
| @util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
def update(self):
| resp = self.node.status(0)
while (('error' in resp) and (resp['error'] is True)):
resp = self.node.status(0)
if ('cmd2' in resp):
self._value = int(resp['cmd2'], 16)
|
'Return the boolean response if the node is on.'
| @property
def is_on(self):
| return (self._value != 0)
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_INSTEON_LOCAL
|
'Turn device on.'
| def turn_on(self, **kwargs):
| brightness = 100
if (ATTR_BRIGHTNESS in kwargs):
brightness = ((int(kwargs[ATTR_BRIGHTNESS]) / 255) * 100)
self.node.change_level(brightness)
|
'Turn device off.'
| def turn_off(self, **kwargs):
| self.node.off()
|
'Initialize one-color PWM LED.'
| def __init__(self, led, name):
| self._led = led
self._name = name
self._is_on = False
self._brightness = 255
|
'No polling needed.'
| @property
def should_poll(self):
| return False
|
'Return the name of the group.'
| @property
def name(self):
| return self._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
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_SIMPLE_LED
|
'Turn on a led.'
| def turn_on(self, **kwargs):
| if (ATTR_BRIGHTNESS in kwargs):
self._brightness = kwargs[ATTR_BRIGHTNESS]
if (ATTR_TRANSITION in kwargs):
transition_time = kwargs[ATTR_TRANSITION]
self._led.transition(transition_time, is_on=True, brightness=_from_hass_brightness(self._brightness))
else:
self._led.set(is_on... |
'Turn off a LED.'
| def turn_off(self, **kwargs):
| if self.is_on:
if (ATTR_TRANSITION in kwargs):
transition_time = kwargs[ATTR_TRANSITION]
self._led.transition(transition_time, is_on=False)
else:
self._led.off()
self._is_on = False
self.schedule_update_ha_state()
|
'Initialize a RGB(W) PWM LED.'
| def __init__(self, led, name):
| super().__init__(led, name)
self._color = DEFAULT_COLOR
|
'Return the color property.'
| @property
def rgb_color(self):
| return self._color
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_RGB_LED
|
'Turn on a LED.'
| def turn_on(self, **kwargs):
| if (ATTR_RGB_COLOR in kwargs):
self._color = kwargs[ATTR_RGB_COLOR]
if (ATTR_BRIGHTNESS in kwargs):
self._brightness = kwargs[ATTR_BRIGHTNESS]
if (ATTR_TRANSITION in kwargs):
transition_time = kwargs[ATTR_TRANSITION]
self._led.transition(transition_time, is_on=True, brightnes... |
'Initialize a Yeelight Sunflower bulb.'
| def __init__(self, light):
| self._light = light
self._available = light.available
self._brightness = light.brightness
self._is_on = light.is_on
self._rgb_color = light.rgb_color
|
'Return the display name of this light.'
| @property
def name(self):
| return 'sunflower_{}'.format(self._light.zid)
|
'Return True if entity is available.'
| @property
def available(self):
| return self._available
|
'Return true if light is on.'
| @property
def is_on(self):
| return self._is_on
|
'Return the brightness is 0-255; Yeelight\'s brightness is 0-100.'
| @property
def brightness(self):
| return int(((self._brightness / 100) * 255))
|
'Return the color property.'
| @property
def rgb_color(self):
| return self._rgb_color
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_YEELIGHT_SUNFLOWER
|
'Instruct the light to turn on, optionally set colour/brightness.'
| def turn_on(self, **kwargs):
| if (not kwargs):
self._light.turn_on()
elif ((ATTR_RGB_COLOR in kwargs) and (ATTR_BRIGHTNESS in kwargs)):
rgb = kwargs[ATTR_RGB_COLOR]
bright = int(((kwargs[ATTR_BRIGHTNESS] / 255) * 100))
self._light.set_all(rgb[0], rgb[1], rgb[2], bright)
elif (ATTR_RGB_COLOR in kwargs):
... |
'Instruct the light to turn off.'
| def turn_off(self, **kwargs):
| self._light.turn_off()
|
'Fetch new state data for this light and update local values.'
| def update(self):
| self._light.update()
self._available = self._light.available
self._brightness = self._light.brightness
self._is_on = self._light.is_on
self._rgb_color = self._light.rgb_color
|
'Initialize the EnOcean light source.'
| def __init__(self, sender_id, devname, dev_id):
| enocean.EnOceanDevice.__init__(self)
self._on_state = False
self._brightness = 50
self._sender_id = sender_id
self.dev_id = dev_id
self._devname = devname
self.stype = 'dimmer'
|
'Return the name of the device if any.'
| @property
def name(self):
| return self._devname
|
'Brightness of the light.
This method is optional. Removing it indicates to Home Assistant
that brightness is not supported for this light.'
| @property
def brightness(self):
| return self._brightness
|
'If light is on.'
| @property
def is_on(self):
| return self._on_state
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_ENOCEAN
|
'Turn the light source on or sets a specific dimmer value.'
| def turn_on(self, **kwargs):
| brightness = kwargs.get(ATTR_BRIGHTNESS)
if (brightness is not None):
self._brightness = brightness
bval = math.floor(((self._brightness / 256.0) * 100.0))
if (bval == 0):
bval = 1
command = [165, 2, bval, 1, 9]
command.extend(self._sender_id)
command.extend([0])
self.sen... |
'Turn the light source off.'
| def turn_off(self, **kwargs):
| command = [165, 2, 0, 1, 9]
command.extend(self._sender_id)
command.extend([0])
self.send_command(command, [], 1)
self._on_state = False
|
'Update the internal state of this device.'
| def value_changed(self, val):
| self._brightness = math.floor(((val / 100.0) * 256.0))
self._on_state = bool((val != 0))
self.schedule_update_ha_state()
|
'Initialize a Group.'
| def __init__(self, light):
| self._group = light
self._name = light.name
|
'Flag supported features.'
| @property
def supported_features(self):
| return SUPPORT_BRIGHTNESS
|
'Return the display name of this group.'
| @property
def name(self):
| return self._name
|
'Return true if group lights are on.'
| @property
def is_on(self):
| return self._group.state
|
'Return the brightness of the group lights.'
| @property
def brightness(self):
| return self._group.dimmer
|
'Instruct the group lights to turn off.'
| def turn_off(self, **kwargs):
| self._group.set_state(0)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.