Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
LimitlessLEDGroup.assumed_state
(self)
Return True because unable to access real state of the entity.
Return True because unable to access real state of the entity.
def assumed_state(self): """Return True because unable to access real state of the entity.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 245, 4 ]
[ 247, 19 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.name
(self)
Return the name of the group.
Return the name of the group.
def name(self): """Return the name of the group.""" return self.group.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "group", ".", "name" ]
[ 250, 4 ]
[ 252, 30 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 255, 4 ]
[ 257, 26 ]
python
en
['en', 'fy', 'en']
True
LimitlessLEDGroup.brightness
(self)
Return the brightness property.
Return the brightness property.
def brightness(self): """Return the brightness property.""" if self._effect == EFFECT_NIGHT: return 1 return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "if", "self", ".", "_effect", "==", "EFFECT_NIGHT", ":", "return", "1", "return", "self", ".", "_brightness" ]
[ 260, 4 ]
[ 265, 31 ]
python
en
['en', 'ru-Latn', 'en']
True
LimitlessLEDGroup.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self): """Return the coldest color_temp that this light supports.""" return 154
[ "def", "min_mireds", "(", "self", ")", ":", "return", "154" ]
[ 268, 4 ]
[ 270, 18 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self): """Return the warmest color_temp that this light supports.""" return 370
[ "def", "max_mireds", "(", "self", ")", ":", "return", "370" ]
[ 273, 4 ]
[ 275, 18 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.color_temp
(self)
Return the temperature property.
Return the temperature property.
def color_temp(self): """Return the temperature property.""" if self.hs_color is not None: return None return self._temperature
[ "def", "color_temp", "(", "self", ")", ":", "if", "self", ".", "hs_color", "is", "not", "None", ":", "return", "None", "return", "self", ".", "_temperature" ]
[ 278, 4 ]
[ 282, 32 ]
python
en
['en', 'la', 'en']
True
LimitlessLEDGroup.hs_color
(self)
Return the color property.
Return the color property.
def hs_color(self): """Return the color property.""" if self._effect == EFFECT_NIGHT: return None if self._color is None or self._color[1] == 0: return None return self._color
[ "def", "hs_color", "(", "self", ")", ":", "if", "self", ".", "_effect", "==", "EFFECT_NIGHT", ":", "return", "None", "if", "self", ".", "_color", "is", "None", "or", "self", ".", "_color", "[", "1", "]", "==", "0", ":", "return", "None", "return", ...
[ 285, 4 ]
[ 293, 26 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return self._supported
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported" ]
[ 296, 4 ]
[ 298, 30 ]
python
en
['da', 'en', 'en']
True
LimitlessLEDGroup.effect
(self)
Return the current effect for this light.
Return the current effect for this light.
def effect(self): """Return the current effect for this light.""" return self._effect
[ "def", "effect", "(", "self", ")", ":", "return", "self", ".", "_effect" ]
[ 301, 4 ]
[ 303, 27 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.effect_list
(self)
Return the list of supported effects for this light.
Return the list of supported effects for this light.
def effect_list(self): """Return the list of supported effects for this light.""" return self._effect_list
[ "def", "effect_list", "(", "self", ")", ":", "return", "self", ".", "_effect_list" ]
[ 306, 4 ]
[ 308, 32 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.turn_off
(self, transition_time, pipeline, **kwargs)
Turn off a group.
Turn off a group.
def turn_off(self, transition_time, pipeline, **kwargs): """Turn off a group.""" if self.config[CONF_FADE]: pipeline.transition(transition_time, brightness=0.0) pipeline.off()
[ "def", "turn_off", "(", "self", ",", "transition_time", ",", "pipeline", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "config", "[", "CONF_FADE", "]", ":", "pipeline", ".", "transition", "(", "transition_time", ",", "brightness", "=", "0.0", ")"...
[ 312, 4 ]
[ 316, 22 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.turn_on
(self, transition_time, pipeline, **kwargs)
Turn on (or adjust property of) a group.
Turn on (or adjust property of) a group.
def turn_on(self, transition_time, pipeline, **kwargs): """Turn on (or adjust property of) a group.""" # The night effect does not need a turned on light if kwargs.get(ATTR_EFFECT) == EFFECT_NIGHT: if EFFECT_NIGHT in self._effect_list: pipeline.night_light() ...
[ "def", "turn_on", "(", "self", ",", "transition_time", ",", "pipeline", ",", "*", "*", "kwargs", ")", ":", "# The night effect does not need a turned on light", "if", "kwargs", ".", "get", "(", "ATTR_EFFECT", ")", "==", "EFFECT_NIGHT", ":", "if", "EFFECT_NIGHT", ...
[ 320, 4 ]
[ 374, 35 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.limitlessled_temperature
(self)
Convert Home Assistant color temperature units to percentage.
Convert Home Assistant color temperature units to percentage.
def limitlessled_temperature(self): """Convert Home Assistant color temperature units to percentage.""" max_kelvin = color_temperature_mired_to_kelvin(self.min_mireds) min_kelvin = color_temperature_mired_to_kelvin(self.max_mireds) width = max_kelvin - min_kelvin kelvin = color_t...
[ "def", "limitlessled_temperature", "(", "self", ")", ":", "max_kelvin", "=", "color_temperature_mired_to_kelvin", "(", "self", ".", "min_mireds", ")", "min_kelvin", "=", "color_temperature_mired_to_kelvin", "(", "self", ".", "max_mireds", ")", "width", "=", "max_kelvi...
[ 376, 4 ]
[ 383, 42 ]
python
en
['en', 'ca', 'en']
True
LimitlessLEDGroup.limitlessled_brightness
(self)
Convert Home Assistant brightness units to percentage.
Convert Home Assistant brightness units to percentage.
def limitlessled_brightness(self): """Convert Home Assistant brightness units to percentage.""" return self._brightness / 255
[ "def", "limitlessled_brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness", "/", "255" ]
[ 385, 4 ]
[ 387, 37 ]
python
en
['en', 'en', 'en']
True
LimitlessLEDGroup.limitlessled_color
(self)
Convert Home Assistant HS list to RGB Color tuple.
Convert Home Assistant HS list to RGB Color tuple.
def limitlessled_color(self): """Convert Home Assistant HS list to RGB Color tuple.""" return Color(*color_hs_to_RGB(*tuple(self._color)))
[ "def", "limitlessled_color", "(", "self", ")", ":", "return", "Color", "(", "*", "color_hs_to_RGB", "(", "*", "tuple", "(", "self", ".", "_color", ")", ")", ")" ]
[ 389, 4 ]
[ 392, 59 ]
python
en
['en', 'en', 'en']
True
debounce
(func)
Decorate function to debounce callbacks from HomeKit.
Decorate function to debounce callbacks from HomeKit.
def debounce(func): """Decorate function to debounce callbacks from HomeKit.""" @ha_callback def call_later_listener(self, *args): """Handle call_later callback.""" debounce_params = self.debounce.pop(func.__name__, None) if debounce_params: self.hass.async_add_executor_...
[ "def", "debounce", "(", "func", ")", ":", "@", "ha_callback", "def", "call_later_listener", "(", "self", ",", "*", "args", ")", ":", "\"\"\"Handle call_later callback.\"\"\"", "debounce_params", "=", "self", ".", "debounce", ".", "pop", "(", "func", ".", "__na...
[ 100, 0 ]
[ 128, 18 ]
python
en
['en', 'en', 'en']
True
get_accessory
(hass, driver, state, aid, config)
Take state and return an accessory object if supported.
Take state and return an accessory object if supported.
def get_accessory(hass, driver, state, aid, config): """Take state and return an accessory object if supported.""" if not aid: _LOGGER.warning( 'The entity "%s" is not supported, since it ' "generates an invalid aid, please change it", state.entity_id, ) ...
[ "def", "get_accessory", "(", "hass", ",", "driver", ",", "state", ",", "aid", ",", "config", ")", ":", "if", "not", "aid", ":", "_LOGGER", ".", "warning", "(", "'The entity \"%s\" is not supported, since it '", "\"generates an invalid aid, please change it\"", ",", ...
[ 131, 0 ]
[ 236, 74 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.__init__
( self, hass, driver, name, entity_id, aid, config, *args, category=CATEGORY_OTHER, **kwargs, )
Initialize a Accessory object.
Initialize a Accessory object.
def __init__( self, hass, driver, name, entity_id, aid, config, *args, category=CATEGORY_OTHER, **kwargs, ): """Initialize a Accessory object.""" super().__init__(driver=driver, display_name=name, aid=aid, *args, **kwarg...
[ "def", "__init__", "(", "self", ",", "hass", ",", "driver", ",", "name", ",", "entity_id", ",", "aid", ",", "config", ",", "*", "args", ",", "category", "=", "CATEGORY_OTHER", ",", "*", "*", "kwargs", ",", ")", ":", "super", "(", ")", ".", "__init_...
[ 242, 4 ]
[ 337, 9 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.available
(self)
Return if accessory is available.
Return if accessory is available.
def available(self): """Return if accessory is available.""" state = self.hass.states.get(self.entity_id) return state is not None and state.state != STATE_UNAVAILABLE
[ "def", "available", "(", "self", ")", ":", "state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "self", ".", "entity_id", ")", "return", "state", "is", "not", "None", "and", "state", ".", "state", "!=", "STATE_UNAVAILABLE" ]
[ 340, 4 ]
[ 343, 69 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.run
(self)
Handle accessory driver started event. Run inside the HAP-python event loop.
Handle accessory driver started event.
async def run(self): """Handle accessory driver started event. Run inside the HAP-python event loop. """ self.hass.add_job(self.run_handler)
[ "async", "def", "run", "(", "self", ")", ":", "self", ".", "hass", ".", "add_job", "(", "self", ".", "run_handler", ")" ]
[ 345, 4 ]
[ 350, 43 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.run_handler
(self)
Handle accessory driver started event. Run inside the Home Assistant event loop.
Handle accessory driver started event.
async def run_handler(self): """Handle accessory driver started event. Run inside the Home Assistant event loop. """ state = self.hass.states.get(self.entity_id) self.async_update_state_callback(state) self._subscriptions.append( async_track_state_change_even...
[ "async", "def", "run_handler", "(", "self", ")", ":", "state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "self", ".", "entity_id", ")", "self", ".", "async_update_state_callback", "(", "state", ")", "self", ".", "_subscriptions", ".", "ap...
[ 352, 4 ]
[ 398, 76 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.async_update_event_state_callback
(self, event)
Handle state change event listener callback.
Handle state change event listener callback.
def async_update_event_state_callback(self, event): """Handle state change event listener callback.""" self.async_update_state_callback(event.data.get("new_state"))
[ "def", "async_update_event_state_callback", "(", "self", ",", "event", ")", ":", "self", ".", "async_update_state_callback", "(", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", ")" ]
[ 401, 4 ]
[ 403, 69 ]
python
en
['fr', 'en', 'en']
True
HomeAccessory.async_update_state_callback
(self, new_state)
Handle state change listener callback.
Handle state change listener callback.
def async_update_state_callback(self, new_state): """Handle state change listener callback.""" _LOGGER.debug("New_state: %s", new_state) if new_state is None: return battery_state = None battery_charging_state = None if ( not self.linked_battery_se...
[ "def", "async_update_state_callback", "(", "self", ",", "new_state", ")", ":", "_LOGGER", ".", "debug", "(", "\"New_state: %s\"", ",", "new_state", ")", "if", "new_state", "is", "None", ":", "return", "battery_state", "=", "None", "battery_charging_state", "=", ...
[ 406, 4 ]
[ 425, 42 ]
python
en
['en', 'sw', 'en']
True
HomeAccessory.async_update_linked_battery_callback
(self, event)
Handle linked battery sensor state change listener callback.
Handle linked battery sensor state change listener callback.
def async_update_linked_battery_callback(self, event): """Handle linked battery sensor state change listener callback.""" new_state = event.data.get("new_state") if new_state is None: return if self.linked_battery_charging_sensor: battery_charging_state = None ...
[ "def", "async_update_linked_battery_callback", "(", "self", ",", "event", ")", ":", "new_state", "=", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", "if", "new_state", "is", "None", ":", "return", "if", "self", ".", "linked_battery_charging_sensor"...
[ 428, 4 ]
[ 437, 74 ]
python
en
['en', 'da', 'en']
True
HomeAccessory.async_update_linked_battery_charging_callback
(self, event)
Handle linked battery charging sensor state change listener callback.
Handle linked battery charging sensor state change listener callback.
def async_update_linked_battery_charging_callback(self, event): """Handle linked battery charging sensor state change listener callback.""" new_state = event.data.get("new_state") if new_state is None: return self.async_update_battery(None, new_state.state == STATE_ON)
[ "def", "async_update_linked_battery_charging_callback", "(", "self", ",", "event", ")", ":", "new_state", "=", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", "if", "new_state", "is", "None", ":", "return", "self", ".", "async_update_battery", "(", ...
[ 440, 4 ]
[ 445, 68 ]
python
en
['en', 'da', 'en']
True
HomeAccessory.async_update_battery
(self, battery_level, battery_charging)
Update battery service if available. Only call this function if self._support_battery_level is True.
Update battery service if available.
def async_update_battery(self, battery_level, battery_charging): """Update battery service if available. Only call this function if self._support_battery_level is True. """ if not self._char_battery: # Battery appeared after homekit was started return ba...
[ "def", "async_update_battery", "(", "self", ",", "battery_level", ",", "battery_charging", ")", ":", "if", "not", "self", ".", "_char_battery", ":", "# Battery appeared after homekit was started", "return", "battery_level", "=", "convert_to_float", "(", "battery_level", ...
[ 448, 4 ]
[ 477, 13 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.async_update_state
(self, new_state)
Handle state change to update HomeKit value. Overridden by accessory types.
Handle state change to update HomeKit value.
def async_update_state(self, new_state): """Handle state change to update HomeKit value. Overridden by accessory types. """ raise NotImplementedError()
[ "def", "async_update_state", "(", "self", ",", "new_state", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 480, 4 ]
[ 485, 35 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.call_service
(self, domain, service, service_data, value=None)
Fire event and call service for changes from HomeKit.
Fire event and call service for changes from HomeKit.
def call_service(self, domain, service, service_data, value=None): """Fire event and call service for changes from HomeKit.""" self.hass.add_job(self.async_call_service, domain, service, service_data, value)
[ "def", "call_service", "(", "self", ",", "domain", ",", "service", ",", "service_data", ",", "value", "=", "None", ")", ":", "self", ".", "hass", ".", "add_job", "(", "self", ".", "async_call_service", ",", "domain", ",", "service", ",", "service_data", ...
[ 487, 4 ]
[ 489, 88 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.async_call_service
(self, domain, service, service_data, value=None)
Fire event and call service for changes from HomeKit. This method must be run in the event loop.
Fire event and call service for changes from HomeKit.
async def async_call_service(self, domain, service, service_data, value=None): """Fire event and call service for changes from HomeKit. This method must be run in the event loop. """ event_data = { ATTR_ENTITY_ID: self.entity_id, ATTR_DISPLAY_NAME: self.display_n...
[ "async", "def", "async_call_service", "(", "self", ",", "domain", ",", "service", ",", "service_data", ",", "value", "=", "None", ")", ":", "event_data", "=", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id", ",", "ATTR_DISPLAY_NAME", ":", "self", ".", ...
[ 491, 4 ]
[ 507, 9 ]
python
en
['en', 'en', 'en']
True
HomeAccessory.async_stop
(self)
Cancel any subscriptions when the bridge is stopped.
Cancel any subscriptions when the bridge is stopped.
def async_stop(self): """Cancel any subscriptions when the bridge is stopped.""" while self._subscriptions: self._subscriptions.pop(0)()
[ "def", "async_stop", "(", "self", ")", ":", "while", "self", ".", "_subscriptions", ":", "self", ".", "_subscriptions", ".", "pop", "(", "0", ")", "(", ")" ]
[ 510, 4 ]
[ 513, 40 ]
python
en
['en', 'en', 'en']
True
HomeBridge.__init__
(self, hass, driver, name)
Initialize a Bridge object.
Initialize a Bridge object.
def __init__(self, hass, driver, name): """Initialize a Bridge object.""" super().__init__(driver, name) self.set_info_service( firmware_revision=__version__, manufacturer=MANUFACTURER, model=BRIDGE_MODEL, serial_number=BRIDGE_SERIAL_NUMBER, ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "driver", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", "driver", ",", "name", ")", "self", ".", "set_info_service", "(", "firmware_revision", "=", "__version__", ",", "manufacturer", "=...
[ 519, 4 ]
[ 528, 24 ]
python
en
['en', 'fr', 'en']
True
HomeBridge.setup_message
(self)
Prevent print of pyhap setup message to terminal.
Prevent print of pyhap setup message to terminal.
def setup_message(self): """Prevent print of pyhap setup message to terminal."""
[ "def", "setup_message", "(", "self", ")", ":" ]
[ 530, 4 ]
[ 531, 63 ]
python
en
['en', 'en', 'en']
True
HomeBridge.get_snapshot
(self, info)
Get snapshot from accessory if supported.
Get snapshot from accessory if supported.
def get_snapshot(self, info): """Get snapshot from accessory if supported.""" acc = self.accessories.get(info["aid"]) if acc is None: raise ValueError("Requested snapshot for missing accessory") if not hasattr(acc, "get_snapshot"): raise ValueError( ...
[ "def", "get_snapshot", "(", "self", ",", "info", ")", ":", "acc", "=", "self", ".", "accessories", ".", "get", "(", "info", "[", "\"aid\"", "]", ")", "if", "acc", "is", "None", ":", "raise", "ValueError", "(", "\"Requested snapshot for missing accessory\"", ...
[ 533, 4 ]
[ 543, 37 ]
python
en
['en', 'en', 'en']
True
HomeDriver.__init__
(self, hass, entry_id, bridge_name, **kwargs)
Initialize a AccessoryDriver object.
Initialize a AccessoryDriver object.
def __init__(self, hass, entry_id, bridge_name, **kwargs): """Initialize a AccessoryDriver object.""" super().__init__(**kwargs) self.hass = hass self._entry_id = entry_id self._bridge_name = bridge_name
[ "def", "__init__", "(", "self", ",", "hass", ",", "entry_id", ",", "bridge_name", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self", ".", "hass", "=", "hass", "self", ".", "_entry_id", "=", ...
[ 549, 4 ]
[ 554, 39 ]
python
en
['en', 'en', 'en']
True
HomeDriver.pair
(self, client_uuid, client_public)
Override super function to dismiss setup message if paired.
Override super function to dismiss setup message if paired.
def pair(self, client_uuid, client_public): """Override super function to dismiss setup message if paired.""" success = super().pair(client_uuid, client_public) if success: dismiss_setup_message(self.hass, self._entry_id) return success
[ "def", "pair", "(", "self", ",", "client_uuid", ",", "client_public", ")", ":", "success", "=", "super", "(", ")", ".", "pair", "(", "client_uuid", ",", "client_public", ")", "if", "success", ":", "dismiss_setup_message", "(", "self", ".", "hass", ",", "...
[ 556, 4 ]
[ 561, 22 ]
python
en
['en', 'en', 'en']
True
HomeDriver.unpair
(self, client_uuid)
Override super function to show setup message if unpaired.
Override super function to show setup message if unpaired.
def unpair(self, client_uuid): """Override super function to show setup message if unpaired.""" super().unpair(client_uuid) show_setup_message( self.hass, self._entry_id, self._bridge_name, self.state.pincode, self.accessory.xhm_uri(), ...
[ "def", "unpair", "(", "self", ",", "client_uuid", ")", ":", "super", "(", ")", ".", "unpair", "(", "client_uuid", ")", "show_setup_message", "(", "self", ".", "hass", ",", "self", ".", "_entry_id", ",", "self", ".", "_bridge_name", ",", "self", ".", "s...
[ 563, 4 ]
[ 572, 9 ]
python
en
['en', 'en', 'en']
True
scaleto255
(value)
Scale the input value from 0-100 to 0-255.
Scale the input value from 0-100 to 0-255.
def scaleto255(value): """Scale the input value from 0-100 to 0-255.""" # Fibaro has a funny way of storing brightness either 0-100 or 0-99 # depending on device type (e.g. dimmer vs led) if value > 98: value = 100 return max(0, min(255, ((value * 255.0) / 100.0)))
[ "def", "scaleto255", "(", "value", ")", ":", "# Fibaro has a funny way of storing brightness either 0-100 or 0-99", "# depending on device type (e.g. dimmer vs led)", "if", "value", ">", "98", ":", "value", "=", "100", "return", "max", "(", "0", ",", "min", "(", "255", ...
[ 20, 0 ]
[ 26, 54 ]
python
en
['en', 'en', 'en']
True
scaleto100
(value)
Scale the input value from 0-255 to 0-100.
Scale the input value from 0-255 to 0-100.
def scaleto100(value): """Scale the input value from 0-255 to 0-100.""" # Make sure a low but non-zero value is not rounded down to zero if 0 < value < 3: return 1 return max(0, min(100, ((value * 100.0) / 255.0)))
[ "def", "scaleto100", "(", "value", ")", ":", "# Make sure a low but non-zero value is not rounded down to zero", "if", "0", "<", "value", "<", "3", ":", "return", "1", "return", "max", "(", "0", ",", "min", "(", "100", ",", "(", "(", "value", "*", "100.0", ...
[ 29, 0 ]
[ 34, 54 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Perform the setup for Fibaro controller devices.
Perform the setup for Fibaro controller devices.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Perform the setup for Fibaro controller devices.""" if discovery_info is None: return async_add_entities( [FibaroLight(device) for device in hass.data[FIBARO_DEVICES]["light"]], True )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "async_add_entities", "(", "[", "FibaroLight", "(", "device", ")", ...
[ 37, 0 ]
[ 44, 5 ]
python
en
['en', 'en', 'en']
True
FibaroLight.__init__
(self, fibaro_device)
Initialize the light.
Initialize the light.
def __init__(self, fibaro_device): """Initialize the light.""" self._brightness = None self._color = (0, 0) self._last_brightness = 0 self._supported_flags = 0 self._update_lock = asyncio.Lock() self._white = 0 devconf = fibaro_device.device_config ...
[ "def", "__init__", "(", "self", ",", "fibaro_device", ")", ":", "self", ".", "_brightness", "=", "None", "self", ".", "_color", "=", "(", "0", ",", "0", ")", "self", ".", "_last_brightness", "=", "0", "self", ".", "_supported_flags", "=", "0", "self", ...
[ 50, 4 ]
[ 76, 49 ]
python
en
['en', 'en', 'en']
True
FibaroLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" return scaleto255(self._brightness)
[ "def", "brightness", "(", "self", ")", ":", "return", "scaleto255", "(", "self", ".", "_brightness", ")" ]
[ 79, 4 ]
[ 81, 43 ]
python
en
['en', 'no', 'en']
True
FibaroLight.hs_color
(self)
Return the color of the light.
Return the color of the light.
def hs_color(self): """Return the color of the light.""" return self._color
[ "def", "hs_color", "(", "self", ")", ":", "return", "self", ".", "_color" ]
[ 84, 4 ]
[ 86, 26 ]
python
en
['en', 'en', 'en']
True
FibaroLight.white_value
(self)
Return the white value of this light between 0..255.
Return the white value of this light between 0..255.
def white_value(self): """Return the white value of this light between 0..255.""" return self._white
[ "def", "white_value", "(", "self", ")", ":", "return", "self", ".", "_white" ]
[ 89, 4 ]
[ 91, 26 ]
python
en
['en', 'en', 'en']
True
FibaroLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return self._supported_flags
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported_flags" ]
[ 94, 4 ]
[ 96, 36 ]
python
en
['da', 'en', 'en']
True
FibaroLight.async_turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
async def async_turn_on(self, **kwargs): """Turn the light on.""" async with self._update_lock: await self.hass.async_add_executor_job(partial(self._turn_on, **kwargs))
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "async", "with", "self", ".", "_update_lock", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "partial", "(", "self", ".", "_turn_on", ",", "*", "*", ...
[ 98, 4 ]
[ 101, 84 ]
python
en
['en', 'et', 'en']
True
FibaroLight._turn_on
(self, **kwargs)
Really turn the light on.
Really turn the light on.
def _turn_on(self, **kwargs): """Really turn the light on.""" if self._supported_flags & SUPPORT_BRIGHTNESS: target_brightness = kwargs.get(ATTR_BRIGHTNESS) # No brightness specified, so we either restore it to # last brightness or switch it on at maximum level ...
[ "def", "_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_supported_flags", "&", "SUPPORT_BRIGHTNESS", ":", "target_brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "# No brightness specified, so we either restore it...
[ 103, 4 ]
[ 153, 27 ]
python
en
['en', 'en', 'en']
True
FibaroLight.async_turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
async def async_turn_off(self, **kwargs): """Turn the light off.""" async with self._update_lock: await self.hass.async_add_executor_job(partial(self._turn_off, **kwargs))
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "async", "with", "self", ".", "_update_lock", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "partial", "(", "self", ".", "_turn_off", ",", "*", "*"...
[ 155, 4 ]
[ 158, 85 ]
python
en
['en', 'zh', 'en']
True
FibaroLight._turn_off
(self, **kwargs)
Really turn the light off.
Really turn the light off.
def _turn_off(self, **kwargs): """Really turn the light off.""" # Let's save the last brightness level before we switch it off if ( (self._supported_flags & SUPPORT_BRIGHTNESS) and self._brightness and self._brightness > 0 ): self._last_bri...
[ "def", "_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Let's save the last brightness level before we switch it off", "if", "(", "(", "self", ".", "_supported_flags", "&", "SUPPORT_BRIGHTNESS", ")", "and", "self", ".", "_brightness", "and", "self", ...
[ 160, 4 ]
[ 170, 28 ]
python
en
['en', 'en', 'en']
True
FibaroLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self.current_binary_state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "current_binary_state" ]
[ 173, 4 ]
[ 175, 40 ]
python
en
['en', 'fy', 'en']
True
FibaroLight.async_update
(self)
Update the state.
Update the state.
async def async_update(self): """Update the state.""" async with self._update_lock: await self.hass.async_add_executor_job(self._update)
[ "async", "def", "async_update", "(", "self", ")", ":", "async", "with", "self", ".", "_update_lock", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_update", ")" ]
[ 177, 4 ]
[ 180, 64 ]
python
en
['en', 'en', 'en']
True
FibaroLight._update
(self)
Really update the state.
Really update the state.
def _update(self): """Really update the state.""" # Brightness handling if self._supported_flags & SUPPORT_BRIGHTNESS: self._brightness = float(self.fibaro_device.properties.value) # Fibaro might report 0-99 or 0-100 for brightness, # based on device type, so ...
[ "def", "_update", "(", "self", ")", ":", "# Brightness handling", "if", "self", ".", "_supported_flags", "&", "SUPPORT_BRIGHTNESS", ":", "self", ".", "_brightness", "=", "float", "(", "self", ".", "fibaro_device", ".", "properties", ".", "value", ")", "# Fibar...
[ 182, 4 ]
[ 205, 87 ]
python
en
['en', 'en', 'en']
True
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 15, 0 ]
[ 22, 43 ]
python
en
['en', 'en', 'en']
True
test_invalid_access_token
(hass)
Test that errors are shown when the access token is invalid.
Test that errors are shown when the access token is invalid.
async def test_invalid_access_token(hass): """Test that errors are shown when the access token is invalid.""" with patch("python_awair.AwairClient.query", side_effect=AuthError()): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ...
[ "async", "def", "test_invalid_access_token", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "AuthError", "(", ")", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "...
[ 25, 0 ]
[ 33, 78 ]
python
en
['en', 'en', 'en']
True
test_unexpected_api_error
(hass)
Test that we abort on generic errors.
Test that we abort on generic errors.
async def test_unexpected_api_error(hass): """Test that we abort on generic errors.""" with patch("python_awair.AwairClient.query", side_effect=AwairError()): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) assert r...
[ "async", "def", "test_unexpected_api_error", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "AwairError", "(", ")", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", ...
[ 36, 0 ]
[ 45, 44 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
(hass)
Test that errors are shown when adding a duplicate config.
Test that errors are shown when adding a duplicate config.
async def test_duplicate_error(hass): """Test that errors are shown when adding a duplicate config.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, ...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "DEVICES_FIXTURE", "]", ")", ",", "patch", "(", "\"homeassistant.components.awair.sensor.async_s...
[ 48, 0 ]
[ 66, 55 ]
python
en
['en', 'en', 'en']
True
test_no_devices_error
(hass)
Test that errors are shown when the API returns no devices.
Test that errors are shown when the API returns no devices.
async def test_no_devices_error(hass): """Test that errors are shown when the API returns no devices.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, NO_DEVICES_FIXTURE] ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source":...
[ "async", "def", "test_no_devices_error", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "NO_DEVICES_FIXTURE", "]", ")", ":", "result", "=", "await", "hass", ".", "config_entries...
[ 69, 0 ]
[ 80, 53 ]
python
en
['en', 'en', 'en']
True
test_import
(hass)
Test config.yaml import.
Test config.yaml import.
async def test_import(hass): """Test config.yaml import.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, ): result = await hass.config_ent...
[ "async", "def", "test_import", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "DEVICES_FIXTURE", "]", ")", ",", "patch", "(", "\"homeassistant.components.awair.sensor.async_setup_entr...
[ 83, 0 ]
[ 101, 54 ]
python
da
['da', 'en', 'sw']
False
test_import_aborts_on_api_error
(hass)
Test config.yaml imports on api error.
Test config.yaml imports on api error.
async def test_import_aborts_on_api_error(hass): """Test config.yaml imports on api error.""" with patch("python_awair.AwairClient.query", side_effect=AwairError()): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data={...
[ "async", "def", "test_import_aborts_on_api_error", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "AwairError", "(", ")", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", "...
[ 104, 0 ]
[ 115, 44 ]
python
en
['en', 'zu', 'sw']
False
test_import_aborts_if_configured
(hass)
Test config import doesn't re-import unnecessarily.
Test config import doesn't re-import unnecessarily.
async def test_import_aborts_if_configured(hass): """Test config import doesn't re-import unnecessarily.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( "homeassistant.components.awair.sensor.async_setup_entry", return_value=Tru...
[ "async", "def", "test_import_aborts_if_configured", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "DEVICES_FIXTURE", "]", ")", ",", "patch", "(", "\"homeassistant.components.awair.se...
[ 118, 0 ]
[ 138, 50 ]
python
en
['da', 'en', 'en']
True
test_reauth
(hass)
Test reauth flow.
Test reauth flow.
async def test_reauth(hass): """Test reauth flow.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, ): mock_config = MockConfigEntry(domain=D...
[ "async", "def", "test_reauth", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "DEVICES_FIXTURE", "]", ")", ",", "patch", "(", "\"homeassistant.components.awair.sensor.async_setup_entr...
[ 141, 0 ]
[ 181, 44 ]
python
en
['en', 'fr', 'en']
True
test_create_entry
(hass)
Test overall flow.
Test overall flow.
async def test_create_entry(hass): """Test overall flow.""" with patch( "python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE] ), patch( "homeassistant.components.awair.sensor.async_setup_entry", return_value=True, ): result = await hass.config_ent...
[ "async", "def", "test_create_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"python_awair.AwairClient.query\"", ",", "side_effect", "=", "[", "USER_FIXTURE", ",", "DEVICES_FIXTURE", "]", ")", ",", "patch", "(", "\"homeassistant.components.awair.sensor.async_setu...
[ 184, 0 ]
[ 200, 54 ]
python
en
['sv', 'en', 'en']
True
test_config_setup
(hass, loop)
Test it sets up hassbian.
Test it sets up hassbian.
async def test_config_setup(hass, loop): """Test it sets up hassbian.""" await async_setup_component(hass, "config", {}) assert "config" in hass.config.components
[ "async", "def", "test_config_setup", "(", "hass", ",", "loop", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"config\"", ",", "{", "}", ")", "assert", "\"config\"", "in", "hass", ".", "config", ".", "components" ]
[ 10, 0 ]
[ 13, 45 ]
python
en
['en', 'fr', 'en']
True
test_load_on_demand_already_loaded
(hass, aiohttp_client)
Test getting suites.
Test getting suites.
async def test_load_on_demand_already_loaded(hass, aiohttp_client): """Test getting suites.""" mock_component(hass, "zwave") with patch.object(config, "SECTIONS", []), patch.object( config, "ON_DEMAND", ["zwave"] ), patch( "homeassistant.components.config.zwave.async_setup", return_valu...
[ "async", "def", "test_load_on_demand_already_loaded", "(", "hass", ",", "aiohttp_client", ")", ":", "mock_component", "(", "hass", ",", "\"zwave\"", ")", "with", "patch", ".", "object", "(", "config", ",", "\"SECTIONS\"", ",", "[", "]", ")", ",", "patch", "....
[ 16, 0 ]
[ 29, 21 ]
python
en
['nl', 'en', 'en']
True
test_load_on_demand_on_load
(hass, aiohttp_client)
Test getting suites.
Test getting suites.
async def test_load_on_demand_on_load(hass, aiohttp_client): """Test getting suites.""" with patch.object(config, "SECTIONS", []), patch.object( config, "ON_DEMAND", ["zwave"] ): await async_setup_component(hass, "config", {}) assert "config.zwave" not in hass.config.components wit...
[ "async", "def", "test_load_on_demand_on_load", "(", "hass", ",", "aiohttp_client", ")", ":", "with", "patch", ".", "object", "(", "config", ",", "\"SECTIONS\"", ",", "[", "]", ")", ",", "patch", ".", "object", "(", "config", ",", "\"ON_DEMAND\"", ",", "[",...
[ 32, 0 ]
[ 47, 21 ]
python
en
['nl', 'en', 'en']
True
listToString
(my_list)
A function to convert a list to a string
A function to convert a list to a string
def listToString(my_list): """ A function to convert a list to a string """ # initialize an empty string str1 = "" # traverse in the string for element in my_list: str1 += element # return string return str1
[ "def", "listToString", "(", "my_list", ")", ":", "# initialize an empty string \r", "str1", "=", "\"\"", "# traverse in the string \r", "for", "element", "in", "my_list", ":", "str1", "+=", "element", "# return string \r", "return", "str1" ]
[ 31, 0 ]
[ 43, 15 ]
python
en
['en', 'ja', 'th']
False
assemble
(instruction, addr)
Returns 6 bits string if the instruction is SUB or ADD Returns 12 bits string when the instruction is LOAD or JNZ When writing into the file, we split the 12 bits strings into half and we have a 6 bits string in each line of the text file ==> addr is the label address
Returns 6 bits string if the instruction is SUB or ADD Returns 12 bits string when the instruction is LOAD or JNZ When writing into the file, we split the 12 bits strings into half and we have a 6 bits string in each line of the text file ==> addr is the label address
def assemble (instruction, addr): """ Returns 6 bits string if the instruction is SUB or ADD Returns 12 bits string when the instruction is LOAD or JNZ When writing into the file, we split the 12 bits strings into half and we have a 6 bits string in each line of the text file ==> addr is t...
[ "def", "assemble", "(", "instruction", ",", "addr", ")", ":", "assembled_string", "=", "list", "(", "\"000000\"", ")", "# We assume that if the string does not contain ',' then it is halt instruction\r", "if", "\",\"", "not", "in", "instruction", ":", "return", "\"000000\...
[ 45, 0 ]
[ 135, 27 ]
python
en
['en', 'ja', 'th']
False
write_into_file
(machine_code)
A function to write the machine code into a text file. This function takes a list of machine code corresponding to the assembly code and writes it line by line in a text file.
A function to write the machine code into a text file. This function takes a list of machine code corresponding to the assembly code and writes it line by line in a text file.
def write_into_file(machine_code): """ A function to write the machine code into a text file. This function takes a list of machine code corresponding to the assembly code and writes it line by line in a text file. """ #This will return an error if the specified file exists f = ope...
[ "def", "write_into_file", "(", "machine_code", ")", ":", "#This will return an error if the specified file exists\r", "f", "=", "open", "(", "\"memory.txt\"", ",", "\"x\"", ")", "#create a text file by name assembly \r", "for", "i", "in", "range", "(", "len", "(", "mach...
[ 168, 0 ]
[ 191, 13 ]
python
en
['en', 'ja', 'th']
False
read_from_file
(filename)
A function to read the assembly code from a file. It take a file by its name, reads it line by line and returns a list containing all the assembly instructions
A function to read the assembly code from a file. It take a file by its name, reads it line by line and returns a list containing all the assembly instructions
def read_from_file(filename): """ A function to read the assembly code from a file. It take a file by its name, reads it line by line and returns a list containing all the assembly instructions """ # Using readline() instructions = [] file1 = open(filename, 'r') count = 0...
[ "def", "read_from_file", "(", "filename", ")", ":", "# Using readline() \r", "instructions", "=", "[", "]", "file1", "=", "open", "(", "filename", ",", "'r'", ")", "count", "=", "0", "while", "True", ":", "count", "+=", "1", "# Get next line from file \r", "...
[ 195, 0 ]
[ 220, 23 ]
python
en
['en', 'ja', 'th']
False
test_sensors
(hass: HomeAssistant, mock_device_tracker_conf)
Test creating an AsusWRT sensor.
Test creating an AsusWRT sensor.
async def test_sensors(hass: HomeAssistant, mock_device_tracker_conf): """Test creating an AsusWRT sensor.""" with patch("homeassistant.components.asuswrt.AsusWrt") as AsusWrt: AsusWrt().connection.async_connect = AsyncMock() AsusWrt().async_get_connected_devices = AsyncMock(return_value=MOCK_DE...
[ "async", "def", "test_sensors", "(", "hass", ":", "HomeAssistant", ",", "mock_device_tracker_conf", ")", ":", "with", "patch", "(", "\"homeassistant.components.asuswrt.AsusWrt\"", ")", "as", "AsusWrt", ":", "AsusWrt", "(", ")", ".", "connection", ".", "async_connect...
[ 52, 0 ]
[ 75, 81 ]
python
en
['en', 'da', 'en']
True
setup_proximity_component
(hass, name, config)
Set up the individual proximity component.
Set up the individual proximity component.
def setup_proximity_component(hass, name, config): """Set up the individual proximity component.""" ignored_zones = config.get(CONF_IGNORED_ZONES) proximity_devices = config.get(CONF_DEVICES) tolerance = config.get(CONF_TOLERANCE) proximity_zone = name unit_of_measurement = config.get( C...
[ "def", "setup_proximity_component", "(", "hass", ",", "name", ",", "config", ")", ":", "ignored_zones", "=", "config", ".", "get", "(", "CONF_IGNORED_ZONES", ")", "proximity_devices", "=", "config", ".", "get", "(", "CONF_DEVICES", ")", "tolerance", "=", "conf...
[ 66, 0 ]
[ 95, 15 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Get the zones and offsets from configuration.yaml.
Get the zones and offsets from configuration.yaml.
def setup(hass, config): """Get the zones and offsets from configuration.yaml.""" for zone, proximity_config in config[DOMAIN].items(): setup_proximity_component(hass, zone, proximity_config) return True
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "for", "zone", ",", "proximity_config", "in", "config", "[", "DOMAIN", "]", ".", "items", "(", ")", ":", "setup_proximity_component", "(", "hass", ",", "zone", ",", "proximity_config", ")", "return", ...
[ 98, 0 ]
[ 103, 15 ]
python
en
['en', 'en', 'en']
True
Proximity.__init__
( self, hass, zone_friendly_name, dist_to, dir_of_travel, nearest, ignored_zones, proximity_devices, tolerance, proximity_zone, unit_of_measurement, )
Initialize the proximity.
Initialize the proximity.
def __init__( self, hass, zone_friendly_name, dist_to, dir_of_travel, nearest, ignored_zones, proximity_devices, tolerance, proximity_zone, unit_of_measurement, ): """Initialize the proximity.""" self.hass = hass...
[ "def", "__init__", "(", "self", ",", "hass", ",", "zone_friendly_name", ",", "dist_to", ",", "dir_of_travel", ",", "nearest", ",", "ignored_zones", ",", "proximity_devices", ",", "tolerance", ",", "proximity_zone", ",", "unit_of_measurement", ",", ")", ":", "sel...
[ 109, 4 ]
[ 132, 55 ]
python
en
['en', 'en', 'en']
True
Proximity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self.friendly_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "friendly_name" ]
[ 135, 4 ]
[ 137, 33 ]
python
en
['en', 'en', 'en']
True
Proximity.state
(self)
Return the state.
Return the state.
def state(self): """Return the state.""" return self.dist_to
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "dist_to" ]
[ 140, 4 ]
[ 142, 27 ]
python
en
['en', 'en', 'en']
True
Proximity.unit_of_measurement
(self)
Return the unit of measurement of this entity.
Return the unit of measurement of this entity.
def unit_of_measurement(self): """Return the unit of measurement of this entity.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 145, 4 ]
[ 147, 40 ]
python
en
['en', 'en', 'en']
True
Proximity.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self): """Return the state attributes.""" return {ATTR_DIR_OF_TRAVEL: self.dir_of_travel, ATTR_NEAREST: self.nearest}
[ "def", "state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_DIR_OF_TRAVEL", ":", "self", ".", "dir_of_travel", ",", "ATTR_NEAREST", ":", "self", ".", "nearest", "}" ]
[ 150, 4 ]
[ 152, 83 ]
python
en
['en', 'en', 'en']
True
Proximity.check_proximity_state_change
(self, entity, old_state, new_state)
Perform the proximity checking.
Perform the proximity checking.
def check_proximity_state_change(self, entity, old_state, new_state): """Perform the proximity checking.""" entity_name = new_state.name devices_to_calculate = False devices_in_zone = "" zone_state = self.hass.states.get(self.proximity_zone) proximity_latitude = zone_sta...
[ "def", "check_proximity_state_change", "(", "self", ",", "entity", ",", "old_state", ",", "new_state", ")", ":", "entity_name", "=", "new_state", ".", "name", "devices_to_calculate", "=", "False", "devices_in_zone", "=", "\"\"", "zone_state", "=", "self", ".", "...
[ 154, 4 ]
[ 294, 71 ]
python
en
['en', 'en', 'en']
True
test_anna_climate_binary_sensor_entities
(hass, mock_smile_anna)
Test creation of climate related binary_sensor entities.
Test creation of climate related binary_sensor entities.
async def test_anna_climate_binary_sensor_entities(hass, mock_smile_anna): """Test creation of climate related binary_sensor entities.""" entry = await async_init_integration(hass, mock_smile_anna) assert entry.state == ENTRY_STATE_LOADED state = hass.states.get("binary_sensor.auxiliary_slave_boiler_st...
[ "async", "def", "test_anna_climate_binary_sensor_entities", "(", "hass", ",", "mock_smile_anna", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_anna", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "state", ...
[ 8, 0 ]
[ 17, 40 ]
python
en
['en', 'en', 'en']
True
test_anna_climate_binary_sensor_change
(hass, mock_smile_anna)
Test change of climate related binary_sensor entities.
Test change of climate related binary_sensor entities.
async def test_anna_climate_binary_sensor_change(hass, mock_smile_anna): """Test change of climate related binary_sensor entities.""" entry = await async_init_integration(hass, mock_smile_anna) assert entry.state == ENTRY_STATE_LOADED hass.states.async_set("binary_sensor.auxiliary_dhw_state", STATE_ON,...
[ "async", "def", "test_anna_climate_binary_sensor_change", "(", "hass", ",", "mock_smile_anna", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_anna", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "hass", "...
[ 20, 0 ]
[ 36, 40 ]
python
en
['en', 'en', 'en']
True
test_adam_climate_binary_sensor_change
(hass, mock_smile_adam)
Test change of climate related binary_sensor entities.
Test change of climate related binary_sensor entities.
async def test_adam_climate_binary_sensor_change(hass, mock_smile_adam): """Test change of climate related binary_sensor entities.""" entry = await async_init_integration(hass, mock_smile_adam) assert entry.state == ENTRY_STATE_LOADED state = hass.states.get("binary_sensor.adam_plugwise_notification") ...
[ "async", "def", "test_adam_climate_binary_sensor_change", "(", "hass", ",", "mock_smile_adam", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_adam", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "state", ...
[ 39, 0 ]
[ 48, 48 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Homekit television.
Set up Homekit television.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Homekit television.""" hkid = config_entry.data["AccessoryPairingID"] conn = hass.data[KNOWN_DEVICES][hkid] @callback def async_add_service(service): if service.short_type != ServicesTypes.TELEVISION: ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "hkid", "=", "config_entry", ".", "data", "[", "\"AccessoryPairingID\"", "]", "conn", "=", "hass", ".", "data", "[", "KNOWN_DEVICES", "]", "[", "hkid", ...
[ 40, 0 ]
[ 53, 40 ]
python
en
['en', 'ky', 'en']
True
HomeKitTelevision.get_characteristic_types
(self)
Define the homekit characteristics the entity cares about.
Define the homekit characteristics the entity cares about.
def get_characteristic_types(self): """Define the homekit characteristics the entity cares about.""" return [ CharacteristicsTypes.ACTIVE, CharacteristicsTypes.CURRENT_MEDIA_STATE, CharacteristicsTypes.TARGET_MEDIA_STATE, CharacteristicsTypes.REMOTE_KEY, ...
[ "def", "get_characteristic_types", "(", "self", ")", ":", "return", "[", "CharacteristicsTypes", ".", "ACTIVE", ",", "CharacteristicsTypes", ".", "CURRENT_MEDIA_STATE", ",", "CharacteristicsTypes", ".", "TARGET_MEDIA_STATE", ",", "CharacteristicsTypes", ".", "REMOTE_KEY",...
[ 59, 4 ]
[ 70, 9 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.device_class
(self)
Define the device class for a HomeKit enabled TV.
Define the device class for a HomeKit enabled TV.
def device_class(self): """Define the device class for a HomeKit enabled TV.""" return DEVICE_CLASS_TV
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TV" ]
[ 73, 4 ]
[ 75, 30 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" features = 0 if self.service.has(CharacteristicsTypes.ACTIVE_IDENTIFIER): features |= SUPPORT_SELECT_SOURCE if self.service.has(CharacteristicsTypes.TARGET_MEDIA_STATE): if Target...
[ "def", "supported_features", "(", "self", ")", ":", "features", "=", "0", "if", "self", ".", "service", ".", "has", "(", "CharacteristicsTypes", ".", "ACTIVE_IDENTIFIER", ")", ":", "features", "|=", "SUPPORT_SELECT_SOURCE", "if", "self", ".", "service", ".", ...
[ 78, 4 ]
[ 99, 23 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.supported_media_states
(self)
Mediate state flags that are supported.
Mediate state flags that are supported.
def supported_media_states(self): """Mediate state flags that are supported.""" if not self.service.has(CharacteristicsTypes.TARGET_MEDIA_STATE): return frozenset() return clamp_enum_to_char( TargetMediaStateValues, self.service[CharacteristicsTypes.TARGET_ME...
[ "def", "supported_media_states", "(", "self", ")", ":", "if", "not", "self", ".", "service", ".", "has", "(", "CharacteristicsTypes", ".", "TARGET_MEDIA_STATE", ")", ":", "return", "frozenset", "(", ")", "return", "clamp_enum_to_char", "(", "TargetMediaStateValues...
[ 102, 4 ]
[ 110, 9 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.supported_remote_keys
(self)
Remote key buttons that are supported.
Remote key buttons that are supported.
def supported_remote_keys(self): """Remote key buttons that are supported.""" if not self.service.has(CharacteristicsTypes.REMOTE_KEY): return frozenset() return clamp_enum_to_char( RemoteKeyValues, self.service[CharacteristicsTypes.REMOTE_KEY] )
[ "def", "supported_remote_keys", "(", "self", ")", ":", "if", "not", "self", ".", "service", ".", "has", "(", "CharacteristicsTypes", ".", "REMOTE_KEY", ")", ":", "return", "frozenset", "(", ")", "return", "clamp_enum_to_char", "(", "RemoteKeyValues", ",", "sel...
[ 113, 4 ]
[ 120, 9 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.source_list
(self)
List of all input sources for this television.
List of all input sources for this television.
def source_list(self): """List of all input sources for this television.""" sources = [] this_accessory = self._accessory.entity_map.aid(self._aid) this_tv = this_accessory.services.iid(self._iid) input_sources = this_accessory.services.filter( service_type=Services...
[ "def", "source_list", "(", "self", ")", ":", "sources", "=", "[", "]", "this_accessory", "=", "self", ".", "_accessory", ".", "entity_map", ".", "aid", "(", "self", ".", "_aid", ")", "this_tv", "=", "this_accessory", ".", "services", ".", "iid", "(", "...
[ 123, 4 ]
[ 138, 22 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.source
(self)
Name of the current input source.
Name of the current input source.
def source(self): """Name of the current input source.""" active_identifier = self.service.value(CharacteristicsTypes.ACTIVE_IDENTIFIER) if not active_identifier: return None this_accessory = self._accessory.entity_map.aid(self._aid) this_tv = this_accessory.services...
[ "def", "source", "(", "self", ")", ":", "active_identifier", "=", "self", ".", "service", ".", "value", "(", "CharacteristicsTypes", ".", "ACTIVE_IDENTIFIER", ")", "if", "not", "active_identifier", ":", "return", "None", "this_accessory", "=", "self", ".", "_a...
[ 141, 4 ]
[ 156, 25 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.state
(self)
State of the tv.
State of the tv.
def state(self): """State of the tv.""" active = self.service.value(CharacteristicsTypes.ACTIVE) if not active: return STATE_PROBLEM homekit_state = self.service.value(CharacteristicsTypes.CURRENT_MEDIA_STATE) if homekit_state is not None: return HK_TO_HA...
[ "def", "state", "(", "self", ")", ":", "active", "=", "self", ".", "service", ".", "value", "(", "CharacteristicsTypes", ".", "ACTIVE", ")", "if", "not", "active", ":", "return", "STATE_PROBLEM", "homekit_state", "=", "self", ".", "service", ".", "value", ...
[ 159, 4 ]
[ 169, 23 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.async_media_play
(self)
Send play command.
Send play command.
async def async_media_play(self): """Send play command.""" if self.state == STATE_PLAYING: _LOGGER.debug("Cannot play while already playing") return if TargetMediaStateValues.PLAY in self.supported_media_states: await self.async_put_characteristics( ...
[ "async", "def", "async_media_play", "(", "self", ")", ":", "if", "self", ".", "state", "==", "STATE_PLAYING", ":", "_LOGGER", ".", "debug", "(", "\"Cannot play while already playing\"", ")", "return", "if", "TargetMediaStateValues", ".", "PLAY", "in", "self", "....
[ 171, 4 ]
[ 184, 13 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.async_media_pause
(self)
Send pause command.
Send pause command.
async def async_media_pause(self): """Send pause command.""" if self.state == STATE_PAUSED: _LOGGER.debug("Cannot pause while already paused") return if TargetMediaStateValues.PAUSE in self.supported_media_states: await self.async_put_characteristics( ...
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "if", "self", ".", "state", "==", "STATE_PAUSED", ":", "_LOGGER", ".", "debug", "(", "\"Cannot pause while already paused\"", ")", "return", "if", "TargetMediaStateValues", ".", "PAUSE", "in", "self", "...
[ 186, 4 ]
[ 199, 13 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.async_media_stop
(self)
Send stop command.
Send stop command.
async def async_media_stop(self): """Send stop command.""" if self.state == STATE_IDLE: _LOGGER.debug("Cannot stop when already idle") return if TargetMediaStateValues.STOP in self.supported_media_states: await self.async_put_characteristics( ...
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "if", "self", ".", "state", "==", "STATE_IDLE", ":", "_LOGGER", ".", "debug", "(", "\"Cannot stop when already idle\"", ")", "return", "if", "TargetMediaStateValues", ".", "STOP", "in", "self", ".", "s...
[ 201, 4 ]
[ 210, 13 ]
python
en
['en', 'en', 'en']
True
HomeKitTelevision.async_select_source
(self, source)
Switch to a different media source.
Switch to a different media source.
async def async_select_source(self, source): """Switch to a different media source.""" this_accessory = self._accessory.entity_map.aid(self._aid) this_tv = this_accessory.services.iid(self._iid) input_source = this_accessory.services.first( service_type=ServicesTypes.INPUT_S...
[ "async", "def", "async_select_source", "(", "self", ",", "source", ")", ":", "this_accessory", "=", "self", ".", "_accessory", ".", "entity_map", ".", "aid", "(", "self", ".", "_aid", ")", "this_tv", "=", "this_accessory", ".", "services", ".", "iid", "(",...
[ 212, 4 ]
[ 230, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Samsung TV from a config entry.
Set up the Samsung TV from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Samsung TV from a config entry.""" ip_address = config_entry.data[CONF_IP_ADDRESS] on_script = None if ( DOMAIN in hass.data and ip_address in hass.data[DOMAIN] and CONF_ON_ACTION in hass.data[DOMA...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "ip_address", "=", "config_entry", ".", "data", "[", "CONF_IP_ADDRESS", "]", "on_script", "=", "None", "if", "(", "DOMAIN", "in", "hass", ".", "data", ...
[ 61, 0 ]
[ 95, 74 ]
python
en
['en', 'en', 'en']
True
SamsungTVDevice.__init__
(self, bridge, config_entry, on_script)
Initialize the Samsung device.
Initialize the Samsung device.
def __init__(self, bridge, config_entry, on_script): """Initialize the Samsung device.""" self._config_entry = config_entry self._manufacturer = config_entry.data.get(CONF_MANUFACTURER) self._model = config_entry.data.get(CONF_MODEL) self._name = config_entry.data.get(CONF_NAME) ...
[ "def", "__init__", "(", "self", ",", "bridge", ",", "config_entry", ",", "on_script", ")", ":", "self", ".", "_config_entry", "=", "config_entry", "self", ".", "_manufacturer", "=", "config_entry", ".", "data", ".", "get", "(", "CONF_MANUFACTURER", ")", "sel...
[ 101, 4 ]
[ 118, 65 ]
python
en
['en', 'en', 'en']
True
SamsungTVDevice.access_denied
(self)
Access denied callback.
Access denied callback.
def access_denied(self): """Access denied callback.""" LOGGER.debug("Access denied in getting remote object") self.hass.add_job( self.hass.config_entries.flow.async_init( DOMAIN, context={"source": "reauth"}, data=self._config_entry.dat...
[ "def", "access_denied", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Access denied in getting remote object\"", ")", "self", ".", "hass", ".", "add_job", "(", "self", ".", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ...
[ 120, 4 ]
[ 129, 9 ]
python
cy
['es', 'cy', 'en']
False
SamsungTVDevice.update
(self)
Update state of device.
Update state of device.
def update(self): """Update state of device.""" if self._power_off_in_progress(): self._state = STATE_OFF else: self._state = STATE_ON if self._bridge.is_on() else STATE_OFF
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_power_off_in_progress", "(", ")", ":", "self", ".", "_state", "=", "STATE_OFF", "else", ":", "self", ".", "_state", "=", "STATE_ON", "if", "self", ".", "_bridge", ".", "is_on", "(", ")", "e...
[ 131, 4 ]
[ 136, 73 ]
python
en
['en', 'en', 'en']
True
SamsungTVDevice.send_key
(self, key)
Send a key to the tv and handles exceptions.
Send a key to the tv and handles exceptions.
def send_key(self, key): """Send a key to the tv and handles exceptions.""" if self._power_off_in_progress() and key != "KEY_POWEROFF": LOGGER.info("TV is powering off, not sending command: %s", key) return self._bridge.send_key(key)
[ "def", "send_key", "(", "self", ",", "key", ")", ":", "if", "self", ".", "_power_off_in_progress", "(", ")", "and", "key", "!=", "\"KEY_POWEROFF\"", ":", "LOGGER", ".", "info", "(", "\"TV is powering off, not sending command: %s\"", ",", "key", ")", "return", ...
[ 138, 4 ]
[ 143, 34 ]
python
en
['en', 'en', 'en']
True
SamsungTVDevice.unique_id
(self)
Return the unique ID of the device.
Return the unique ID of the device.
def unique_id(self) -> str: """Return the unique ID of the device.""" return self._uuid
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_uuid" ]
[ 152, 4 ]
[ 154, 25 ]
python
en
['en', 'en', 'en']
True