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
ZwaveGarageDoorBarrier.open_cover
(self, **kwargs)
Open the garage door.
Open the garage door.
def open_cover(self, **kwargs): """Open the garage door.""" self.values.primary.data = "Opened"
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "values", ".", "primary", ".", "data", "=", "\"Opened\"" ]
[ 206, 4 ]
[ 208, 43 ]
python
en
['en', 'nl', 'en']
True
async_get_blueprints
(hass: HomeAssistant)
Get automation blueprints.
Get automation blueprints.
def async_get_blueprints(hass: HomeAssistant) -> blueprint.DomainBlueprints: # type: ignore """Get automation blueprints.""" return blueprint.DomainBlueprints(hass, DOMAIN, LOGGER)
[ "def", "async_get_blueprints", "(", "hass", ":", "HomeAssistant", ")", "->", "blueprint", ".", "DomainBlueprints", ":", "# type: ignore", "return", "blueprint", ".", "DomainBlueprints", "(", "hass", ",", "DOMAIN", ",", "LOGGER", ")" ]
[ 12, 0 ]
[ 14, 59 ]
python
fr
['fr', 'fr', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Z-Wave lock from config entry.
Set up Z-Wave lock from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Z-Wave lock from config entry.""" @callback def async_add_lock(value): """Add Z-Wave Lock.""" lock = ZWaveLock(value) async_add_entities([lock]) hass.data[DOMAIN][config_entry.entry_id][DATA_UNSUBSC...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_add_lock", "(", "value", ")", ":", "\"\"\"Add Z-Wave Lock.\"\"\"", "lock", "=", "ZWaveLock", "(", "value", ")", "async_add_en...
[ 25, 0 ]
[ 54, 5 ]
python
en
['en', 'en', 'en']
True
_call_util_lock_function
(function, *args)
Call an openzwavemqtt.util.lock function and return success of call.
Call an openzwavemqtt.util.lock function and return success of call.
def _call_util_lock_function(function, *args): """Call an openzwavemqtt.util.lock function and return success of call.""" try: function(*args) except BaseOZWError as err: _LOGGER.error("%s: %s", type(err), err.args[0]) return False return True
[ "def", "_call_util_lock_function", "(", "function", ",", "*", "args", ")", ":", "try", ":", "function", "(", "*", "args", ")", "except", "BaseOZWError", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"%s: %s\"", ",", "type", "(", "err", ")", ",", "e...
[ 57, 0 ]
[ 65, 15 ]
python
en
['en', 'en', 'en']
True
ZWaveLock.is_locked
(self)
Return a boolean for the state of the lock.
Return a boolean for the state of the lock.
def is_locked(self): """Return a boolean for the state of the lock.""" return bool(self.values.primary.value)
[ "def", "is_locked", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "values", ".", "primary", ".", "value", ")" ]
[ 72, 4 ]
[ 74, 46 ]
python
en
['en', 'en', 'en']
True
ZWaveLock.async_lock
(self, **kwargs)
Lock the lock.
Lock the lock.
async def async_lock(self, **kwargs): """Lock the lock.""" self.values.primary.send_value(True)
[ "async", "def", "async_lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "values", ".", "primary", ".", "send_value", "(", "True", ")" ]
[ 76, 4 ]
[ 78, 44 ]
python
en
['en', 'la', 'en']
True
ZWaveLock.async_unlock
(self, **kwargs)
Unlock the lock.
Unlock the lock.
async def async_unlock(self, **kwargs): """Unlock the lock.""" self.values.primary.send_value(False)
[ "async", "def", "async_unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "values", ".", "primary", ".", "send_value", "(", "False", ")" ]
[ 80, 4 ]
[ 82, 45 ]
python
en
['en', 'ms', 'en']
True
ZWaveLock.async_set_usercode
(self, code_slot, usercode)
Set the usercode to index X on the lock.
Set the usercode to index X on the lock.
def async_set_usercode(self, code_slot, usercode): """Set the usercode to index X on the lock.""" if _call_util_lock_function( set_usercode, self.values.primary.node, code_slot, usercode ): _LOGGER.debug("User code at slot %s set", code_slot)
[ "def", "async_set_usercode", "(", "self", ",", "code_slot", ",", "usercode", ")", ":", "if", "_call_util_lock_function", "(", "set_usercode", ",", "self", ".", "values", ".", "primary", ".", "node", ",", "code_slot", ",", "usercode", ")", ":", "_LOGGER", "."...
[ 85, 4 ]
[ 90, 64 ]
python
en
['en', 'en', 'en']
True
ZWaveLock.async_clear_usercode
(self, code_slot)
Clear usercode in slot X on the lock.
Clear usercode in slot X on the lock.
def async_clear_usercode(self, code_slot): """Clear usercode in slot X on the lock.""" if _call_util_lock_function( clear_usercode, self.values.primary.node, code_slot ): _LOGGER.info("Usercode at slot %s is cleared", code_slot)
[ "def", "async_clear_usercode", "(", "self", ",", "code_slot", ")", ":", "if", "_call_util_lock_function", "(", "clear_usercode", ",", "self", ".", "values", ".", "primary", ".", "node", ",", "code_slot", ")", ":", "_LOGGER", ".", "info", "(", "\"Usercode at sl...
[ 93, 4 ]
[ 98, 69 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer._tokenize
(self, text, sample=False)
Take as input a string and return a list of strings (tokens) for words/sub-words
Take as input a string and return a list of strings (tokens) for words/sub-words
def _tokenize(self, text, sample=False): """Take as input a string and return a list of strings (tokens) for words/sub-words""" if not sample: pieces = self.sp_model.EncodeAsPieces(text) else: pieces = self.sp_model.SampleEncodeAsPieces(text, 64, 0.1) return piece...
[ "def", "_tokenize", "(", "self", ",", "text", ",", "sample", "=", "False", ")", ":", "if", "not", "sample", ":", "pieces", "=", "self", ".", "sp_model", ".", "EncodeAsPieces", "(", "text", ")", "else", ":", "pieces", "=", "self", ".", "sp_model", "."...
[ 168, 4 ]
[ 174, 21 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer._convert_token_to_id
(self, token: str)
Converts a token (str) to an id using the vocab.
Converts a token (str) to an id using the vocab.
def _convert_token_to_id(self, token: str) -> int: """ Converts a token (str) to an id using the vocab. """ if token in self.decoder: return self.decoder[token] elif token in self.added_tokens_decoder: return self.added_tokens_decoder[token] sp_id = self.sp_model....
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ":", "str", ")", "->", "int", ":", "if", "token", "in", "self", ".", "decoder", ":", "return", "self", ".", "decoder", "[", "token", "]", "elif", "token", "in", "self", ".", "added_tokens_decoder"...
[ 176, 4 ]
[ 183, 34 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer._convert_id_to_token
(self, index: int)
Converts an index (integer) to a token (str) using the vocab.
Converts an index (integer) to a token (str) using the vocab.
def _convert_id_to_token(self, index: int) -> str: """Converts an index (integer) to a token (str) using the vocab.""" if index in self.encoder: return self.encoder[index] elif index in self.added_tokens_encoder: return self.added_tokens_encoder[index] else: ...
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ":", "int", ")", "->", "str", ":", "if", "index", "in", "self", ".", "encoder", ":", "return", "self", ".", "encoder", "[", "index", "]", "elif", "index", "in", "self", ".", "added_tokens_encoder"...
[ 185, 4 ]
[ 193, 20 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (string) in a single string.
Converts a sequence of tokens (string) in a single string.
def convert_tokens_to_string(self, tokens): """ Converts a sequence of tokens (string) in a single string. """ out_string = self.sp_model.decode_pieces(tokens) return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "self", ".", "sp_model", ".", "decode_pieces", "(", "tokens", ")", "return", "out_string" ]
[ 195, 4 ]
[ 198, 25 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer.get_special_tokens_mask
( self, token_ids_0: List, token_ids_1: Optional[List] = None, already_has_special_tokens: bool = False )
Get list where entries are [1] if a token is [eos] or [pad] else 0.
Get list where entries are [1] if a token is [eos] or [pad] else 0.
def get_special_tokens_mask( self, token_ids_0: List, token_ids_1: Optional[List] = None, already_has_special_tokens: bool = False ) -> List[int]: """Get list where entries are [1] if a token is [eos] or [pad] else 0.""" if already_has_special_tokens: return self._special_token_m...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", ",", "token_ids_1", ":", "Optional", "[", "List", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", "List", "[", "int", "]", ":", "if",...
[ 214, 4 ]
[ 223, 76 ]
python
en
['en', 'en', 'en']
True
PegasusTokenizer.build_inputs_with_special_tokens
(self, token_ids_0, token_ids_1=None)
Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating and adding special tokens. A PEGASUS sequence has the following format, where ``X`` represents the sequence: - single sequence: ``X </s>`` - pair of sequences: ``A B </s>`` (not...
Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating and adding special tokens. A PEGASUS sequence has the following format, where ``X`` represents the sequence:
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None) -> List[int]: """ Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating and adding special tokens. A PEGASUS sequence has the following format, where ``X`` represents ...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ",", "token_ids_1", "=", "None", ")", "->", "List", "[", "int", "]", ":", "if", "token_ids_1", "is", "None", ":", "return", "token_ids_0", "+", "[", "self", ".", "eos_token_id", "]",...
[ 225, 4 ]
[ 248, 62 ]
python
en
['en', 'error', 'th']
False
CustomerTuner.generate_new_id
(self)
generate new id and event hook for new Individual
generate new id and event hook for new Individual
def generate_new_id(self): """ generate new id and event hook for new Individual """ self.events.append(Event()) indiv_id = self.indiv_counter self.indiv_counter += 1 return indiv_id
[ "def", "generate_new_id", "(", "self", ")", ":", "self", ".", "events", ".", "append", "(", "Event", "(", ")", ")", "indiv_id", "=", "self", ".", "indiv_counter", "self", ".", "indiv_counter", "+=", "1", "return", "indiv_id" ]
[ 83, 4 ]
[ 90, 23 ]
python
en
['en', 'error', 'th']
False
CustomerTuner.init_population
(self, population_size, graph_max_layer, graph_min_layer)
initialize populations for evolution tuner
initialize populations for evolution tuner
def init_population(self, population_size, graph_max_layer, graph_min_layer): """ initialize populations for evolution tuner """ population = [] graph = Graph(max_layer_num=graph_max_layer, min_layer_num=graph_min_layer, inputs=[Layer(LayerType.input.value, ...
[ "def", "init_population", "(", "self", ",", "population_size", ",", "graph_max_layer", ",", "graph_min_layer", ")", ":", "population", "=", "[", "]", "graph", "=", "Graph", "(", "max_layer_num", "=", "graph_max_layer", ",", "min_layer_num", "=", "graph_min_layer",...
[ 98, 4 ]
[ 112, 25 ]
python
en
['en', 'error', 'th']
False
CustomerTuner.generate_parameters
(self, parameter_id, **kwargs)
Returns a set of trial graph config, as a serializable object. An example configuration: ```json { "shared_id": [ "4a11b2ef9cb7211590dfe81039b27670", "370af04de24985e5ea5b3d72b12644c9", "11f646e9f650f5f3fedc12b6349ec60f", ...
Returns a set of trial graph config, as a serializable object. An example configuration: ```json { "shared_id": [ "4a11b2ef9cb7211590dfe81039b27670", "370af04de24985e5ea5b3d72b12644c9", "11f646e9f650f5f3fedc12b6349ec60f", ...
def generate_parameters(self, parameter_id, **kwargs): """Returns a set of trial graph config, as a serializable object. An example configuration: ```json { "shared_id": [ "4a11b2ef9cb7211590dfe81039b27670", "370af04de24985e5ea5b3d72b12644c9", ...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'acquiring lock for param {}'", ".", "format", "(", "parameter_id", ")", ")", "self", ".", "thread_lock", ".", "acquire", "(", ")...
[ 114, 4 ]
[ 196, 25 ]
python
en
['en', 'en', 'en']
True
CustomerTuner.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Record an observation of the objective function parameter_id : int parameters : dict of parameters value: final metrics of the trial, including reward
Record an observation of the objective function parameter_id : int parameters : dict of parameters value: final metrics of the trial, including reward
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): ''' Record an observation of the objective function parameter_id : int parameters : dict of parameters value: final metrics of the trial, including reward ''' logger.debug('acquiring lock f...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'acquiring lock for param {}'", ".", "format", "(", "parameter_id", ")", ")", "self", ".", "thr...
[ 198, 4 ]
[ 221, 41 ]
python
en
['en', 'error', 'th']
False
identify_event_type
(event)
Look at event to determine type of device. Async friendly.
Look at event to determine type of device.
def identify_event_type(event): """Look at event to determine type of device. Async friendly. """ if EVENT_KEY_COMMAND in event: return EVENT_KEY_COMMAND if EVENT_KEY_SENSOR in event: return EVENT_KEY_SENSOR return "unknown"
[ "def", "identify_event_type", "(", "event", ")", ":", "if", "EVENT_KEY_COMMAND", "in", "event", ":", "return", "EVENT_KEY_COMMAND", "if", "EVENT_KEY_SENSOR", "in", "event", ":", "return", "EVENT_KEY_SENSOR", "return", "\"unknown\"" ]
[ 104, 0 ]
[ 113, 20 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Rflink component.
Set up the Rflink component.
async def async_setup(hass, config): """Set up the Rflink component.""" # Allow entities to register themselves by device_id to be looked up when # new rflink events arrive to be handled hass.data[DATA_ENTITY_LOOKUP] = { EVENT_KEY_COMMAND: defaultdict(list), EVENT_KEY_SENSOR: defaultdict...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "# Allow entities to register themselves by device_id to be looked up when", "# new rflink events arrive to be handled", "hass", ".", "data", "[", "DATA_ENTITY_LOOKUP", "]", "=", "{", "EVENT_KEY_COMMAND", ":...
[ 116, 0 ]
[ 267, 15 ]
python
en
['en', 'en', 'en']
True
RflinkDevice.__init__
( self, device_id, initial_event=None, name=None, aliases=None, group=True, group_aliases=None, nogroup_aliases=None, fire_event=False, signal_repetitions=DEFAULT_SIGNAL_REPETITIONS, )
Initialize the device.
Initialize the device.
def __init__( self, device_id, initial_event=None, name=None, aliases=None, group=True, group_aliases=None, nogroup_aliases=None, fire_event=False, signal_repetitions=DEFAULT_SIGNAL_REPETITIONS, ): """Initialize the device.""" ...
[ "def", "__init__", "(", "self", ",", "device_id", ",", "initial_event", "=", "None", ",", "name", "=", "None", ",", "aliases", "=", "None", ",", "group", "=", "True", ",", "group_aliases", "=", "None", ",", "nogroup_aliases", "=", "None", ",", "fire_even...
[ 280, 4 ]
[ 306, 53 ]
python
en
['en', 'en', 'en']
True
RflinkDevice.handle_event_callback
(self, event)
Handle incoming event for device type.
Handle incoming event for device type.
def handle_event_callback(self, event): """Handle incoming event for device type.""" # Call platform specific event handler self._handle_event(event) # Propagate changes through ha self.async_write_ha_state() # Put command onto bus for user to subscribe to if se...
[ "def", "handle_event_callback", "(", "self", ",", "event", ")", ":", "# Call platform specific event handler", "self", ".", "_handle_event", "(", "event", ")", "# Propagate changes through ha", "self", ".", "async_write_ha_state", "(", ")", "# Put command onto bus for user ...
[ 309, 4 ]
[ 325, 13 ]
python
en
['da', 'en', 'en']
True
RflinkDevice._handle_event
(self, event)
Platform specific event handler.
Platform specific event handler.
def _handle_event(self, event): """Platform specific event handler.""" raise NotImplementedError()
[ "def", "_handle_event", "(", "self", ",", "event", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 327, 4 ]
[ 329, 35 ]
python
en
['en', 'da', 'en']
True
RflinkDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 332, 4 ]
[ 334, 20 ]
python
en
['en', 'en', 'en']
True
RflinkDevice.name
(self)
Return a name for the device.
Return a name for the device.
def name(self): """Return a name for the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 337, 4 ]
[ 339, 25 ]
python
en
['en', 'en', 'en']
True
RflinkDevice.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.""" if self.assumed_state: return False return self._state
[ "def", "is_on", "(", "self", ")", ":", "if", "self", ".", "assumed_state", ":", "return", "False", "return", "self", ".", "_state" ]
[ 342, 4 ]
[ 346, 26 ]
python
en
['en', 'fy', 'en']
True
RflinkDevice.assumed_state
(self)
Assume device state until first device event sets state.
Assume device state until first device event sets state.
def assumed_state(self): """Assume device state until first device event sets state.""" return self._state is None
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_state", "is", "None" ]
[ 349, 4 ]
[ 351, 34 ]
python
en
['da', 'en', 'en']
True
RflinkDevice.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 354, 4 ]
[ 356, 30 ]
python
en
['en', 'en', 'en']
True
RflinkDevice._availability_callback
(self, availability)
Update availability state.
Update availability state.
def _availability_callback(self, availability): """Update availability state.""" self._available = availability self.async_write_ha_state()
[ "def", "_availability_callback", "(", "self", ",", "availability", ")", ":", "self", ".", "_available", "=", "availability", "self", ".", "async_write_ha_state", "(", ")" ]
[ 359, 4 ]
[ 362, 35 ]
python
en
['en', 'en', 'en']
True
RflinkDevice.async_added_to_hass
(self)
Register update callback.
Register update callback.
async def async_added_to_hass(self): """Register update callback.""" await super().async_added_to_hass() # Remove temporary bogus entity_id if added tmp_entity = TMP_ENTITY.format(self._device_id) if ( tmp_entity in self.hass.data[DATA_ENTITY_LOOKUP][EVENT...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "# Remove temporary bogus entity_id if added", "tmp_entity", "=", "TMP_ENTITY", ".", "format", "(", "self", ".", "_device_id", ")", "if"...
[ 364, 4 ]
[ 421, 59 ]
python
en
['fr', 'no', 'en']
False
RflinkCommand.set_rflink_protocol
(cls, protocol, wait_ack=None)
Set the Rflink asyncio protocol as a class variable.
Set the Rflink asyncio protocol as a class variable.
def set_rflink_protocol(cls, protocol, wait_ack=None): """Set the Rflink asyncio protocol as a class variable.""" cls._protocol = protocol if wait_ack is not None: cls._wait_ack = wait_ack
[ "def", "set_rflink_protocol", "(", "cls", ",", "protocol", ",", "wait_ack", "=", "None", ")", ":", "cls", ".", "_protocol", "=", "protocol", "if", "wait_ack", "is", "not", "None", ":", "cls", ".", "_wait_ack", "=", "wait_ack" ]
[ 442, 4 ]
[ 446, 36 ]
python
en
['en', 'gl', 'en']
True
RflinkCommand.is_connected
(cls)
Return connection status.
Return connection status.
def is_connected(cls): """Return connection status.""" return bool(cls._protocol)
[ "def", "is_connected", "(", "cls", ")", ":", "return", "bool", "(", "cls", ".", "_protocol", ")" ]
[ 449, 4 ]
[ 451, 34 ]
python
en
['en', 'la', 'en']
True
RflinkCommand.send_command
(cls, device_id, action)
Send device command to Rflink and wait for acknowledgement.
Send device command to Rflink and wait for acknowledgement.
async def send_command(cls, device_id, action): """Send device command to Rflink and wait for acknowledgement.""" return await cls._protocol.send_command_ack(device_id, action)
[ "async", "def", "send_command", "(", "cls", ",", "device_id", ",", "action", ")", ":", "return", "await", "cls", ".", "_protocol", ".", "send_command_ack", "(", "device_id", ",", "action", ")" ]
[ 454, 4 ]
[ 456, 70 ]
python
en
['en', 'en', 'en']
True
RflinkCommand._async_handle_command
(self, command, *args)
Do bookkeeping for command, send it to rflink and update state.
Do bookkeeping for command, send it to rflink and update state.
async def _async_handle_command(self, command, *args): """Do bookkeeping for command, send it to rflink and update state.""" self.cancel_queued_send_commands() if command == "turn_on": cmd = "on" self._state = True elif command == "turn_off": cmd = "...
[ "async", "def", "_async_handle_command", "(", "self", ",", "command", ",", "*", "args", ")", ":", "self", ".", "cancel_queued_send_commands", "(", ")", "if", "command", "==", "\"turn_on\"", ":", "cmd", "=", "\"on\"", "self", ".", "_state", "=", "True", "el...
[ 458, 4 ]
[ 500, 35 ]
python
en
['en', 'en', 'en']
True
RflinkCommand.cancel_queued_send_commands
(self)
Cancel queued signal repetition commands. For example when user changed state while repetitions are still queued for broadcast. Or when an incoming Rflink command (remote switch) changes the state.
Cancel queued signal repetition commands.
def cancel_queued_send_commands(self): """Cancel queued signal repetition commands. For example when user changed state while repetitions are still queued for broadcast. Or when an incoming Rflink command (remote switch) changes the state. """ # cancel any outstanding ta...
[ "def", "cancel_queued_send_commands", "(", "self", ")", ":", "# cancel any outstanding tasks from the previous state change", "if", "self", ".", "_repetition_task", ":", "self", ".", "_repetition_task", ".", "cancel", "(", ")" ]
[ 502, 4 ]
[ 511, 42 ]
python
ca
['es', 'ca', 'en']
False
RflinkCommand._async_send_command
(self, cmd, repetitions)
Send a command for device to Rflink gateway.
Send a command for device to Rflink gateway.
async def _async_send_command(self, cmd, repetitions): """Send a command for device to Rflink gateway.""" _LOGGER.debug("Sending command: %s to Rflink device: %s", cmd, self._device_id) if not self.is_connected(): raise HomeAssistantError("Cannot send command, not connected!") ...
[ "async", "def", "_async_send_command", "(", "self", ",", "cmd", ",", "repetitions", ")", ":", "_LOGGER", ".", "debug", "(", "\"Sending command: %s to Rflink device: %s\"", ",", "cmd", ",", "self", ".", "_device_id", ")", "if", "not", "self", ".", "is_connected",...
[ 513, 4 ]
[ 534, 13 ]
python
en
['en', 'en', 'en']
True
SwitchableRflinkDevice.async_added_to_hass
(self)
Restore RFLink device state (ON/OFF).
Restore RFLink device state (ON/OFF).
async def async_added_to_hass(self): """Restore RFLink device state (ON/OFF).""" await super().async_added_to_hass() old_state = await self.async_get_last_state() if old_state is not None: self._state = old_state.state == STATE_ON
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "old_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", "old_state", "is", "not", "None", ":", "self", "...
[ 540, 4 ]
[ 546, 53 ]
python
en
['it', 'en', 'en']
True
SwitchableRflinkDevice._handle_event
(self, event)
Adjust state if Rflink picks up a remote command for this device.
Adjust state if Rflink picks up a remote command for this device.
def _handle_event(self, event): """Adjust state if Rflink picks up a remote command for this device.""" self.cancel_queued_send_commands() command = event["command"] if command in ["on", "allon"]: self._state = True elif command in ["off", "alloff"]: self...
[ "def", "_handle_event", "(", "self", ",", "event", ")", ":", "self", ".", "cancel_queued_send_commands", "(", ")", "command", "=", "event", "[", "\"command\"", "]", "if", "command", "in", "[", "\"on\"", ",", "\"allon\"", "]", ":", "self", ".", "_state", ...
[ 548, 4 ]
[ 556, 31 ]
python
en
['en', 'en', 'en']
True
SwitchableRflinkDevice.async_turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
async def async_turn_on(self, **kwargs): """Turn the device on.""" await self._async_handle_command("turn_on")
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_async_handle_command", "(", "\"turn_on\"", ")" ]
[ 558, 4 ]
[ 560, 51 ]
python
en
['en', 'en', 'en']
True
SwitchableRflinkDevice.async_turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
async def async_turn_off(self, **kwargs): """Turn the device off.""" await self._async_handle_command("turn_off")
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_async_handle_command", "(", "\"turn_off\"", ")" ]
[ 562, 4 ]
[ 564, 52 ]
python
en
['en', 'en', 'en']
True
create_stream_buffer
(stream_output, video_stream, audio_stream, sequence)
Create a new StreamBuffer.
Create a new StreamBuffer.
def create_stream_buffer(stream_output, video_stream, audio_stream, sequence): """Create a new StreamBuffer.""" segment = io.BytesIO() container_options = ( stream_output.container_options(sequence) if stream_output.container_options else {} ) output = av.open( segme...
[ "def", "create_stream_buffer", "(", "stream_output", ",", "video_stream", ",", "audio_stream", ",", "sequence", ")", ":", "segment", "=", "io", ".", "BytesIO", "(", ")", "container_options", "=", "(", "stream_output", ".", "container_options", "(", "sequence", "...
[ 22, 0 ]
[ 45, 58 ]
python
en
['en', 'ig', 'en']
True
stream_worker
(hass, stream, quit_event)
Handle consuming streams and restart keepalive streams.
Handle consuming streams and restart keepalive streams.
def stream_worker(hass, stream, quit_event): """Handle consuming streams and restart keepalive streams.""" wait_timeout = 0 while not quit_event.wait(timeout=wait_timeout): start_time = time.time() try: _stream_worker_internal(hass, stream, quit_event) except av.error.FF...
[ "def", "stream_worker", "(", "hass", ",", "stream", ",", "quit_event", ")", ":", "wait_timeout", "=", "0", "while", "not", "quit_event", ".", "wait", "(", "timeout", "=", "wait_timeout", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "try", ...
[ 48, 0 ]
[ 71, 9 ]
python
en
['en', 'en', 'en']
True
_stream_worker_internal
(hass, stream, quit_event)
Handle consuming streams.
Handle consuming streams.
def _stream_worker_internal(hass, stream, quit_event): """Handle consuming streams.""" try: container = av.open( stream.source, options=stream.options, timeout=STREAM_TIMEOUT ) except av.AVError: _LOGGER.error("Error opening stream %s", stream.source) return ...
[ "def", "_stream_worker_internal", "(", "hass", ",", "stream", ",", "quit_event", ")", ":", "try", ":", "container", "=", "av", ".", "open", "(", "stream", ".", "source", ",", "options", "=", "stream", ".", "options", ",", "timeout", "=", "STREAM_TIMEOUT", ...
[ 74, 0 ]
[ 300, 21 ]
python
en
['en', 'es', 'en']
True
test_all_sensor
(hass, mock_hub, cfg, regs, expected)
Run test for sensor.
Run test for sensor.
async def test_all_sensor(hass, mock_hub, cfg, regs, expected): """Run test for sensor.""" sensor_name = "modbus_test_sensor" scan_interval = 5 entity_id, now, device = await setup_base_test( sensor_name, hass, mock_hub, { CONF_REGISTERS: [ dic...
[ "async", "def", "test_all_sensor", "(", "hass", ",", "mock_hub", ",", "cfg", ",", "regs", ",", "expected", ")", ":", "sensor_name", "=", "\"modbus_test_sensor\"", "scan_interval", "=", "5", "entity_id", ",", "now", ",", "device", "=", "await", "setup_base_test...
[ 238, 0 ]
[ 262, 5 ]
python
en
['en', 'no', 'en']
True
JWTAuthentication._authenticate_credentials
(self, request, token)
Try to authenticate the given credentials. If authentication is successful, return the user and token. If not, throw an error.
Try to authenticate the given credentials. If authentication is successful, return the user and token. If not, throw an error.
def _authenticate_credentials(self, request, token): """ Try to authenticate the given credentials. If authentication is successful, return the user and token. If not, throw an error. """ try: payload = jwt.decode(token, settings.SECRET_KEY, ...
[ "def", "_authenticate_credentials", "(", "self", ",", "request", ",", "token", ")", ":", "try", ":", "payload", "=", "jwt", ".", "decode", "(", "token", ",", "settings", ".", "SECRET_KEY", ",", "algorithms", "=", "'HS256'", ")", "except", "ExpiredSignatureEr...
[ 34, 4 ]
[ 63, 28 ]
python
en
['en', 'error', 'th']
False
init_integration
( hass, *, data: dict = ENTRY_CONFIG, options: dict = ENTRY_OPTIONS, )
Set up the Cloudflare integration in Home Assistant.
Set up the Cloudflare integration in Home Assistant.
async def init_integration( hass, *, data: dict = ENTRY_CONFIG, options: dict = ENTRY_OPTIONS, ) -> MockConfigEntry: """Set up the Cloudflare integration in Home Assistant.""" entry = MockConfigEntry(domain=DOMAIN, data=data, options=options) entry.add_to_hass(hass) await hass.config_en...
[ "async", "def", "init_integration", "(", "hass", ",", "*", ",", "data", ":", "dict", "=", "ENTRY_CONFIG", ",", "options", ":", "dict", "=", "ENTRY_OPTIONS", ",", ")", "->", "MockConfigEntry", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAI...
[ 54, 0 ]
[ 67, 16 ]
python
en
['en', 'en', 'en']
True
SmartHabConfigFlow._show_setup_form
(self, user_input=None, errors=None)
Show the setup form to the user.
Show the setup form to the user.
def _show_setup_form(self, user_input=None, errors=None): """Show the setup form to the user.""" if user_input is None: user_input = {} return self.async_show_form( step_id="user", data_schema=vol.Schema( { vol.Required( ...
[ "def", "_show_setup_form", "(", "self", ",", "user_input", "=", "None", ",", "errors", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "user_input", "=", "{", "}", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", "...
[ 21, 4 ]
[ 38, 9 ]
python
en
['en', 'en', 'en']
True
SmartHabConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" errors = {} if user_input is None: return self._show_setup_form(user_input, None) username = user_input[CONF_EMAIL] password = user_input[CONF_PASSWORD] # Check if ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "None", ":", "return", "self", ".", "_show_setup_form", "(", "user_input", ",", "None", ")", "username", "=", "us...
[ 40, 4 ]
[ 75, 56 ]
python
en
['en', 'en', 'en']
True
SmartHabConfigFlow.async_step_import
(self, import_info)
Handle import from legacy config.
Handle import from legacy config.
async def async_step_import(self, import_info): """Handle import from legacy config.""" return await self.async_step_user(import_info)
[ "async", "def", "async_step_import", "(", "self", ",", "import_info", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "import_info", ")" ]
[ 77, 4 ]
[ 79, 54 ]
python
en
['en', 'en', 'en']
True
split_entity_id
(entity_id: str)
Split a state entity_id into domain, object_id.
Split a state entity_id into domain, object_id.
def split_entity_id(entity_id: str) -> List[str]: """Split a state entity_id into domain, object_id.""" return entity_id.split(".", 1)
[ "def", "split_entity_id", "(", "entity_id", ":", "str", ")", "->", "List", "[", "str", "]", ":", "return", "entity_id", ".", "split", "(", "\".\"", ",", "1", ")" ]
[ 119, 0 ]
[ 121, 34 ]
python
en
['it', 'en', 'en']
True
valid_entity_id
(entity_id: str)
Test if an entity ID is a valid format. Format: <domain>.<entity> where both are slugs.
Test if an entity ID is a valid format.
def valid_entity_id(entity_id: str) -> bool: """Test if an entity ID is a valid format. Format: <domain>.<entity> where both are slugs. """ return VALID_ENTITY_ID.match(entity_id) is not None
[ "def", "valid_entity_id", "(", "entity_id", ":", "str", ")", "->", "bool", ":", "return", "VALID_ENTITY_ID", ".", "match", "(", "entity_id", ")", "is", "not", "None" ]
[ 127, 0 ]
[ 132, 55 ]
python
en
['en', 'en', 'en']
True
valid_state
(state: str)
Test if a state is valid.
Test if a state is valid.
def valid_state(state: str) -> bool: """Test if a state is valid.""" return len(state) < 256
[ "def", "valid_state", "(", "state", ":", "str", ")", "->", "bool", ":", "return", "len", "(", "state", ")", "<", "256" ]
[ 135, 0 ]
[ 137, 27 ]
python
en
['en', 'en', 'en']
True
callback
(func: CALLABLE_T)
Annotation to mark method as safe to call from within the event loop.
Annotation to mark method as safe to call from within the event loop.
def callback(func: CALLABLE_T) -> CALLABLE_T: """Annotation to mark method as safe to call from within the event loop.""" setattr(func, "_hass_callback", True) return func
[ "def", "callback", "(", "func", ":", "CALLABLE_T", ")", "->", "CALLABLE_T", ":", "setattr", "(", "func", ",", "\"_hass_callback\"", ",", "True", ")", "return", "func" ]
[ 140, 0 ]
[ 143, 15 ]
python
en
['en', 'en', 'en']
True
is_callback
(func: Callable[..., Any])
Check if function is safe to be called in the event loop.
Check if function is safe to be called in the event loop.
def is_callback(func: Callable[..., Any]) -> bool: """Check if function is safe to be called in the event loop.""" return getattr(func, "_hass_callback", False) is True
[ "def", "is_callback", "(", "func", ":", "Callable", "[", "...", ",", "Any", "]", ")", "->", "bool", ":", "return", "getattr", "(", "func", ",", "\"_hass_callback\"", ",", "False", ")", "is", "True" ]
[ 146, 0 ]
[ 148, 57 ]
python
en
['en', 'en', 'en']
True
_get_callable_job_type
(target: Callable)
Determine the job type from the callable.
Determine the job type from the callable.
def _get_callable_job_type(target: Callable) -> HassJobType: """Determine the job type from the callable.""" # Check for partials to properly determine if coroutine function check_target = target while isinstance(check_target, functools.partial): check_target = check_target.func if asyncio....
[ "def", "_get_callable_job_type", "(", "target", ":", "Callable", ")", "->", "HassJobType", ":", "# Check for partials to properly determine if coroutine function", "check_target", "=", "target", "while", "isinstance", "(", "check_target", ",", "functools", ".", "partial", ...
[ 183, 0 ]
[ 194, 31 ]
python
en
['en', 'en', 'en']
True
_async_create_timer
(hass: HomeAssistant)
Create a timer that will start on HOMEASSISTANT_START.
Create a timer that will start on HOMEASSISTANT_START.
def _async_create_timer(hass: HomeAssistant) -> None: """Create a timer that will start on HOMEASSISTANT_START.""" handle = None timer_context = Context() def schedule_tick(now: datetime.datetime) -> None: """Schedule a timer tick when the next second rolls around.""" nonlocal handle ...
[ "def", "_async_create_timer", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "handle", "=", "None", "timer_context", "=", "Context", "(", ")", "def", "schedule_tick", "(", "now", ":", "datetime", ".", "datetime", ")", "->", "None", ":", "\"\"\"...
[ 1738, 0 ]
[ 1781, 35 ]
python
en
['en', 'en', 'en']
True
HassJob.__init__
(self, target: Callable)
Create a job object.
Create a job object.
def __init__(self, target: Callable): """Create a job object.""" if asyncio.iscoroutine(target): raise ValueError("Coroutine not allowed to be passed to HassJob") self.target = target self.job_type = _get_callable_job_type(target)
[ "def", "__init__", "(", "self", ",", "target", ":", "Callable", ")", ":", "if", "asyncio", ".", "iscoroutine", "(", "target", ")", ":", "raise", "ValueError", "(", "\"Coroutine not allowed to be passed to HassJob\"", ")", "self", ".", "target", "=", "target", ...
[ 170, 4 ]
[ 176, 54 ]
python
en
['en', 'ga', 'en']
True
HassJob.__repr__
(self)
Return the job.
Return the job.
def __repr__(self) -> str: """Return the job.""" return f"<Job {self.job_type} {self.target}>"
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "f\"<Job {self.job_type} {self.target}>\"" ]
[ 178, 4 ]
[ 180, 53 ]
python
en
['en', 'sq', 'en']
True
CoreState.__str__
(self)
Return the event.
Return the event.
def __str__(self) -> str: # pylint: disable=invalid-str-returned """Return the event.""" return self.value
[ "def", "__str__", "(", "self", ")", "->", "str", ":", "# pylint: disable=invalid-str-returned", "return", "self", ".", "value" ]
[ 207, 4 ]
[ 209, 25 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.__init__
(self)
Initialize new Home Assistant object.
Initialize new Home Assistant object.
def __init__(self) -> None: """Initialize new Home Assistant object.""" self.loop = asyncio.get_running_loop() self._pending_tasks: list = [] self._track_task = True self.bus = EventBus(self) self.services = ServiceRegistry(self) self.states = StateMachine(self.bu...
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "self", ".", "loop", "=", "asyncio", ".", "get_running_loop", "(", ")", "self", ".", "_pending_tasks", ":", "list", "=", "[", "]", "self", ".", "_track_task", "=", "True", "self", ".", "bus", "=...
[ 219, 4 ]
[ 237, 55 ]
python
en
['fr', 'en', 'en']
True
HomeAssistant.is_running
(self)
Return if Home Assistant is running.
Return if Home Assistant is running.
def is_running(self) -> bool: """Return if Home Assistant is running.""" return self.state in (CoreState.starting, CoreState.running)
[ "def", "is_running", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "state", "in", "(", "CoreState", ".", "starting", ",", "CoreState", ".", "running", ")" ]
[ 240, 4 ]
[ 242, 68 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.is_stopping
(self)
Return if Home Assistant is stopping.
Return if Home Assistant is stopping.
def is_stopping(self) -> bool: """Return if Home Assistant is stopping.""" return self.state in (CoreState.stopping, CoreState.final_write)
[ "def", "is_stopping", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "state", "in", "(", "CoreState", ".", "stopping", ",", "CoreState", ".", "final_write", ")" ]
[ 245, 4 ]
[ 247, 72 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.start
(self)
Start Home Assistant. Note: This function is only used for testing. For regular use, use "await hass.run()".
Start Home Assistant.
def start(self) -> int: """Start Home Assistant. Note: This function is only used for testing. For regular use, use "await hass.run()". """ # Register the async start fire_coroutine_threadsafe(self.async_start(), self.loop) # Run forever # Block until st...
[ "def", "start", "(", "self", ")", "->", "int", ":", "# Register the async start", "fire_coroutine_threadsafe", "(", "self", ".", "async_start", "(", ")", ",", "self", ".", "loop", ")", "# Run forever", "# Block until stopped", "_LOGGER", ".", "info", "(", "\"Sta...
[ 249, 4 ]
[ 262, 29 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_run
(self, *, attach_signals: bool = True)
Home Assistant main entry point. Start Home Assistant and block until stopped. This method is a coroutine.
Home Assistant main entry point.
async def async_run(self, *, attach_signals: bool = True) -> int: """Home Assistant main entry point. Start Home Assistant and block until stopped. This method is a coroutine. """ if self.state != CoreState.not_running: raise RuntimeError("Home Assistant is already ...
[ "async", "def", "async_run", "(", "self", ",", "*", ",", "attach_signals", ":", "bool", "=", "True", ")", "->", "int", ":", "if", "self", ".", "state", "!=", "CoreState", ".", "not_running", ":", "raise", "RuntimeError", "(", "\"Home Assistant is already run...
[ 264, 4 ]
[ 285, 29 ]
python
en
['en', 'en', 'ur']
True
HomeAssistant.async_start
(self)
Finalize startup from inside the event loop. This method is a coroutine.
Finalize startup from inside the event loop.
async def async_start(self) -> None: """Finalize startup from inside the event loop. This method is a coroutine. """ _LOGGER.info("Starting Home Assistant") setattr(self.loop, "_thread_ident", threading.get_ident()) self.state = CoreState.starting self.bus.async...
[ "async", "def", "async_start", "(", "self", ")", "->", "None", ":", "_LOGGER", ".", "info", "(", "\"Starting Home Assistant\"", ")", "setattr", "(", "self", ".", "loop", ",", "\"_thread_ident\"", ",", "threading", ".", "get_ident", "(", ")", ")", "self", "...
[ 287, 4 ]
[ 325, 33 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.add_job
(self, target: Callable[..., Any], *args: Any)
Add job to the executor pool. target: target to call. args: parameters for method to call.
Add job to the executor pool.
def add_job(self, target: Callable[..., Any], *args: Any) -> None: """Add job to the executor pool. target: target to call. args: parameters for method to call. """ if target is None: raise ValueError("Don't call add_job with None") self.loop.call_soon_thread...
[ "def", "add_job", "(", "self", ",", "target", ":", "Callable", "[", "...", ",", "Any", "]", ",", "*", "args", ":", "Any", ")", "->", "None", ":", "if", "target", "is", "None", ":", "raise", "ValueError", "(", "\"Don't call add_job with None\"", ")", "s...
[ 327, 4 ]
[ 335, 73 ]
python
en
['en', 'ceb', 'en']
True
HomeAssistant.async_add_job
( self, target: Callable[..., Any], *args: Any )
Add a job from within the event loop. This method must be run in the event loop. target: target to call. args: parameters for method to call.
Add a job from within the event loop.
def async_add_job( self, target: Callable[..., Any], *args: Any ) -> Optional[asyncio.Future]: """Add a job from within the event loop. This method must be run in the event loop. target: target to call. args: parameters for method to call. """ if target is N...
[ "def", "async_add_job", "(", "self", ",", "target", ":", "Callable", "[", "...", ",", "Any", "]", ",", "*", "args", ":", "Any", ")", "->", "Optional", "[", "asyncio", ".", "Future", "]", ":", "if", "target", "is", "None", ":", "raise", "ValueError", ...
[ 338, 4 ]
[ 354, 62 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_add_hass_job
( self, hassjob: HassJob, *args: Any )
Add a HassJob from within the event loop. This method must be run in the event loop. hassjob: HassJob to call. args: parameters for method to call.
Add a HassJob from within the event loop.
def async_add_hass_job( self, hassjob: HassJob, *args: Any ) -> Optional[asyncio.Future]: """Add a HassJob from within the event loop. This method must be run in the event loop. hassjob: HassJob to call. args: parameters for method to call. """ if hassjob.job...
[ "def", "async_add_hass_job", "(", "self", ",", "hassjob", ":", "HassJob", ",", "*", "args", ":", "Any", ")", "->", "Optional", "[", "asyncio", ".", "Future", "]", ":", "if", "hassjob", ".", "job_type", "==", "HassJobType", ".", "Coroutinefunction", ":", ...
[ 357, 4 ]
[ 380, 19 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_create_task
(self, target: Coroutine)
Create a task from within the eventloop. This method must be run in the event loop. target: target to call.
Create a task from within the eventloop.
def async_create_task(self, target: Coroutine) -> asyncio.tasks.Task: """Create a task from within the eventloop. This method must be run in the event loop. target: target to call. """ task: asyncio.tasks.Task = self.loop.create_task(target) if self._track_task: ...
[ "def", "async_create_task", "(", "self", ",", "target", ":", "Coroutine", ")", "->", "asyncio", ".", "tasks", ".", "Task", ":", "task", ":", "asyncio", ".", "tasks", ".", "Task", "=", "self", ".", "loop", ".", "create_task", "(", "target", ")", "if", ...
[ 383, 4 ]
[ 395, 19 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_add_executor_job
( self, target: Callable[..., T], *args: Any )
Add an executor job from within the event loop.
Add an executor job from within the event loop.
def async_add_executor_job( self, target: Callable[..., T], *args: Any ) -> Awaitable[T]: """Add an executor job from within the event loop.""" task = self.loop.run_in_executor(None, target, *args) # If a task is scheduled if self._track_task: self._pending_tasks...
[ "def", "async_add_executor_job", "(", "self", ",", "target", ":", "Callable", "[", "...", ",", "T", "]", ",", "*", "args", ":", "Any", ")", "->", "Awaitable", "[", "T", "]", ":", "task", "=", "self", ".", "loop", ".", "run_in_executor", "(", "None", ...
[ 398, 4 ]
[ 408, 19 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_track_tasks
(self)
Track tasks so you can wait for all tasks to be done.
Track tasks so you can wait for all tasks to be done.
def async_track_tasks(self) -> None: """Track tasks so you can wait for all tasks to be done.""" self._track_task = True
[ "def", "async_track_tasks", "(", "self", ")", "->", "None", ":", "self", ".", "_track_task", "=", "True" ]
[ 411, 4 ]
[ 413, 31 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_stop_track_tasks
(self)
Stop track tasks so you can't wait for all tasks to be done.
Stop track tasks so you can't wait for all tasks to be done.
def async_stop_track_tasks(self) -> None: """Stop track tasks so you can't wait for all tasks to be done.""" self._track_task = False
[ "def", "async_stop_track_tasks", "(", "self", ")", "->", "None", ":", "self", ".", "_track_task", "=", "False" ]
[ 416, 4 ]
[ 418, 32 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_run_hass_job
(self, hassjob: HassJob, *args: Any)
Run a HassJob from within the event loop. This method must be run in the event loop. hassjob: HassJob args: parameters for method to call.
Run a HassJob from within the event loop.
def async_run_hass_job(self, hassjob: HassJob, *args: Any) -> None: """Run a HassJob from within the event loop. This method must be run in the event loop. hassjob: HassJob args: parameters for method to call. """ if hassjob.job_type == HassJobType.Callback: ...
[ "def", "async_run_hass_job", "(", "self", ",", "hassjob", ":", "HassJob", ",", "*", "args", ":", "Any", ")", "->", "None", ":", "if", "hassjob", ".", "job_type", "==", "HassJobType", ".", "Callback", ":", "hassjob", ".", "target", "(", "*", "args", ")"...
[ 421, 4 ]
[ 432, 51 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_run_job
( self, target: Callable[..., Union[None, Awaitable]], *args: Any )
Run a job from within the event loop. This method must be run in the event loop. target: target to call. args: parameters for method to call.
Run a job from within the event loop.
def async_run_job( self, target: Callable[..., Union[None, Awaitable]], *args: Any ) -> None: """Run a job from within the event loop. This method must be run in the event loop. target: target to call. args: parameters for method to call. """ if asyncio.isco...
[ "def", "async_run_job", "(", "self", ",", "target", ":", "Callable", "[", "...", ",", "Union", "[", "None", ",", "Awaitable", "]", "]", ",", "*", "args", ":", "Any", ")", "->", "None", ":", "if", "asyncio", ".", "iscoroutine", "(", "target", ")", "...
[ 435, 4 ]
[ 449, 55 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.block_till_done
(self)
Block until all pending work is done.
Block until all pending work is done.
def block_till_done(self) -> None: """Block until all pending work is done.""" asyncio.run_coroutine_threadsafe( self.async_block_till_done(), self.loop ).result()
[ "def", "block_till_done", "(", "self", ")", "->", "None", ":", "asyncio", ".", "run_coroutine_threadsafe", "(", "self", ".", "async_block_till_done", "(", ")", ",", "self", ".", "loop", ")", ".", "result", "(", ")" ]
[ 451, 4 ]
[ 455, 18 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_block_till_done
(self)
Block until all pending work is done.
Block until all pending work is done.
async def async_block_till_done(self) -> None: """Block until all pending work is done.""" # To flush out any call_soon_threadsafe await asyncio.sleep(0) start_time: Optional[float] = None while self._pending_tasks: pending = [task for task in self._pending_tasks if ...
[ "async", "def", "async_block_till_done", "(", "self", ")", "->", "None", ":", "# To flush out any call_soon_threadsafe", "await", "asyncio", ".", "sleep", "(", "0", ")", "start_time", ":", "Optional", "[", "float", "]", "=", "None", "while", "self", ".", "_pen...
[ 457, 4 ]
[ 484, 38 ]
python
en
['en', 'en', 'en']
True
HomeAssistant._await_and_log_pending
(self, pending: Iterable[Awaitable[Any]])
Await and log tasks that take a long time.
Await and log tasks that take a long time.
async def _await_and_log_pending(self, pending: Iterable[Awaitable[Any]]) -> None: """Await and log tasks that take a long time.""" wait_time = 0 while pending: _, pending = await asyncio.wait(pending, timeout=BLOCK_LOG_TIMEOUT) if not pending: return ...
[ "async", "def", "_await_and_log_pending", "(", "self", ",", "pending", ":", "Iterable", "[", "Awaitable", "[", "Any", "]", "]", ")", "->", "None", ":", "wait_time", "=", "0", "while", "pending", ":", "_", ",", "pending", "=", "await", "asyncio", ".", "...
[ 486, 4 ]
[ 495, 80 ]
python
en
['en', 'jv', 'en']
True
HomeAssistant.stop
(self)
Stop Home Assistant and shuts down all threads.
Stop Home Assistant and shuts down all threads.
def stop(self) -> None: """Stop Home Assistant and shuts down all threads.""" if self.state == CoreState.not_running: # just ignore return fire_coroutine_threadsafe(self.async_stop(), self.loop)
[ "def", "stop", "(", "self", ")", "->", "None", ":", "if", "self", ".", "state", "==", "CoreState", ".", "not_running", ":", "# just ignore", "return", "fire_coroutine_threadsafe", "(", "self", ".", "async_stop", "(", ")", ",", "self", ".", "loop", ")" ]
[ 497, 4 ]
[ 501, 63 ]
python
en
['en', 'en', 'en']
True
HomeAssistant.async_stop
(self, exit_code: int = 0, *, force: bool = False)
Stop Home Assistant and shuts down all threads. The "force" flag commands async_stop to proceed regardless of Home Assistan't current state. You should not set this flag unless you're testing. This method is a coroutine.
Stop Home Assistant and shuts down all threads.
async def async_stop(self, exit_code: int = 0, *, force: bool = False) -> None: """Stop Home Assistant and shuts down all threads. The "force" flag commands async_stop to proceed regardless of Home Assistan't current state. You should not set this flag unless you're testing. Th...
[ "async", "def", "async_stop", "(", "self", ",", "exit_code", ":", "int", "=", "0", ",", "*", ",", "force", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "not", "force", ":", "# Some tests require async_stop to run,", "# regardless of the state of th...
[ 503, 4 ]
[ 562, 31 ]
python
en
['en', 'en', 'en']
True
EventOrigin.__str__
(self)
Return the event.
Return the event.
def __str__(self) -> str: # pylint: disable=invalid-str-returned """Return the event.""" return self.value
[ "def", "__str__", "(", "self", ")", "->", "str", ":", "# pylint: disable=invalid-str-returned", "return", "self", ".", "value" ]
[ 584, 4 ]
[ 586, 25 ]
python
en
['en', 'en', 'en']
True
Event.__init__
( self, event_type: str, data: Optional[Dict[str, Any]] = None, origin: EventOrigin = EventOrigin.local, time_fired: Optional[datetime.datetime] = None, context: Optional[Context] = None, )
Initialize a new event.
Initialize a new event.
def __init__( self, event_type: str, data: Optional[Dict[str, Any]] = None, origin: EventOrigin = EventOrigin.local, time_fired: Optional[datetime.datetime] = None, context: Optional[Context] = None, ) -> None: """Initialize a new event.""" self.event_...
[ "def", "__init__", "(", "self", ",", "event_type", ":", "str", ",", "data", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", "origin", ":", "EventOrigin", "=", "EventOrigin", ".", "local", ",", "time_fired", ":", "Opt...
[ 594, 4 ]
[ 607, 52 ]
python
en
['en', 'en', 'en']
True
Event.__hash__
(self)
Make hashable.
Make hashable.
def __hash__(self) -> int: """Make hashable.""" # The only event type that shares context are the TIME_CHANGED return hash((self.event_type, self.context.id, self.time_fired))
[ "def", "__hash__", "(", "self", ")", "->", "int", ":", "# The only event type that shares context are the TIME_CHANGED", "return", "hash", "(", "(", "self", ".", "event_type", ",", "self", ".", "context", ".", "id", ",", "self", ".", "time_fired", ")", ")" ]
[ 609, 4 ]
[ 612, 72 ]
python
en
['en', 'sw', 'en']
False
Event.as_dict
(self)
Create a dict representation of this Event. Async friendly.
Create a dict representation of this Event.
def as_dict(self) -> Dict: """Create a dict representation of this Event. Async friendly. """ return { "event_type": self.event_type, "data": dict(self.data), "origin": str(self.origin.value), "time_fired": self.time_fired.isoformat(), ...
[ "def", "as_dict", "(", "self", ")", "->", "Dict", ":", "return", "{", "\"event_type\"", ":", "self", ".", "event_type", ",", "\"data\"", ":", "dict", "(", "self", ".", "data", ")", ",", "\"origin\"", ":", "str", "(", "self", ".", "origin", ".", "valu...
[ 614, 4 ]
[ 625, 9 ]
python
en
['en', 'en', 'en']
True
Event.__repr__
(self)
Return the representation.
Return the representation.
def __repr__(self) -> str: """Return the representation.""" # pylint: disable=maybe-no-member if self.data: return f"<Event {self.event_type}[{str(self.origin)[0]}]: {util.repr_helper(self.data)}>" return f"<Event {self.event_type}[{str(self.origin)[0]}]>"
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "# pylint: disable=maybe-no-member", "if", "self", ".", "data", ":", "return", "f\"<Event {self.event_type}[{str(self.origin)[0]}]: {util.repr_helper(self.data)}>\"", "return", "f\"<Event {self.event_type}[{str(self.origin)[0]}...
[ 627, 4 ]
[ 633, 66 ]
python
en
['en', 'id', 'en']
True
Event.__eq__
(self, other: Any)
Return the comparison.
Return the comparison.
def __eq__(self, other: Any) -> bool: """Return the comparison.""" return ( # type: ignore self.__class__ == other.__class__ and self.event_type == other.event_type and self.data == other.data and self.origin == other.origin and self.time_fire...
[ "def", "__eq__", "(", "self", ",", "other", ":", "Any", ")", "->", "bool", ":", "return", "(", "# type: ignore", "self", ".", "__class__", "==", "other", ".", "__class__", "and", "self", ".", "event_type", "==", "other", ".", "event_type", "and", "self",...
[ 635, 4 ]
[ 644, 9 ]
python
en
['en', 'it', 'en']
True
EventBus.__init__
(self, hass: HomeAssistant)
Initialize a new event bus.
Initialize a new event bus.
def __init__(self, hass: HomeAssistant) -> None: """Initialize a new event bus.""" self._listeners: Dict[str, List[HassJob]] = {} self._hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "self", ".", "_listeners", ":", "Dict", "[", "str", ",", "List", "[", "HassJob", "]", "]", "=", "{", "}", "self", ".", "_hass", "=", "hass" ]
[ 650, 4 ]
[ 653, 25 ]
python
en
['en', 'en', 'en']
True
EventBus.async_listeners
(self)
Return dictionary with events and the number of listeners. This method must be run in the event loop.
Return dictionary with events and the number of listeners.
def async_listeners(self) -> Dict[str, int]: """Return dictionary with events and the number of listeners. This method must be run in the event loop. """ return {key: len(self._listeners[key]) for key in self._listeners}
[ "def", "async_listeners", "(", "self", ")", "->", "Dict", "[", "str", ",", "int", "]", ":", "return", "{", "key", ":", "len", "(", "self", ".", "_listeners", "[", "key", "]", ")", "for", "key", "in", "self", ".", "_listeners", "}" ]
[ 656, 4 ]
[ 661, 74 ]
python
en
['en', 'en', 'en']
True
EventBus.listeners
(self)
Return dictionary with events and the number of listeners.
Return dictionary with events and the number of listeners.
def listeners(self) -> Dict[str, int]: """Return dictionary with events and the number of listeners.""" return run_callback_threadsafe(self._hass.loop, self.async_listeners).result()
[ "def", "listeners", "(", "self", ")", "->", "Dict", "[", "str", ",", "int", "]", ":", "return", "run_callback_threadsafe", "(", "self", ".", "_hass", ".", "loop", ",", "self", ".", "async_listeners", ")", ".", "result", "(", ")" ]
[ 664, 4 ]
[ 666, 86 ]
python
en
['en', 'en', 'en']
True
EventBus.fire
( self, event_type: str, event_data: Optional[Dict] = None, origin: EventOrigin = EventOrigin.local, context: Optional[Context] = None, )
Fire an event.
Fire an event.
def fire( self, event_type: str, event_data: Optional[Dict] = None, origin: EventOrigin = EventOrigin.local, context: Optional[Context] = None, ) -> None: """Fire an event.""" self._hass.loop.call_soon_threadsafe( self.async_fire, event_type, event...
[ "def", "fire", "(", "self", ",", "event_type", ":", "str", ",", "event_data", ":", "Optional", "[", "Dict", "]", "=", "None", ",", "origin", ":", "EventOrigin", "=", "EventOrigin", ".", "local", ",", "context", ":", "Optional", "[", "Context", "]", "="...
[ 668, 4 ]
[ 678, 9 ]
python
en
['en', 'lb', 'en']
True
EventBus.async_fire
( self, event_type: str, event_data: Optional[Dict] = None, origin: EventOrigin = EventOrigin.local, context: Optional[Context] = None, time_fired: Optional[datetime.datetime] = None, )
Fire an event. This method must be run in the event loop.
Fire an event.
def async_fire( self, event_type: str, event_data: Optional[Dict] = None, origin: EventOrigin = EventOrigin.local, context: Optional[Context] = None, time_fired: Optional[datetime.datetime] = None, ) -> None: """Fire an event. This method must be run ...
[ "def", "async_fire", "(", "self", ",", "event_type", ":", "str", ",", "event_data", ":", "Optional", "[", "Dict", "]", "=", "None", ",", "origin", ":", "EventOrigin", "=", "EventOrigin", ".", "local", ",", "context", ":", "Optional", "[", "Context", "]",...
[ 681, 4 ]
[ 709, 53 ]
python
en
['en', 'lb', 'en']
True
EventBus.listen
(self, event_type: str, listener: Callable)
Listen for all events or events of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type.
Listen for all events or events of a specific type.
def listen(self, event_type: str, listener: Callable) -> CALLBACK_TYPE: """Listen for all events or events of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. """ async_remove_listener = run_callback_threadsafe( self._hass.lo...
[ "def", "listen", "(", "self", ",", "event_type", ":", "str", ",", "listener", ":", "Callable", ")", "->", "CALLBACK_TYPE", ":", "async_remove_listener", "=", "run_callback_threadsafe", "(", "self", ".", "_hass", ".", "loop", ",", "self", ".", "async_listen", ...
[ 711, 4 ]
[ 725, 30 ]
python
en
['en', 'en', 'en']
True
EventBus.async_listen
(self, event_type: str, listener: Callable)
Listen for all events or events of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. This method must be run in the event loop.
Listen for all events or events of a specific type.
def async_listen(self, event_type: str, listener: Callable) -> CALLBACK_TYPE: """Listen for all events or events of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. This method must be run in the event loop. """ return self._asy...
[ "def", "async_listen", "(", "self", ",", "event_type", ":", "str", ",", "listener", ":", "Callable", ")", "->", "CALLBACK_TYPE", ":", "return", "self", ".", "_async_listen_job", "(", "event_type", ",", "HassJob", "(", "listener", ")", ")" ]
[ 728, 4 ]
[ 736, 68 ]
python
en
['en', 'en', 'en']
True
EventBus.listen_once
(self, event_type: str, listener: Callable)
Listen once for event of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. Returns function to unsubscribe the listener.
Listen once for event of a specific type.
def listen_once(self, event_type: str, listener: Callable) -> CALLBACK_TYPE: """Listen once for event of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. Returns function to unsubscribe the listener. """ async_remove_listener = ...
[ "def", "listen_once", "(", "self", ",", "event_type", ":", "str", ",", "listener", ":", "Callable", ")", "->", "CALLBACK_TYPE", ":", "async_remove_listener", "=", "run_callback_threadsafe", "(", "self", ".", "_hass", ".", "loop", ",", "self", ".", "async_liste...
[ 748, 4 ]
[ 764, 30 ]
python
en
['en', 'en', 'en']
True
EventBus.async_listen_once
(self, event_type: str, listener: Callable)
Listen once for event of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. Returns registered listener that can be used with remove_listener. This method must be run in the event loop.
Listen once for event of a specific type.
def async_listen_once(self, event_type: str, listener: Callable) -> CALLBACK_TYPE: """Listen once for event of a specific type. To listen to all events specify the constant ``MATCH_ALL`` as event_type. Returns registered listener that can be used with remove_listener. This met...
[ "def", "async_listen_once", "(", "self", ",", "event_type", ":", "str", ",", "listener", ":", "Callable", ")", "->", "CALLBACK_TYPE", ":", "job", ":", "Optional", "[", "HassJob", "]", "=", "None", "@", "callback", "def", "_onetime_listener", "(", "event", ...
[ 767, 4 ]
[ 797, 54 ]
python
en
['en', 'en', 'en']
True
EventBus._async_remove_listener
(self, event_type: str, hassjob: HassJob)
Remove a listener of a specific event_type. This method must be run in the event loop.
Remove a listener of a specific event_type.
def _async_remove_listener(self, event_type: str, hassjob: HassJob) -> None: """Remove a listener of a specific event_type. This method must be run in the event loop. """ try: self._listeners[event_type].remove(hassjob) # delete event_type list if empty ...
[ "def", "_async_remove_listener", "(", "self", ",", "event_type", ":", "str", ",", "hassjob", ":", "HassJob", ")", "->", "None", ":", "try", ":", "self", ".", "_listeners", "[", "event_type", "]", ".", "remove", "(", "hassjob", ")", "# delete event_type list ...
[ 800, 4 ]
[ 814, 82 ]
python
en
['en', 'en', 'en']
True
State.__init__
( self, entity_id: str, state: str, attributes: Optional[Mapping] = None, last_changed: Optional[datetime.datetime] = None, last_updated: Optional[datetime.datetime] = None, context: Optional[Context] = None, validate_entity_id: Optional[bool] = True, ...
Initialize a new state.
Initialize a new state.
def __init__( self, entity_id: str, state: str, attributes: Optional[Mapping] = None, last_changed: Optional[datetime.datetime] = None, last_updated: Optional[datetime.datetime] = None, context: Optional[Context] = None, validate_entity_id: Optional[bool] ...
[ "def", "__init__", "(", "self", ",", "entity_id", ":", "str", ",", "state", ":", "str", ",", "attributes", ":", "Optional", "[", "Mapping", "]", "=", "None", ",", "last_changed", ":", "Optional", "[", "datetime", ".", "datetime", "]", "=", "None", ",",...
[ 842, 4 ]
[ 874, 66 ]
python
en
['en', 'en', 'en']
True
State.name
(self)
Name of this state.
Name of this state.
def name(self) -> str: """Name of this state.""" return self.attributes.get(ATTR_FRIENDLY_NAME) or self.object_id.replace( "_", " " )
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "attributes", ".", "get", "(", "ATTR_FRIENDLY_NAME", ")", "or", "self", ".", "object_id", ".", "replace", "(", "\"_\"", ",", "\" \"", ")" ]
[ 877, 4 ]
[ 881, 9 ]
python
en
['en', 'en', 'en']
True
State.as_dict
(self)
Return a dict representation of the State. Async friendly. To be used for JSON serialization. Ensures: state == State.from_dict(state.as_dict())
Return a dict representation of the State.
def as_dict(self) -> Dict: """Return a dict representation of the State. Async friendly. To be used for JSON serialization. Ensures: state == State.from_dict(state.as_dict()) """ if not self._as_dict: last_changed_isoformat = self.last_changed.isoformat() ...
[ "def", "as_dict", "(", "self", ")", "->", "Dict", ":", "if", "not", "self", ".", "_as_dict", ":", "last_changed_isoformat", "=", "self", ".", "last_changed", ".", "isoformat", "(", ")", "if", "self", ".", "last_changed", "==", "self", ".", "last_updated", ...
[ 883, 4 ]
[ 905, 28 ]
python
en
['en', 'en', 'en']
True
State.from_dict
(cls, json_dict: Dict)
Initialize a state from a dict. Async friendly. Ensures: state == State.from_json_dict(state.to_json_dict())
Initialize a state from a dict.
def from_dict(cls, json_dict: Dict) -> Any: """Initialize a state from a dict. Async friendly. Ensures: state == State.from_json_dict(state.to_json_dict()) """ if not (json_dict and "entity_id" in json_dict and "state" in json_dict): return None last_change...
[ "def", "from_dict", "(", "cls", ",", "json_dict", ":", "Dict", ")", "->", "Any", ":", "if", "not", "(", "json_dict", "and", "\"entity_id\"", "in", "json_dict", "and", "\"state\"", "in", "json_dict", ")", ":", "return", "None", "last_changed", "=", "json_di...
[ 908, 4 ]
[ 939, 9 ]
python
en
['en', 'en', 'en']
True