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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_entity_debug_info_message | (hass, mqtt_mock) | Test MQTT debug info. | Test MQTT debug info. | async def test_entity_debug_info_message(hass, mqtt_mock):
"""Test MQTT debug info."""
await help_test_entity_debug_info_message(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"fan",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
765,
0
] | [
769,
5
] | python | es | ['es', 'mt', 'it'] | False |
Mutator.sample_search | (self) |
Override to implement this method to iterate over mutables and make decisions.
Returns
-------
dict
A mapping from key of mutables to decisions.
|
Override to implement this method to iterate over mutables and make decisions. | def sample_search(self):
"""
Override to implement this method to iterate over mutables and make decisions.
Returns
-------
dict
A mapping from key of mutables to decisions.
"""
raise NotImplementedError | [
"def",
"sample_search",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
23,
4
] | [
32,
33
] | python | en | ['en', 'error', 'th'] | False |
Mutator.sample_final | (self) |
Override to implement this method to iterate over mutables and make decisions that is final
for export and retraining.
Returns
-------
dict
A mapping from key of mutables to decisions.
|
Override to implement this method to iterate over mutables and make decisions that is final
for export and retraining. | def sample_final(self):
"""
Override to implement this method to iterate over mutables and make decisions that is final
for export and retraining.
Returns
-------
dict
A mapping from key of mutables to decisions.
"""
raise NotImplementedError | [
"def",
"sample_final",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
34,
4
] | [
44,
33
] | python | en | ['en', 'error', 'th'] | False |
Mutator.reset | (self) |
Reset the mutator by call the `sample_search` to resample (for search). Stores the result in a local
variable so that `on_forward_layer_choice` and `on_forward_input_choice` can use the decision directly.
|
Reset the mutator by call the `sample_search` to resample (for search). Stores the result in a local
variable so that `on_forward_layer_choice` and `on_forward_input_choice` can use the decision directly.
| def reset(self):
"""
Reset the mutator by call the `sample_search` to resample (for search). Stores the result in a local
variable so that `on_forward_layer_choice` and `on_forward_input_choice` can use the decision directly.
"""
self._cache = self.sample_search() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_cache",
"=",
"self",
".",
"sample_search",
"(",
")"
] | [
46,
4
] | [
51,
42
] | python | en | ['en', 'error', 'th'] | False |
Mutator.export | (self) |
Resample (for final) and return results.
Returns
-------
dict
A mapping from key of mutables to decisions.
|
Resample (for final) and return results. | def export(self):
"""
Resample (for final) and return results.
Returns
-------
dict
A mapping from key of mutables to decisions.
"""
sampled = self.sample_final()
result = dict()
for mutable in self.mutables:
if not isinsta... | [
"def",
"export",
"(",
"self",
")",
":",
"sampled",
"=",
"self",
".",
"sample_final",
"(",
")",
"result",
"=",
"dict",
"(",
")",
"for",
"mutable",
"in",
"self",
".",
"mutables",
":",
"if",
"not",
"isinstance",
"(",
"mutable",
",",
"(",
"LayerChoice",
... | [
53,
4
] | [
71,
21
] | python | en | ['en', 'error', 'th'] | False |
Mutator.status | (self) |
Return current selection status of mutator.
Returns
-------
dict
A mapping from key of mutables to decisions. All weights (boolean type and float type)
are converted into real number values. Numpy arrays and tensors are converted into list.
|
Return current selection status of mutator. | def status(self):
"""
Return current selection status of mutator.
Returns
-------
dict
A mapping from key of mutables to decisions. All weights (boolean type and float type)
are converted into real number values. Numpy arrays and tensors are converted int... | [
"def",
"status",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_cache",
".",
"items",
"(",
")",
":",
"if",
"torch",
".",
"is_tensor",
"(",
"v",
")",
":",
"v",
"=",
"v",
".",
"detach",
"(",
"... | [
73,
4
] | [
90,
19
] | python | en | ['en', 'error', 'th'] | False |
Mutator.graph | (self, inputs) |
Return model supernet graph.
Parameters
----------
inputs: tuple of tensor
Inputs that will be feeded into the network.
Returns
-------
dict
Containing ``node``, in Tensorboard GraphDef format.
Additional key ``mutable`` is a... |
Return model supernet graph. | def graph(self, inputs):
"""
Return model supernet graph.
Parameters
----------
inputs: tuple of tensor
Inputs that will be feeded into the network.
Returns
-------
dict
Containing ``node``, in Tensorboard GraphDef format.
... | [
"def",
"graph",
"(",
"self",
",",
"inputs",
")",
":",
"if",
"not",
"torch",
".",
"__version__",
".",
"startswith",
"(",
"\"1.4\"",
")",
":",
"logger",
".",
"warning",
"(",
"\"Graph is only tested with PyTorch 1.4. Other versions might not work.\"",
")",
"from",
"n... | [
92,
4
] | [
139,
21
] | python | en | ['en', 'error', 'th'] | False |
Mutator.on_forward_layer_choice | (self, mutable, *args, **kwargs) |
On default, this method retrieves the decision obtained previously, and select certain operations.
Only operations with non-zero weight will be executed. The results will be added to a list.
Then it will reduce the list of all tensor outputs with the policy specified in `mutable.reduction`.
... |
On default, this method retrieves the decision obtained previously, and select certain operations.
Only operations with non-zero weight will be executed. The results will be added to a list.
Then it will reduce the list of all tensor outputs with the policy specified in `mutable.reduction`. | def on_forward_layer_choice(self, mutable, *args, **kwargs):
"""
On default, this method retrieves the decision obtained previously, and select certain operations.
Only operations with non-zero weight will be executed. The results will be added to a list.
Then it will reduce the list of ... | [
"def",
"on_forward_layer_choice",
"(",
"self",
",",
"mutable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_connect_all",
":",
"return",
"self",
".",
"_all_connect_tensor_reduction",
"(",
"mutable",
".",
"reduction",
",",
"[",
... | [
141,
4
] | [
173,
67
] | python | en | ['en', 'error', 'th'] | False |
Mutator.on_forward_input_choice | (self, mutable, tensor_list) |
On default, this method retrieves the decision obtained previously, and select certain tensors.
Then it will reduce the list of all tensor outputs with the policy specified in `mutable.reduction`.
Parameters
----------
mutable : nni.nas.pytorch.mutables.InputChoice
... |
On default, this method retrieves the decision obtained previously, and select certain tensors.
Then it will reduce the list of all tensor outputs with the policy specified in `mutable.reduction`. | def on_forward_input_choice(self, mutable, tensor_list):
"""
On default, this method retrieves the decision obtained previously, and select certain tensors.
Then it will reduce the list of all tensor outputs with the policy specified in `mutable.reduction`.
Parameters
----------... | [
"def",
"on_forward_input_choice",
"(",
"self",
",",
"mutable",
",",
"tensor_list",
")",
":",
"if",
"self",
".",
"_connect_all",
":",
"return",
"self",
".",
"_all_connect_tensor_reduction",
"(",
"mutable",
".",
"reduction",
",",
"tensor_list",
")",
",",
"torch",
... | [
175,
4
] | [
199,
67
] | python | en | ['en', 'error', 'th'] | False |
Mutator._select_with_mask | (self, map_fn, candidates, mask) |
Select masked tensors and return a list of tensors.
Parameters
----------
map_fn : function
Convert candidates to target candidates. Can be simply identity.
candidates : list of torch.Tensor
Tensor list to apply the decision on.
mask : list-like ... |
Select masked tensors and return a list of tensors. | def _select_with_mask(self, map_fn, candidates, mask):
"""
Select masked tensors and return a list of tensors.
Parameters
----------
map_fn : function
Convert candidates to target candidates. Can be simply identity.
candidates : list of torch.Tensor
... | [
"def",
"_select_with_mask",
"(",
"self",
",",
"map_fn",
",",
"candidates",
",",
"mask",
")",
":",
"if",
"(",
"isinstance",
"(",
"mask",
",",
"list",
")",
"and",
"len",
"(",
"mask",
")",
">=",
"1",
"and",
"isinstance",
"(",
"mask",
"[",
"0",
"]",
",... | [
201,
4
] | [
232,
24
] | python | en | ['en', 'error', 'th'] | False |
Mutator._get_decision | (self, mutable) |
By default, this method checks whether `mutable.key` is already in the decision cache,
and returns the result without double-check.
Parameters
----------
mutable : Mutable
Returns
-------
object
|
By default, this method checks whether `mutable.key` is already in the decision cache,
and returns the result without double-check. | def _get_decision(self, mutable):
"""
By default, this method checks whether `mutable.key` is already in the decision cache,
and returns the result without double-check.
Parameters
----------
mutable : Mutable
Returns
-------
object
"""
... | [
"def",
"_get_decision",
"(",
"self",
",",
"mutable",
")",
":",
"if",
"mutable",
".",
"key",
"not",
"in",
"self",
".",
"_cache",
":",
"raise",
"ValueError",
"(",
"\"\\\"{}\\\" not found in decision cache.\"",
".",
"format",
"(",
"mutable",
".",
"key",
")",
")... | [
256,
4
] | [
273,
21
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info) | Set up Netgear LTE binary sensor devices. | Set up Netgear LTE binary sensor devices. | async def async_setup_platform(hass, config, async_add_entities, discovery_info):
"""Set up Netgear LTE binary sensor devices."""
if discovery_info is None:
return
modem_data = hass.data[DATA_KEY].get_modem_data(discovery_info)
if not modem_data or not modem_data.data:
raise PlatformNo... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"modem_data",
"=",
"hass",
".",
"data",
"[",
"DATA_KEY",
"]",
".",
"get_modem_d... | [
8,
0
] | [
25,
38
] | python | en | ['en', 'haw', 'en'] | True |
LTEBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return getattr(self.modem_data.data, self.sensor_type) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"modem_data",
".",
"data",
",",
"self",
".",
"sensor_type",
")"
] | [
32,
4
] | [
34,
62
] | python | en | ['en', 'fy', 'en'] | True |
LTEBinarySensor.device_class | (self) | Return the class of binary sensor. | Return the class of binary sensor. | def device_class(self):
"""Return the class of binary sensor."""
return BINARY_SENSOR_CLASSES[self.sensor_type] | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"BINARY_SENSOR_CLASSES",
"[",
"self",
".",
"sensor_type",
"]"
] | [
37,
4
] | [
39,
54
] | python | en | ['en', 'ku', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
26,
0
] | [
28,
57
] | python | en | ['en', 'en', 'en'] | True |
test_missing_optional_config | (hass, calls) | Test: missing optional template is ok. | Test: missing optional template is ok. | async def test_missing_optional_config(hass, calls):
"""Test: missing optional template is ok."""
with assert_setup_component(1, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "templat... | [
"async",
"def",
"test_missing_optional_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\... | [
32,
0
] | [
52,
38
] | python | en | ['en', 'en', 'en'] | True |
test_missing_start_config | (hass, calls) | Test: missing 'start' will fail. | Test: missing 'start' will fail. | async def test_missing_start_config(hass, calls):
"""Test: missing 'start' will fail."""
with assert_setup_component(0, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
... | [
"async",
"def",
"test_missing_start_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"va... | [
55,
0
] | [
73,
40
] | python | en | ['en', 'mt', 'en'] | True |
test_invalid_config | (hass, calls) | Test: invalid config structure will fail. | Test: invalid config structure will fail. | async def test_invalid_config(hass, calls):
"""Test: invalid config structure will fail."""
with assert_setup_component(0, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"platform": "template",
"vacuums": {
... | [
"async",
"def",
"test_invalid_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"platform... | [
76,
0
] | [
94,
40
] | python | en | ['en', 'en', 'en'] | True |
test_templates_with_entities | (hass, calls) | Test templates with values from other entities. | Test templates with values from other entities. | async def test_templates_with_entities(hass, calls):
"""Test templates with values from other entities."""
with assert_setup_component(1, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform":... | [
"async",
"def",
"test_templates_with_entities",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\... | [
101,
0
] | [
131,
38
] | python | en | ['en', 'en', 'en'] | True |
test_templates_with_valid_values | (hass, calls) | Test templates with valid values. | Test templates with valid values. | async def test_templates_with_valid_values(hass, calls):
"""Test templates with valid values."""
with assert_setup_component(1, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template... | [
"async",
"def",
"test_templates_with_valid_values",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
... | [
134,
0
] | [
158,
38
] | python | en | ['en', 'en', 'en'] | True |
test_templates_invalid_values | (hass, calls) | Test templates with invalid values. | Test templates with invalid values. | async def test_templates_invalid_values(hass, calls):
"""Test templates with invalid values."""
with assert_setup_component(1, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template"... | [
"async",
"def",
"test_templates_invalid_values",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"... | [
161,
0
] | [
185,
38
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_templates | (hass, calls) | Test invalid templates. | Test invalid templates. | async def test_invalid_templates(hass, calls):
"""Test invalid templates."""
with assert_setup_component(1, "vacuum"):
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
... | [
"async",
"def",
"test_invalid_templates",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"vacuum\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuu... | [
188,
0
] | [
213,
38
] | python | en | ['en', 'et', 'en'] | True |
test_available_template_with_entities | (hass, calls) | Test availability templates with values from other entities. | Test availability templates with values from other entities. | async def test_available_template_with_entities(hass, calls):
"""Test availability templates with values from other entities."""
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
"vacuums": {
... | [
"async",
"def",
"test_available_template_with_entities",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuum\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\... | [
216,
0
] | [
251,
84
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_availability_template_keeps_component_available | (hass, caplog) | Test that an invalid availability keeps the device available. | Test that an invalid availability keeps the device available. | async def test_invalid_availability_template_keeps_component_available(hass, caplog):
"""Test that an invalid availability keeps the device available."""
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
... | [
"async",
"def",
"test_invalid_availability_template_keeps_component_available",
"(",
"hass",
",",
"caplog",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuum\"",
":",
"{",
"\"platform\"",
":",
"\"... | [
254,
0
] | [
277,
62
] | python | en | ['en', 'en', 'en'] | True |
test_attribute_templates | (hass, calls) | Test attribute_templates template. | Test attribute_templates template. | async def test_attribute_templates(hass, calls):
"""Test attribute_templates template."""
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
"vacuums": {
"test_template_vacuum": {... | [
"async",
"def",
"test_attribute_templates",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuum\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"vacuums\"",
... | [
280,
0
] | [
314,
60
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_attribute_template | (hass, caplog) | Test that errors are logged if rendering template fails. | Test that errors are logged if rendering template fails. | async def test_invalid_attribute_template(hass, caplog):
"""Test that errors are logged if rendering template fails."""
assert await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
"vacuums": {
... | [
"async",
"def",
"test_invalid_attribute_template",
"(",
"hass",
",",
"caplog",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuum\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"vacu... | [
317,
0
] | [
344,
41
] | python | en | ['en', 'en', 'en'] | True |
test_state_services | (hass, calls) | Test state services. | Test state services. | async def test_state_services(hass, calls):
"""Test state services."""
await _register_components(hass)
# Start vacuum
await common.async_start(hass, _TEST_VACUUM)
await hass.async_block_till_done()
# verify
assert hass.states.get(_STATE_INPUT_SELECT).state == STATE_CLEANING
_verify(ha... | [
"async",
"def",
"test_state_services",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Start vacuum",
"await",
"common",
".",
"async_start",
"(",
"hass",
",",
"_TEST_VACUUM",
")",
"await",
"hass",
".",
"async_block_till... | [
351,
0
] | [
385,
40
] | python | en | ['en', 'en', 'en'] | True |
test_unused_services | (hass, calls) | Test calling unused services should not crash. | Test calling unused services should not crash. | async def test_unused_services(hass, calls):
"""Test calling unused services should not crash."""
await _register_basic_vacuum(hass)
# Pause vacuum
await common.async_pause(hass, _TEST_VACUUM)
await hass.async_block_till_done()
# Stop vacuum
await common.async_stop(hass, _TEST_VACUUM)
... | [
"async",
"def",
"test_unused_services",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_basic_vacuum",
"(",
"hass",
")",
"# Pause vacuum",
"await",
"common",
".",
"async_pause",
"(",
"hass",
",",
"_TEST_VACUUM",
")",
"await",
"hass",
".",
"async_block_t... | [
388,
0
] | [
416,
38
] | python | en | ['en', 'en', 'en'] | True |
test_clean_spot_service | (hass, calls) | Test clean spot service. | Test clean spot service. | async def test_clean_spot_service(hass, calls):
"""Test clean spot service."""
await _register_components(hass)
# Clean spot
await common.async_clean_spot(hass, _TEST_VACUUM)
await hass.async_block_till_done()
# verify
assert hass.states.get(_SPOT_CLEANING_INPUT_BOOLEAN).state == STATE_ON | [
"async",
"def",
"test_clean_spot_service",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Clean spot",
"await",
"common",
".",
"async_clean_spot",
"(",
"hass",
",",
"_TEST_VACUUM",
")",
"await",
"hass",
".",
"async_blo... | [
419,
0
] | [
428,
74
] | python | en | ['en', 'fr', 'en'] | True |
test_locate_service | (hass, calls) | Test locate service. | Test locate service. | async def test_locate_service(hass, calls):
"""Test locate service."""
await _register_components(hass)
# Locate vacuum
await common.async_locate(hass, _TEST_VACUUM)
await hass.async_block_till_done()
# verify
assert hass.states.get(_LOCATING_INPUT_BOOLEAN).state == STATE_ON | [
"async",
"def",
"test_locate_service",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Locate vacuum",
"await",
"common",
".",
"async_locate",
"(",
"hass",
",",
"_TEST_VACUUM",
")",
"await",
"hass",
".",
"async_block_ti... | [
431,
0
] | [
440,
69
] | python | en | ['en', 'co', 'en'] | True |
test_set_fan_speed | (hass, calls) | Test set valid fan speed. | Test set valid fan speed. | async def test_set_fan_speed(hass, calls):
"""Test set valid fan speed."""
await _register_components(hass)
# Set vacuum's fan speed to high
await common.async_set_fan_speed(hass, "high", _TEST_VACUUM)
await hass.async_block_till_done()
# verify
assert hass.states.get(_FAN_SPEED_INPUT_SELE... | [
"async",
"def",
"test_set_fan_speed",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Set vacuum's fan speed to high",
"await",
"common",
".",
"async_set_fan_speed",
"(",
"hass",
",",
"\"high\"",
",",
"_TEST_VACUUM",
")",
... | [
443,
0
] | [
459,
69
] | python | en | ['en', 'fy', 'nl'] | False |
test_set_invalid_fan_speed | (hass, calls) | Test set invalid fan speed when fan has valid speed. | Test set invalid fan speed when fan has valid speed. | async def test_set_invalid_fan_speed(hass, calls):
"""Test set invalid fan speed when fan has valid speed."""
await _register_components(hass)
# Set vacuum's fan speed to high
await common.async_set_fan_speed(hass, "high", _TEST_VACUUM)
await hass.async_block_till_done()
# verify
assert ha... | [
"async",
"def",
"test_set_invalid_fan_speed",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Set vacuum's fan speed to high",
"await",
"common",
".",
"async_set_fan_speed",
"(",
"hass",
",",
"\"high\"",
",",
"_TEST_VACUUM",
... | [
462,
0
] | [
478,
67
] | python | en | ['en', 'fy', 'en'] | True |
_verify | (hass, expected_state, expected_battery_level) | Verify vacuum's state and speed. | Verify vacuum's state and speed. | def _verify(hass, expected_state, expected_battery_level):
"""Verify vacuum's state and speed."""
state = hass.states.get(_TEST_VACUUM)
attributes = state.attributes
assert state.state == expected_state
assert attributes.get(ATTR_BATTERY_LEVEL) == expected_battery_level | [
"def",
"_verify",
"(",
"hass",
",",
"expected_state",
",",
"expected_battery_level",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"_TEST_VACUUM",
")",
"attributes",
"=",
"state",
".",
"attributes",
"assert",
"state",
".",
"state",
"==",
... | [
481,
0
] | [
486,
71
] | python | en | ['en', 'en', 'en'] | True |
_register_basic_vacuum | (hass) | Register basic vacuum with only required options for testing. | Register basic vacuum with only required options for testing. | async def _register_basic_vacuum(hass):
"""Register basic vacuum with only required options for testing."""
with assert_setup_component(1, "input_select"):
assert await setup.async_setup_component(
hass,
"input_select",
{"input_select": {"state": {"name": "State", "op... | [
"async",
"def",
"_register_basic_vacuum",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"input_select\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"input_select\"",
",",
"{",
"\"input_selec... | [
489,
0
] | [
522,
38
] | python | en | ['en', 'en', 'en'] | True |
_register_components | (hass) | Register basic components for testing. | Register basic components for testing. | async def _register_components(hass):
"""Register basic components for testing."""
with assert_setup_component(2, "input_boolean"):
assert await setup.async_setup_component(
hass,
"input_boolean",
{"input_boolean": {"spot_cleaning": None, "locating": None}},
)... | [
"async",
"def",
"_register_components",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"2",
",",
"\"input_boolean\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"input_boolean\"",
",",
"{",
"\"input_boole... | [
525,
0
] | [
612,
38
] | python | en | ['en', 'da', 'en'] | True |
test_unique_id | (hass) | Test unique_id option only creates one vacuum per id. | Test unique_id option only creates one vacuum per id. | async def test_unique_id(hass):
"""Test unique_id option only creates one vacuum per id."""
await setup.async_setup_component(
hass,
"vacuum",
{
"vacuum": {
"platform": "template",
"vacuums": {
"test_template_vacuum_01": {
... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"vacuum\"",
",",
"{",
"\"vacuum\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"vacuums\"",
":",
"{",
"\"test_template_vacuum_... | [
615,
0
] | [
643,
44
] | python | en | ['en', 'la', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Pilight platform. | Set up the Pilight platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Pilight platform."""
switches = config.get(CONF_SWITCHES)
devices = []
for dev_name, dev_config in switches.items():
devices.append(PilightSwitch(hass, dev_name, dev_config))
add_entities(devices) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"switches",
"=",
"config",
".",
"get",
"(",
"CONF_SWITCHES",
")",
"devices",
"=",
"[",
"]",
"for",
"dev_name",
",",
"dev_config",
"in",
... | [
14,
0
] | [
22,
25
] | python | en | ['en', 'lv', 'en'] | True |
RVdynamical.__init__ | (self, *args, **kwargs) | Orbital parameters to be used in the dynamical fit | Orbital parameters to be used in the dynamical fit | def __init__(self, *args, **kwargs):
super(RVdynamical, self).__init__(*args, **kwargs)
''' Orbital parameters to be used in the dynamical fit '''
self.list_pams_common = {
'P', # Period in days
'M', # Mass in Earth masses
'lN', # longitude of ascending no... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"RVdynamical",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"list_pams_common",
"=",
"{",
"'P'",
... | [
100,
4
] | [
113,
39
] | python | en | ['en', 'en', 'en'] | True |
TransitTimeDynamical.__init__ | (self, *args, **kwargs) | Orbital parameters to be used in the dynamical fit | Orbital parameters to be used in the dynamical fit | def __init__(self, *args, **kwargs):
super(TransitTimeDynamical, self).__init__(*args, **kwargs)
''' Orbital parameters to be used in the dynamical fit '''
self.list_pams_common = {
'P', # Period in days
'M', # Mass in Earth masses
'lN', # longitude o... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"TransitTimeDynamical",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"list_pams_common",
"=",
"{",
... | [
184,
4
] | [
203,
40
] | python | en | ['en', 'en', 'en'] | True |
DynamicalIntegrator.prepare | (self, mc) |
Prepare the input parameters according to chosen dynamical integrator
:param mc:
pcv:
:return:
|
Prepare the input parameters according to chosen dynamical integrator
:param mc:
pcv:
:return:
| def prepare(self, mc):
"""
Prepare the input parameters according to chosen dynamical integrator
:param mc:
pcv:
:return:
"""
if self.dynamical_integrator == 'TRADES':
try:
from pytrades_lib import pytrades
except Im... | [
"def",
"prepare",
"(",
"self",
",",
"mc",
")",
":",
"if",
"self",
".",
"dynamical_integrator",
"==",
"'TRADES'",
":",
"try",
":",
"from",
"pytrades_lib",
"import",
"pytrades",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: TRADES not installed, this will no... | [
240,
4
] | [
265,
14
] | python | en | ['en', 'error', 'th'] | False |
DynamicalIntegrator.compute | (self, mc, *args, **kwargs) |
Run the appropriate subroutine according to chosen dynamical integrator
:param mc:
:return:
|
Run the appropriate subroutine according to chosen dynamical integrator
:param mc:
:return:
| def compute(self, mc, *args, **kwargs):
"""
Run the appropriate subroutine according to chosen dynamical integrator
:param mc:
:return:
"""
if self.dynamical_integrator == 'TRADES':
output = self.compute_trades(mc, *args, **kwargs)
if self.dynamical_i... | [
"def",
"compute",
"(",
"self",
",",
"mc",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"dynamical_integrator",
"==",
"'TRADES'",
":",
"output",
"=",
"self",
".",
"compute_trades",
"(",
"mc",
",",
"*",
"args",
",",
"*",
"*... | [
267,
4
] | [
278,
21
] | python | en | ['en', 'error', 'th'] | False |
DynamicalIntegrator.prepare_trades | (self, mc) |
:param mc:
:return:
|
:param mc:
:return:
| def prepare_trades(self, mc):
"""
:param mc:
:return:
"""
dataset_rv = 0
int_buffer = dict(rv_times=[], t0_times=[], rv_ref=[], t0_ref=[], key_ref={})
""" Putting all the RV epochs in the same array, flagging in the temporary buffer
the stored values ... | [
"def",
"prepare_trades",
"(",
"self",
",",
"mc",
")",
":",
"dataset_rv",
"=",
"0",
"int_buffer",
"=",
"dict",
"(",
"rv_times",
"=",
"[",
"]",
",",
"t0_times",
"=",
"[",
"]",
",",
"rv_ref",
"=",
"[",
"]",
",",
"t0_ref",
"=",
"[",
"]",
",",
"key_re... | [
280,
4
] | [
425,
14
] | python | en | ['en', 'error', 'th'] | False |
DynamicalIntegrator.compute_trades | (self, mc, theta, x_input=None) | This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function | This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function | def compute_trades(self, mc, theta, x_input=None):
""" This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function"""
""... | [
"def",
"compute_trades",
"(",
"self",
",",
"mc",
",",
"theta",
",",
"x_input",
"=",
"None",
")",
":",
"\"\"\" setting up the dictionaries with the orbital parameters required by TRADES,\n \"\"\"",
"if",
"self",
".",
"to_be_initialized",
":",
"self",
".",
"prepare_t... | [
427,
4
] | [
590,
21
] | python | en | ['en', 'en', 'en'] | True |
DynamicalIntegrator.compute_ttvfast | (self, mc, theta, x_input=None) | This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function | This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function | def compute_ttvfast(self, mc, theta, x_input=None):
""" This function compute the expected TTV and RVs for dynamically interacting planets.
The user can specify which planets are subject to interactions, e.g. long-period planets can be approximated
with a Keplerian function"""
i... | [
"def",
"compute_ttvfast",
"(",
"self",
",",
"mc",
",",
"theta",
",",
"x_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"to_be_initialized",
":",
"self",
".",
"prepare_ttvfast",
"(",
"mc",
")",
"input_flag",
"=",
"0",
"n_plan",
"=",
"0",
"P_min",
"="... | [
646,
4
] | [
769,
21
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.__init__ | (self) | Initialize the Broadlink flow. | Initialize the Broadlink flow. | def __init__(self):
"""Initialize the Broadlink flow."""
self.device = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"device",
"=",
"None"
] | [
35,
4
] | [
37,
26
] | python | en | ['en', 'pl', 'en'] | True |
BroadlinkFlowHandler.async_set_device | (self, device, raise_on_progress=True) | Define a device for the config flow. | Define a device for the config flow. | async def async_set_device(self, device, raise_on_progress=True):
"""Define a device for the config flow."""
supported_types = {
device_type
for _, device_types in DOMAINS_AND_TYPES
for device_type in device_types
}
if device.type not in supported_type... | [
"async",
"def",
"async_set_device",
"(",
"self",
",",
"device",
",",
"raise_on_progress",
"=",
"True",
")",
":",
"supported_types",
"=",
"{",
"device_type",
"for",
"_",
",",
"device_types",
"in",
"DOMAINS_AND_TYPES",
"for",
"device_type",
"in",
"device_types",
"... | [
39,
4
] | [
64,
9
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.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 not None:
host = user_input[CONF_HOST]
timeout = user_input.get(CONF_TIMEOUT, DEFAULT_TIMEOUT)
try:
hello = partial(blk.... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"host",
"=",
"user_input",
"[",
"CONF_HOST",
"]",
"timeout",
"=",
"user_input",
".",
"get",
... | [
66,
4
] | [
126,
9
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.async_step_auth | (self) | Authenticate to the device. | Authenticate to the device. | async def async_step_auth(self):
"""Authenticate to the device."""
device = self.device
errors = {}
try:
await self.hass.async_add_executor_job(device.auth)
except AuthenticationError:
errors["base"] = "invalid_auth"
await self.async_set_uniq... | [
"async",
"def",
"async_step_auth",
"(",
"self",
")",
":",
"device",
"=",
"self",
".",
"device",
"errors",
"=",
"{",
"}",
"try",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"device",
".",
"auth",
")",
"except",
"AuthenticationErro... | [
128,
4
] | [
177,
66
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.async_step_reset | (self, user_input=None, errors=None) | Guide the user to unlock the device manually.
We are unable to authenticate because the device is locked.
The user needs to open the Broadlink app and unlock the device.
| Guide the user to unlock the device manually. | async def async_step_reset(self, user_input=None, errors=None):
"""Guide the user to unlock the device manually.
We are unable to authenticate because the device is locked.
The user needs to open the Broadlink app and unlock the device.
"""
device = self.device
if user_... | [
"async",
"def",
"async_step_reset",
"(",
"self",
",",
"user_input",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"device",
"=",
"self",
".",
"device",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
... | [
179,
4
] | [
200,
9
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.async_step_unlock | (self, user_input=None) | Unlock the device.
The authentication succeeded, but the device is locked.
We can offer an unlock to prevent authorization errors.
| Unlock the device. | async def async_step_unlock(self, user_input=None):
"""Unlock the device.
The authentication succeeded, but the device is locked.
We can offer an unlock to prevent authorization errors.
"""
device = self.device
errors = {}
if user_input is None:
pass... | [
"async",
"def",
"async_step_unlock",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"device",
"=",
"self",
".",
"device",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"None",
":",
"pass",
"elif",
"user_input",
"[",
"\"unlock\"",
"]",
":",
... | [
202,
4
] | [
254,
9
] | python | en | ['en', 'zh', 'en'] | True |
BroadlinkFlowHandler.async_step_finish | (self, user_input=None) | Choose a name for the device and create config entry. | Choose a name for the device and create config entry. | async def async_step_finish(self, user_input=None):
"""Choose a name for the device and create config entry."""
device = self.device
errors = {}
# Abort reauthentication flow.
self._abort_if_unique_id_configured(
updates={CONF_HOST: device.host[0], CONF_TIMEOUT: devi... | [
"async",
"def",
"async_step_finish",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"device",
"=",
"self",
".",
"device",
"errors",
"=",
"{",
"}",
"# Abort reauthentication flow.",
"self",
".",
"_abort_if_unique_id_configured",
"(",
"updates",
"=",
"{",
... | [
256,
4
] | [
280,
9
] | python | en | ['en', 'en', 'en'] | True |
BroadlinkFlowHandler.async_step_import | (self, import_info) | Import a device. | Import a device. | async def async_step_import(self, import_info):
"""Import a device."""
if any(
import_info[CONF_HOST] == entry.data[CONF_HOST]
for entry in self._async_current_entries()
):
return self.async_abort(reason="already_configured")
return await self.async_st... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_info",
")",
":",
"if",
"any",
"(",
"import_info",
"[",
"CONF_HOST",
"]",
"==",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"for",
"entry",
"in",
"self",
".",
"_async_current_entries",
"(",
")"... | [
282,
4
] | [
289,
54
] | python | en | ['es', 'en', 'en'] | True |
BroadlinkFlowHandler.async_step_reauth | (self, data) | Reauthenticate to the device. | Reauthenticate to the device. | async def async_step_reauth(self, data):
"""Reauthenticate to the device."""
device = blk.gendevice(
data[CONF_TYPE],
(data[CONF_HOST], DEFAULT_PORT),
bytes.fromhex(data[CONF_MAC]),
name=data[CONF_NAME],
)
device.timeout = data[CONF_TIMEOUT... | [
"async",
"def",
"async_step_reauth",
"(",
"self",
",",
"data",
")",
":",
"device",
"=",
"blk",
".",
"gendevice",
"(",
"data",
"[",
"CONF_TYPE",
"]",
",",
"(",
"data",
"[",
"CONF_HOST",
"]",
",",
"DEFAULT_PORT",
")",
",",
"bytes",
".",
"fromhex",
"(",
... | [
291,
4
] | [
301,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Russound RNET platform. | Set up the Russound RNET platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Russound RNET platform."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
if host is None or port is None:
_LOGGER.error("Invalid config. Expected %s and %s", CONF_HOST, CONF_PORT)
return False... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"if",
"host",
"i... | [
45,
0
] | [
67,
59
] | python | en | ['en', 'lb', 'en'] | True |
RussoundRNETDevice.__init__ | (self, hass, russ, sources, zone_id, extra) | Initialise the Russound RNET device. | Initialise the Russound RNET device. | def __init__(self, hass, russ, sources, zone_id, extra):
"""Initialise the Russound RNET device."""
self._name = extra["name"]
self._russ = russ
self._sources = sources
self._zone_id = zone_id
self._state = None
self._volume = None
self._source = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"russ",
",",
"sources",
",",
"zone_id",
",",
"extra",
")",
":",
"self",
".",
"_name",
"=",
"extra",
"[",
"\"name\"",
"]",
"self",
".",
"_russ",
"=",
"russ",
"self",
".",
"_sources",
"=",
"sources",
... | [
73,
4
] | [
82,
27
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.update | (self) | Retrieve latest state. | Retrieve latest state. | def update(self):
"""Retrieve latest state."""
# Updated this function to make a single call to get_zone_info, so that
# with a single call we can get On/Off, Volume and Source, reducing the
# amount of traffic and speeding up the update process.
ret = self._russ.get_zone_info("1... | [
"def",
"update",
"(",
"self",
")",
":",
"# Updated this function to make a single call to get_zone_info, so that",
"# with a single call we can get On/Off, Volume and Source, reducing the",
"# amount of traffic and speeding up the update process.",
"ret",
"=",
"self",
".",
"_russ",
".",
... | [
84,
4
] | [
109,
79
] | python | en | ['es', 'sk', 'en'] | False |
RussoundRNETDevice.name | (self) | Return the name of the zone. | Return the name of the zone. | def name(self):
"""Return the name of the zone."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
112,
4
] | [
114,
25
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
117,
4
] | [
119,
26
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_RUSSOUND | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_RUSSOUND"
] | [
122,
4
] | [
124,
31
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.source | (self) | Get the currently selected source. | Get the currently selected source. | def source(self):
"""Get the currently selected source."""
return self._source | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source"
] | [
127,
4
] | [
129,
27
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.volume_level | (self) | Volume level of the media player (0..1).
Value is returned based on a range (0..100).
Therefore float divide by 100 to get to the required range.
| Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1).
Value is returned based on a range (0..100).
Therefore float divide by 100 to get to the required range.
"""
return self._volume | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume"
] | [
132,
4
] | [
138,
27
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.set_volume_level | (self, volume) | Set volume level. Volume has a range (0..1).
Translate this to a range of (0..100) as expected
by _russ.set_volume()
| Set volume level. Volume has a range (0..1). | def set_volume_level(self, volume):
"""Set volume level. Volume has a range (0..1).
Translate this to a range of (0..100) as expected
by _russ.set_volume()
"""
self._russ.set_volume("1", self._zone_id, volume * 100) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"self",
".",
"_russ",
".",
"set_volume",
"(",
"\"1\"",
",",
"self",
".",
"_zone_id",
",",
"volume",
"*",
"100",
")"
] | [
140,
4
] | [
146,
63
] | python | en | ['en', 'sr', 'en'] | True |
RussoundRNETDevice.turn_on | (self) | Turn the media player on. | Turn the media player on. | def turn_on(self):
"""Turn the media player on."""
self._russ.set_power("1", self._zone_id, "1") | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"_russ",
".",
"set_power",
"(",
"\"1\"",
",",
"self",
".",
"_zone_id",
",",
"\"1\"",
")"
] | [
148,
4
] | [
150,
53
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self._russ.set_power("1", self._zone_id, "0") | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_russ",
".",
"set_power",
"(",
"\"1\"",
",",
"self",
".",
"_zone_id",
",",
"\"0\"",
")"
] | [
152,
4
] | [
154,
53
] | python | en | ['en', 'en', 'en'] | True |
RussoundRNETDevice.mute_volume | (self, mute) | Send mute command. | Send mute command. | def mute_volume(self, mute):
"""Send mute command."""
self._russ.toggle_mute("1", self._zone_id) | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"_russ",
".",
"toggle_mute",
"(",
"\"1\"",
",",
"self",
".",
"_zone_id",
")"
] | [
156,
4
] | [
158,
50
] | python | en | ['en', 'co', 'en'] | True |
RussoundRNETDevice.select_source | (self, source) | Set the input source. | Set the input source. | def select_source(self, source):
"""Set the input source."""
if source in self._sources:
index = self._sources.index(source)
# 0 based value for source
self._russ.set_source("1", self._zone_id, index) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"source",
"in",
"self",
".",
"_sources",
":",
"index",
"=",
"self",
".",
"_sources",
".",
"index",
"(",
"source",
")",
"# 0 based value for source",
"self",
".",
"_russ",
".",
"set_source"... | [
160,
4
] | [
165,
60
] | python | en | ['en', 'su', 'en'] | True |
RussoundRNETDevice.source_list | (self) | Return a list of available input sources. | Return a list of available input sources. | def source_list(self):
"""Return a list of available input sources."""
return self._sources | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sources"
] | [
168,
4
] | [
170,
28
] | python | en | ['en', 'en', 'en'] | True |
_check_for_node_def | (
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) | Check if the node matches the node_def_id for any platforms.
This is only present on the 5.0 ISY firmware, and is the most reliable
way to determine a device's type.
| Check if the node matches the node_def_id for any platforms. | def _check_for_node_def(
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) -> bool:
"""Check if the node matches the node_def_id for any platforms.
This is only present on the 5.0 ISY firmware, and is the most reliable
way to determine a device's type.
"""
if not hasa... | [
"def",
"_check_for_node_def",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
",",
"single_platform",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"not",
"hasattr",
"(",
"node",
",",
"\"node_def_id\... | [
57,
0
] | [
77,
16
] | python | en | ['en', 'en', 'en'] | True |
_check_for_insteon_type | (
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) | Check if the node matches the Insteon type for any platforms.
This is for (presumably) every version of the ISY firmware, but only
works for Insteon device. "Node Server" (v5+) and Z-Wave and others will
not have a type.
| Check if the node matches the Insteon type for any platforms. | def _check_for_insteon_type(
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) -> bool:
"""Check if the node matches the Insteon type for any platforms.
This is for (presumably) every version of the ISY firmware, but only
works for Insteon device. "Node Server" (v5+) and Z-Wa... | [
"def",
"_check_for_insteon_type",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
",",
"single_platform",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"not",
"hasattr",
"(",
"node",
",",
"\"protocol... | [
80,
0
] | [
144,
16
] | python | en | ['en', 'en', 'en'] | True |
_check_for_zwave_cat | (
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) | Check if the node matches the ISY Z-Wave Category for any platforms.
This is for (presumably) every version of the ISY firmware, but only
works for Z-Wave Devices with the devtype.cat property.
| Check if the node matches the ISY Z-Wave Category for any platforms. | def _check_for_zwave_cat(
hass_isy_data: dict, node: Union[Group, Node], single_platform: str = None
) -> bool:
"""Check if the node matches the ISY Z-Wave Category for any platforms.
This is for (presumably) every version of the ISY firmware, but only
works for Z-Wave Devices with the devtype.cat prop... | [
"def",
"_check_for_zwave_cat",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
",",
"single_platform",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"not",
"hasattr",
"(",
"node",
",",
"\"protocol\""... | [
147,
0
] | [
175,
16
] | python | en | ['en', 'en', 'en'] | True |
_check_for_uom_id | (
hass_isy_data: dict,
node: Union[Group, Node],
single_platform: str = None,
uom_list: list = None,
) | Check if a node's uom matches any of the platforms uom filter.
This is used for versions of the ISY firmware that report uoms as a single
ID. We can often infer what type of device it is by that ID.
| Check if a node's uom matches any of the platforms uom filter. | def _check_for_uom_id(
hass_isy_data: dict,
node: Union[Group, Node],
single_platform: str = None,
uom_list: list = None,
) -> bool:
"""Check if a node's uom matches any of the platforms uom filter.
This is used for versions of the ISY firmware that report uoms as a single
ID. We can often ... | [
"def",
"_check_for_uom_id",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
",",
"single_platform",
":",
"str",
"=",
"None",
",",
"uom_list",
":",
"list",
"=",
"None",
",",
")",
"->",
"bool",
":",
"if",
"... | [
178,
0
] | [
210,
16
] | python | en | ['en', 'en', 'en'] | True |
_check_for_states_in_uom | (
hass_isy_data: dict,
node: Union[Group, Node],
single_platform: str = None,
states_list: list = None,
) | Check if a list of uoms matches two possible filters.
This is for versions of the ISY firmware that report uoms as a list of all
possible "human readable" states. This filter passes if all of the possible
states fit inside the given filter.
| Check if a list of uoms matches two possible filters. | def _check_for_states_in_uom(
hass_isy_data: dict,
node: Union[Group, Node],
single_platform: str = None,
states_list: list = None,
) -> bool:
"""Check if a list of uoms matches two possible filters.
This is for versions of the ISY firmware that report uoms as a list of all
possible "human ... | [
"def",
"_check_for_states_in_uom",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
",",
"single_platform",
":",
"str",
"=",
"None",
",",
"states_list",
":",
"list",
"=",
"None",
",",
")",
"->",
"bool",
":",
... | [
213,
0
] | [
247,
16
] | python | en | ['en', 'en', 'en'] | True |
_is_sensor_a_binary_sensor | (hass_isy_data: dict, node: Union[Group, Node]) | Determine if the given sensor node should be a binary_sensor. | Determine if the given sensor node should be a binary_sensor. | def _is_sensor_a_binary_sensor(hass_isy_data: dict, node: Union[Group, Node]) -> bool:
"""Determine if the given sensor node should be a binary_sensor."""
if _check_for_node_def(hass_isy_data, node, single_platform=BINARY_SENSOR):
return True
if _check_for_insteon_type(hass_isy_data, node, single_pl... | [
"def",
"_is_sensor_a_binary_sensor",
"(",
"hass_isy_data",
":",
"dict",
",",
"node",
":",
"Union",
"[",
"Group",
",",
"Node",
"]",
")",
"->",
"bool",
":",
"if",
"_check_for_node_def",
"(",
"hass_isy_data",
",",
"node",
",",
"single_platform",
"=",
"BINARY_SENS... | [
250,
0
] | [
273,
16
] | python | en | ['en', 'ca', 'en'] | True |
_categorize_nodes | (
hass_isy_data: dict, nodes: Nodes, ignore_identifier: str, sensor_identifier: str
) | Sort the nodes to their proper platforms. | Sort the nodes to their proper platforms. | def _categorize_nodes(
hass_isy_data: dict, nodes: Nodes, ignore_identifier: str, sensor_identifier: str
) -> None:
"""Sort the nodes to their proper platforms."""
for (path, node) in nodes:
ignored = ignore_identifier in path or ignore_identifier in node.name
if ignored:
# Don't... | [
"def",
"_categorize_nodes",
"(",
"hass_isy_data",
":",
"dict",
",",
"nodes",
":",
"Nodes",
",",
"ignore_identifier",
":",
"str",
",",
"sensor_identifier",
":",
"str",
")",
"->",
"None",
":",
"for",
"(",
"path",
",",
"node",
")",
"in",
"nodes",
":",
"igno... | [
276,
0
] | [
313,
56
] | python | en | ['en', 'en', 'en'] | True |
_categorize_programs | (hass_isy_data: dict, programs: Programs) | Categorize the ISY994 programs. | Categorize the ISY994 programs. | def _categorize_programs(hass_isy_data: dict, programs: Programs) -> None:
"""Categorize the ISY994 programs."""
for platform in SUPPORTED_PROGRAM_PLATFORMS:
folder = programs.get_by_name(f"{DEFAULT_PROGRAM_STRING}{platform}")
if not folder:
continue
for dtype, _, node_id in... | [
"def",
"_categorize_programs",
"(",
"hass_isy_data",
":",
"dict",
",",
"programs",
":",
"Programs",
")",
"->",
"None",
":",
"for",
"platform",
"in",
"SUPPORTED_PROGRAM_PLATFORMS",
":",
"folder",
"=",
"programs",
".",
"get_by_name",
"(",
"f\"{DEFAULT_PROGRAM_STRING}{... | [
316,
0
] | [
349,
67
] | python | en | ['en', 'cs', 'en'] | True |
_categorize_variables | (
hass_isy_data: dict, variables: Variables, identifier: str
) | Gather the ISY994 Variables to be added as sensors. | Gather the ISY994 Variables to be added as sensors. | def _categorize_variables(
hass_isy_data: dict, variables: Variables, identifier: str
) -> None:
"""Gather the ISY994 Variables to be added as sensors."""
try:
var_to_add = [
(vtype, vname, vid)
for (vtype, vname, vid) in variables.children
if identifier in vname
... | [
"def",
"_categorize_variables",
"(",
"hass_isy_data",
":",
"dict",
",",
"variables",
":",
"Variables",
",",
"identifier",
":",
"str",
")",
"->",
"None",
":",
"try",
":",
"var_to_add",
"=",
"[",
"(",
"vtype",
",",
"vname",
",",
"vid",
")",
"for",
"(",
"... | [
352,
0
] | [
366,
78
] | python | en | ['en', 'en', 'en'] | True |
migrate_old_unique_ids | (
hass: HomeAssistantType, platform: str, devices: Optional[List[Any]]
) | Migrate to new controller-specific unique ids. | Migrate to new controller-specific unique ids. | async def migrate_old_unique_ids(
hass: HomeAssistantType, platform: str, devices: Optional[List[Any]]
) -> None:
"""Migrate to new controller-specific unique ids."""
registry = await async_get_registry(hass)
for device in devices:
old_entity_id = registry.async_get_entity_id(
platf... | [
"async",
"def",
"migrate_old_unique_ids",
"(",
"hass",
":",
"HomeAssistantType",
",",
"platform",
":",
"str",
",",
"devices",
":",
"Optional",
"[",
"List",
"[",
"Any",
"]",
"]",
")",
"->",
"None",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"... | [
369,
0
] | [
398,
13
] | python | en | ['en', 'en', 'en'] | True |
convert_isy_value_to_hass | (
value: Union[int, float, None],
uom: str,
precision: Union[int, str],
fallback_precision: Optional[int] = None,
) | Fix ISY Reported Values.
ISY provides float values as an integer and precision component.
Correct by shifting the decimal place left by the value of precision.
(e.g. value=2345, prec="2" == 23.45)
Insteon Thermostats report temperature in 0.5-deg precision as an int
by sending a value of 2 times t... | Fix ISY Reported Values. | def convert_isy_value_to_hass(
value: Union[int, float, None],
uom: str,
precision: Union[int, str],
fallback_precision: Optional[int] = None,
) -> Union[float, int]:
"""Fix ISY Reported Values.
ISY provides float values as an integer and precision component.
Correct by shifting the decimal... | [
"def",
"convert_isy_value_to_hass",
"(",
"value",
":",
"Union",
"[",
"int",
",",
"float",
",",
"None",
"]",
",",
"uom",
":",
"str",
",",
"precision",
":",
"Union",
"[",
"int",
",",
"str",
"]",
",",
"fallback_precision",
":",
"Optional",
"[",
"int",
"]"... | [
401,
0
] | [
424,
16
] | python | en | ['de', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the sensor platform. | Set up the sensor platform. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
entities = []
for item_id, item in coordinator.data.items():
id_len = len(item_id)
item_kind = item_id[-2]
entity_setting... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"COORDINATOR",
"]",
"entities",
"=",
"[",
"]",
"for... | [
15,
0
] | [
58,
32
] | python | en | ['en', 'da', 'en'] | True |
OmnilogicSensor.__init__ | (
self,
coordinator: OmniLogicUpdateCoordinator,
kind: str,
name: str,
device_class: str,
icon: str,
unit: str,
item_id: tuple,
state_key: str,
) | Initialize Entities. | Initialize Entities. | def __init__(
self,
coordinator: OmniLogicUpdateCoordinator,
kind: str,
name: str,
device_class: str,
icon: str,
unit: str,
item_id: tuple,
state_key: str,
):
"""Initialize Entities."""
super().__init__(
coordinator=... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"OmniLogicUpdateCoordinator",
",",
"kind",
":",
"str",
",",
"name",
":",
"str",
",",
"device_class",
":",
"str",
",",
"icon",
":",
"str",
",",
"unit",
":",
"str",
",",
"item_id",
":",
"tuple",
",... | [
64,
4
] | [
90,
35
] | python | en | ['en', 'en', 'en'] | False |
OmnilogicSensor.device_class | (self) | Return the device class of the entity. | Return the device class of the entity. | def device_class(self):
"""Return the device class of the entity."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
93,
4
] | [
95,
33
] | python | en | ['en', 'en', 'en'] | True |
OmnilogicSensor.unit_of_measurement | (self) | Return the right unit of measure. | Return the right unit of measure. | def unit_of_measurement(self):
"""Return the right unit of measure."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
98,
4
] | [
100,
25
] | python | en | ['en', 'en', 'en'] | True |
OmniLogicTemperatureSensor.state | (self) | Return the state for the temperature sensor. | Return the state for the temperature sensor. | def state(self):
"""Return the state for the temperature sensor."""
sensor_data = self.coordinator.data[self._item_id][self._state_key]
hayward_state = sensor_data
hayward_unit_of_measure = TEMP_FAHRENHEIT
state = sensor_data
if self._unit_type == "Metric":
... | [
"def",
"state",
"(",
"self",
")",
":",
"sensor_data",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"self",
".",
"_state_key",
"]",
"hayward_state",
"=",
"sensor_data",
"hayward_unit_of_measure",
"=",
"TEMP_FAHRENHEIT",
... | [
107,
4
] | [
128,
20
] | python | en | ['en', 'en', 'en'] | True |
OmniLogicPumpSpeedSensor.state | (self) | Return the state for the pump speed sensor. | Return the state for the pump speed sensor. | def state(self):
"""Return the state for the pump speed sensor."""
pump_type = PUMP_TYPES[self.coordinator.data[self._item_id]["Filter-Type"]]
pump_speed = self.coordinator.data[self._item_id][self._state_key]
if pump_type == "VARIABLE":
self._unit = PERCENTAGE
... | [
"def",
"state",
"(",
"self",
")",
":",
"pump_type",
"=",
"PUMP_TYPES",
"[",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"\"Filter-Type\"",
"]",
"]",
"pump_speed",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"... | [
135,
4
] | [
158,
20
] | python | en | ['en', 'en', 'en'] | True |
OmniLogicSaltLevelSensor.state | (self) | Return the state for the salt level sensor. | Return the state for the salt level sensor. | def state(self):
"""Return the state for the salt level sensor."""
salt_return = self.coordinator.data[self._item_id][self._state_key]
unit_of_measurement = self._unit
if self._unit_type == "Metric":
salt_return = round(int(salt_return) / 1000, 2)
unit_of_measur... | [
"def",
"state",
"(",
"self",
")",
":",
"salt_return",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"self",
".",
"_state_key",
"]",
"unit_of_measurement",
"=",
"self",
".",
"_unit",
"if",
"self",
".",
"_unit_type",... | [
165,
4
] | [
177,
26
] | python | en | ['en', 'no', 'en'] | True |
OmniLogicChlorinatorSensor.state | (self) | Return the state for the chlorinator sensor. | Return the state for the chlorinator sensor. | def state(self):
"""Return the state for the chlorinator sensor."""
state = self.coordinator.data[self._item_id][self._state_key]
return state | [
"def",
"state",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"self",
".",
"_state_key",
"]",
"return",
"state"
] | [
184,
4
] | [
188,
20
] | python | en | ['en', 'no', 'en'] | True |
OmniLogicPHSensor.state | (self) | Return the state for the pH sensor. | Return the state for the pH sensor. | def state(self):
"""Return the state for the pH sensor."""
ph_state = self.coordinator.data[self._item_id][self._state_key]
if ph_state == 0:
ph_state = None
return ph_state | [
"def",
"state",
"(",
"self",
")",
":",
"ph_state",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"self",
".",
"_state_key",
"]",
"if",
"ph_state",
"==",
"0",
":",
"ph_state",
"=",
"None",
"return",
"ph_state"
] | [
195,
4
] | [
203,
23
] | python | en | ['en', 'en', 'en'] | True |
OmniLogicORPSensor.__init__ | (
self,
coordinator: OmniLogicUpdateCoordinator,
state_key: str,
name: str,
kind: str,
item_id: tuple,
device_class: str,
icon: str,
unit: str,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
coordinator: OmniLogicUpdateCoordinator,
state_key: str,
name: str,
kind: str,
item_id: tuple,
device_class: str,
icon: str,
unit: str,
):
"""Initialize the sensor."""
super().__init__(
coordinato... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"OmniLogicUpdateCoordinator",
",",
"state_key",
":",
"str",
",",
"name",
":",
"str",
",",
"kind",
":",
"str",
",",
"item_id",
":",
"tuple",
",",
"device_class",
":",
"str",
",",
"icon",
":",
"str",... | [
209,
4
] | [
230,
9
] | python | en | ['en', 'en', 'en'] | True |
OmniLogicORPSensor.state | (self) | Return the state for the ORP sensor. | Return the state for the ORP sensor. | def state(self):
"""Return the state for the ORP sensor."""
orp_state = self.coordinator.data[self._item_id][self._state_key]
if orp_state == -1:
orp_state = None
return orp_state | [
"def",
"state",
"(",
"self",
")",
":",
"orp_state",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_item_id",
"]",
"[",
"self",
".",
"_state_key",
"]",
"if",
"orp_state",
"==",
"-",
"1",
":",
"orp_state",
"=",
"None",
"return",
"orp... | [
233,
4
] | [
241,
24
] | python | en | ['en', 'en', 'en'] | True |
tuya_fixture | () | Patch libraries. | Patch libraries. | def tuya_fixture() -> Mock:
"""Patch libraries."""
with patch("homeassistant.components.tuya.config_flow.TuyaApi") as tuya:
yield tuya | [
"def",
"tuya_fixture",
"(",
")",
"->",
"Mock",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tuya.config_flow.TuyaApi\"",
")",
"as",
"tuya",
":",
"yield",
"tuya"
] | [
25,
0
] | [
28,
18
] | python | en | ['en', 'en', 'en'] | False |
test_user | (hass, tuya) | Test user config. | Test user config. | async def test_user(hass, tuya):
"""Test user config."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_F... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"tuya",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"... | [
31,
0
] | [
60,
48
] | python | en | ['en', 'da', 'en'] | True |
test_import | (hass, tuya) | Test import step. | Test import step. | async def test_import(hass, tuya):
"""Test import step."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.tuya.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.tuya.async_setup_entry",... | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"tuya",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.tuya.async_setup\"",
",",
"ret... | [
63,
0
] | [
89,
48
] | python | de | ['de', 'sd', 'en'] | False |
test_abort_if_already_setup | (hass, tuya) | Test we abort if Tuya is already setup. | Test we abort if Tuya is already setup. | async def test_abort_if_already_setup(hass, tuya):
"""Test we abort if Tuya is already setup."""
MockConfigEntry(domain=DOMAIN, data=TUYA_USER_DATA).add_to_hass(hass)
# Should fail, config exist (import)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entri... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
",",
"tuya",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"TUYA_USER_DATA",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"# Should fail, config exist (import)",
"result",
"="... | [
92,
0
] | [
110,
56
] | python | en | ['en', 'zu', 'en'] | True |
test_abort_on_invalid_credentials | (hass, tuya) | Test when we have invalid credentials. | Test when we have invalid credentials. | async def test_abort_on_invalid_credentials(hass, tuya):
"""Test when we have invalid credentials."""
tuya().init.side_effect = TuyaAPIException("Boom")
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=TUYA_USER_DATA
)
assert ... | [
"async",
"def",
"test_abort_on_invalid_credentials",
"(",
"hass",
",",
"tuya",
")",
":",
"tuya",
"(",
")",
".",
"init",
".",
"side_effect",
"=",
"TuyaAPIException",
"(",
"\"Boom\"",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
"."... | [
113,
0
] | [
129,
45
] | python | en | ['en', 'en', 'en'] | True |
test_abort_on_connection_error | (hass, tuya) | Test when we have a network error. | Test when we have a network error. | async def test_abort_on_connection_error(hass, tuya):
"""Test when we have a network error."""
tuya().init.side_effect = TuyaNetException("Boom")
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=TUYA_USER_DATA
)
assert result[... | [
"async",
"def",
"test_abort_on_connection_error",
"(",
"hass",
",",
"tuya",
")",
":",
"tuya",
"(",
")",
".",
"init",
".",
"side_effect",
"=",
"TuyaNetException",
"(",
"\"Boom\"",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
132,
0
] | [
148,
47
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up the WUnderground sensor. | Set up the WUnderground sensor. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up the WUnderground sensor."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
pws_id = config.get(C... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"latitude",
"=",
"config",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
... | [
1086,
0
] | [
1116,
37
] | python | en | ['en', 'zu', 'en'] | True |
WUSensorConfig.__init__ | (
self,
friendly_name: Union[str, Callable],
feature: str,
value: Callable[["WUndergroundData"], Any],
unit_of_measurement: Optional[str] = None,
entity_picture=None,
icon: str = "mdi:gauge",
device_state_attributes=None,
device_class=None,
) | Initialize sensor configuration.
:param friendly_name: Friendly name
:param feature: WU feature. See:
https://www.wunderground.com/weather/api/d/docs?d=data/index
:param value: callback that extracts desired value from WUndergroundData object
:param unit_of_measurement: ... | Initialize sensor configuration. | def __init__(
self,
friendly_name: Union[str, Callable],
feature: str,
value: Callable[["WUndergroundData"], Any],
unit_of_measurement: Optional[str] = None,
entity_picture=None,
icon: str = "mdi:gauge",
device_state_attributes=None,
device_class=N... | [
"def",
"__init__",
"(",
"self",
",",
"friendly_name",
":",
"Union",
"[",
"str",
",",
"Callable",
"]",
",",
"feature",
":",
"str",
",",
"value",
":",
"Callable",
"[",
"[",
"\"WUndergroundData\"",
"]",
",",
"Any",
"]",
",",
"unit_of_measurement",
":",
"Opt... | [
64,
4
] | [
93,
40
] | python | en | ['en', 'ro', 'en'] | True |
WUCurrentConditionsSensorConfig.__init__ | (
self,
friendly_name: Union[str, Callable],
field: str,
icon: Optional[str] = "mdi:gauge",
unit_of_measurement: Optional[str] = None,
device_class=None,
) | Initialize current conditions sensor configuration.
:param friendly_name: Friendly name of sensor
:field: Field name in the "current_observation" dictionary.
:icon: icon name or URL, if None sensor will use current weather symbol
:unit_of_measurement: unit of measurement
| Initialize current conditions sensor configuration. | def __init__(
self,
friendly_name: Union[str, Callable],
field: str,
icon: Optional[str] = "mdi:gauge",
unit_of_measurement: Optional[str] = None,
device_class=None,
):
"""Initialize current conditions sensor configuration.
:param friendly_name: Frien... | [
"def",
"__init__",
"(",
"self",
",",
"friendly_name",
":",
"Union",
"[",
"str",
",",
"Callable",
"]",
",",
"field",
":",
"str",
",",
"icon",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"mdi:gauge\"",
",",
"unit_of_measurement",
":",
"Optional",
"[",
"str",
... | [
99,
4
] | [
127,
9
] | python | en | ['en', 'fr', 'en'] | True |
WUDailyTextForecastSensorConfig.__init__ | (
self, period: int, field: str, unit_of_measurement: Optional[str] = None
) | Initialize daily text forecast sensor configuration.
:param period: forecast period number
:param field: field name to use as value
:param unit_of_measurement: unit of measurement
| Initialize daily text forecast sensor configuration. | def __init__(
self, period: int, field: str, unit_of_measurement: Optional[str] = None
):
"""Initialize daily text forecast sensor configuration.
:param period: forecast period number
:param field: field name to use as value
:param unit_of_measurement: unit of measurement
... | [
"def",
"__init__",
"(",
"self",
",",
"period",
":",
"int",
",",
"field",
":",
"str",
",",
"unit_of_measurement",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"friendly_name",
"=",
"lambda",
"wu",
"... | [
133,
4
] | [
157,
9
] | python | en | ['en', 'pt', 'en'] | True |
WUDailySimpleForecastSensorConfig.__init__ | (
self,
friendly_name: str,
period: int,
field: str,
wu_unit: Optional[str] = None,
ha_unit: Optional[str] = None,
icon=None,
device_class=None,
) | Initialize daily simple forecast sensor configuration.
:param friendly_name: friendly_name of the sensor
:param period: forecast period number
:param field: field name to use as value
:param wu_unit: "fahrenheit", "celsius", "degrees" etc. see the example json at:
https:... | Initialize daily simple forecast sensor configuration. | def __init__(
self,
friendly_name: str,
period: int,
field: str,
wu_unit: Optional[str] = None,
ha_unit: Optional[str] = None,
icon=None,
device_class=None,
):
"""Initialize daily simple forecast sensor configuration.
:param friendly_n... | [
"def",
"__init__",
"(",
"self",
",",
"friendly_name",
":",
"str",
",",
"period",
":",
"int",
",",
"field",
":",
"str",
",",
"wu_unit",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"ha_unit",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
","... | [
163,
4
] | [
209,
9
] | python | en | ['en', 'pt', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.