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
ModuleUtilsMixin.floating_point_ops
( self, input_dict: Dict[str, Union[torch.Tensor, Any]], exclude_embeddings: bool = True )
Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a batch with this transformer model. Default approximation neglects the quadratic dependency on the number of tokens (valid if :obj:`12 * d_model << sequence_length`) as laid out in `this...
Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a batch with this transformer model. Default approximation neglects the quadratic dependency on the number of tokens (valid if :obj:`12 * d_model << sequence_length`) as laid out in `this...
def floating_point_ops( self, input_dict: Dict[str, Union[torch.Tensor, Any]], exclude_embeddings: bool = True ) -> int: """ Get number of (optionally, non-embeddings) floating-point operations for the forward and backward passes of a batch with this transformer model. Default approx...
[ "def", "floating_point_ops", "(", "self", ",", "input_dict", ":", "Dict", "[", "str", ",", "Union", "[", "torch", ".", "Tensor", ",", "Any", "]", "]", ",", "exclude_embeddings", ":", "bool", "=", "True", ")", "->", "int", ":", "return", "6", "*", "se...
[ 362, 4 ]
[ 386, 112 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.dummy_inputs
(self)
:obj:`Dict[str, torch.Tensor]`: Dummy inputs to do a forward pass in the network.
:obj:`Dict[str, torch.Tensor]`: Dummy inputs to do a forward pass in the network.
def dummy_inputs(self) -> Dict[str, torch.Tensor]: """ :obj:`Dict[str, torch.Tensor]`: Dummy inputs to do a forward pass in the network. """ return {"input_ids": torch.tensor(DUMMY_INPUTS)}
[ "def", "dummy_inputs", "(", "self", ")", "->", "Dict", "[", "str", ",", "torch", ".", "Tensor", "]", ":", "return", "{", "\"input_ids\"", ":", "torch", ".", "tensor", "(", "DUMMY_INPUTS", ")", "}" ]
[ 431, 4 ]
[ 435, 56 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.base_model
(self)
:obj:`torch.nn.Module`: The main body of the model.
:obj:`torch.nn.Module`: The main body of the model.
def base_model(self) -> nn.Module: """ :obj:`torch.nn.Module`: The main body of the model. """ return getattr(self, self.base_model_prefix, self)
[ "def", "base_model", "(", "self", ")", "->", "nn", ".", "Module", ":", "return", "getattr", "(", "self", ",", "self", ".", "base_model_prefix", ",", "self", ")" ]
[ 452, 4 ]
[ 456, 58 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.get_input_embeddings
(self)
Returns the model's input embeddings. Returns: :obj:`nn.Module`: A torch module mapping vocabulary to hidden states.
Returns the model's input embeddings.
def get_input_embeddings(self) -> nn.Module: """ Returns the model's input embeddings. Returns: :obj:`nn.Module`: A torch module mapping vocabulary to hidden states. """ base_model = getattr(self, self.base_model_prefix, self) if base_model is not self: ...
[ "def", "get_input_embeddings", "(", "self", ")", "->", "nn", ".", "Module", ":", "base_model", "=", "getattr", "(", "self", ",", "self", ".", "base_model_prefix", ",", "self", ")", "if", "base_model", "is", "not", "self", ":", "return", "base_model", ".", ...
[ 458, 4 ]
[ 469, 37 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.set_input_embeddings
(self, value: nn.Module)
Set model's input embeddings. Args: value (:obj:`nn.Module`): A module mapping vocabulary to hidden states.
Set model's input embeddings.
def set_input_embeddings(self, value: nn.Module): """ Set model's input embeddings. Args: value (:obj:`nn.Module`): A module mapping vocabulary to hidden states. """ base_model = getattr(self, self.base_model_prefix, self) if base_model is not self: ...
[ "def", "set_input_embeddings", "(", "self", ",", "value", ":", "nn", ".", "Module", ")", ":", "base_model", "=", "getattr", "(", "self", ",", "self", ".", "base_model_prefix", ",", "self", ")", "if", "base_model", "is", "not", "self", ":", "base_model", ...
[ 471, 4 ]
[ 482, 37 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.get_output_embeddings
(self)
Returns the model's output embeddings. Returns: :obj:`nn.Module`: A torch module mapping hidden states to vocabulary.
Returns the model's output embeddings.
def get_output_embeddings(self) -> nn.Module: """ Returns the model's output embeddings. Returns: :obj:`nn.Module`: A torch module mapping hidden states to vocabulary. """ return None
[ "def", "get_output_embeddings", "(", "self", ")", "->", "nn", ".", "Module", ":", "return", "None" ]
[ 484, 4 ]
[ 491, 19 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.tie_weights
(self)
Tie the weights between the input embeddings and the output embeddings. If the :obj:`torchscript` flag is set in the configuration, can't handle parameter sharing so we are cloning the weights instead.
Tie the weights between the input embeddings and the output embeddings.
def tie_weights(self): """ Tie the weights between the input embeddings and the output embeddings. If the :obj:`torchscript` flag is set in the configuration, can't handle parameter sharing so we are cloning the weights instead. """ output_embeddings = self.get_output_em...
[ "def", "tie_weights", "(", "self", ")", ":", "output_embeddings", "=", "self", ".", "get_output_embeddings", "(", ")", "if", "output_embeddings", "is", "not", "None", "and", "self", ".", "config", ".", "tie_word_embeddings", ":", "self", ".", "_tie_or_clone_weig...
[ 493, 4 ]
[ 507, 97 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel._tie_or_clone_weights
(self, output_embeddings, input_embeddings)
Tie or clone module weights depending of whether we are using TorchScript or not
Tie or clone module weights depending of whether we are using TorchScript or not
def _tie_or_clone_weights(self, output_embeddings, input_embeddings): """Tie or clone module weights depending of whether we are using TorchScript or not""" if self.config.torchscript: output_embeddings.weight = nn.Parameter(input_embeddings.weight.clone()) else: output_e...
[ "def", "_tie_or_clone_weights", "(", "self", ",", "output_embeddings", ",", "input_embeddings", ")", ":", "if", "self", ".", "config", ".", "torchscript", ":", "output_embeddings", ".", "weight", "=", "nn", ".", "Parameter", "(", "input_embeddings", ".", "weight...
[ 582, 4 ]
[ 600, 76 ]
python
en
['en', 'en', 'en']
True
PreTrainedModel.resize_token_embeddings
(self, new_num_tokens: Optional[int] = None)
Resizes input token embeddings matrix of the model if :obj:`new_num_tokens != config.vocab_size`. Takes care of tying weights embeddings afterwards if the model class has a :obj:`tie_weights()` method. Arguments: new_num_tokens (:obj:`int`, `optional`): The number ...
Resizes input token embeddings matrix of the model if :obj:`new_num_tokens != config.vocab_size`.
def resize_token_embeddings(self, new_num_tokens: Optional[int] = None) -> torch.nn.Embedding: """ Resizes input token embeddings matrix of the model if :obj:`new_num_tokens != config.vocab_size`. Takes care of tying weights embeddings afterwards if the model class has a :obj:`tie_weights()` me...
[ "def", "resize_token_embeddings", "(", "self", ",", "new_num_tokens", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "torch", ".", "nn", ".", "Embedding", ":", "model_embeds", "=", "self", ".", "_resize_token_embeddings", "(", "new_num_tokens", ")",...
[ 602, 4 ]
[ 629, 27 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel._get_resized_embeddings
( self, old_embeddings: torch.nn.Embedding, new_num_tokens: Optional[int] = None )
Build a resized Embedding Module from a provided token Embedding Module. Increasing the size will add newly initialized vectors at the end. Reducing the size will remove vectors from the end Args: old_embeddings (:obj:`torch.nn.Embedding`): Old embeddings to be resi...
Build a resized Embedding Module from a provided token Embedding Module. Increasing the size will add newly initialized vectors at the end. Reducing the size will remove vectors from the end
def _get_resized_embeddings( self, old_embeddings: torch.nn.Embedding, new_num_tokens: Optional[int] = None ) -> torch.nn.Embedding: """ Build a resized Embedding Module from a provided token Embedding Module. Increasing the size will add newly initialized vectors at the end. Reducin...
[ "def", "_get_resized_embeddings", "(", "self", ",", "old_embeddings", ":", "torch", ".", "nn", ".", "Embedding", ",", "new_num_tokens", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "torch", ".", "nn", ".", "Embedding", ":", "if", "new_num_toke...
[ 644, 4 ]
[ 688, 29 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel._get_resized_lm_head
( self, old_lm_head: torch.nn.Linear, new_num_tokens: Optional[int] = None, transposed: Optional[bool] = False )
Build a resized Linear Module from a provided old Linear Module. Increasing the size will add newly initialized vectors at the end. Reducing the size will remove vectors from the end Args: old_lm_head (:obj:`torch.nn.Linear`): Old lm head liner layer to be resized. ...
Build a resized Linear Module from a provided old Linear Module. Increasing the size will add newly initialized vectors at the end. Reducing the size will remove vectors from the end
def _get_resized_lm_head( self, old_lm_head: torch.nn.Linear, new_num_tokens: Optional[int] = None, transposed: Optional[bool] = False ) -> torch.nn.Linear: """ Build a resized Linear Module from a provided old Linear Module. Increasing the size will add newly initialized vectors at ...
[ "def", "_get_resized_lm_head", "(", "self", ",", "old_lm_head", ":", "torch", ".", "nn", ".", "Linear", ",", "new_num_tokens", ":", "Optional", "[", "int", "]", "=", "None", ",", "transposed", ":", "Optional", "[", "bool", "]", "=", "False", ")", "->", ...
[ 690, 4 ]
[ 750, 26 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.init_weights
(self)
Initializes and prunes weights if needed.
Initializes and prunes weights if needed.
def init_weights(self): """ Initializes and prunes weights if needed. """ # Initialize weights self.apply(self._init_weights) # Prune heads if needed if self.config.pruned_heads: self.prune_heads(self.config.pruned_heads) # Tie weights if nee...
[ "def", "init_weights", "(", "self", ")", ":", "# Initialize weights", "self", ".", "apply", "(", "self", ".", "_init_weights", ")", "# Prune heads if needed", "if", "self", ".", "config", ".", "pruned_heads", ":", "self", ".", "prune_heads", "(", "self", ".", ...
[ 752, 4 ]
[ 764, 26 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.prune_heads
(self, heads_to_prune: Dict[int, List[int]])
Prunes heads of the base model. Arguments: heads_to_prune (:obj:`Dict[int, List[int]]`): Dictionary with keys being selected layer indices (:obj:`int`) and associated values being the list of heads to prune in said layer (list of :obj:`int`). For instance {1...
Prunes heads of the base model.
def prune_heads(self, heads_to_prune: Dict[int, List[int]]): """ Prunes heads of the base model. Arguments: heads_to_prune (:obj:`Dict[int, List[int]]`): Dictionary with keys being selected layer indices (:obj:`int`) and associated values being the list of ...
[ "def", "prune_heads", "(", "self", ",", "heads_to_prune", ":", "Dict", "[", "int", ",", "List", "[", "int", "]", "]", ")", ":", "# save new sets of pruned heads as union of previously stored pruned heads and newly pruned heads", "for", "layer", ",", "heads", "in", "he...
[ 766, 4 ]
[ 781, 52 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.save_pretrained
( self, save_directory: Union[str, os.PathLike], save_config: bool = True, state_dict: Optional[dict] = None, save_function: Callable = torch.save, )
Save a model and its configuration file to a directory, so that it can be re-loaded using the `:func:`~transformers.PreTrainedModel.from_pretrained`` class method. Arguments: save_directory (:obj:`str` or :obj:`os.PathLike`): Directory to which to save. Will be crea...
Save a model and its configuration file to a directory, so that it can be re-loaded using the `:func:`~transformers.PreTrainedModel.from_pretrained`` class method.
def save_pretrained( self, save_directory: Union[str, os.PathLike], save_config: bool = True, state_dict: Optional[dict] = None, save_function: Callable = torch.save, ): """ Save a model and its configuration file to a directory, so that it can be re-loaded us...
[ "def", "save_pretrained", "(", "self", ",", "save_directory", ":", "Union", "[", "str", ",", "os", ".", "PathLike", "]", ",", "save_config", ":", "bool", "=", "True", ",", "state_dict", ":", "Optional", "[", "dict", "]", "=", "None", ",", "save_function"...
[ 783, 4 ]
[ 836, 74 ]
python
en
['en', 'error', 'th']
False
PreTrainedModel.from_pretrained
(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], *model_args, **kwargs)
r""" Instantiate a pretrained pytorch model from a pre-trained model configuration. The model is set in evaluation mode by default using ``model.eval()`` (Dropout modules are deactivated). To train the model, you should first set it back in training mode with ``model.train()``. The war...
r""" Instantiate a pretrained pytorch model from a pre-trained model configuration.
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], *model_args, **kwargs): r""" Instantiate a pretrained pytorch model from a pre-trained model configuration. The model is set in evaluation mode by default using ``model.eval()`` (Dropout modules are deact...
[ "def", "from_pretrained", "(", "cls", ",", "pretrained_model_name_or_path", ":", "Optional", "[", "Union", "[", "str", ",", "os", ".", "PathLike", "]", "]", ",", "*", "model_args", ",", "*", "*", "kwargs", ")", ":", "config", "=", "kwargs", ".", "pop", ...
[ 839, 4 ]
[ 1199, 20 ]
python
cy
['en', 'cy', 'hi']
False
PoolerStartLogits.forward
( self, hidden_states: torch.FloatTensor, p_mask: Optional[torch.FloatTensor] = None )
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. p_mask (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len)`, `optional`): Mask for tokens at invalid positi...
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. p_mask (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len)`, `optional`): Mask for tokens at invalid positi...
def forward( self, hidden_states: torch.FloatTensor, p_mask: Optional[torch.FloatTensor] = None ) -> torch.FloatTensor: """ Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. ...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "FloatTensor", ",", "p_mask", ":", "Optional", "[", "torch", ".", "FloatTensor", "]", "=", "None", ")", "->", "torch", ".", "FloatTensor", ":", "x", "=", "self", ".", "dense", "(",...
[ 1241, 4 ]
[ 1263, 16 ]
python
en
['en', 'error', 'th']
False
PoolerEndLogits.forward
( self, hidden_states: torch.FloatTensor, start_states: Optional[torch.FloatTensor] = None, start_positions: Optional[torch.LongTensor] = None, p_mask: Optional[torch.FloatTensor] = None, )
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. start_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`, `optional`): The hidden sta...
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. start_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`, `optional`): The hidden sta...
def forward( self, hidden_states: torch.FloatTensor, start_states: Optional[torch.FloatTensor] = None, start_positions: Optional[torch.LongTensor] = None, p_mask: Optional[torch.FloatTensor] = None, ) -> torch.FloatTensor: """ Args: hidden_states (...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "FloatTensor", ",", "start_states", ":", "Optional", "[", "torch", ".", "FloatTensor", "]", "=", "None", ",", "start_positions", ":", "Optional", "[", "torch", ".", "LongTensor", "]", ...
[ 1283, 4 ]
[ 1330, 16 ]
python
en
['en', 'error', 'th']
False
PoolerAnswerClass.forward
( self, hidden_states: torch.FloatTensor, start_states: Optional[torch.FloatTensor] = None, start_positions: Optional[torch.LongTensor] = None, cls_index: Optional[torch.LongTensor] = None, )
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. start_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`, `optional`): The hidden sta...
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): The final hidden states of the model. start_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`, `optional`): The hidden sta...
def forward( self, hidden_states: torch.FloatTensor, start_states: Optional[torch.FloatTensor] = None, start_positions: Optional[torch.LongTensor] = None, cls_index: Optional[torch.LongTensor] = None, ) -> torch.FloatTensor: """ Args: hidden_states...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "FloatTensor", ",", "start_states", ":", "Optional", "[", "torch", ".", "FloatTensor", "]", "=", "None", ",", "start_positions", ":", "Optional", "[", "torch", ".", "LongTensor", "]", ...
[ 1348, 4 ]
[ 1393, 16 ]
python
en
['en', 'error', 'th']
False
SQuADHead.forward
( self, hidden_states: torch.FloatTensor, start_positions: Optional[torch.LongTensor] = None, end_positions: Optional[torch.LongTensor] = None, cls_index: Optional[torch.LongTensor] = None, is_impossible: Optional[torch.LongTensor] = None, p_mask: Optional[torch.F...
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): Final hidden states of the model on the sequence tokens. start_positions (:obj:`torch.LongTensor` of shape :obj:`(batch_size,)`, `optional`): Positions of t...
Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, seq_len, hidden_size)`): Final hidden states of the model on the sequence tokens. start_positions (:obj:`torch.LongTensor` of shape :obj:`(batch_size,)`, `optional`): Positions of t...
def forward( self, hidden_states: torch.FloatTensor, start_positions: Optional[torch.LongTensor] = None, end_positions: Optional[torch.LongTensor] = None, cls_index: Optional[torch.LongTensor] = None, is_impossible: Optional[torch.LongTensor] = None, p_mask: Optio...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "FloatTensor", ",", "start_positions", ":", "Optional", "[", "torch", ".", "LongTensor", "]", "=", "None", ",", "end_positions", ":", "Optional", "[", "torch", ".", "LongTensor", "]", ...
[ 1447, 4 ]
[ 1541, 17 ]
python
en
['en', 'error', 'th']
False
SequenceSummary.forward
( self, hidden_states: torch.FloatTensor, cls_index: Optional[torch.LongTensor] = None )
Compute a single vector summary of a sequence hidden states. Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`[batch_size, seq_len, hidden_size]`): The hidden states of the last layer. cls_index (:obj:`torch.LongTensor` of shape :obj:`[batch_size]` o...
Compute a single vector summary of a sequence hidden states.
def forward( self, hidden_states: torch.FloatTensor, cls_index: Optional[torch.LongTensor] = None ) -> torch.FloatTensor: """ Compute a single vector summary of a sequence hidden states. Args: hidden_states (:obj:`torch.FloatTensor` of shape :obj:`[batch_size, seq_len, h...
[ "def", "forward", "(", "self", ",", "hidden_states", ":", "torch", ".", "FloatTensor", ",", "cls_index", ":", "Optional", "[", "torch", ".", "LongTensor", "]", "=", "None", ")", "->", "torch", ".", "FloatTensor", ":", "if", "self", ".", "summary_type", "...
[ 1601, 4 ]
[ 1643, 21 ]
python
en
['en', 'error', 'th']
False
test_air_quality
(hass)
Test states of the air_quality.
Test states of the air_quality.
async def test_air_quality(hass): """Test states of the air_quality.""" await init_integration(hass) registry = await hass.helpers.entity_registry.async_get_registry() state = hass.states.get("air_quality.home") assert state assert state.state == "4" assert state.attributes.get(ATTR_ATTRIBU...
[ "async", "def", "test_air_quality", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "state", "=", "hass", ".", "states", ".",...
[ 31, 0 ]
[ 56, 33 ]
python
en
['en', 'en', 'en']
True
test_air_quality_with_incomplete_data
(hass)
Test states of the air_quality with incomplete data from measuring station.
Test states of the air_quality with incomplete data from measuring station.
async def test_air_quality_with_incomplete_data(hass): """Test states of the air_quality with incomplete data from measuring station.""" await init_integration(hass, incomplete_data=True) registry = await hass.helpers.entity_registry.async_get_registry() state = hass.states.get("air_quality.home") ...
[ "async", "def", "test_air_quality_with_incomplete_data", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ",", "incomplete_data", "=", "True", ")", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", ...
[ 59, 0 ]
[ 84, 33 ]
python
en
['en', 'en', 'en']
True
test_availability
(hass)
Ensure that we mark the entities unavailable correctly when service causes an error.
Ensure that we mark the entities unavailable correctly when service causes an error.
async def test_availability(hass): """Ensure that we mark the entities unavailable correctly when service causes an error.""" await init_integration(hass) state = hass.states.get("air_quality.home") assert state assert state.state != STATE_UNAVAILABLE assert state.state == "4" future = utc...
[ "async", "def", "test_availability", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"air_quality.home\"", ")", "assert", "state", "assert", "state", ".", "state", "!=", "STATE_UNA...
[ 87, 0 ]
[ 122, 33 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the sensor platform.
Set up the sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the sensor platform.""" api_connector = OpenERZConnector(config[CONF_ZIP], config[CONF_WASTE_TYPE]) add_entities([OpenERZSensor(api_connector, config.get(CONF_NAME))], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "api_connector", "=", "OpenERZConnector", "(", "config", "[", "CONF_ZIP", "]", ",", "config", "[", "CONF_WASTE_TYPE", "]", ")", "add_entitie...
[ 25, 0 ]
[ 28, 77 ]
python
en
['en', 'da', 'en']
True
OpenERZSensor.__init__
(self, api_connector, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, api_connector, name): """Initialize the sensor.""" self._state = None self._name = name self.api_connector = api_connector
[ "def", "__init__", "(", "self", ",", "api_connector", ",", "name", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_name", "=", "name", "self", ".", "api_connector", "=", "api_connector" ]
[ 34, 4 ]
[ 38, 42 ]
python
en
['en', 'en', 'en']
True
OpenERZSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 41, 4 ]
[ 43, 25 ]
python
en
['en', 'mi', 'en']
True
OpenERZSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 46, 4 ]
[ 48, 26 ]
python
en
['en', 'en', 'en']
True
OpenERZSensor.update
(self)
Fetch new state data for the sensor. This is the only method that should fetch new data for Home Assistant.
Fetch new state data for the sensor.
def update(self): """Fetch new state data for the sensor. This is the only method that should fetch new data for Home Assistant. """ self._state = self.api_connector.find_next_pickup(day_offset=31)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "api_connector", ".", "find_next_pickup", "(", "day_offset", "=", "31", ")" ]
[ 50, 4 ]
[ 55, 72 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up from config entry.
Set up from config entry.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up from config entry.""" router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]] entities: List[Entity] = [] if router.data.ge...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None...
[ 28, 0 ]
[ 46, 38 ]
python
en
['en', 'en', 'en']
True
HuaweiLteBaseWifiStatusBinarySensor.is_on
(self)
Return whether the binary sensor is on.
Return whether the binary sensor is on.
def is_on(self) -> bool: """Return whether the binary sensor is on.""" return self._raw_state is not None and int(self._raw_state) == 1
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_raw_state", "is", "not", "None", "and", "int", "(", "self", ".", "_raw_state", ")", "==", "1" ]
[ 160, 4 ]
[ 162, 72 ]
python
en
['en', 'ig', 'en']
True
HuaweiLteBaseWifiStatusBinarySensor.assumed_state
(self)
Return True if real state is assumed, not known.
Return True if real state is assumed, not known.
def assumed_state(self) -> bool: """Return True if real state is assumed, not known.""" return self._raw_state is None
[ "def", "assumed_state", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_raw_state", "is", "None" ]
[ 165, 4 ]
[ 167, 38 ]
python
en
['en', 'en', 'en']
True
HuaweiLteBaseWifiStatusBinarySensor.icon
(self)
Return WiFi status sensor icon.
Return WiFi status sensor icon.
def icon(self) -> str: """Return WiFi status sensor icon.""" return "mdi:wifi" if self.is_on else "mdi:wifi-off"
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "\"mdi:wifi\"", "if", "self", ".", "is_on", "else", "\"mdi:wifi-off\"" ]
[ 170, 4 ]
[ 172, 59 ]
python
en
['en', 'eo', 'en']
True
DistillHeadCIFAR.__init__
(self, C, size, num_classes, bn_affine=False)
assuming input size 8x8 or 16x16
assuming input size 8x8 or 16x16
def __init__(self, C, size, num_classes, bn_affine=False): """assuming input size 8x8 or 16x16""" super(DistillHeadCIFAR, self).__init__() self.features = nn.Sequential( nn.ReLU(), nn.AvgPool2d(size, stride=2, padding=0, count_include_pad=False), # image size = 2 x 2 / 6...
[ "def", "__init__", "(", "self", ",", "C", ",", "size", ",", "num_classes", ",", "bn_affine", "=", "False", ")", ":", "super", "(", "DistillHeadCIFAR", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "features", "=", "nn", ".", "Sequential", ...
[ 8, 4 ]
[ 22, 42 ]
python
en
['en', 'su', 'en']
True
DistillHeadImagenet.__init__
(self, C, size, num_classes, bn_affine=False)
assuming input size 7x7 or 14x14
assuming input size 7x7 or 14x14
def __init__(self, C, size, num_classes, bn_affine=False): """assuming input size 7x7 or 14x14""" super(DistillHeadImagenet, self).__init__() self.features = nn.Sequential( nn.ReLU(), nn.AvgPool2d(size, stride=2, padding=0, count_include_pad=False), # image size = 2 x 2 ...
[ "def", "__init__", "(", "self", ",", "C", ",", "size", ",", "num_classes", ",", "bn_affine", "=", "False", ")", ":", "super", "(", "DistillHeadImagenet", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "features", "=", "nn", ".", "Sequential"...
[ 33, 4 ]
[ 47, 42 ]
python
en
['en', 'su', 'en']
True
AuxiliaryHeadCIFAR.__init__
(self, C, size=5, num_classes=10)
assuming input size 8x8
assuming input size 8x8
def __init__(self, C, size=5, num_classes=10): """assuming input size 8x8""" super(AuxiliaryHeadCIFAR, self).__init__() self.features = nn.Sequential( nn.ReLU(inplace=True), nn.AvgPool2d(5, stride=3, padding=0, count_include_pad=False), # image size = 2 x 2 n...
[ "def", "__init__", "(", "self", ",", "C", ",", "size", "=", "5", ",", "num_classes", "=", "10", ")", ":", "super", "(", "AuxiliaryHeadCIFAR", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "features", "=", "nn", ".", "Sequential", "(", "...
[ 58, 4 ]
[ 71, 53 ]
python
en
['en', 'su', 'en']
True
AuxiliaryHeadImageNet.__init__
(self, C, size=5, num_classes=1000)
assuming input size 7x7
assuming input size 7x7
def __init__(self, C, size=5, num_classes=1000): """assuming input size 7x7""" super(AuxiliaryHeadImageNet, self).__init__() self.features = nn.Sequential( nn.ReLU(inplace=True), nn.AvgPool2d(size, stride=2, padding=0, count_include_pad=False), nn.Conv2d(C, 12...
[ "def", "__init__", "(", "self", ",", "C", ",", "size", "=", "5", ",", "num_classes", "=", "1000", ")", ":", "super", "(", "AuxiliaryHeadImageNet", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "features", "=", "nn", ".", "Sequential", "("...
[ 81, 4 ]
[ 96, 53 ]
python
en
['en', 'su', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if user_input is not None: return self.async_create_entry(title=DEFAULT_NAME, data={}) re...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"single_instance_allowed\"", ")", "if", "user_inpu...
[ 15, 4 ]
[ 23, 79 ]
python
en
['en', 'en', 'en']
True
NZBGetDataUpdateCoordinator.__init__
(self, hass: HomeAssistantType, *, config: dict, options: dict)
Initialize global NZBGet data updater.
Initialize global NZBGet data updater.
def __init__(self, hass: HomeAssistantType, *, config: dict, options: dict): """Initialize global NZBGet data updater.""" self.nzbget = NZBGetAPI( config[CONF_HOST], config.get(CONF_USERNAME), config.get(CONF_PASSWORD), config[CONF_SSL], config...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "*", ",", "config", ":", "dict", ",", "options", ":", "dict", ")", ":", "self", ".", "nzbget", "=", "NZBGetAPI", "(", "config", "[", "CONF_HOST", "]", ",", "config", ".", "ge...
[ 27, 4 ]
[ 48, 9 ]
python
en
['fr', 'en', 'nl']
False
NZBGetDataUpdateCoordinator._check_completed_downloads
(self, history)
Check history for newly completed downloads.
Check history for newly completed downloads.
def _check_completed_downloads(self, history): """Check history for newly completed downloads.""" actual_completed_downloads = { (x["Name"], x["Category"], x["Status"]) for x in history } if self._completed_downloads_init: tmp_completed_downloads = list( ...
[ "def", "_check_completed_downloads", "(", "self", ",", "history", ")", ":", "actual_completed_downloads", "=", "{", "(", "x", "[", "\"Name\"", "]", ",", "x", "[", "\"Category\"", "]", ",", "x", "[", "\"Status\"", "]", ")", "for", "x", "in", "history", "}...
[ 50, 4 ]
[ 72, 45 ]
python
en
['en', 'en', 'en']
True
NZBGetDataUpdateCoordinator._async_update_data
(self)
Fetch data from NZBGet.
Fetch data from NZBGet.
async def _async_update_data(self) -> dict: """Fetch data from NZBGet.""" def _update_data() -> dict: """Fetch data from NZBGet via sync functions.""" status = self.nzbget.status() history = self.nzbget.history() self._check_completed_downloads(history) ...
[ "async", "def", "_async_update_data", "(", "self", ")", "->", "dict", ":", "def", "_update_data", "(", ")", "->", "dict", ":", "\"\"\"Fetch data from NZBGet via sync functions.\"\"\"", "status", "=", "self", ".", "nzbget", ".", "status", "(", ")", "history", "="...
[ 74, 4 ]
[ 93, 80 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Schluter component.
Set up the Schluter component.
def setup(hass, config): """Set up the Schluter component.""" _LOGGER.debug("Starting setup of schluter") conf = config[DOMAIN] api_http_session = Session() api = Api(timeout=API_TIMEOUT, http_session=api_http_session) authenticator = Authenticator( api, conf.get(CONF_USERNAME)...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "_LOGGER", ".", "debug", "(", "\"Starting setup of schluter\"", ")", "conf", "=", "config", "[", "DOMAIN", "]", "api_http_session", "=", "Session", "(", ")", "api", "=", "Api", "(", "timeout", "=", "A...
[ 33, 0 ]
[ 72, 16 ]
python
en
['en', 'en', 'en']
True
events
(hass)
Fixture that catches alexa events.
Fixture that catches alexa events.
def events(hass): """Fixture that catches alexa events.""" events = [] hass.bus.async_listen( smart_home.EVENT_ALEXA_SMART_HOME, callback(lambda e: events.append(e)) ) yield events
[ "def", "events", "(", "hass", ")", ":", "events", "=", "[", "]", "hass", ".", "bus", ".", "async_listen", "(", "smart_home", ".", "EVENT_ALEXA_SMART_HOME", ",", "callback", "(", "lambda", "e", ":", "events", ".", "append", "(", "e", ")", ")", ")", "y...
[ 47, 0 ]
[ 53, 16 ]
python
en
['en', 'sr', 'en']
True
mock_camera
(hass)
Initialize a demo camera platform.
Initialize a demo camera platform.
async def mock_camera(hass): """Initialize a demo camera platform.""" assert await async_setup_component( hass, "camera", {camera.DOMAIN: {"platform": "demo"}} ) await hass.async_block_till_done()
[ "async", "def", "mock_camera", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"camera\"", ",", "{", "camera", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "\"demo\"", "}", "}", ")", "await", "hass", ".", "async_bloc...
[ 57, 0 ]
[ 62, 38 ]
python
en
['es', 'pt', 'en']
False
mock_stream
(hass)
Initialize a demo camera platform with streaming.
Initialize a demo camera platform with streaming.
async def mock_stream(hass): """Initialize a demo camera platform with streaming.""" assert await async_setup_component(hass, "stream", {"stream": {}}) await hass.async_block_till_done()
[ "async", "def", "mock_stream", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 66, 0 ]
[ 69, 38 ]
python
en
['en', 'en', 'en']
True
test_create_api_message_defaults
(hass)
Create a API message response of a request with defaults.
Create a API message response of a request with defaults.
def test_create_api_message_defaults(hass): """Create a API message response of a request with defaults.""" request = get_new_request("Alexa.PowerController", "TurnOn", "switch#xy") directive_header = request["directive"]["header"] directive = messages.AlexaDirective(request) msg = directive.respon...
[ "def", "test_create_api_message_defaults", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.PowerController\"", ",", "\"TurnOn\"", ",", "\"switch#xy\"", ")", "directive_header", "=", "request", "[", "\"directive\"", "]", "[", "\"header\"", "]", ...
[ 72, 0 ]
[ 94, 66 ]
python
en
['en', 'en', 'en']
True
test_create_api_message_special
()
Create a API message response of a request with non defaults.
Create a API message response of a request with non defaults.
def test_create_api_message_special(): """Create a API message response of a request with non defaults.""" request = get_new_request("Alexa.PowerController", "TurnOn") directive_header = request["directive"]["header"] directive_header.pop("correlationToken") directive = messages.AlexaDirective(reque...
[ "def", "test_create_api_message_special", "(", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.PowerController\"", ",", "\"TurnOn\"", ")", "directive_header", "=", "request", "[", "\"directive\"", "]", "[", "\"header\"", "]", "directive_header", ".", "pop",...
[ 97, 0 ]
[ 117, 32 ]
python
en
['en', 'en', 'en']
True
test_wrong_version
(hass)
Test with wrong version.
Test with wrong version.
async def test_wrong_version(hass): """Test with wrong version.""" msg = get_new_request("Alexa.PowerController", "TurnOn") msg["directive"]["header"]["payloadVersion"] = "2" with pytest.raises(AssertionError): await smart_home.async_handle_message(hass, DEFAULT_CONFIG, msg)
[ "async", "def", "test_wrong_version", "(", "hass", ")", ":", "msg", "=", "get_new_request", "(", "\"Alexa.PowerController\"", ",", "\"TurnOn\"", ")", "msg", "[", "\"directive\"", "]", "[", "\"header\"", "]", "[", "\"payloadVersion\"", "]", "=", "\"2\"", "with", ...
[ 120, 0 ]
[ 126, 72 ]
python
en
['en', 'en', 'en']
True
discovery_test
(device, hass, expected_endpoints=1)
Test alexa discovery request.
Test alexa discovery request.
async def discovery_test(device, hass, expected_endpoints=1): """Test alexa discovery request.""" request = get_new_request("Alexa.Discovery", "Discover") # setup test devices hass.states.async_set(*device) msg = await smart_home.async_handle_message(hass, DEFAULT_CONFIG, request) assert "eve...
[ "async", "def", "discovery_test", "(", "device", ",", "hass", ",", "expected_endpoints", "=", "1", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "# setup test devices", "hass", ".", "states", ".", "async_set", ...
[ 129, 0 ]
[ 150, 15 ]
python
en
['ro', 'en', 'en']
True
get_capability
(capabilities, capability_name, instance=None)
Search a set of capabilities for a specific one.
Search a set of capabilities for a specific one.
def get_capability(capabilities, capability_name, instance=None): """Search a set of capabilities for a specific one.""" for capability in capabilities: if instance and capability.get("instance") == instance: return capability if not instance and capability["interface"] == capability...
[ "def", "get_capability", "(", "capabilities", ",", "capability_name", ",", "instance", "=", "None", ")", ":", "for", "capability", "in", "capabilities", ":", "if", "instance", "and", "capability", ".", "get", "(", "\"instance\"", ")", "==", "instance", ":", ...
[ 153, 0 ]
[ 161, 15 ]
python
en
['en', 'en', 'en']
True
assert_endpoint_capabilities
(endpoint, *interfaces)
Assert the endpoint supports the given interfaces. Returns a set of capabilities, in case you want to assert more things about them.
Assert the endpoint supports the given interfaces.
def assert_endpoint_capabilities(endpoint, *interfaces): """Assert the endpoint supports the given interfaces. Returns a set of capabilities, in case you want to assert more things about them. """ capabilities = endpoint["capabilities"] supported = {feature["interface"] for feature in capabilit...
[ "def", "assert_endpoint_capabilities", "(", "endpoint", ",", "*", "interfaces", ")", ":", "capabilities", "=", "endpoint", "[", "\"capabilities\"", "]", "supported", "=", "{", "feature", "[", "\"interface\"", "]", "for", "feature", "in", "capabilities", "}", "as...
[ 164, 0 ]
[ 174, 23 ]
python
en
['en', 'en', 'en']
True
test_switch
(hass, events)
Test switch discovery.
Test switch discovery.
async def test_switch(hass, events): """Test switch discovery.""" device = ("switch.test", "on", {"friendly_name": "Test switch"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "switch#test" assert appliance["displayCategories"][0] == "SWITCH" assert appliance...
[ "async", "def", "test_switch", "(", "hass", ",", "events", ")", ":", "device", "=", "(", "\"switch.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test switch\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass...
[ 177, 0 ]
[ 194, 72 ]
python
en
['de', 'en', 'en']
True
test_outlet
(hass, events)
Test switch with device class outlet discovery.
Test switch with device class outlet discovery.
async def test_outlet(hass, events): """Test switch with device class outlet discovery.""" device = ( "switch.test", "on", {"friendly_name": "Test switch", "device_class": "outlet"}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "switch#t...
[ "async", "def", "test_outlet", "(", "hass", ",", "events", ")", ":", "device", "=", "(", "\"switch.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test switch\"", ",", "\"device_class\"", ":", "\"outlet\"", "}", ",", ")", "appliance", "=", "aw...
[ 197, 0 ]
[ 211, 5 ]
python
en
['en', 'en', 'en']
True
test_light
(hass)
Test light discovery.
Test light discovery.
async def test_light(hass): """Test light discovery.""" device = ("light.test_1", "on", {"friendly_name": "Test light 1"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "light#test_1" assert appliance["displayCategories"][0] == "LIGHT" assert appliance["friend...
[ "async", "def", "test_light", "(", "hass", ")", ":", "device", "=", "(", "\"light.test_1\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test light 1\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "asser...
[ 214, 0 ]
[ 228, 5 ]
python
en
['fr', 'en', 'en']
True
test_dimmable_light
(hass)
Test dimmable light discovery.
Test dimmable light discovery.
async def test_dimmable_light(hass): """Test dimmable light discovery.""" device = ( "light.test_2", "on", {"brightness": 128, "friendly_name": "Test light 2", "supported_features": 1}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "light...
[ "async", "def", "test_dimmable_light", "(", "hass", ")", ":", "device", "=", "(", "\"light.test_2\"", ",", "\"on\"", ",", "{", "\"brightness\"", ":", "128", ",", "\"friendly_name\"", ":", "\"Test light 2\"", ",", "\"supported_features\"", ":", "1", "}", ",", "...
[ 231, 0 ]
[ 264, 44 ]
python
en
['id', 'en', 'en']
True
test_color_light
(hass)
Test color light discovery.
Test color light discovery.
async def test_color_light(hass): """Test color light discovery.""" device = ( "light.test_3", "on", { "friendly_name": "Test light 3", "supported_features": 19, "min_mireds": 142, "color_temp": "333", }, ) appliance = await...
[ "async", "def", "test_color_light", "(", "hass", ")", ":", "device", "=", "(", "\"light.test_3\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test light 3\"", ",", "\"supported_features\"", ":", "19", ",", "\"min_mireds\"", ":", "142", ",", "\"color_t...
[ 267, 0 ]
[ 293, 5 ]
python
en
['ro', 'en', 'en']
True
test_script
(hass)
Test script discovery.
Test script discovery.
async def test_script(hass): """Test script discovery.""" device = ("script.test", "off", {"friendly_name": "Test script"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "script#test" assert appliance["displayCategories"][0] == "ACTIVITY_TRIGGER" assert applia...
[ "async", "def", "test_script", "(", "hass", ")", ":", "device", "=", "(", "\"script.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test script\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "asser...
[ 299, 0 ]
[ 316, 5 ]
python
en
['fr', 'en', 'en']
True
test_input_boolean
(hass)
Test input boolean discovery.
Test input boolean discovery.
async def test_input_boolean(hass): """Test input boolean discovery.""" device = ("input_boolean.test", "off", {"friendly_name": "Test input boolean"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "input_boolean#test" assert appliance["displayCategories"][0] == "...
[ "async", "def", "test_input_boolean", "(", "hass", ")", ":", "device", "=", "(", "\"input_boolean.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test input boolean\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "h...
[ 319, 0 ]
[ 333, 5 ]
python
en
['nl', 'en', 'en']
True
test_scene
(hass)
Test scene discovery.
Test scene discovery.
async def test_scene(hass): """Test scene discovery.""" device = ("scene.test", "off", {"friendly_name": "Test scene"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "scene#test" assert appliance["displayCategories"][0] == "SCENE_TRIGGER" assert appliance["fri...
[ "async", "def", "test_scene", "(", "hass", ")", ":", "device", "=", "(", "\"scene.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test scene\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "assert",...
[ 336, 0 ]
[ 351, 82 ]
python
en
['it', 'en', 'en']
True
test_fan
(hass)
Test fan discovery.
Test fan discovery.
async def test_fan(hass): """Test fan discovery.""" device = ("fan.test_1", "off", {"friendly_name": "Test fan 1"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "fan#test_1" assert appliance["displayCategories"][0] == "FAN" assert appliance["friendlyName"] ==...
[ "async", "def", "test_fan", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_1\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 1\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "assert", ...
[ 354, 0 ]
[ 368, 50 ]
python
en
['nl', 'fy', 'en']
False
test_variable_fan
(hass)
Test fan discovery. This one has variable speed.
Test fan discovery.
async def test_variable_fan(hass): """Test fan discovery. This one has variable speed. """ device = ( "fan.test_2", "off", { "friendly_name": "Test fan 2", "supported_features": 1, "speed_list": ["low", "medium", "high"], "speed": ...
[ "async", "def", "test_variable_fan", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_2\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 2\"", ",", "\"supported_features\"", ":", "1", ",", "\"speed_list\"", ":", "[", "\"low\"", ",", "\...
[ 371, 0 ]
[ 500, 5 ]
python
en
['nl', 'fy', 'en']
False
test_oscillating_fan
(hass)
Test oscillating fan with ToggleController.
Test oscillating fan with ToggleController.
async def test_oscillating_fan(hass): """Test oscillating fan with ToggleController.""" device = ( "fan.test_3", "off", {"friendly_name": "Test fan 3", "supported_features": 2}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "fan#test_3" ...
[ "async", "def", "test_oscillating_fan", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_3\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 3\"", ",", "\"supported_features\"", ":", "2", "}", ",", ")", "appliance", "=", "await", "disco...
[ 503, 0 ]
[ 558, 39 ]
python
en
['en', 'en', 'en']
True
test_direction_fan
(hass)
Test fan direction with modeController.
Test fan direction with modeController.
async def test_direction_fan(hass): """Test fan direction with modeController.""" device = ( "fan.test_4", "on", { "friendly_name": "Test fan 4", "supported_features": 4, "direction": "forward", }, ) appliance = await discovery_test(dev...
[ "async", "def", "test_direction_fan", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_4\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 4\"", ",", "\"supported_features\"", ":", "4", ",", "\"direction\"", ":", "\"forward\"", ",", "}", ...
[ 561, 0 ]
[ 664, 24 ]
python
en
['en', 'en', 'en']
True
test_fan_range
(hass)
Test fan speed with rangeController.
Test fan speed with rangeController.
async def test_fan_range(hass): """Test fan speed with rangeController.""" device = ( "fan.test_5", "off", { "friendly_name": "Test fan 5", "supported_features": 1, "speed_list": ["off", "low", "medium", "high", "turbo", 5, "warp_speed"], "...
[ "async", "def", "test_fan_range", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_5\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 5\"", ",", "\"supported_features\"", ":", "1", ",", "\"speed_list\"", ":", "[", "\"off\"", ",", "\"lo...
[ 667, 0 ]
[ 802, 5 ]
python
en
['en', 'fy', 'en']
True
test_fan_range_off
(hass)
Test fan range controller 0 turns_off fan.
Test fan range controller 0 turns_off fan.
async def test_fan_range_off(hass): """Test fan range controller 0 turns_off fan.""" device = ( "fan.test_6", "off", { "friendly_name": "Test fan 6", "supported_features": 1, "speed_list": ["off", "low", "medium", "high"], "speed": "high", ...
[ "async", "def", "test_fan_range_off", "(", "hass", ")", ":", "device", "=", "(", "\"fan.test_6\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test fan 6\"", ",", "\"supported_features\"", ":", "1", ",", "\"speed_list\"", ":", "[", "\"off\"", ",", "...
[ 805, 0 ]
[ 839, 5 ]
python
en
['sv', 'fy', 'en']
False
test_lock
(hass)
Test lock discovery.
Test lock discovery.
async def test_lock(hass): """Test lock discovery.""" device = ("lock.test", "off", {"friendly_name": "Test lock"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "lock#test" assert appliance["displayCategories"][0] == "SMARTLOCK" assert appliance["friendlyName...
[ "async", "def", "test_lock", "(", "hass", ")", ":", "device", "=", "(", "\"lock.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test lock\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "assert", ...
[ 842, 0 ]
[ 870, 44 ]
python
en
['en', 'en', 'en']
True
test_media_player
(hass)
Test media player discovery.
Test media player discovery.
async def test_media_player(hass): """Test media player discovery.""" device = ( "media_player.test", "off", { "friendly_name": "Test media player", "supported_features": SUPPORT_NEXT_TRACK | SUPPORT_PAUSE | SUPPORT_PLAY | SUPPO...
[ "async", "def", "test_media_player", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player\"", ",", "\"supported_features\"", ":", "SUPPORT_NEXT_TRACK", "|", "SUPPORT_PAUSE", "|", ...
[ 873, 0 ]
[ 1028, 5 ]
python
en
['fr', 'en', 'en']
True
test_media_player_power
(hass)
Test media player discovery with mapped on/off.
Test media player discovery with mapped on/off.
async def test_media_player_power(hass): """Test media player discovery with mapped on/off.""" device = ( "media_player.test", "off", { "friendly_name": "Test media player", "supported_features": 0xFA3F, "volume_level": 0.75, }, ) appli...
[ "async", "def", "test_media_player_power", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player\"", ",", "\"supported_features\"", ":", "0xFA3F", ",", "\"volume_level\"", ":", "0...
[ 1031, 0 ]
[ 1074, 5 ]
python
en
['en', 'en', 'en']
True
test_media_player_inputs
(hass)
Test media player discovery with source list inputs.
Test media player discovery with source list inputs.
async def test_media_player_inputs(hass): """Test media player discovery with source list inputs.""" device = ( "media_player.test", "on", { "friendly_name": "Test media player", "supported_features": SUPPORT_SELECT_SOURCE, "volume_level": 0.75, ...
[ "async", "def", "test_media_player_inputs", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player\"", ",", "\"supported_features\"", ":", "SUPPORT_SELECT_SOURCE", ",", "\"volume_level\...
[ 1077, 0 ]
[ 1178, 38 ]
python
en
['en', 'en', 'en']
True
test_media_player_no_supported_inputs
(hass)
Test media player discovery with no supported inputs.
Test media player discovery with no supported inputs.
async def test_media_player_no_supported_inputs(hass): """Test media player discovery with no supported inputs.""" device = ( "media_player.test_no_inputs", "off", { "friendly_name": "Test media player", "supported_features": SUPPORT_SELECT_SOURCE, "vo...
[ "async", "def", "test_media_player_no_supported_inputs", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test_no_inputs\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player\"", ",", "\"supported_features\"", ":", "SUPPORT_SELECT_SOURCE", ...
[ 1181, 0 ]
[ 1213, 5 ]
python
en
['en', 'en', 'en']
True
test_media_player_speaker
(hass)
Test media player with speaker interface.
Test media player with speaker interface.
async def test_media_player_speaker(hass): """Test media player with speaker interface.""" device = ( "media_player.test_speaker", "off", { "friendly_name": "Test media player speaker", "supported_features": SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, "v...
[ "async", "def", "test_media_player_speaker", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test_speaker\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player speaker\"", ",", "\"supported_features\"", ":", "SUPPORT_VOLUME_MUTE", "|", ...
[ 1216, 0 ]
[ 1286, 5 ]
python
en
['en', 'en', 'en']
True
test_media_player_step_speaker
(hass)
Test media player with step speaker interface.
Test media player with step speaker interface.
async def test_media_player_step_speaker(hass): """Test media player with step speaker interface.""" device = ( "media_player.test_step_speaker", "off", { "friendly_name": "Test media player step speaker", "supported_features": SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME...
[ "async", "def", "test_media_player_step_speaker", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test_step_speaker\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player step speaker\"", ",", "\"supported_features\"", ":", "SUPPORT_VOLUME_M...
[ 1289, 0 ]
[ 1351, 5 ]
python
en
['en', 'en', 'en']
True
test_media_player_seek
(hass)
Test media player seek capability.
Test media player seek capability.
async def test_media_player_seek(hass): """Test media player seek capability.""" device = ( "media_player.test_seek", "playing", { "friendly_name": "Test media player seek", "supported_features": SUPPORT_SEEK, "media_position": 300, # 5min ...
[ "async", "def", "test_media_player_seek", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test_seek\"", ",", "\"playing\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player seek\"", ",", "\"supported_features\"", ":", "SUPPORT_SEEK", ",", "\"media_pos...
[ 1354, 0 ]
[ 1438, 74 ]
python
en
['en', 'ig', 'en']
True
test_media_player_seek_error
(hass)
Test media player seek capability for media_position Error.
Test media player seek capability for media_position Error.
async def test_media_player_seek_error(hass): """Test media player seek capability for media_position Error.""" device = ( "media_player.test_seek", "playing", {"friendly_name": "Test media player seek", "supported_features": SUPPORT_SEEK}, ) await discovery_test(device, hass) ...
[ "async", "def", "test_media_player_seek_error", "(", "hass", ")", ":", "device", "=", "(", "\"media_player.test_seek\"", ",", "\"playing\"", ",", "{", "\"friendly_name\"", ":", "\"Test media player seek\"", ",", "\"supported_features\"", ":", "SUPPORT_SEEK", "}", ",", ...
[ 1441, 0 ]
[ 1466, 75 ]
python
en
['en', 'no', 'en']
True
test_alert
(hass)
Test alert discovery.
Test alert discovery.
async def test_alert(hass): """Test alert discovery.""" device = ("alert.test", "off", {"friendly_name": "Test alert"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "alert#test" assert appliance["displayCategories"][0] == "OTHER" assert appliance["friendlyNam...
[ "async", "def", "test_alert", "(", "hass", ")", ":", "device", "=", "(", "\"alert.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test alert\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "assert",...
[ 1469, 0 ]
[ 1483, 5 ]
python
en
['fr', 'en', 'en']
True
test_automation
(hass)
Test automation discovery.
Test automation discovery.
async def test_automation(hass): """Test automation discovery.""" device = ("automation.test", "off", {"friendly_name": "Test automation"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "automation#test" assert appliance["displayCategories"][0] == "ACTIVITY_TRIGGE...
[ "async", "def", "test_automation", "(", "hass", ")", ":", "device", "=", "(", "\"automation.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test automation\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", "...
[ 1486, 0 ]
[ 1500, 5 ]
python
en
['de', 'en', 'en']
True
test_group
(hass)
Test group discovery.
Test group discovery.
async def test_group(hass): """Test group discovery.""" device = ("group.test", "off", {"friendly_name": "Test group"}) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "group#test" assert appliance["displayCategories"][0] == "OTHER" assert appliance["friendlyNam...
[ "async", "def", "test_group", "(", "hass", ")", ":", "device", "=", "(", "\"group.test\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test group\"", "}", ")", "appliance", "=", "await", "discovery_test", "(", "device", ",", "hass", ")", "assert",...
[ 1503, 0 ]
[ 1517, 5 ]
python
en
['nl', 'en', 'en']
True
test_cover_position_range
(hass)
Test cover discovery and position using rangeController.
Test cover discovery and position using rangeController.
async def test_cover_position_range(hass): """Test cover discovery and position using rangeController.""" device = ( "cover.test_range", "open", { "friendly_name": "Test cover range", "device_class": "blind", "supported_features": 7, "posit...
[ "async", "def", "test_cover_position_range", "(", "hass", ")", ":", "device", "=", "(", "\"cover.test_range\"", ",", "\"open\"", ",", "{", "\"friendly_name\"", ":", "\"Test cover range\"", ",", "\"device_class\"", ":", "\"blind\"", ",", "\"supported_features\"", ":", ...
[ 1520, 0 ]
[ 1681, 5 ]
python
en
['en', 'en', 'en']
True
assert_percentage_changes
( hass, adjustments, namespace, name, endpoint, parameter, service, changed_parameter )
Assert an API request making percentage changes works. AdjustPercentage, AdjustBrightness, etc. are examples of such requests.
Assert an API request making percentage changes works.
async def assert_percentage_changes( hass, adjustments, namespace, name, endpoint, parameter, service, changed_parameter ): """Assert an API request making percentage changes works. AdjustPercentage, AdjustBrightness, etc. are examples of such requests. """ for result_volume, adjustment in adjustme...
[ "async", "def", "assert_percentage_changes", "(", "hass", ",", "adjustments", ",", "namespace", ",", "name", ",", "endpoint", ",", "parameter", ",", "service", ",", "changed_parameter", ")", ":", "for", "result_volume", ",", "adjustment", "in", "adjustments", ":...
[ 1684, 0 ]
[ 1696, 60 ]
python
en
['en', 'en', 'en']
True
assert_range_changes
( hass, adjustments, namespace, name, endpoint, service, changed_parameter, instance )
Assert an API request making range changes works. AdjustRangeValue are examples of such requests.
Assert an API request making range changes works.
async def assert_range_changes( hass, adjustments, namespace, name, endpoint, service, changed_parameter, instance ): """Assert an API request making range changes works. AdjustRangeValue are examples of such requests. """ for result_range, adjustment, delta_default in adjustments: payload ...
[ "async", "def", "assert_range_changes", "(", "hass", ",", "adjustments", ",", "namespace", ",", "name", ",", "endpoint", ",", "service", ",", "changed_parameter", ",", "instance", ")", ":", "for", "result_range", ",", "adjustment", ",", "delta_default", "in", ...
[ 1699, 0 ]
[ 1715, 59 ]
python
en
['en', 'en', 'en']
True
test_temp_sensor
(hass)
Test temperature sensor discovery.
Test temperature sensor discovery.
async def test_temp_sensor(hass): """Test temperature sensor discovery.""" device = ( "sensor.test_temp", "42", {"friendly_name": "Test Temp Sensor", "unit_of_measurement": TEMP_FAHRENHEIT}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "...
[ "async", "def", "test_temp_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"sensor.test_temp\"", ",", "\"42\"", ",", "{", "\"friendly_name\"", ":", "\"Test Temp Sensor\"", ",", "\"unit_of_measurement\"", ":", "TEMP_FAHRENHEIT", "}", ",", ")", "appliance", "=...
[ 1718, 0 ]
[ 1744, 5 ]
python
en
['es', 'en', 'en']
True
test_contact_sensor
(hass)
Test contact sensor discovery.
Test contact sensor discovery.
async def test_contact_sensor(hass): """Test contact sensor discovery.""" device = ( "binary_sensor.test_contact", "on", {"friendly_name": "Test Contact Sensor", "device_class": "door"}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "bina...
[ "async", "def", "test_contact_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_contact\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test Contact Sensor\"", ",", "\"device_class\"", ":", "\"door\"", "}", ",", ")", "appliance", ...
[ 1747, 0 ]
[ 1773, 84 ]
python
en
['da', 'en', 'en']
True
test_forced_contact_sensor
(hass)
Test contact sensor discovery with specified display_category.
Test contact sensor discovery with specified display_category.
async def test_forced_contact_sensor(hass): """Test contact sensor discovery with specified display_category.""" device = ( "binary_sensor.test_contact_forced", "on", {"friendly_name": "Test Contact Sensor With DisplayCategory"}, ) appliance = await discovery_test(device, hass) ...
[ "async", "def", "test_forced_contact_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_contact_forced\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test Contact Sensor With DisplayCategory\"", "}", ",", ")", "appliance", "=", "await",...
[ 1776, 0 ]
[ 1802, 84 ]
python
en
['en', 'en', 'en']
True
test_motion_sensor
(hass)
Test motion sensor discovery.
Test motion sensor discovery.
async def test_motion_sensor(hass): """Test motion sensor discovery.""" device = ( "binary_sensor.test_motion", "on", {"friendly_name": "Test Motion Sensor", "device_class": "motion"}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "binary...
[ "async", "def", "test_motion_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_motion\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test Motion Sensor\"", ",", "\"device_class\"", ":", "\"motion\"", "}", ",", ")", "appliance", "...
[ 1805, 0 ]
[ 1829, 79 ]
python
en
['nl', 'en', 'en']
True
test_forced_motion_sensor
(hass)
Test motion sensor discovery with specified display_category.
Test motion sensor discovery with specified display_category.
async def test_forced_motion_sensor(hass): """Test motion sensor discovery with specified display_category.""" device = ( "binary_sensor.test_motion_forced", "on", {"friendly_name": "Test Motion Sensor With DisplayCategory"}, ) appliance = await discovery_test(device, hass) ...
[ "async", "def", "test_forced_motion_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_motion_forced\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test Motion Sensor With DisplayCategory\"", "}", ",", ")", "appliance", "=", "await", ...
[ 1832, 0 ]
[ 1858, 84 ]
python
en
['en', 'en', 'en']
True
test_doorbell_sensor
(hass)
Test doorbell sensor discovery.
Test doorbell sensor discovery.
async def test_doorbell_sensor(hass): """Test doorbell sensor discovery.""" device = ( "binary_sensor.test_doorbell", "off", {"friendly_name": "Test Doorbell Sensor", "device_class": "occupancy"}, ) appliance = await discovery_test(device, hass) assert appliance["endpointId"...
[ "async", "def", "test_doorbell_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_doorbell\"", ",", "\"off\"", ",", "{", "\"friendly_name\"", ":", "\"Test Doorbell Sensor\"", ",", "\"device_class\"", ":", "\"occupancy\"", "}", ",", ")", "appli...
[ 1861, 0 ]
[ 1880, 61 ]
python
nl
['nl', 'nl', 'en']
True
test_unknown_sensor
(hass)
Test sensors of unknown quantities are not discovered.
Test sensors of unknown quantities are not discovered.
async def test_unknown_sensor(hass): """Test sensors of unknown quantities are not discovered.""" device = ( "sensor.test_sickness", "0.1", {"friendly_name": "Test Space Sickness Sensor", "unit_of_measurement": "garn"}, ) await discovery_test(device, hass, expected_endpoints=0)
[ "async", "def", "test_unknown_sensor", "(", "hass", ")", ":", "device", "=", "(", "\"sensor.test_sickness\"", ",", "\"0.1\"", ",", "{", "\"friendly_name\"", ":", "\"Test Space Sickness Sensor\"", ",", "\"unit_of_measurement\"", ":", "\"garn\"", "}", ",", ")", "await...
[ 1883, 0 ]
[ 1890, 60 ]
python
en
['en', 'en', 'en']
True
test_thermostat
(hass)
Test thermostat discovery.
Test thermostat discovery.
async def test_thermostat(hass): """Test thermostat discovery.""" hass.config.units.temperature_unit = TEMP_FAHRENHEIT device = ( "climate.test_thermostat", "cool", { "temperature": 70.0, "target_temp_high": 80.0, "target_temp_low": 60.0, ...
[ "async", "def", "test_thermostat", "(", "hass", ")", ":", "hass", ".", "config", ".", "units", ".", "temperature_unit", "=", "TEMP_FAHRENHEIT", "device", "=", "(", "\"climate.test_thermostat\"", ",", "\"cool\"", ",", "{", "\"temperature\"", ":", "70.0", ",", "...
[ 1893, 0 ]
[ 2152, 53 ]
python
en
['en', 'en', 'en']
True
test_exclude_filters
(hass)
Test exclusion filters.
Test exclusion filters.
async def test_exclude_filters(hass): """Test exclusion filters.""" request = get_new_request("Alexa.Discovery", "Discover") # setup test devices hass.states.async_set("switch.test", "on", {"friendly_name": "Test switch"}) hass.states.async_set("script.deny", "off", {"friendly_name": "Blocked scri...
[ "async", "def", "test_exclude_filters", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "# setup test devices", "hass", ".", "states", ".", "async_set", "(", "\"switch.test\"", ",", "\"on\"", ",", "{"...
[ 2155, 0 ]
[ 2179, 48 ]
python
en
['de', 'en', 'en']
True
test_include_filters
(hass)
Test inclusion filters.
Test inclusion filters.
async def test_include_filters(hass): """Test inclusion filters.""" request = get_new_request("Alexa.Discovery", "Discover") # setup test devices hass.states.async_set("switch.deny", "on", {"friendly_name": "Blocked switch"}) hass.states.async_set("script.deny", "off", {"friendly_name": "Blocked s...
[ "async", "def", "test_include_filters", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "# setup test devices", "hass", ".", "states", ".", "async_set", "(", "\"switch.deny\"", ",", "\"on\"", ",", "{"...
[ 2182, 0 ]
[ 2210, 48 ]
python
en
['en', 'en', 'en']
True
test_never_exposed_entities
(hass)
Test never exposed locks do not get discovered.
Test never exposed locks do not get discovered.
async def test_never_exposed_entities(hass): """Test never exposed locks do not get discovered.""" request = get_new_request("Alexa.Discovery", "Discover") # setup test devices hass.states.async_set("group.all_locks", "on", {"friendly_name": "Blocked locks"}) hass.states.async_set("group.allow", "...
[ "async", "def", "test_never_exposed_entities", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "# setup test devices", "hass", ".", "states", ".", "async_set", "(", "\"group.all_locks\"", ",", "\"on\"", ...
[ 2213, 0 ]
[ 2235, 48 ]
python
en
['br', 'en', 'en']
True
test_api_entity_not_exists
(hass)
Test api turn on process without entity.
Test api turn on process without entity.
async def test_api_entity_not_exists(hass): """Test api turn on process without entity.""" request = get_new_request("Alexa.PowerController", "TurnOn", "switch#test") call_switch = async_mock_service(hass, "switch", "turn_on") msg = await smart_home.async_handle_message(hass, DEFAULT_CONFIG, request) ...
[ "async", "def", "test_api_entity_not_exists", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.PowerController\"", ",", "\"TurnOn\"", ",", "\"switch#test\"", ")", "call_switch", "=", "async_mock_service", "(", "hass", ",", "\"switch\"", ",", "...
[ 2238, 0 ]
[ 2253, 55 ]
python
en
['en', 'en', 'en']
True
test_api_function_not_implemented
(hass)
Test api call that is not implemented to us.
Test api call that is not implemented to us.
async def test_api_function_not_implemented(hass): """Test api call that is not implemented to us.""" request = get_new_request("Alexa.HAHAAH", "Sweet") msg = await smart_home.async_handle_message(hass, DEFAULT_CONFIG, request) assert "event" in msg msg = msg["event"] assert msg["header"]["nam...
[ "async", "def", "test_api_function_not_implemented", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.HAHAAH\"", ",", "\"Sweet\"", ")", "msg", "=", "await", "smart_home", ".", "async_handle_message", "(", "hass", ",", "DEFAULT_CONFIG", ",", ...
[ 2256, 0 ]
[ 2266, 53 ]
python
en
['en', 'en', 'en']
True
test_api_accept_grant
(hass)
Test api AcceptGrant process.
Test api AcceptGrant process.
async def test_api_accept_grant(hass): """Test api AcceptGrant process.""" request = get_new_request("Alexa.Authorization", "AcceptGrant") # add payload request["directive"]["payload"] = { "grant": { "type": "OAuth2.AuthorizationCode", "code": "VGhpcyBpcyBhbiBhdXRob3Jpem...
[ "async", "def", "test_api_accept_grant", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Authorization\"", ",", "\"AcceptGrant\"", ")", "# add payload", "request", "[", "\"directive\"", "]", "[", "\"payload\"", "]", "=", "{", "\"grant\"", "...
[ 2269, 0 ]
[ 2289, 58 ]
python
ca
['fr', 'ca', 'en']
False
test_entity_config
(hass)
Test that we can configure things via entity config.
Test that we can configure things via entity config.
async def test_entity_config(hass): """Test that we can configure things via entity config.""" request = get_new_request("Alexa.Discovery", "Discover") hass.states.async_set("light.test_1", "on", {"friendly_name": "Test light 1"}) hass.states.async_set("scene.test_1", "scening", {"friendly_name": "Test...
[ "async", "def", "test_entity_config", "(", "hass", ")", ":", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "hass", ".", "states", ".", "async_set", "(", "\"light.test_1\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ...
[ 2292, 0 ]
[ 2329, 82 ]
python
en
['en', 'en', 'en']
True
test_logging_request
(hass, events)
Test that we log requests.
Test that we log requests.
async def test_logging_request(hass, events): """Test that we log requests.""" context = Context() request = get_new_request("Alexa.Discovery", "Discover") await smart_home.async_handle_message(hass, DEFAULT_CONFIG, request, context) # To trigger event listener await hass.async_block_till_done(...
[ "async", "def", "test_logging_request", "(", "hass", ",", "events", ")", ":", "context", "=", "Context", "(", ")", "request", "=", "get_new_request", "(", "\"Alexa.Discovery\"", ",", "\"Discover\"", ")", "await", "smart_home", ".", "async_handle_message", "(", "...
[ 2332, 0 ]
[ 2349, 35 ]
python
en
['en', 'en', 'en']
True
test_logging_request_with_entity
(hass, events)
Test that we log requests.
Test that we log requests.
async def test_logging_request_with_entity(hass, events): """Test that we log requests.""" context = Context() request = get_new_request("Alexa.PowerController", "TurnOn", "switch#xy") await smart_home.async_handle_message(hass, DEFAULT_CONFIG, request, context) # To trigger event listener awai...
[ "async", "def", "test_logging_request_with_entity", "(", "hass", ",", "events", ")", ":", "context", "=", "Context", "(", ")", "request", "=", "get_new_request", "(", "\"Alexa.PowerController\"", ",", "\"TurnOn\"", ",", "\"switch#xy\"", ")", "await", "smart_home", ...
[ 2352, 0 ]
[ 2371, 35 ]
python
en
['en', 'en', 'en']
True
test_disabled
(hass)
When enabled=False, everything fails.
When enabled=False, everything fails.
async def test_disabled(hass): """When enabled=False, everything fails.""" hass.states.async_set("switch.test", "on", {"friendly_name": "Test switch"}) request = get_new_request("Alexa.PowerController", "TurnOn", "switch#test") call_switch = async_mock_service(hass, "switch", "turn_on") msg = awai...
[ "async", "def", "test_disabled", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"switch.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test switch\"", "}", ")", "request", "=", "get_new_request", "(", "\"Alexa.PowerControl...
[ 2374, 0 ]
[ 2392, 57 ]
python
en
['en', 'en', 'en']
True
test_endpoint_good_health
(hass)
Test endpoint health reporting.
Test endpoint health reporting.
async def test_endpoint_good_health(hass): """Test endpoint health reporting.""" device = ( "binary_sensor.test_contact", "on", {"friendly_name": "Test Contact Sensor", "device_class": "door"}, ) await discovery_test(device, hass) properties = await reported_properties(hass, ...
[ "async", "def", "test_endpoint_good_health", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_contact\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test Contact Sensor\"", ",", "\"device_class\"", ":", "\"door\"", "}", ",", ")", "await", ...
[ 2395, 0 ]
[ 2404, 84 ]
python
en
['nl', 'en', 'en']
True
test_endpoint_bad_health
(hass)
Test endpoint health reporting.
Test endpoint health reporting.
async def test_endpoint_bad_health(hass): """Test endpoint health reporting.""" device = ( "binary_sensor.test_contact", "unavailable", {"friendly_name": "Test Contact Sensor", "device_class": "door"}, ) await discovery_test(device, hass) properties = await reported_propertie...
[ "async", "def", "test_endpoint_bad_health", "(", "hass", ")", ":", "device", "=", "(", "\"binary_sensor.test_contact\"", ",", "\"unavailable\"", ",", "{", "\"friendly_name\"", ":", "\"Test Contact Sensor\"", ",", "\"device_class\"", ":", "\"door\"", "}", ",", ")", "...
[ 2407, 0 ]
[ 2418, 5 ]
python
en
['nl', 'en', 'en']
True
test_alarm_control_panel_disarmed
(hass)
Test alarm_control_panel discovery.
Test alarm_control_panel discovery.
async def test_alarm_control_panel_disarmed(hass): """Test alarm_control_panel discovery.""" device = ( "alarm_control_panel.test_1", "disarmed", { "friendly_name": "Test Alarm Control Panel 1", "code_arm_required": False, "code_format": "number", ...
[ "async", "def", "test_alarm_control_panel_disarmed", "(", "hass", ")", ":", "device", "=", "(", "\"alarm_control_panel.test_1\"", ",", "\"disarmed\"", ",", "{", "\"friendly_name\"", ":", "\"Test Alarm Control Panel 1\"", ",", "\"code_arm_required\"", ":", "False", ",", ...
[ 2421, 0 ]
[ 2490, 87 ]
python
en
['tr', 'en', 'en']
True