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_multi_level_wildcard_topic | (hass, mock_device_tracker_conf) | Test multi level wildcard topic. | Test multi level wildcard topic. | async def test_multi_level_wildcard_topic(hass, mock_device_tracker_conf):
"""Test multi level wildcard topic."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
subscription = "/location/#"
topic = "/location/room/paulus"
location = "work"
hass.config.components = {"mqtt", "zone"}
a... | [
"async",
"def",
"test_multi_level_wildcard_topic",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"subscription",
"=",
"\"/location/#\"",
"topic",
"=",
"\"/location/room/paulus\"",
"location",... | [
73,
0
] | [
89,
55
] | python | en | ['en', 'en', 'en'] | True |
test_single_level_wildcard_topic_not_matching | (hass, mock_device_tracker_conf) | Test not matching single level wildcard topic. | Test not matching single level wildcard topic. | async def test_single_level_wildcard_topic_not_matching(hass, mock_device_tracker_conf):
"""Test not matching single level wildcard topic."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
subscription = "/location/+/paulus"
topic = "/location/paulus"
location = "work"
hass.config.compo... | [
"async",
"def",
"test_single_level_wildcard_topic_not_matching",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"subscription",
"=",
"\"/location/+/paulus\"",
"topic",
"=",
"\"/location/paulus\"... | [
92,
0
] | [
108,
45
] | python | en | ['en', 'en', 'en'] | True |
test_multi_level_wildcard_topic_not_matching | (hass, mock_device_tracker_conf) | Test not matching multi level wildcard topic. | Test not matching multi level wildcard topic. | async def test_multi_level_wildcard_topic_not_matching(hass, mock_device_tracker_conf):
"""Test not matching multi level wildcard topic."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
subscription = "/location/#"
topic = "/somewhere/room/paulus"
location = "work"
hass.config.componen... | [
"async",
"def",
"test_multi_level_wildcard_topic_not_matching",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"subscription",
"=",
"\"/location/#\"",
"topic",
"=",
"\"/somewhere/room/paulus\"",... | [
111,
0
] | [
127,
45
] | python | en | ['en', 'en', 'en'] | True |
test_matching_custom_payload_for_home_and_not_home | (
hass, mock_device_tracker_conf
) | Test custom payload_home sets state to home and custom payload_not_home sets state to not_home. | Test custom payload_home sets state to home and custom payload_not_home sets state to not_home. | async def test_matching_custom_payload_for_home_and_not_home(
hass, mock_device_tracker_conf
):
"""Test custom payload_home sets state to home and custom payload_not_home sets state to not_home."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
topic = "/location/paulus"
payload_home = "pres... | [
"async",
"def",
"test_matching_custom_payload_for_home_and_not_home",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"topic",
"=",
"\"/location/paulus\"",
"payload_home",
"=",
"\"present\"",
"... | [
130,
0
] | [
159,
61
] | python | en | ['en', 'en', 'en'] | True |
test_not_matching_custom_payload_for_home_and_not_home | (
hass, mock_device_tracker_conf
) | Test not matching payload does not set state to home or not_home. | Test not matching payload does not set state to home or not_home. | async def test_not_matching_custom_payload_for_home_and_not_home(
hass, mock_device_tracker_conf
):
"""Test not matching payload does not set state to home or not_home."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
topic = "/location/paulus"
payload_home = "present"
payload_not_home ... | [
"async",
"def",
"test_not_matching_custom_payload_for_home_and_not_home",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"topic",
"=",
"\"/location/paulus\"",
"payload_home",
"=",
"\"present\"",... | [
162,
0
] | [
189,
61
] | python | en | ['en', 'en', 'en'] | True |
test_matching_source_type | (hass, mock_device_tracker_conf) | Test setting source type. | Test setting source type. | async def test_matching_source_type(hass, mock_device_tracker_conf):
"""Test setting source type."""
dev_id = "paulus"
entity_id = f"{DOMAIN}.{dev_id}"
topic = "/location/paulus"
source_type = SOURCE_TYPE_BLUETOOTH
location = "work"
hass.config.components = {"mqtt", "zone"}
assert await... | [
"async",
"def",
"test_matching_source_type",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"dev_id",
"=",
"\"paulus\"",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\"",
"topic",
"=",
"\"/location/paulus\"",
"source_type",
"=",
"SOURCE_TYPE_BLUETOOTH",
"location",
"="... | [
192,
0
] | [
215,
88
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up scenes for the LiteJet platform. | Set up scenes for the LiteJet platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up scenes for the LiteJet platform."""
litejet_ = hass.data["litejet_system"]
devices = []
for i in litejet_.scenes():
name = litejet_.get_scene_name(i)
if not litejet.is_ignored(hass, name):
devices... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"litejet_",
"=",
"hass",
".",
"data",
"[",
"\"litejet_system\"",
"]",
"devices",
"=",
"[",
"]",
"for",
"i",
"in",
"litejet_",
".",
"sc... | [
9,
0
] | [
18,
25
] | python | en | ['en', 'da', 'en'] | True |
LiteJetScene.__init__ | (self, lj, i, name) | Initialize the scene. | Initialize the scene. | def __init__(self, lj, i, name):
"""Initialize the scene."""
self._lj = lj
self._index = i
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"lj",
",",
"i",
",",
"name",
")",
":",
"self",
".",
"_lj",
"=",
"lj",
"self",
".",
"_index",
"=",
"i",
"self",
".",
"_name",
"=",
"name"
] | [
24,
4
] | [
28,
25
] | python | en | ['en', 'it', 'en'] | True |
LiteJetScene.name | (self) | Return the name of the scene. | Return the name of the scene. | def name(self):
"""Return the name of the scene."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
31,
4
] | [
33,
25
] | python | en | ['en', 'ig', 'en'] | True |
LiteJetScene.device_state_attributes | (self) | Return the device-specific state attributes. | Return the device-specific state attributes. | def device_state_attributes(self):
"""Return the device-specific state attributes."""
return {ATTR_NUMBER: self._index} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_NUMBER",
":",
"self",
".",
"_index",
"}"
] | [
36,
4
] | [
38,
41
] | python | en | ['en', 'en', 'en'] | True |
LiteJetScene.activate | (self, **kwargs: Any) | Activate the scene. | Activate the scene. | def activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
self._lj.activate_scene(self._index) | [
"def",
"activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"_lj",
".",
"activate_scene",
"(",
"self",
".",
"_index",
")"
] | [
40,
4
] | [
42,
44
] | python | en | ['en', 'it', 'en'] | True |
check_jwt_validity | (func) | Check JWT validity and do data decryption before getting into the actual logistic.
Args:
func:
Returns:
None.
| Check JWT validity and do data decryption before getting into the actual logistic. | def check_jwt_validity(func):
"""Check JWT validity and do data decryption before getting into the actual logistic.
Args:
func:
Returns:
None.
"""
@functools.wraps(func)
def with_checker(*args, **kwargs):
# Get jwt_token and its payload
authorization = request.... | [
"def",
"check_jwt_validity",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"with_checker",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get jwt_token and its payload",
"authorization",
"=",
"request",
".",
"header... | [
21,
0
] | [
65,
23
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Fibaro switches. | Set up the Fibaro switches. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Fibaro switches."""
if discovery_info is None:
return
add_entities(
[FibaroSwitch(device) for device in hass.data[FIBARO_DEVICES]["switch"]], True
) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"add_entities",
"(",
"[",
"FibaroSwitch",
"(",
"device",
")",
"for",
"device",
"in",
... | [
7,
0
] | [
14,
5
] | python | en | ['en', 'sr', 'en'] | True |
FibaroSwitch.__init__ | (self, fibaro_device) | Initialize the Fibaro device. | Initialize the Fibaro device. | def __init__(self, fibaro_device):
"""Initialize the Fibaro device."""
self._state = False
super().__init__(fibaro_device)
self.entity_id = f"{DOMAIN}.{self.ha_id}" | [
"def",
"__init__",
"(",
"self",
",",
"fibaro_device",
")",
":",
"self",
".",
"_state",
"=",
"False",
"super",
"(",
")",
".",
"__init__",
"(",
"fibaro_device",
")",
"self",
".",
"entity_id",
"=",
"f\"{DOMAIN}.{self.ha_id}\""
] | [
20,
4
] | [
24,
49
] | python | en | ['en', 'en', 'en'] | True |
FibaroSwitch.turn_on | (self, **kwargs) | Turn device on. | Turn device on. | def turn_on(self, **kwargs):
"""Turn device on."""
self.call_turn_on()
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"call_turn_on",
"(",
")",
"self",
".",
"_state",
"=",
"True"
] | [
26,
4
] | [
29,
26
] | python | en | ['es', 'en', 'en'] | True |
FibaroSwitch.turn_off | (self, **kwargs) | Turn device off. | Turn device off. | def turn_off(self, **kwargs):
"""Turn device off."""
self.call_turn_off()
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"call_turn_off",
"(",
")",
"self",
".",
"_state",
"=",
"False"
] | [
31,
4
] | [
34,
27
] | python | en | ['en', 'en', 'en'] | True |
FibaroSwitch.current_power_w | (self) | Return the current power usage in W. | Return the current power usage in W. | def current_power_w(self):
"""Return the current power usage in W."""
if "power" in self.fibaro_device.interfaces:
return convert(self.fibaro_device.properties.power, float, 0.0)
return None | [
"def",
"current_power_w",
"(",
"self",
")",
":",
"if",
"\"power\"",
"in",
"self",
".",
"fibaro_device",
".",
"interfaces",
":",
"return",
"convert",
"(",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"power",
",",
"float",
",",
"0.0",
")",
"return"... | [
37,
4
] | [
41,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroSwitch.today_energy_kwh | (self) | Return the today total energy usage in kWh. | Return the today total energy usage in kWh. | def today_energy_kwh(self):
"""Return the today total energy usage in kWh."""
if "energy" in self.fibaro_device.interfaces:
return convert(self.fibaro_device.properties.energy, float, 0.0)
return None | [
"def",
"today_energy_kwh",
"(",
"self",
")",
":",
"if",
"\"energy\"",
"in",
"self",
".",
"fibaro_device",
".",
"interfaces",
":",
"return",
"convert",
"(",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"energy",
",",
"float",
",",
"0.0",
")",
"retu... | [
44,
4
] | [
48,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
51,
4
] | [
53,
26
] | python | en | ['en', 'fy', 'en'] | True |
FibaroSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
self._state = self.current_binary_state | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"current_binary_state"
] | [
55,
4
] | [
57,
47
] | python | en | ['fr', 'en', 'en'] | True |
PickledCorpusReader.__init__ | (self, root, fileids=PKL_PATTERN, **kwargs) |
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining arguments
are passed to the ``CorpusReader`` constructor.
|
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining arguments
are passed to the ``CorpusReader`` constructor.
| def __init__(self, root, fileids=PKL_PATTERN, **kwargs):
"""
Initialize the corpus reader. Categorization arguments
(``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to
the ``CategorizedCorpusReader`` constructor. The remaining arguments
are passed to the ``CorpusRead... | [
"def",
"__init__",
"(",
"self",
",",
"root",
",",
"fileids",
"=",
"PKL_PATTERN",
",",
"*",
"*",
"kwargs",
")",
":",
"# Add the default category pattern if not passed into the class.",
"if",
"not",
"any",
"(",
"key",
".",
"startswith",
"(",
"'cat_'",
")",
"for",
... | [
15,
4
] | [
27,
50
] | python | en | ['en', 'error', 'th'] | False |
PickledCorpusReader._resolve | (self, fileids, categories) |
Returns a list of fileids or categories depending on what is passed
to each internal corpus reader function. This primarily bubbles up to
the high level ``docs`` method, but is implemented here similar to
the nltk ``CategorizedPlaintextCorpusReader``.
|
Returns a list of fileids or categories depending on what is passed
to each internal corpus reader function. This primarily bubbles up to
the high level ``docs`` method, but is implemented here similar to
the nltk ``CategorizedPlaintextCorpusReader``.
| def _resolve(self, fileids, categories):
"""
Returns a list of fileids or categories depending on what is passed
to each internal corpus reader function. This primarily bubbles up to
the high level ``docs`` method, but is implemented here similar to
the nltk ``CategorizedPlaintex... | [
"def",
"_resolve",
"(",
"self",
",",
"fileids",
",",
"categories",
")",
":",
"if",
"fileids",
"is",
"not",
"None",
"and",
"categories",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"\"Specify fileids or categories, not both\"",
")",
"if",
"categories",
... | [
29,
4
] | [
41,
22
] | python | en | ['en', 'error', 'th'] | False |
PickledCorpusReader.docs | (self, fileids=None, categories=None) |
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the BaleenCorpusReader, this uses a generator
to acheive memory safe iteration.
|
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the BaleenCorpusReader, this uses a generator
to acheive memory safe iteration.
| def docs(self, fileids=None, categories=None):
"""
Returns the document loaded from a pickled object for every file in
the corpus. Similar to the BaleenCorpusReader, this uses a generator
to acheive memory safe iteration.
"""
# Resolve the fileids and the categories
... | [
"def",
"docs",
"(",
"self",
",",
"fileids",
"=",
"None",
",",
"categories",
"=",
"None",
")",
":",
"# Resolve the fileids and the categories",
"fileids",
"=",
"self",
".",
"_resolve",
"(",
"fileids",
",",
"categories",
")",
"# Create a generator, loading one documen... | [
43,
4
] | [
55,
36
] | python | en | ['en', 'error', 'th'] | False |
PickledCorpusReader.paras | (self, fileids=None, categories=None) |
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
|
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
| def paras(self, fileids=None, categories=None):
"""
Returns a generator of paragraphs where each paragraph is a list of
sentences, which is in turn a list of (token, tag) tuples.
"""
for doc in self.docs(fileids, categories):
for paragraph in doc:
yiel... | [
"def",
"paras",
"(",
"self",
",",
"fileids",
"=",
"None",
",",
"categories",
"=",
"None",
")",
":",
"for",
"doc",
"in",
"self",
".",
"docs",
"(",
"fileids",
",",
"categories",
")",
":",
"for",
"paragraph",
"in",
"doc",
":",
"yield",
"paragraph"
] | [
57,
4
] | [
64,
31
] | python | en | ['en', 'error', 'th'] | False |
PickledCorpusReader.sents | (self, fileids=None, categories=None) |
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
|
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
| def sents(self, fileids=None, categories=None):
"""
Returns a generator of sentences where each sentence is a list of
(token, tag) tuples.
"""
for paragraph in self.paras(fileids, categories):
for sentence in paragraph:
yield sentence | [
"def",
"sents",
"(",
"self",
",",
"fileids",
"=",
"None",
",",
"categories",
"=",
"None",
")",
":",
"for",
"paragraph",
"in",
"self",
".",
"paras",
"(",
"fileids",
",",
"categories",
")",
":",
"for",
"sentence",
"in",
"paragraph",
":",
"yield",
"senten... | [
66,
4
] | [
73,
30
] | python | en | ['en', 'error', 'th'] | False |
PickledCorpusReader.words | (self, fileids=None, categories=None) |
Returns a generator of (token, tag) tuples.
|
Returns a generator of (token, tag) tuples.
| def words(self, fileids=None, categories=None):
"""
Returns a generator of (token, tag) tuples.
"""
for sentence in self.sents(fileids, categories):
for token in sentence:
yield token | [
"def",
"words",
"(",
"self",
",",
"fileids",
"=",
"None",
",",
"categories",
"=",
"None",
")",
":",
"for",
"sentence",
"in",
"self",
".",
"sents",
"(",
"fileids",
",",
"categories",
")",
":",
"for",
"token",
"in",
"sentence",
":",
"yield",
"token"
] | [
75,
4
] | [
81,
27
] | python | en | ['en', 'error', 'th'] | False |
accuracy | (output, target, topk=(1,)) |
Computes the precision@k for the specified values of k
Parameters
----------
output : pytorch tensor
output, e.g., predicted value
target : pytorch tensor
label
topk : tuple
specify top1 and top5
Returns
-------
list
accuracy of top1 and top5
|
Computes the precision@k for the specified values of k | def accuracy(output, target, topk=(1,)):
"""
Computes the precision@k for the specified values of k
Parameters
----------
output : pytorch tensor
output, e.g., predicted value
target : pytorch tensor
label
topk : tuple
specify top1 and top5
Returns
-------
... | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"_",
",",
"pred",
"=",
"output",
".",
"topk",
"(",
... | [
106,
0
] | [
135,
14
] | python | en | ['en', 'error', 'th'] | False |
supernet_sample | (model, state_dict, sampled_arch=[], lookup_table=None) |
Initialize the searched sub-model from supernet.
Parameters
----------
model : pytorch model
the created subnet
state_dict : checkpoint
the checkpoint of supernet, including the pre-trained params
sampled_arch : list of str
the searched layer names of the subnet
loo... |
Initialize the searched sub-model from supernet. | def supernet_sample(model, state_dict, sampled_arch=[], lookup_table=None):
"""
Initialize the searched sub-model from supernet.
Parameters
----------
model : pytorch model
the created subnet
state_dict : checkpoint
the checkpoint of supernet, including the pre-trained params
... | [
"def",
"supernet_sample",
"(",
"model",
",",
"state_dict",
",",
"sampled_arch",
"=",
"[",
"]",
",",
"lookup_table",
"=",
"None",
")",
":",
"replace",
"=",
"list",
"(",
")",
"stages",
"=",
"[",
"stage",
"for",
"stage",
"in",
"lookup_table",
".",
"layer_nu... | [
138,
0
] | [
172,
50
] | python | en | ['en', 'error', 'th'] | False |
model_init | (model, state_dict, replace=[]) | Initialize the model from state_dict. | Initialize the model from state_dict. | def model_init(model, state_dict, replace=[]):
"""Initialize the model from state_dict."""
prefix = "module."
param_dict = dict()
for k, v in state_dict.items():
if k.startswith(prefix):
k = k[7:]
param_dict[k] = v
for k, (name, m) in enumerate(model.named_modules()):
... | [
"def",
"model_init",
"(",
"model",
",",
"state_dict",
",",
"replace",
"=",
"[",
"]",
")",
":",
"prefix",
"=",
"\"module.\"",
"param_dict",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"state_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
".",... | [
175,
0
] | [
215,
60
] | python | en | ['en', 'en', 'en'] | True |
RegularizerLoss.__init__ | (self, config) |
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
|
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
| def __init__(self, config):
"""
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
"""
super(RegularizerLoss, self).__init__()
self.mode = config.mode
self.alpha = config.alpha
self.... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"super",
"(",
"RegularizerLoss",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"mode",
"=",
"config",
".",
"mode",
"self",
".",
"alpha",
"=",
"config",
".",
"alpha",
"self",
".",
... | [
70,
4
] | [
80,
31
] | python | en | ['en', 'error', 'th'] | False |
RegularizerLoss.forward | (self, perf_cost, batch_size=1) |
Parameters
----------
perf_cost : tensor
the accumulated performance cost
batch_size : int
batch size for normalization
Returns
-------
output: tensor
the hardware-aware constraint loss
|
Parameters
----------
perf_cost : tensor
the accumulated performance cost
batch_size : int
batch size for normalization | def forward(self, perf_cost, batch_size=1):
"""
Parameters
----------
perf_cost : tensor
the accumulated performance cost
batch_size : int
batch size for normalization
Returns
-------
output: tensor
the hardware-aware c... | [
"def",
"forward",
"(",
"self",
",",
"perf_cost",
",",
"batch_size",
"=",
"1",
")",
":",
"if",
"self",
".",
"mode",
"==",
"\"mul\"",
":",
"log_loss",
"=",
"torch",
".",
"log",
"(",
"perf_cost",
"/",
"batch_size",
")",
"**",
"self",
".",
"beta",
"retur... | [
82,
4
] | [
103,
37
] | python | en | ['en', 'error', 'th'] | False |
LookUpTable.__init__ | (self, config, primitives) |
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
|
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
| def __init__(self, config, primitives):
"""
Parameters
----------
config : class
to manage the configuration for NAS training, and search space etc.
"""
self.config = config
# definition of search blocks and space
self.search_space = config.sea... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"primitives",
")",
":",
"self",
".",
"config",
"=",
"config",
"# definition of search blocks and space",
"self",
".",
"search_space",
"=",
"config",
".",
"search_space",
"# layers for NAS",
"self",
".",
"cnt_laye... | [
221,
4
] | [
258,
36
] | python | en | ['en', 'error', 'th'] | False |
LookUpTable._layer_configs | (self) | Generate basic params for different layers. | Generate basic params for different layers. | def _layer_configs(self):
"""Generate basic params for different layers."""
# layer_configs are : c_in, c_out, stride, fm_size
layer_configs = [
[
self.search_space["input_shape"][layer_id][0],
self.search_space["channel_size"][layer_id],
... | [
"def",
"_layer_configs",
"(",
"self",
")",
":",
"# layer_configs are : c_in, c_out, stride, fm_size",
"layer_configs",
"=",
"[",
"[",
"self",
".",
"search_space",
"[",
"\"input_shape\"",
"]",
"[",
"layer_id",
"]",
"[",
"0",
"]",
",",
"self",
".",
"search_space",
... | [
260,
4
] | [
276,
45
] | python | en | ['en', 'en', 'en'] | True |
LookUpTable._create_perfs | (self, cnt_of_runs=200) | Create performance cost for each op. | Create performance cost for each op. | def _create_perfs(self, cnt_of_runs=200):
"""Create performance cost for each op."""
if self.perf_metric == "latency":
self.lut_perf = self._calculate_latency(cnt_of_runs)
elif self.perf_metric == "flops":
self.lut_perf = self._calculate_flops()
self._write_lut_t... | [
"def",
"_create_perfs",
"(",
"self",
",",
"cnt_of_runs",
"=",
"200",
")",
":",
"if",
"self",
".",
"perf_metric",
"==",
"\"latency\"",
":",
"self",
".",
"lut_perf",
"=",
"self",
".",
"_calculate_latency",
"(",
"cnt_of_runs",
")",
"elif",
"self",
".",
"perf_... | [
278,
4
] | [
285,
33
] | python | en | ['en', 'en', 'en'] | True |
LookUpTable._calculate_flops | (self, eps=0.001) | FLOPs cost. | FLOPs cost. | def _calculate_flops(self, eps=0.001):
"""FLOPs cost."""
flops_lut = [{} for i in range(self.cnt_layers)]
layer_id = 0
for stage_name in self.lut_ops:
stage_ops = self.lut_ops[stage_name]
ops_num = self.layer_num[stage_name]
for _ in range(ops_num):
... | [
"def",
"_calculate_flops",
"(",
"self",
",",
"eps",
"=",
"0.001",
")",
":",
"flops_lut",
"=",
"[",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"cnt_layers",
")",
"]",
"layer_id",
"=",
"0",
"for",
"stage_name",
"in",
"self",
".",
"lut_ops",... | [
287,
4
] | [
310,
24
] | python | en | ['en', 'nl', 'en'] | False |
LookUpTable._calculate_latency | (self, cnt_of_runs) | Latency cost. | Latency cost. | def _calculate_latency(self, cnt_of_runs):
"""Latency cost."""
LATENCY_BATCH_SIZE = 1
latency_lut = [{} for i in range(self.cnt_layers)]
layer_id = 0
for stage_name in self.lut_ops:
stage_ops = self.lut_ops[stage_name]
ops_num = self.layer_num[stage_name]... | [
"def",
"_calculate_latency",
"(",
"self",
",",
"cnt_of_runs",
")",
":",
"LATENCY_BATCH_SIZE",
"=",
"1",
"latency_lut",
"=",
"[",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"cnt_layers",
")",
"]",
"layer_id",
"=",
"0",
"for",
"stage_name",
"in... | [
312,
4
] | [
343,
26
] | python | de | ['de', 'fy', 'it'] | False |
LookUpTable._write_lut_to_file | (self) | Save lut as numpy file. | Save lut as numpy file. | def _write_lut_to_file(self):
"""Save lut as numpy file."""
np.save(self.lut_file, self.lut_perf) | [
"def",
"_write_lut_to_file",
"(",
"self",
")",
":",
"np",
".",
"save",
"(",
"self",
".",
"lut_file",
",",
"self",
".",
"lut_perf",
")"
] | [
345,
4
] | [
347,
45
] | python | en | ['en', 'en', 'en'] | True |
LookUpTable._load_from_file | (self) | Load numpy file. | Load numpy file. | def _load_from_file(self):
"""Load numpy file."""
self.lut_perf = np.load(self.lut_file, allow_pickle=True) | [
"def",
"_load_from_file",
"(",
"self",
")",
":",
"self",
".",
"lut_perf",
"=",
"np",
".",
"load",
"(",
"self",
".",
"lut_file",
",",
"allow_pickle",
"=",
"True",
")"
] | [
349,
4
] | [
351,
65
] | python | en | ['en', 'sm', 'sw'] | False |
_base_schema | (discovery_info) | Generate base schema. | Generate base schema. | def _base_schema(discovery_info):
"""Generate base schema."""
base_schema = {}
if not discovery_info:
base_schema.update(
{
vol.Optional(CONF_HOST, default=DEFAULT_HOST): str,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): int,
}
)
... | [
"def",
"_base_schema",
"(",
"discovery_info",
")",
":",
"base_schema",
"=",
"{",
"}",
"if",
"not",
"discovery_info",
":",
"base_schema",
".",
"update",
"(",
"{",
"vol",
".",
"Optional",
"(",
"CONF_HOST",
",",
"default",
"=",
"DEFAULT_HOST",
")",
":",
"str"... | [
39,
0
] | [
53,
34
] | python | de | ['de', 'de', 'it'] | True |
_resource_schema_base | (available_resources, selected_resources) | Resource selection schema. | Resource selection schema. | def _resource_schema_base(available_resources, selected_resources):
"""Resource selection schema."""
known_available_resources = {
sensor_id: sensor[SENSOR_NAME]
for sensor_id, sensor in SENSOR_TYPES.items()
if sensor_id in available_resources
}
if KEY_STATUS in known_available... | [
"def",
"_resource_schema_base",
"(",
"available_resources",
",",
"selected_resources",
")",
":",
"known_available_resources",
"=",
"{",
"sensor_id",
":",
"sensor",
"[",
"SENSOR_NAME",
"]",
"for",
"sensor_id",
",",
"sensor",
"in",
"SENSOR_TYPES",
".",
"items",
"(",
... | [
56,
0
] | [
74,
5
] | python | en | ['de', 'en', 'en'] | True |
_ups_schema | (ups_list) | UPS selection schema. | UPS selection schema. | def _ups_schema(ups_list):
"""UPS selection schema."""
return vol.Schema({vol.Required(CONF_ALIAS): vol.In(ups_list)}) | [
"def",
"_ups_schema",
"(",
"ups_list",
")",
":",
"return",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_ALIAS",
")",
":",
"vol",
".",
"In",
"(",
"ups_list",
")",
"}",
")"
] | [
77,
0
] | [
79,
67
] | python | en | ['de', 'en', 'en'] | True |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from _base_schema with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from _base_schema with values provided by the user.
"""
host = data[CONF_HOST]
port = data[CONF_PORT]
alias = data.get(CONF_ALIAS)
username = data.get(CONF_USERNAME)... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"host",
"=",
"data",
"[",
"CONF_HOST",
"]",
"port",
"=",
"data",
"[",
"CONF_PORT",
"]",
"alias",
"=",
"data",
".",
"get",
"(",
"CONF_ALIAS",
")",
... | [
82,
0
] | [
100,
69
] | python | en | ['en', 'en', 'en'] | True |
_format_host_port_alias | (user_input) | Format a host, port, and alias so it can be used for comparison or display. | Format a host, port, and alias so it can be used for comparison or display. | def _format_host_port_alias(user_input):
"""Format a host, port, and alias so it can be used for comparison or display."""
host = user_input[CONF_HOST]
port = user_input[CONF_PORT]
alias = user_input.get(CONF_ALIAS)
if alias:
return f"{alias}@{host}:{port}"
return f"{host}:{port}" | [
"def",
"_format_host_port_alias",
"(",
"user_input",
")",
":",
"host",
"=",
"user_input",
"[",
"CONF_HOST",
"]",
"port",
"=",
"user_input",
"[",
"CONF_PORT",
"]",
"alias",
"=",
"user_input",
".",
"get",
"(",
"CONF_ALIAS",
")",
"if",
"alias",
":",
"return",
... | [
103,
0
] | [
110,
27
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.__init__ | (self) | Initialize the nut config flow. | Initialize the nut config flow. | def __init__(self):
"""Initialize the nut config flow."""
self.nut_config = {}
self.available_resources = {}
self.discovery_info = {}
self.ups_list = None
self.title = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"nut_config",
"=",
"{",
"}",
"self",
".",
"available_resources",
"=",
"{",
"}",
"self",
".",
"discovery_info",
"=",
"{",
"}",
"self",
".",
"ups_list",
"=",
"None",
"self",
".",
"title",
"=",
"Non... | [
119,
4
] | [
125,
25
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_zeroconf | (self, discovery_info) | Prepare configuration for a discovered nut device. | Prepare configuration for a discovered nut device. | async def async_step_zeroconf(self, discovery_info):
"""Prepare configuration for a discovered nut device."""
self.discovery_info = discovery_info
await self._async_handle_discovery_without_unique_id()
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
")",
":",
"self",
".",
"discovery_info",
"=",
"discovery_info",
"await",
"self",
".",
"_async_handle_discovery_without_unique_id",
"(",
")",
"# pylint: disable=no-member # https://github.com/PyCQA/pyli... | [
127,
4
] | [
136,
43
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, user_input=None) | Handle the import. | Handle the import. | async def async_step_import(self, user_input=None):
"""Handle the import."""
errors = {}
if user_input is not None:
if self._host_port_alias_already_configured(user_input):
return self.async_abort(reason="already_configured")
_, errors = await self._async_... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_host_port_alias_already_configured",
"(",
"user_input",
")",
":",
"return"... | [
138,
4
] | [
152,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the user input. | Handle the user input. | async def async_step_user(self, user_input=None):
"""Handle the user input."""
errors = {}
if user_input is not None:
if self.discovery_info:
user_input.update(
{
CONF_HOST: self.discovery_info[CONF_HOST],
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"self",
".",
"discovery_info",
":",
"user_input",
".",
"update",
"(",
"{",
"CONF_HOST",... | [
154,
4
] | [
180,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_ups | (self, user_input=None) | Handle the picking the ups. | Handle the picking the ups. | async def async_step_ups(self, user_input=None):
"""Handle the picking the ups."""
errors = {}
if user_input is not None:
self.nut_config.update(user_input)
if self._host_port_alias_already_configured(self.nut_config):
return self.async_abort(reason="alre... | [
"async",
"def",
"async_step_ups",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"nut_config",
".",
"update",
"(",
"user_input",
")",
"if",
"self",
".",
"_host_... | [
182,
4
] | [
199,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_resources | (self, user_input=None) | Handle the picking the resources. | Handle the picking the resources. | async def async_step_resources(self, user_input=None):
"""Handle the picking the resources."""
if user_input is None:
return self.async_show_form(
step_id="resources",
data_schema=vol.Schema(
_resource_schema_base(self.available_resources, ... | [
"async",
"def",
"async_step_resources",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"resources\"",
",",
"data_schema",
"=",
"vol",
".",
"Schema... | [
201,
4
] | [
213,
73
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow._host_port_alias_already_configured | (self, user_input) | See if we already have a nut entry matching user input configured. | See if we already have a nut entry matching user input configured. | def _host_port_alias_already_configured(self, user_input):
"""See if we already have a nut entry matching user input configured."""
existing_host_port_aliases = {
_format_host_port_alias(entry.data)
for entry in self._async_current_entries()
if CONF_HOST in entry.data... | [
"def",
"_host_port_alias_already_configured",
"(",
"self",
",",
"user_input",
")",
":",
"existing_host_port_aliases",
"=",
"{",
"_format_host_port_alias",
"(",
"entry",
".",
"data",
")",
"for",
"entry",
"in",
"self",
".",
"_async_current_entries",
"(",
")",
"if",
... | [
215,
4
] | [
222,
80
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
238,
4
] | [
240,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
246,
4
] | [
248,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
resources = find_resources_in_config_entry(self.config_entry)
scan_interval = self.config_entry.options.get(
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"user_input",
")",
"resources"... | [
250,
4
] | [
270,
9
] | python | en | ['en', 'nl', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Mycroft notification service. | Get the Mycroft notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Mycroft notification service."""
return MycroftNotificationService(hass.data["mycroft"]) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"MycroftNotificationService",
"(",
"hass",
".",
"data",
"[",
"\"mycroft\"",
"]",
")"
] | [
10,
0
] | [
12,
59
] | python | en | ['en', 'en', 'en'] | True |
MycroftNotificationService.__init__ | (self, mycroft_ip) | Initialize the service. | Initialize the service. | def __init__(self, mycroft_ip):
"""Initialize the service."""
self.mycroft_ip = mycroft_ip | [
"def",
"__init__",
"(",
"self",
",",
"mycroft_ip",
")",
":",
"self",
".",
"mycroft_ip",
"=",
"mycroft_ip"
] | [
18,
4
] | [
20,
36
] | python | en | ['en', 'en', 'en'] | True |
MycroftNotificationService.send_message | (self, message="", **kwargs) | Send a message mycroft to speak on instance. | Send a message mycroft to speak on instance. | def send_message(self, message="", **kwargs):
"""Send a message mycroft to speak on instance."""
text = message
mycroft = MycroftAPI(self.mycroft_ip)
if mycroft is not None:
mycroft.speak_text(text)
else:
_LOGGER.log("Could not reach this instance of mycr... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"message",
"mycroft",
"=",
"MycroftAPI",
"(",
"self",
".",
"mycroft_ip",
")",
"if",
"mycroft",
"is",
"not",
"None",
":",
"mycroft",
".",
... | [
22,
4
] | [
30,
67
] | python | en | ['en', 'de', 'en'] | True |
registry | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def registry(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"registry",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
17,
0
] | [
19,
30
] | python | en | ['en', 'fy', 'en'] | True |
update_events | (hass) | Capture update events. | Capture update events. | def update_events(hass):
"""Capture update events."""
events = []
@callback
def async_capture(event):
events.append(event.data)
hass.bus.async_listen(entity_registry.EVENT_ENTITY_REGISTRY_UPDATED, async_capture)
return events | [
"def",
"update_events",
"(",
"hass",
")",
":",
"events",
"=",
"[",
"]",
"@",
"callback",
"def",
"async_capture",
"(",
"event",
")",
":",
"events",
".",
"append",
"(",
"event",
".",
"data",
")",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"entity_regi... | [
23,
0
] | [
33,
17
] | python | en | ['es', 'nl', 'en'] | False |
test_get_or_create_returns_same_entry | (hass, registry, update_events) | Make sure we do not duplicate entries. | Make sure we do not duplicate entries. | async def test_get_or_create_returns_same_entry(hass, registry, update_events):
"""Make sure we do not duplicate entries."""
entry = registry.async_get_or_create("light", "hue", "1234")
entry2 = registry.async_get_or_create("light", "hue", "1234")
await hass.async_block_till_done()
assert len(regi... | [
"async",
"def",
"test_get_or_create_returns_same_entry",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
")",
"entry2",
"=",
"registry",
".",
"... | [
36,
0
] | [
48,
59
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_suggested_object_id | (registry) | Test that suggested_object_id works. | Test that suggested_object_id works. | def test_get_or_create_suggested_object_id(registry):
"""Test that suggested_object_id works."""
entry = registry.async_get_or_create(
"light", "hue", "1234", suggested_object_id="beer"
)
assert entry.entity_id == "light.beer" | [
"def",
"test_get_or_create_suggested_object_id",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
",",
"suggested_object_id",
"=",
"\"beer\"",
")",
"assert",
"entry",
".",
"entity_id"... | [
51,
0
] | [
57,
42
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_updates_data | (registry) | Test that we update data in get_or_create. | Test that we update data in get_or_create. | def test_get_or_create_updates_data(registry):
"""Test that we update data in get_or_create."""
orig_config_entry = MockConfigEntry(domain="light")
orig_entry = registry.async_get_or_create(
"light",
"hue",
"5678",
config_entry=orig_config_entry,
device_id="mock-dev-... | [
"def",
"test_get_or_create_updates_data",
"(",
"registry",
")",
":",
"orig_config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
")",
"orig_entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"5678\"",
",",... | [
60,
0
] | [
115,
65
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_suggested_object_id_conflict_register | (registry) | Test that we don't generate an entity id that is already registered. | Test that we don't generate an entity id that is already registered. | def test_get_or_create_suggested_object_id_conflict_register(registry):
"""Test that we don't generate an entity id that is already registered."""
entry = registry.async_get_or_create(
"light", "hue", "1234", suggested_object_id="beer"
)
entry2 = registry.async_get_or_create(
"light", "h... | [
"def",
"test_get_or_create_suggested_object_id_conflict_register",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
",",
"suggested_object_id",
"=",
"\"beer\"",
")",
"entry2",
"=",
"reg... | [
118,
0
] | [
128,
45
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_suggested_object_id_conflict_existing | (hass, registry) | Test that we don't generate an entity id that currently exists. | Test that we don't generate an entity id that currently exists. | def test_get_or_create_suggested_object_id_conflict_existing(hass, registry):
"""Test that we don't generate an entity id that currently exists."""
hass.states.async_set("light.hue_1234", "on")
entry = registry.async_get_or_create("light", "hue", "1234")
assert entry.entity_id == "light.hue_1234_2" | [
"def",
"test_get_or_create_suggested_object_id_conflict_existing",
"(",
"hass",
",",
"registry",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.hue_1234\"",
",",
"\"on\"",
")",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
... | [
131,
0
] | [
135,
48
] | python | en | ['en', 'en', 'en'] | True |
test_create_triggers_save | (hass, registry) | Test that registering entry triggers a save. | Test that registering entry triggers a save. | def test_create_triggers_save(hass, registry):
"""Test that registering entry triggers a save."""
with patch.object(registry, "async_schedule_save") as mock_schedule_save:
registry.async_get_or_create("light", "hue", "1234")
assert len(mock_schedule_save.mock_calls) == 1 | [
"def",
"test_create_triggers_save",
"(",
"hass",
",",
"registry",
")",
":",
"with",
"patch",
".",
"object",
"(",
"registry",
",",
"\"async_schedule_save\"",
")",
"as",
"mock_schedule_save",
":",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue... | [
138,
0
] | [
143,
50
] | python | en | ['en', 'en', 'en'] | True |
test_loading_saving_data | (hass, registry) | Test that we load/save data correctly. | Test that we load/save data correctly. | async def test_loading_saving_data(hass, registry):
"""Test that we load/save data correctly."""
mock_config = MockConfigEntry(domain="light")
orig_entry1 = registry.async_get_or_create("light", "hue", "1234")
orig_entry2 = registry.async_get_or_create(
"light",
"hue",
"5678",
... | [
"async",
"def",
"test_loading_saving_data",
"(",
"hass",
",",
"registry",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
")",
"orig_entry1",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\... | [
146,
0
] | [
193,
59
] | python | en | ['en', 'en', 'en'] | True |
test_generate_entity_considers_registered_entities | (registry) | Test that we don't create entity id that are already registered. | Test that we don't create entity id that are already registered. | def test_generate_entity_considers_registered_entities(registry):
"""Test that we don't create entity id that are already registered."""
entry = registry.async_get_or_create("light", "hue", "1234")
assert entry.entity_id == "light.hue_1234"
assert registry.async_generate_entity_id("light", "hue_1234") =... | [
"def",
"test_generate_entity_considers_registered_entities",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
")",
"assert",
"entry",
".",
"entity_id",
"==",
"\"light.hue_1234\"",
"asse... | [
196,
0
] | [
200,
87
] | python | en | ['en', 'en', 'en'] | True |
test_generate_entity_considers_existing_entities | (hass, registry) | Test that we don't create entity id that currently exists. | Test that we don't create entity id that currently exists. | def test_generate_entity_considers_existing_entities(hass, registry):
"""Test that we don't create entity id that currently exists."""
hass.states.async_set("light.kitchen", "on")
assert registry.async_generate_entity_id("light", "kitchen") == "light.kitchen_2" | [
"def",
"test_generate_entity_considers_existing_entities",
"(",
"hass",
",",
"registry",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.kitchen\"",
",",
"\"on\"",
")",
"assert",
"registry",
".",
"async_generate_entity_id",
"(",
"\"light\"",
",",
"\... | [
203,
0
] | [
206,
85
] | python | en | ['en', 'en', 'en'] | True |
test_is_registered | (registry) | Test that is_registered works. | Test that is_registered works. | def test_is_registered(registry):
"""Test that is_registered works."""
entry = registry.async_get_or_create("light", "hue", "1234")
assert registry.async_is_registered(entry.entity_id)
assert not registry.async_is_registered("light.non_existing") | [
"def",
"test_is_registered",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
")",
"assert",
"registry",
".",
"async_is_registered",
"(",
"entry",
".",
"entity_id",
")",
"assert",... | [
209,
0
] | [
213,
65
] | python | en | ['en', 'en', 'en'] | True |
test_loading_extra_values | (hass, hass_storage) | Test we load extra data from the registry. | Test we load extra data from the registry. | async def test_loading_extra_values(hass, hass_storage):
"""Test we load extra data from the registry."""
hass_storage[entity_registry.STORAGE_KEY] = {
"version": entity_registry.STORAGE_VERSION,
"data": {
"entities": [
{
"entity_id": "test.named",... | [
"async",
"def",
"test_loading_extra_values",
"(",
"hass",
",",
"hass_storage",
")",
":",
"hass_storage",
"[",
"entity_registry",
".",
"STORAGE_KEY",
"]",
"=",
"{",
"\"version\"",
":",
"entity_registry",
".",
"STORAGE_VERSION",
",",
"\"data\"",
":",
"{",
"\"entitie... | [
216,
0
] | [
278,
75
] | python | en | ['en', 'en', 'en'] | True |
test_async_get_entity_id | (registry) | Test that entity_id is returned. | Test that entity_id is returned. | def test_async_get_entity_id(registry):
"""Test that entity_id is returned."""
entry = registry.async_get_or_create("light", "hue", "1234")
assert entry.entity_id == "light.hue_1234"
assert registry.async_get_entity_id("light", "hue", "1234") == "light.hue_1234"
assert registry.async_get_entity_id("... | [
"def",
"test_async_get_entity_id",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"1234\"",
")",
"assert",
"entry",
".",
"entity_id",
"==",
"\"light.hue_1234\"",
"assert",
"registry",
".",
... | [
281,
0
] | [
286,
70
] | python | en | ['en', 'en', 'en'] | True |
test_updating_config_entry_id | (hass, registry, update_events) | Test that we update config entry id in registry. | Test that we update config entry id in registry. | async def test_updating_config_entry_id(hass, registry, update_events):
"""Test that we update config entry id in registry."""
mock_config_1 = MockConfigEntry(domain="light", entry_id="mock-id-1")
entry = registry.async_get_or_create(
"light", "hue", "5678", config_entry=mock_config_1
)
moc... | [
"async",
"def",
"test_updating_config_entry_id",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"mock_config_1",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
")",
"entry",
"=",
"registry",
".",
"a... | [
289,
0
] | [
310,
61
] | python | en | ['en', 'en', 'en'] | True |
test_removing_config_entry_id | (hass, registry, update_events) | Test that we update config entry id in registry. | Test that we update config entry id in registry. | async def test_removing_config_entry_id(hass, registry, update_events):
"""Test that we update config entry id in registry."""
mock_config = MockConfigEntry(domain="light", entry_id="mock-id-1")
entry = registry.async_get_or_create(
"light", "hue", "5678", config_entry=mock_config
)
assert ... | [
"async",
"def",
"test_removing_config_entry_id",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
")",
"entry",
"=",
"registry",
".",
"asy... | [
313,
0
] | [
331,
59
] | python | en | ['en', 'en', 'en'] | True |
test_removing_area_id | (registry) | Make sure we can clear area id. | Make sure we can clear area id. | async def test_removing_area_id(registry):
"""Make sure we can clear area id."""
entry = registry.async_get_or_create("light", "hue", "5678")
entry_w_area = registry.async_update_entity(entry.entity_id, area_id="12345A")
registry.async_clear_area_id("12345A")
entry_wo_area = registry.async_get(ent... | [
"async",
"def",
"test_removing_area_id",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"5678\"",
")",
"entry_w_area",
"=",
"registry",
".",
"async_update_entity",
"(",
"entry",
".",
"ent... | [
334,
0
] | [
344,
40
] | python | en | ['en', 'en', 'en'] | True |
test_migration | (hass) | Test migration from old data to new. | Test migration from old data to new. | async def test_migration(hass):
"""Test migration from old data to new."""
mock_config = MockConfigEntry(domain="test-platform", entry_id="test-config-id")
old_conf = {
"light.kitchen": {
"config_entry_id": "test-config-id",
"unique_id": "test-unique",
"platform"... | [
"async",
"def",
"test_migration",
"(",
"hass",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test-platform\"",
",",
"entry_id",
"=",
"\"test-config-id\"",
")",
"old_conf",
"=",
"{",
"\"light.kitchen\"",
":",
"{",
"\"config_entry_id\"",
":... | [
347,
0
] | [
374,
52
] | python | en | ['en', 'en', 'en'] | True |
test_loading_invalid_entity_id | (hass, hass_storage) | Test we autofix invalid entity IDs. | Test we autofix invalid entity IDs. | async def test_loading_invalid_entity_id(hass, hass_storage):
"""Test we autofix invalid entity IDs."""
hass_storage[entity_registry.STORAGE_KEY] = {
"version": entity_registry.STORAGE_VERSION,
"data": {
"entities": [
{
"entity_id": "test.invalid__... | [
"async",
"def",
"test_loading_invalid_entity_id",
"(",
"hass",
",",
"hass_storage",
")",
":",
"hass_storage",
"[",
"entity_registry",
".",
"STORAGE_KEY",
"]",
"=",
"{",
"\"version\"",
":",
"entity_registry",
".",
"STORAGE_VERSION",
",",
"\"data\"",
":",
"{",
"\"en... | [
377,
0
] | [
421,
58
] | python | en | ['en', 'fr', 'en'] | True |
test_loading_race_condition | (hass) | Test only one storage load called when concurrent loading occurred . | Test only one storage load called when concurrent loading occurred . | async def test_loading_race_condition(hass):
"""Test only one storage load called when concurrent loading occurred ."""
with tests.async_mock.patch(
"homeassistant.helpers.entity_registry.EntityRegistry.async_load"
) as mock_load:
results = await asyncio.gather(
entity_registry.a... | [
"async",
"def",
"test_loading_race_condition",
"(",
"hass",
")",
":",
"with",
"tests",
".",
"async_mock",
".",
"patch",
"(",
"\"homeassistant.helpers.entity_registry.EntityRegistry.async_load\"",
")",
"as",
"mock_load",
":",
"results",
"=",
"await",
"asyncio",
".",
"g... | [
424,
0
] | [
435,
39
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity_unique_id | (registry) | Test entity's unique_id is updated. | Test entity's unique_id is updated. | async def test_update_entity_unique_id(registry):
"""Test entity's unique_id is updated."""
mock_config = MockConfigEntry(domain="light", entry_id="mock-id-1")
entry = registry.async_get_or_create(
"light", "hue", "5678", config_entry=mock_config
)
assert registry.async_get_entity_id("light... | [
"async",
"def",
"test_update_entity_unique_id",
"(",
"registry",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
")",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
"... | [
438,
0
] | [
457,
82
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity_unique_id_conflict | (registry) | Test migration raises when unique_id already in use. | Test migration raises when unique_id already in use. | async def test_update_entity_unique_id_conflict(registry):
"""Test migration raises when unique_id already in use."""
mock_config = MockConfigEntry(domain="light", entry_id="mock-id-1")
entry = registry.async_get_or_create(
"light", "hue", "5678", config_entry=mock_config
)
entry2 = registry... | [
"async",
"def",
"test_update_entity_unique_id_conflict",
"(",
"registry",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
")",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"ligh... | [
460,
0
] | [
475,
83
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity | (registry) | Test updating entity. | Test updating entity. | async def test_update_entity(registry):
"""Test updating entity."""
mock_config = MockConfigEntry(domain="light", entry_id="mock-id-1")
entry = registry.async_get_or_create(
"light", "hue", "5678", config_entry=mock_config
)
for attr_name, new_value in (
("name", "new name"),
... | [
"async",
"def",
"test_update_entity",
"(",
"registry",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
")",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"h... | [
478,
0
] | [
501,
29
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by | (registry) | Test that we can disable an entry when we create it. | Test that we can disable an entry when we create it. | async def test_disabled_by(registry):
"""Test that we can disable an entry when we create it."""
entry = registry.async_get_or_create("light", "hue", "5678", disabled_by="hass")
assert entry.disabled_by == "hass"
entry = registry.async_get_or_create(
"light", "hue", "5678", disabled_by="integra... | [
"async",
"def",
"test_disabled_by",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"\"light\"",
",",
"\"hue\"",
",",
"\"5678\"",
",",
"disabled_by",
"=",
"\"hass\"",
")",
"assert",
"entry",
".",
"disabled_by",
"==",
"\"ha... | [
504,
0
] | [
515,
37
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by_system_options | (registry) | Test system options setting disabled_by. | Test system options setting disabled_by. | async def test_disabled_by_system_options(registry):
"""Test system options setting disabled_by."""
mock_config = MockConfigEntry(
domain="light",
entry_id="mock-id-1",
system_options={"disable_new_entities": True},
)
entry = registry.async_get_or_create(
"light", "hue", ... | [
"async",
"def",
"test_disabled_by_system_options",
"(",
"registry",
")",
":",
"mock_config",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"light\"",
",",
"entry_id",
"=",
"\"mock-id-1\"",
",",
"system_options",
"=",
"{",
"\"disable_new_entities\"",
":",
"True",
"}"... | [
518,
0
] | [
533,
39
] | python | en | ['id', 'en', 'en'] | True |
test_restore_states | (hass) | Test restoring states. | Test restoring states. | async def test_restore_states(hass):
"""Test restoring states."""
hass.state = CoreState.not_running
registry = await entity_registry.async_get_registry(hass)
registry.async_get_or_create(
"light",
"hue",
"1234",
suggested_object_id="simple",
)
# Should not be c... | [
"async",
"def",
"test_restore_states",
"(",
"hass",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"registry",
".",
"async_get_or_create",
"(",
"\"li... | [
536,
0
] | [
599,
56
] | python | en | ['en', 'jv', 'en'] | True |
test_async_get_device_class_lookup | (hass) | Test registry device class lookup. | Test registry device class lookup. | async def test_async_get_device_class_lookup(hass):
"""Test registry device class lookup."""
hass.state = CoreState.not_running
ent_reg = await entity_registry.async_get_registry(hass)
ent_reg.async_get_or_create(
"binary_sensor",
"light",
"battery_charging",
device_id=... | [
"async",
"def",
"test_async_get_device_class_lookup",
"(",
"hass",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"ent_reg",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"ent_reg",
".",
"async_get_or_create",
... | [
602,
0
] | [
678,
5
] | python | en | ['en', 'fy', 'en'] | True |
setup | (hass, config) | Set up the streamlabs water component. | Set up the streamlabs water component. | def setup(hass, config):
"""Set up the streamlabs water component."""
conf = config[DOMAIN]
api_key = conf.get(CONF_API_KEY)
location_id = conf.get(CONF_LOCATION_ID)
client = streamlabswater.StreamlabsClient(api_key)
locations = client.get_locations().get("locations")
if locations is None... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"api_key",
"=",
"conf",
".",
"get",
"(",
"CONF_API_KEY",
")",
"location_id",
"=",
"conf",
".",
"get",
"(",
"CONF_LOCATION_ID",
")",
"client",
"=",
"streaml... | [
40,
0
] | [
88,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up MQTT binary sensor through configuration.yaml. | Set up MQTT binary sensor through configuration.yaml. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up MQTT binary sensor through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
await _async_setup_entity(hass, config, async_add_entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATF... | [
73,
0
] | [
78,
63
] | python | en | ['en', 'ny', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT binary sensor dynamically through MQTT discovery. | Set up MQTT binary sensor dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT binary sensor dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add a MQTT binary sensor."""
discovery_data = discovery_payload.discovery_data
try:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add a MQTT binary sensor.\"\"\"",
"discovery_data",
"=",
"discovery_payload"... | [
81,
0
] | [
98,
5
] | python | en | ['en', 'vi', 'en'] | True |
_async_setup_entity | (
hass, config, async_add_entities, config_entry=None, discovery_data=None
) | Set up the MQTT binary sensor. | Set up the MQTT binary sensor. | async def _async_setup_entity(
hass, config, async_add_entities, config_entry=None, discovery_data=None
):
"""Set up the MQTT binary sensor."""
async_add_entities([MqttBinarySensor(hass, config, config_entry, discovery_data)]) | [
"async",
"def",
"_async_setup_entity",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"config_entry",
"=",
"None",
",",
"discovery_data",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"MqttBinarySensor",
"(",
"hass",
",",
"config",
",",
"... | [
101,
0
] | [
105,
86
] | python | en | ['en', 'mt', 'en'] | True |
MqttBinarySensor.__init__ | (self, hass, config, config_entry, discovery_data) | Initialize the MQTT binary sensor. | Initialize the MQTT binary sensor. | def __init__(self, hass, config, config_entry, discovery_data):
"""Initialize the MQTT binary sensor."""
self.hass = hass
self._unique_id = config.get(CONF_UNIQUE_ID)
self._state = None
self._sub_state = None
self._expiration_trigger = None
self._delay_listener = ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_unique_id",
"=",
"config",
".",
"get",
"(",
"CONF_UNIQUE_ID",
")",
"self",
".",
"_state",
... | [
117,
4
] | [
139,
72
] | python | en | ['en', 'co', 'en'] | True |
MqttBinarySensor.async_added_to_hass | (self) | Subscribe mqtt events. | Subscribe mqtt events. | async def async_added_to_hass(self):
"""Subscribe mqtt events."""
await super().async_added_to_hass()
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
141,
4
] | [
144,
38
] | python | en | ['en', 'en', 'it'] | True |
MqttBinarySensor.discovery_update | (self, discovery_payload) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, discovery_payload):
"""Handle updated discovery message."""
config = PLATFORM_SCHEMA(discovery_payload)
self._setup_from_config(config)
await self.attributes_discovery_update(config)
await self.availability_discovery_update(config)
await s... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"discovery_payload",
")",
":",
"config",
"=",
"PLATFORM_SCHEMA",
"(",
"discovery_payload",
")",
"self",
".",
"_setup_from_config",
"(",
"config",
")",
"await",
"self",
".",
"attributes_discovery_update",
"(",
"... | [
146,
4
] | [
154,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
@callback
def off_delay_listener(now):
"""Switch device off after a delay."""
self._delay_listener = None
self._state = False
self.async_write_ha_state()
@callback
... | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"off_delay_listener",
"(",
"now",
")",
":",
"\"\"\"Switch device off after a delay.\"\"\"",
"self",
".",
"_delay_listener",
"=",
"None",
"self",
".",
"_state",
"=",
"False",
"self"... | [
162,
4
] | [
252,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state
)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_fro... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_sub_state",
"=",
"await",
"subscription",
".",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sub_state",
")",
"await",
"MqttAttributes",
".",
"async_... | [
254,
4
] | [
261,
67
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor._value_is_expired | (self, *_) | Triggered when value is expired. | Triggered when value is expired. | def _value_is_expired(self, *_):
"""Triggered when value is expired."""
self._expiration_trigger = None
self._expired = True
self.async_write_ha_state() | [
"def",
"_value_is_expired",
"(",
"self",
",",
"*",
"_",
")",
":",
"self",
".",
"_expiration_trigger",
"=",
"None",
"self",
".",
"_expired",
"=",
"True",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
264,
4
] | [
270,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
273,
4
] | [
275,
20
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self):
"""Return the name of the binary sensor."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
278,
4
] | [
280,
38
] | python | en | ['en', 'mi', 'en'] | True |
MqttBinarySensor.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 self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
283,
4
] | [
285,
26
] | python | en | ['en', 'fy', 'en'] | True |
MqttBinarySensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return self._config.get(CONF_DEVICE_CLASS) | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_DEVICE_CLASS",
")"
] | [
288,
4
] | [
290,
50
] | python | en | ['en', 'en', 'en'] | True |
MqttBinarySensor.force_update | (self) | Force update. | Force update. | def force_update(self):
"""Force update."""
return self._config[CONF_FORCE_UPDATE] | [
"def",
"force_update",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_FORCE_UPDATE",
"]"
] | [
293,
4
] | [
295,
46
] | python | en | ['en', 'en', 'en'] | False |
MqttBinarySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
298,
4
] | [
300,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
MqttBinarySensor.available | (self) | Return true if the device is available and value has not expired. | Return true if the device is available and value has not expired. | def available(self) -> bool:
"""Return true if the device is available and value has not expired."""
expire_after = self._config.get(CONF_EXPIRE_AFTER)
# pylint: disable=no-member
return MqttAvailability.available.fget(self) and (
expire_after is None or not self._expired
... | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"expire_after",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_EXPIRE_AFTER",
")",
"# pylint: disable=no-member",
"return",
"MqttAvailability",
".",
"available",
".",
"fget",
"(",
"self",
")",
"and"... | [
303,
4
] | [
309,
9
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.