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_entry_created_existing_app_new_oauth_client | (
hass, app, app_oauth_client, location, smartthings_mock
) | Test entry is created with an existing app and generation of a new oauth client. | Test entry is created with an existing app and generation of a new oauth client. | async def test_entry_created_existing_app_new_oauth_client(
hass, app, app_oauth_client, location, smartthings_mock
):
"""Test entry is created with an existing app and generation of a new oauth client."""
token = str(uuid4())
installed_app_id = str(uuid4())
refresh_token = str(uuid4())
smartthi... | [
"async",
"def",
"test_entry_created_existing_app_new_oauth_client",
"(",
"hass",
",",
"app",
",",
"app_oauth_client",
",",
"location",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"installed_app_id",
"=",
"str",
"(",
"uuid... | [
182,
0
] | [
250,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entry_created_existing_app_copies_oauth_client | (
hass, app, location, smartthings_mock
) | Test entry is created with an existing app and copies the oauth client from another entry. | Test entry is created with an existing app and copies the oauth client from another entry. | async def test_entry_created_existing_app_copies_oauth_client(
hass, app, location, smartthings_mock
):
"""Test entry is created with an existing app and copies the oauth client from another entry."""
token = str(uuid4())
installed_app_id = str(uuid4())
refresh_token = str(uuid4())
oauth_client_... | [
"async",
"def",
"test_entry_created_existing_app_copies_oauth_client",
"(",
"hass",
",",
"app",
",",
"location",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"installed_app_id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
... | [
253,
0
] | [
340,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entry_created_with_cloudhook | (
hass, app, app_oauth_client, location, smartthings_mock
) | Test cloud, new app, install event creates entry. | Test cloud, new app, install event creates entry. | async def test_entry_created_with_cloudhook(
hass, app, app_oauth_client, location, smartthings_mock
):
"""Test cloud, new app, install event creates entry."""
hass.config.components.add("cloud")
# Unload the endpoint so we can reload it under the cloud.
await smartapp.unload_smartapp_endpoint(hass)... | [
"async",
"def",
"test_entry_created_with_cloudhook",
"(",
"hass",
",",
"app",
",",
"app_oauth_client",
",",
"location",
",",
"smartthings_mock",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"cloud\"",
")",
"# Unload the endpoint so we can r... | [
343,
0
] | [
425,
9
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_webhook_aborts | (hass) | Test flow aborts if webhook is invalid. | Test flow aborts if webhook is invalid. | async def test_invalid_webhook_aborts(hass):
"""Test flow aborts if webhook is invalid."""
# Webhook confirmation shown
await async_process_ha_core_config(
hass,
{"external_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, conte... | [
"async",
"def",
"test_invalid_webhook_aborts",
"(",
"hass",
")",
":",
"# Webhook confirmation shown",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",... | [
428,
0
] | [
443,
64
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_token_shows_error | (hass) | Test an error is shown for invalid token formats. | Test an error is shown for invalid token formats. | async def test_invalid_token_shows_error(hass):
"""Test an error is shown for invalid token formats."""
token = "123456789"
# Webhook confirmation shown
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert result["type"] == data_entry_flow.RESU... | [
"async",
"def",
"test_invalid_token_shows_error",
"(",
"hass",
")",
":",
"token",
"=",
"\"123456789\"",
"# Webhook confirmation shown",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
... | [
446,
0
] | [
476,
64
] | python | en | ['en', 'en', 'en'] | True |
test_unauthorized_token_shows_error | (hass, smartthings_mock) | Test an error is shown for unauthorized token formats. | Test an error is shown for unauthorized token formats. | async def test_unauthorized_token_shows_error(hass, smartthings_mock):
"""Test an error is shown for unauthorized token formats."""
token = str(uuid4())
request_info = Mock(real_url="http://example.com")
smartthings_mock.apps.side_effect = ClientResponseError(
request_info=request_info, history=... | [
"async",
"def",
"test_unauthorized_token_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"smartthings_mock",
".",
"a... | [
479,
0
] | [
513,
64
] | python | en | ['en', 'en', 'en'] | True |
test_forbidden_token_shows_error | (hass, smartthings_mock) | Test an error is shown for forbidden token formats. | Test an error is shown for forbidden token formats. | async def test_forbidden_token_shows_error(hass, smartthings_mock):
"""Test an error is shown for forbidden token formats."""
token = str(uuid4())
request_info = Mock(real_url="http://example.com")
smartthings_mock.apps.side_effect = ClientResponseError(
request_info=request_info, history=None, ... | [
"async",
"def",
"test_forbidden_token_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"smartthings_mock",
".",
"apps... | [
516,
0
] | [
550,
64
] | python | en | ['en', 'lb', 'en'] | True |
test_webhook_problem_shows_error | (hass, smartthings_mock) | Test an error is shown when there's an problem with the webhook endpoint. | Test an error is shown when there's an problem with the webhook endpoint. | async def test_webhook_problem_shows_error(hass, smartthings_mock):
"""Test an error is shown when there's an problem with the webhook endpoint."""
token = str(uuid4())
data = {"error": {}}
request_info = Mock(real_url="http://example.com")
error = APIResponseError(
request_info=request_info... | [
"async",
"def",
"test_webhook_problem_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"data",
"=",
"{",
"\"error\"",
":",
"{",
"}",
"}",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\... | [
553,
0
] | [
590,
64
] | python | en | ['en', 'en', 'en'] | True |
test_api_error_shows_error | (hass, smartthings_mock) | Test an error is shown when other API errors occur. | Test an error is shown when other API errors occur. | async def test_api_error_shows_error(hass, smartthings_mock):
"""Test an error is shown when other API errors occur."""
token = str(uuid4())
data = {"error": {}}
request_info = Mock(real_url="http://example.com")
error = APIResponseError(
request_info=request_info, history=None, data=data, s... | [
"async",
"def",
"test_api_error_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"data",
"=",
"{",
"\"error\"",
":",
"{",
"}",
"}",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http:... | [
593,
0
] | [
629,
64
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_response_error_shows_error | (hass, smartthings_mock) | Test an error is shown when there is an unknown API error. | Test an error is shown when there is an unknown API error. | async def test_unknown_response_error_shows_error(hass, smartthings_mock):
"""Test an error is shown when there is an unknown API error."""
token = str(uuid4())
request_info = Mock(real_url="http://example.com")
error = ClientResponseError(
request_info=request_info, history=None, status=HTTP_NO... | [
"async",
"def",
"test_unknown_response_error_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"error",
"=",
"ClientRe... | [
632,
0
] | [
667,
64
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_error_shows_error | (hass, smartthings_mock) | Test an error is shown when there is an unknown API error. | Test an error is shown when there is an unknown API error. | async def test_unknown_error_shows_error(hass, smartthings_mock):
"""Test an error is shown when there is an unknown API error."""
token = str(uuid4())
smartthings_mock.apps.side_effect = Exception("Unknown error")
# Webhook confirmation shown
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_unknown_error_shows_error",
"(",
"hass",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"smartthings_mock",
".",
"apps",
".",
"side_effect",
"=",
"Exception",
"(",
"\"Unknown error\"",
")",
"# Webhook c... | [
670,
0
] | [
701,
64
] | python | en | ['en', 'en', 'en'] | True |
test_no_available_locations_aborts | (
hass, app, app_oauth_client, location, smartthings_mock
) | Test select location aborts if no available locations. | Test select location aborts if no available locations. | async def test_no_available_locations_aborts(
hass, app, app_oauth_client, location, smartthings_mock
):
"""Test select location aborts if no available locations."""
token = str(uuid4())
smartthings_mock.apps.return_value = []
smartthings_mock.create_app.return_value = (app, app_oauth_client)
sm... | [
"async",
"def",
"test_no_available_locations_aborts",
"(",
"hass",
",",
"app",
",",
"app_oauth_client",
",",
"location",
",",
"smartthings_mock",
")",
":",
"token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"smartthings_mock",
".",
"apps",
".",
"return_value",
... | [
704,
0
] | [
739,
55
] | python | en | ['en', 'en', 'en'] | True |
run | (args) | Handle ensure config commandline script. | Handle ensure config commandline script. | def run(args):
"""Handle ensure config commandline script."""
parser = argparse.ArgumentParser(
description=("Ensure a Home Assistant config exists, creates one if necessary.")
)
parser.add_argument(
"-c",
"--config",
metavar="path_to_config_dir",
default=config_u... | [
"def",
"run",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"Ensure a Home Assistant config exists, creates one if necessary.\"",
")",
")",
"parser",
".",
"add_argument",
"(",
"\"-c\"",
",",
"\"--config\"",
... | [
11,
0
] | [
36,
12
] | python | da | ['da', 'es', 'en'] | False |
async_run | (config_dir) | Make sure config exists. | Make sure config exists. | async def async_run(config_dir):
"""Make sure config exists."""
hass = HomeAssistant()
hass.config.config_dir = config_dir
path = await config_util.async_ensure_config_exists(hass)
await hass.async_stop(force=True)
return path | [
"async",
"def",
"async_run",
"(",
"config_dir",
")",
":",
"hass",
"=",
"HomeAssistant",
"(",
")",
"hass",
".",
"config",
".",
"config_dir",
"=",
"config_dir",
"path",
"=",
"await",
"config_util",
".",
"async_ensure_config_exists",
"(",
"hass",
")",
"await",
... | [
39,
0
] | [
45,
15
] | python | en | ['en', 'es', 'en'] | True |
async_attach_trigger | (
hass, config, action, automation_info, *, platform_type="event"
) | Listen for events based on configuration. | Listen for events based on configuration. | async def async_attach_trigger(
hass, config, action, automation_info, *, platform_type="event"
):
"""Listen for events based on configuration."""
event_types = config.get(CONF_EVENT_TYPE)
removes = []
event_data_schema = None
if config.get(CONF_EVENT_DATA):
event_data_schema = vol.Sche... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
",",
"*",
",",
"platform_type",
"=",
"\"event\"",
")",
":",
"event_types",
"=",
"config",
".",
"get",
"(",
"CONF_EVENT_TYPE",
")",
"removes",
"=",
"[",... | [
30,
0
] | [
95,
31
] | python | en | ['en', 'en', 'en'] | True |
get_engine | (hass, config, discovery_info=None) | Set up Demo speech component. | Set up Demo speech component. | def get_engine(hass, config, discovery_info=None):
"""Set up Demo speech component."""
return DemoProvider(config.get(CONF_LANG, DEFAULT_LANG)) | [
"def",
"get_engine",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"DemoProvider",
"(",
"config",
".",
"get",
"(",
"CONF_LANG",
",",
"DEFAULT_LANG",
")",
")"
] | [
16,
0
] | [
18,
60
] | python | en | ['en', 'lb', 'en'] | True |
DemoProvider.__init__ | (self, lang) | Initialize demo provider. | Initialize demo provider. | def __init__(self, lang):
"""Initialize demo provider."""
self._lang = lang
self.name = "Demo" | [
"def",
"__init__",
"(",
"self",
",",
"lang",
")",
":",
"self",
".",
"_lang",
"=",
"lang",
"self",
".",
"name",
"=",
"\"Demo\""
] | [
24,
4
] | [
27,
26
] | python | it | ['es', 'it', 'it'] | True |
DemoProvider.default_language | (self) | Return the default language. | Return the default language. | def default_language(self):
"""Return the default language."""
return self._lang | [
"def",
"default_language",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lang"
] | [
30,
4
] | [
32,
25
] | python | en | ['en', 'et', 'en'] | True |
DemoProvider.supported_languages | (self) | Return list of supported languages. | Return list of supported languages. | def supported_languages(self):
"""Return list of supported languages."""
return SUPPORT_LANGUAGES | [
"def",
"supported_languages",
"(",
"self",
")",
":",
"return",
"SUPPORT_LANGUAGES"
] | [
35,
4
] | [
37,
32
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.supported_options | (self) | Return list of supported options like voice, emotionen. | Return list of supported options like voice, emotionen. | def supported_options(self):
"""Return list of supported options like voice, emotionen."""
return ["voice", "age"] | [
"def",
"supported_options",
"(",
"self",
")",
":",
"return",
"[",
"\"voice\"",
",",
"\"age\"",
"]"
] | [
40,
4
] | [
42,
31
] | python | en | ['en', 'en', 'en'] | True |
DemoProvider.get_tts_audio | (self, message, language, options=None) | Load TTS from demo. | Load TTS from demo. | def get_tts_audio(self, message, language, options=None):
"""Load TTS from demo."""
filename = os.path.join(os.path.dirname(__file__), "tts.mp3")
try:
with open(filename, "rb") as voice:
data = voice.read()
except OSError:
return (None, None)
... | [
"def",
"get_tts_audio",
"(",
"self",
",",
"message",
",",
"language",
",",
"options",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"tts.mp3\"",
")",
"try"... | [
44,
4
] | [
53,
28
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
19,
0
] | [
21,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
25,
0
] | [
27,
30
] | python | en | ['en', 'fy', 'en'] | True |
test_aid_generation | (hass, device_reg, entity_reg) | Test generating aids. | Test generating aids. | async def test_aid_generation(hass, device_reg, entity_reg):
"""Test generating aids."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={(device_regist... | [
"async",
"def",
"test_aid_generation",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",... | [
30,
0
] | [
97,
9
] | python | en | ['nl', 'en', 'it'] | False |
test_no_aid_collision | (hass, device_reg, entity_reg) | Test generating aids. | Test generating aids. | async def test_no_aid_collision(hass, device_reg, entity_reg):
"""Test generating aids."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={(device_regi... | [
"async",
"def",
"test_no_aid_collision",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")... | [
100,
0
] | [
124,
26
] | python | en | ['nl', 'en', 'it'] | False |
test_aid_generation_no_unique_ids_handles_collision | (
hass, device_reg, entity_reg
) | Test colliding aids is stable. | Test colliding aids is stable. | async def test_aid_generation_no_unique_ids_handles_collision(
hass, device_reg, entity_reg
):
"""Test colliding aids is stable."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
aid_storage = AccessoryAidStorage(hass, config_entry)
await aid_storage.async_... | [
"async",
"def",
"test_aid_generation_no_unique_ids_handles_collision",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_t... | [
127,
0
] | [
621,
70
] | python | en | ['en', 'en', 'en'] | True |
test_owner_fetching_owner_permissions | () | Test we fetch the owner permissions for an owner user. | Test we fetch the owner permissions for an owner user. | def test_owner_fetching_owner_permissions():
"""Test we fetch the owner permissions for an owner user."""
group = models.Group(name="Test Group", policy={})
owner = models.User(
name="Test User", perm_lookup=None, groups=[group], is_owner=True
)
assert owner.permissions is permissions.OwnerP... | [
"def",
"test_owner_fetching_owner_permissions",
"(",
")",
":",
"group",
"=",
"models",
".",
"Group",
"(",
"name",
"=",
"\"Test Group\"",
",",
"policy",
"=",
"{",
"}",
")",
"owner",
"=",
"models",
".",
"User",
"(",
"name",
"=",
"\"Test User\"",
",",
"perm_l... | [
4,
0
] | [
10,
60
] | python | en | ['en', 'en', 'en'] | True |
test_permissions_merged | () | Test we merge the groups permissions. | Test we merge the groups permissions. | def test_permissions_merged():
"""Test we merge the groups permissions."""
group = models.Group(
name="Test Group", policy={"entities": {"domains": {"switch": True}}}
)
group2 = models.Group(
name="Test Group", policy={"entities": {"entity_ids": {"light.kitchen": True}}}
)
user =... | [
"def",
"test_permissions_merged",
"(",
")",
":",
"group",
"=",
"models",
".",
"Group",
"(",
"name",
"=",
"\"Test Group\"",
",",
"policy",
"=",
"{",
"\"entities\"",
":",
"{",
"\"domains\"",
":",
"{",
"\"switch\"",
":",
"True",
"}",
"}",
"}",
")",
"group2"... | [
13,
0
] | [
27,
78
] | python | en | ['en', 'en', 'en'] | True |
ResNetVLBERT._collect_obj_reps | (self, span_tags, object_reps) |
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
|
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
| def _collect_obj_reps(self, span_tags, object_reps):
"""
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
"""
span_tags_fixed = torch.clamp(spa... | [
"def",
"_collect_obj_reps",
"(",
"self",
",",
"span_tags",
",",
"object_reps",
")",
":",
"span_tags_fixed",
"=",
"torch",
".",
"clamp",
"(",
"span_tags",
",",
"min",
"=",
"0",
")",
"# In case there were masked values here",
"row_id",
"=",
"span_tags_fixed",
".",
... | [
115,
4
] | [
132,
102
] | python | en | ['en', 'error', 'th'] | False |
test_user_flow_cannot_create_multiple_instances | (hass) | Test that the user flow aborts if an instance is already configured. | Test that the user flow aborts if an instance is already configured. | async def test_user_flow_cannot_create_multiple_instances(hass):
"""Test that the user flow aborts if an instance is already configured."""
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_DEVICE: "/already/configured/path"}
)
entry.add_to_hass(hass)
with patch(DONGLE_VALIDATE_PATH_METHOD... | [
"async",
"def",
"test_user_flow_cannot_create_multiple_instances",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_DEVICE",
":",
"\"/already/configured/path\"",
"}",
")",
"entry",
".",
"add_to_hass",... | [
13,
0
] | [
26,
56
] | python | en | ['en', 'en', 'en'] | True |
test_user_flow_with_detected_dongle | (hass) | Test the user flow with a detected ENOcean dongle. | Test the user flow with a detected ENOcean dongle. | async def test_user_flow_with_detected_dongle(hass):
"""Test the user flow with a detected ENOcean dongle."""
FAKE_DONGLE_PATH = "/fake/dongle"
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[FAKE_DONGLE_PATH])):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"... | [
"async",
"def",
"test_user_flow_with_detected_dongle",
"(",
"hass",
")",
":",
"FAKE_DONGLE_PATH",
"=",
"\"/fake/dongle\"",
"with",
"patch",
"(",
"DONGLE_DETECT_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"[",
"FAKE_DONGLE_PATH",
"]",
")",
")",
":",
"result",
"... | [
29,
0
] | [
42,
58
] | python | en | ['en', 'en', 'en'] | True |
test_user_flow_with_no_detected_dongle | (hass) | Test the user flow with a detected ENOcean dongle. | Test the user flow with a detected ENOcean dongle. | async def test_user_flow_with_no_detected_dongle(hass):
"""Test the user flow with a detected ENOcean dongle."""
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[])):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert result["type"... | [
"async",
"def",
"test_user_flow_with_no_detected_dongle",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"DONGLE_DETECT_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"[",
"]",
")",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
... | [
45,
0
] | [
53,
40
] | python | en | ['en', 'en', 'en'] | True |
test_detection_flow_with_valid_path | (hass) | Test the detection flow with a valid path selected. | Test the detection flow with a valid path selected. | async def test_detection_flow_with_valid_path(hass):
"""Test the detection flow with a valid path selected."""
USER_PROVIDED_PATH = "/user/provided/path"
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
result = await hass.config_entries.flow.async_init(
DOMAIN, context... | [
"async",
"def",
"test_detection_flow_with_valid_path",
"(",
"hass",
")",
":",
"USER_PROVIDED_PATH",
"=",
"\"/user/provided/path\"",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"True",
")",
")",
":",
"result",
"=",
"awa... | [
56,
0
] | [
66,
60
] | python | en | ['en', 'en', 'en'] | True |
test_detection_flow_with_custom_path | (hass) | Test the detection flow with custom path selected. | Test the detection flow with custom path selected. | async def test_detection_flow_with_custom_path(hass):
"""Test the detection flow with custom path selected."""
USER_PROVIDED_PATH = EnOceanFlowHandler.MANUAL_PATH_VALUE
FAKE_DONGLE_PATH = "/fake/dongle"
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
with patch(DONGLE_DETECT_M... | [
"async",
"def",
"test_detection_flow_with_custom_path",
"(",
"hass",
")",
":",
"USER_PROVIDED_PATH",
"=",
"EnOceanFlowHandler",
".",
"MANUAL_PATH_VALUE",
"FAKE_DONGLE_PATH",
"=",
"\"/fake/dongle\"",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"r... | [
69,
0
] | [
83,
40
] | python | en | ['en', 'en', 'en'] | True |
test_detection_flow_with_invalid_path | (hass) | Test the detection flow with an invalid path selected. | Test the detection flow with an invalid path selected. | async def test_detection_flow_with_invalid_path(hass):
"""Test the detection flow with an invalid path selected."""
USER_PROVIDED_PATH = "/invalid/path"
FAKE_DONGLE_PATH = "/fake/dongle"
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=False)):
with patch(DONGLE_DETECT_METHOD, Mock(ret... | [
"async",
"def",
"test_detection_flow_with_invalid_path",
"(",
"hass",
")",
":",
"USER_PROVIDED_PATH",
"=",
"\"/invalid/path\"",
"FAKE_DONGLE_PATH",
"=",
"\"/fake/dongle\"",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"False"... | [
86,
0
] | [
101,
42
] | python | en | ['en', 'en', 'en'] | True |
test_manual_flow_with_valid_path | (hass) | Test the manual flow with a valid path. | Test the manual flow with a valid path. | async def test_manual_flow_with_valid_path(hass):
"""Test the manual flow with a valid path."""
USER_PROVIDED_PATH = "/user/provided/path"
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "ma... | [
"async",
"def",
"test_manual_flow_with_valid_path",
"(",
"hass",
")",
":",
"USER_PROVIDED_PATH",
"=",
"\"/user/provided/path\"",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"True",
")",
")",
":",
"result",
"=",
"await"... | [
104,
0
] | [
114,
60
] | python | en | ['en', 'en', 'en'] | True |
test_manual_flow_with_invalid_path | (hass) | Test the manual flow with an invalid path. | Test the manual flow with an invalid path. | async def test_manual_flow_with_invalid_path(hass):
"""Test the manual flow with an invalid path."""
USER_PROVIDED_PATH = "/user/provided/path"
with patch(
DONGLE_VALIDATE_PATH_METHOD,
Mock(return_value=False),
):
result = await hass.config_entries.flow.async_init(
D... | [
"async",
"def",
"test_manual_flow_with_invalid_path",
"(",
"hass",
")",
":",
"USER_PROVIDED_PATH",
"=",
"\"/user/provided/path\"",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"False",
")",
",",
")",
":",
"result",
"=",... | [
117,
0
] | [
131,
42
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_with_valid_path | (hass) | Test the import flow with a valid path. | Test the import flow with a valid path. | async def test_import_flow_with_valid_path(hass):
"""Test the import flow with a valid path."""
DATA_TO_IMPORT = {CONF_DEVICE: "/valid/path/to/import"}
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={... | [
"async",
"def",
"test_import_flow_with_valid_path",
"(",
"hass",
")",
":",
"DATA_TO_IMPORT",
"=",
"{",
"CONF_DEVICE",
":",
"\"/valid/path/to/import\"",
"}",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"True",
")",
")",... | [
134,
0
] | [
144,
69
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_with_invalid_path | (hass) | Test the import flow with an invalid path. | Test the import flow with an invalid path. | async def test_import_flow_with_invalid_path(hass):
"""Test the import flow with an invalid path."""
DATA_TO_IMPORT = {CONF_DEVICE: "/invalid/path/to/import"}
with patch(
DONGLE_VALIDATE_PATH_METHOD,
Mock(return_value=False),
):
result = await hass.config_entries.flow.async_init... | [
"async",
"def",
"test_import_flow_with_invalid_path",
"(",
"hass",
")",
":",
"DATA_TO_IMPORT",
"=",
"{",
"CONF_DEVICE",
":",
"\"/invalid/path/to/import\"",
"}",
"with",
"patch",
"(",
"DONGLE_VALIDATE_PATH_METHOD",
",",
"Mock",
"(",
"return_value",
"=",
"False",
")",
... | [
147,
0
] | [
160,
52
] | python | en | ['en', 'en', 'en'] | True |
test_system_health_info_autogen | (hass) | Test system health info endpoint. | Test system health info endpoint. | async def test_system_health_info_autogen(hass):
"""Test system health info endpoint."""
assert await async_setup_component(hass, "lovelace", {})
assert await async_setup_component(hass, "system_health", {})
info = await get_system_health_info(hass, "lovelace")
assert info == {"dashboards": 1, "mode... | [
"async",
"def",
"test_system_health_info_autogen",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"lovelace\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"system_health\"",
",",
"{",... | [
8,
0
] | [
13,
72
] | python | en | ['es', 'en', 'en'] | True |
test_system_health_info_storage | (hass, hass_storage) | Test system health info endpoint. | Test system health info endpoint. | async def test_system_health_info_storage(hass, hass_storage):
"""Test system health info endpoint."""
assert await async_setup_component(hass, "system_health", {})
hass_storage[dashboard.CONFIG_STORAGE_KEY_DEFAULT] = {
"key": "lovelace",
"version": 1,
"data": {"config": {"resources"... | [
"async",
"def",
"test_system_health_info_storage",
"(",
"hass",
",",
"hass_storage",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"system_health\"",
",",
"{",
"}",
")",
"hass_storage",
"[",
"dashboard",
".",
"CONFIG_STORAGE_KEY_DEFAULT",
... | [
16,
0
] | [
26,
83
] | python | en | ['es', 'en', 'en'] | True |
test_system_health_info_yaml | (hass) | Test system health info endpoint. | Test system health info endpoint. | async def test_system_health_info_yaml(hass):
"""Test system health info endpoint."""
assert await async_setup_component(hass, "system_health", {})
assert await async_setup_component(hass, "lovelace", {"lovelace": {"mode": "YAML"}})
with patch(
"homeassistant.components.lovelace.dashboard.load_y... | [
"async",
"def",
"test_system_health_info_yaml",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"system_health\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"lovelace\"",
",",
"{",
... | [
29,
0
] | [
38,
80
] | python | en | ['es', 'en', 'en'] | True |
test_system_health_info_yaml_not_found | (hass) | Test system health info endpoint. | Test system health info endpoint. | async def test_system_health_info_yaml_not_found(hass):
"""Test system health info endpoint."""
assert await async_setup_component(hass, "system_health", {})
assert await async_setup_component(hass, "lovelace", {"lovelace": {"mode": "YAML"}})
info = await get_system_health_info(hass, "lovelace")
ass... | [
"async",
"def",
"test_system_health_info_yaml_not_found",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"system_health\"",
",",
"{",
"}",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"lovelace\"",
",",... | [
41,
0
] | [
51,
5
] | python | en | ['es', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a sensor for a raincloud device. | Set up a sensor for a raincloud device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a sensor for a raincloud device."""
raincloud = hass.data[DATA_RAINCLOUD].data
sensors = []
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
if sensor_type == "battery":
sensors.append(RainCloudS... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"raincloud",
"=",
"hass",
".",
"data",
"[",
"DATA_RAINCLOUD",
"]",
".",
"data",
"sensors",
"=",
"[",
"]",
"for",
"sensor_type",
"in",
... | [
23,
0
] | [
37,
15
] | python | en | ['en', 'ca', 'en'] | True |
RainCloudSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
44,
4
] | [
46,
26
] | python | en | ['en', 'en', 'en'] | True |
RainCloudSensor.update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update(self):
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
if self._sensor_type == "battery":
self._state = self.data.battery
else:
self._state = getattr(self.data, self._sensor_type) | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating RainCloud sensor: %s\"",
",",
"self",
".",
"_name",
")",
"if",
"self",
".",
"_sensor_type",
"==",
"\"battery\"",
":",
"self",
".",
"_state",
"=",
"self",
".",
"data",
".",
... | [
48,
4
] | [
54,
63
] | python | en | ['en', 'en', 'en'] | True |
RainCloudSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
if self._sensor_type == "battery" and self._state is not None:
return icon_for_battery_level(
battery_level=int(self._state), charging=False
)
return ICON_MAP.get(self._sensor_type) | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sensor_type",
"==",
"\"battery\"",
"and",
"self",
".",
"_state",
"is",
"not",
"None",
":",
"return",
"icon_for_battery_level",
"(",
"battery_level",
"=",
"int",
"(",
"self",
".",
"_state",
")",
"... | [
57,
4
] | [
63,
46
] | python | en | ['en', 'en', 'en'] | True |
GAG.build_net | (self, is_training) | Build the whole neural network for the QA model. | Build the whole neural network for the QA model. | def build_net(self, is_training):
"""Build the whole neural network for the QA model."""
cfg = self.cfg
word_embed = tf.get_variable(
name='word_embed', initializer=self.embed, dtype=tf.float32, trainable=False)
char_embed = tf.get_variable(name='char_embed',
... | [
"def",
"build_net",
"(",
"self",
",",
"is_training",
")",
":",
"cfg",
"=",
"self",
".",
"cfg",
"word_embed",
"=",
"tf",
".",
"get_variable",
"(",
"name",
"=",
"'word_embed'",
",",
"initializer",
"=",
"self",
".",
"embed",
",",
"dtype",
"=",
"tf",
".",
... | [
86,
4
] | [
231,
57
] | python | en | ['en', 'en', 'en'] | True |
GAG.build_char_states | (self, char_embed, is_training, reuse, char_ids, char_lengths) | Build char embedding network for the QA model. | Build char embedding network for the QA model. | def build_char_states(self, char_embed, is_training, reuse, char_ids, char_lengths):
"""Build char embedding network for the QA model."""
max_char_length = self.cfg.max_char_length
inputs = dropout(tf.nn.embedding_lookup(char_embed, char_ids),
self.cfg.dropout, is_train... | [
"def",
"build_char_states",
"(",
"self",
",",
"char_embed",
",",
"is_training",
",",
"reuse",
",",
"char_ids",
",",
"char_lengths",
")",
":",
"max_char_length",
"=",
"self",
".",
"cfg",
".",
"max_char_length",
"inputs",
"=",
"dropout",
"(",
"tf",
".",
"nn",
... | [
233,
4
] | [
262,
50
] | python | en | ['en', 'en', 'en'] | True |
convert_with_map | (config, conf_map) | Create the initial converted map with just the basic key:value pairs updated. | Create the initial converted map with just the basic key:value pairs updated. | def convert_with_map(config, conf_map):
"""Create the initial converted map with just the basic key:value pairs updated."""
result = {}
for conf in conf_map:
if conf in config:
result[conf_map[conf]] = config[conf]
return result | [
"def",
"convert_with_map",
"(",
"config",
",",
"conf_map",
")",
":",
"result",
"=",
"{",
"}",
"for",
"conf",
"in",
"conf_map",
":",
"if",
"conf",
"in",
"config",
":",
"result",
"[",
"conf_map",
"[",
"conf",
"]",
"]",
"=",
"config",
"[",
"conf",
"]",
... | [
49,
0
] | [
55,
17
] | python | en | ['en', 'en', 'en'] | True |
convert_channel | (config: Dict[str, Any]) | Convert the config for a channel. | Convert the config for a channel. | def convert_channel(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert the config for a channel."""
my_map = {
CONF_NAME: dyn_const.CONF_NAME,
CONF_FADE: dyn_const.CONF_FADE,
CONF_TYPE: dyn_const.CONF_CHANNEL_TYPE,
}
return convert_with_map(config, my_map) | [
"def",
"convert_channel",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"my_map",
"=",
"{",
"CONF_NAME",
":",
"dyn_const",
".",
"CONF_NAME",
",",
"CONF_FADE",
":",
"dyn_const",
".",
"CON... | [
58,
0
] | [
65,
43
] | python | en | ['en', 'en', 'en'] | True |
convert_preset | (config: Dict[str, Any]) | Convert the config for a preset. | Convert the config for a preset. | def convert_preset(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert the config for a preset."""
my_map = {
CONF_NAME: dyn_const.CONF_NAME,
CONF_FADE: dyn_const.CONF_FADE,
CONF_LEVEL: dyn_const.CONF_LEVEL,
}
return convert_with_map(config, my_map) | [
"def",
"convert_preset",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"my_map",
"=",
"{",
"CONF_NAME",
":",
"dyn_const",
".",
"CONF_NAME",
",",
"CONF_FADE",
":",
"dyn_const",
".",
"CONF... | [
68,
0
] | [
75,
43
] | python | en | ['en', 'en', 'en'] | True |
convert_area | (config: Dict[str, Any]) | Convert the config for an area. | Convert the config for an area. | def convert_area(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert the config for an area."""
my_map = {
CONF_NAME: dyn_const.CONF_NAME,
CONF_FADE: dyn_const.CONF_FADE,
CONF_NO_DEFAULT: dyn_const.CONF_NO_DEFAULT,
CONF_ROOM_ON: dyn_const.CONF_ROOM_ON,
CONF_ROOM_OFF: dy... | [
"def",
"convert_area",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"my_map",
"=",
"{",
"CONF_NAME",
":",
"dyn_const",
".",
"CONF_NAME",
",",
"CONF_FADE",
":",
"dyn_const",
".",
"CONF_F... | [
78,
0
] | [
107,
17
] | python | en | ['en', 'en', 'en'] | True |
convert_default | (config: Dict[str, Any]) | Convert the config for the platform defaults. | Convert the config for the platform defaults. | def convert_default(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert the config for the platform defaults."""
return convert_with_map(config, {CONF_FADE: dyn_const.CONF_FADE}) | [
"def",
"convert_default",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"convert_with_map",
"(",
"config",
",",
"{",
"CONF_FADE",
":",
"dyn_const",
".",
"CONF_FADE",
"}",
")"
] | [
110,
0
] | [
112,
69
] | python | en | ['en', 'en', 'en'] | True |
convert_template | (config: Dict[str, Any]) | Convert the config for a template. | Convert the config for a template. | def convert_template(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert the config for a template."""
my_map = {
CONF_ROOM_ON: dyn_const.CONF_ROOM_ON,
CONF_ROOM_OFF: dyn_const.CONF_ROOM_OFF,
CONF_CHANNEL_COVER: dyn_const.CONF_CHANNEL_COVER,
CONF_DEVICE_CLASS: dyn_const.CONF_DE... | [
"def",
"convert_template",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"my_map",
"=",
"{",
"CONF_ROOM_ON",
":",
"dyn_const",
".",
"CONF_ROOM_ON",
",",
"CONF_ROOM_OFF",
":",
"dyn_const",
... | [
115,
0
] | [
128,
43
] | python | en | ['en', 'en', 'en'] | True |
convert_config | (config: Dict[str, Any]) | Convert a config dict by replacing component consts with library consts. | Convert a config dict by replacing component consts with library consts. | def convert_config(config: Dict[str, Any]) -> Dict[str, Any]:
"""Convert a config dict by replacing component consts with library consts."""
my_map = {
CONF_NAME: dyn_const.CONF_NAME,
CONF_HOST: dyn_const.CONF_HOST,
CONF_PORT: dyn_const.CONF_PORT,
CONF_AUTO_DISCOVER: dyn_const.CO... | [
"def",
"convert_config",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"my_map",
"=",
"{",
"CONF_NAME",
":",
"dyn_const",
".",
"CONF_NAME",
",",
"CONF_HOST",
":",
"dyn_const",
".",
"CONF... | [
131,
0
] | [
160,
17
] | python | en | ['en', 'en', 'en'] | True |
prepare_backend | (model_name, backend_name, im_size: List[int] = None,
max_batch_size: int = 1,
force_fp16: bool = False,
download_model: bool = True,
config: Configs = None) |
Check if ONNX, MXNet and TensorRT models exist and download/create them otherwise.
:param model_name: Name of required model. Must be one of keys in `models` dict.
:param backend_name: Name of inference backend. (onnx, trt)
:param im_size: Desired maximum size of image in W,H form. Will be overridden ... |
Check if ONNX, MXNet and TensorRT models exist and download/create them otherwise. | def prepare_backend(model_name, backend_name, im_size: List[int] = None,
max_batch_size: int = 1,
force_fp16: bool = False,
download_model: bool = True,
config: Configs = None):
"""
Check if ONNX, MXNet and TensorRT models exist and... | [
"def",
"prepare_backend",
"(",
"model_name",
",",
"backend_name",
",",
"im_size",
":",
"List",
"[",
"int",
"]",
"=",
"None",
",",
"max_batch_size",
":",
"int",
"=",
"1",
",",
"force_fp16",
":",
"bool",
"=",
"False",
",",
"download_model",
":",
"bool",
"=... | [
47,
0
] | [
127,
23
] | python | en | ['en', 'error', 'th'] | False |
get_model | (model_name: str, backend_name: str, im_size: List[int] = None, max_batch_size: int = 1,
force_fp16: bool = False,
root_dir: str = "/models", download_model: bool = True, triton_uri=None, **kwargs) |
Returns inference backend instance with loaded model.
:param model_name: Name of required model. Must be one of keys in `models` dict.
:param backend_name: Name of inference backend. (onnx, mxnet, trt)
:param im_size: Desired maximum size of image in W,H form. Will be overridden if model doesn't suppo... |
Returns inference backend instance with loaded model. | def get_model(model_name: str, backend_name: str, im_size: List[int] = None, max_batch_size: int = 1,
force_fp16: bool = False,
root_dir: str = "/models", download_model: bool = True, triton_uri=None, **kwargs):
"""
Returns inference backend instance with loaded model.
:param mo... | [
"def",
"get_model",
"(",
"model_name",
":",
"str",
",",
"backend_name",
":",
"str",
",",
"im_size",
":",
"List",
"[",
"int",
"]",
"=",
"None",
",",
"max_batch_size",
":",
"int",
"=",
"1",
",",
"force_fp16",
":",
"bool",
"=",
"False",
",",
"root_dir",
... | [
130,
0
] | [
175,
16
] | python | en | ['en', 'error', 'th'] | False |
parse_path | (path) | Extract data attributes from directory names. | Extract data attributes from directory names. | def parse_path(path):
"""Extract data attributes from directory names."""
path_dirs = path.split(' > ')
is_top_dir = True if len(path_dirs) < 4 else False
categ = path_dirs[1]
p_name = path_dirs[2]
cas = re.match('([\d-]+)_*', p_name).groups()[0]
rest = p_name[len(cas) + 1:] # compound_mass... | [
"def",
"parse_path",
"(",
"path",
")",
":",
"path_dirs",
"=",
"path",
".",
"split",
"(",
"' > '",
")",
"is_top_dir",
"=",
"True",
"if",
"len",
"(",
"path_dirs",
")",
"<",
"4",
"else",
"False",
"categ",
"=",
"path_dirs",
"[",
"1",
"]",
"p_name",
"=",
... | [
68,
0
] | [
80,
55
] | python | en | ['en', 'en', 'en'] | True |
load_prebuilt_listing | () | Populate module-level COMPOUNDS dictionary from prebuilt listing. | Populate module-level COMPOUNDS dictionary from prebuilt listing. | def load_prebuilt_listing():
"""Populate module-level COMPOUNDS dictionary from prebuilt listing."""
global COMPOUNDS
from flask import current_app
compounds_pickle = current_app.config['COMPOUNDS_PICKLE']
df = pd.read_pickle(compounds_pickle)
categ, cas, compound, mass, date, is_top_dir = \
... | [
"def",
"load_prebuilt_listing",
"(",
")",
":",
"global",
"COMPOUNDS",
"from",
"flask",
"import",
"current_app",
"compounds_pickle",
"=",
"current_app",
".",
"config",
"[",
"'COMPOUNDS_PICKLE'",
"]",
"df",
"=",
"pd",
".",
"read_pickle",
"(",
"compounds_pickle",
")"... | [
107,
0
] | [
146,
20
] | python | en | ['en', 'en', 'en'] | True |
test_setups | (hass: HomeAssistant, protocol, connection, title) | Test flow for setting up the available AlarmDecoder protocols. | Test flow for setting up the available AlarmDecoder protocols. | async def test_setups(hass: HomeAssistant, protocol, connection, title):
"""Test flow for setting up the available AlarmDecoder protocols."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RE... | [
"async",
"def",
"test_setups",
"(",
"hass",
":",
"HomeAssistant",
",",
"protocol",
",",
"connection",
",",
"title",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
... | [
56,
0
] | [
94,
48
] | python | en | ['en', 'en', 'en'] | True |
test_setup_connection_error | (hass: HomeAssistant) | Test flow for setup with a connection error. | Test flow for setup with a connection error. | async def test_setup_connection_error(hass: HomeAssistant):
"""Test flow for setup with a connection error."""
port = 1001
host = "alarmdecoder"
protocol = PROTOCOL_SOCKET
connection_settings = {CONF_HOST: host, CONF_PORT: port}
result = await hass.config_entries.flow.async_init(
DOMAI... | [
"async",
"def",
"test_setup_connection_error",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"port",
"=",
"1001",
"host",
"=",
"\"alarmdecoder\"",
"protocol",
"=",
"PROTOCOL_SOCKET",
"connection_settings",
"=",
"{",
"CONF_HOST",
":",
"host",
",",
"CONF_PORT",
":",
... | [
97,
0
] | [
128,
61
] | python | en | ['en', 'en', 'en'] | True |
test_options_arm_flow | (hass: HomeAssistant) | Test arm options flow. | Test arm options flow. | async def test_options_arm_flow(hass: HomeAssistant):
"""Test arm options flow."""
user_input = {
CONF_ALT_NIGHT_MODE: True,
CONF_AUTO_BYPASS: True,
CONF_CODE_ARM_REQUIRED: True,
}
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await hass.config_entries.a... | [
"async",
"def",
"test_options_arm_flow",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"user_input",
"=",
"{",
"CONF_ALT_NIGHT_MODE",
":",
"True",
",",
"CONF_AUTO_BYPASS",
":",
"True",
",",
"CONF_CODE_ARM_REQUIRED",
":",
"True",
",",
"}",
"entry",
"=",
"MockConfi... | [
131,
0
] | [
169,
5
] | python | en | ['en', 'fr', 'en'] | True |
test_options_zone_flow | (hass: HomeAssistant) | Test options flow for adding/deleting zones. | Test options flow for adding/deleting zones. | async def test_options_zone_flow(hass: HomeAssistant):
"""Test options flow for adding/deleting zones."""
zone_number = "2"
zone_settings = {CONF_ZONE_NAME: "Front Entry", CONF_ZONE_TYPE: DEVICE_CLASS_WINDOW}
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await hass.config_entri... | [
"async",
"def",
"test_options_zone_flow",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"zone_number",
"=",
"\"2\"",
"zone_settings",
"=",
"{",
"CONF_ZONE_NAME",
":",
"\"Front Entry\"",
",",
"CONF_ZONE_TYPE",
":",
"DEVICE_CLASS_WINDOW",
"}",
"entry",
"=",
"MockConfig... | [
172,
0
] | [
245,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_zone_flow_validation | (hass: HomeAssistant) | Test input validation for zone options flow. | Test input validation for zone options flow. | async def test_options_zone_flow_validation(hass: HomeAssistant):
"""Test input validation for zone options flow."""
zone_number = "2"
zone_settings = {CONF_ZONE_NAME: "Front Entry", CONF_ZONE_TYPE: DEVICE_CLASS_WINDOW}
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
await hass.c... | [
"async",
"def",
"test_options_zone_flow_validation",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"zone_number",
"=",
"\"2\"",
"zone_settings",
"=",
"{",
"CONF_ZONE_NAME",
":",
"\"Front Entry\"",
",",
"CONF_ZONE_TYPE",
":",
"DEVICE_CLASS_WINDOW",
"}",
"entry",
"=",
... | [
248,
0
] | [
378,
5
] | python | en | ['en', 'en', 'en'] | True |
test_one_device_allowed | (hass, protocol, connection) | Test that only one AlarmDecoder device is allowed. | Test that only one AlarmDecoder device is allowed. | async def test_one_device_allowed(hass, protocol, connection):
"""Test that only one AlarmDecoder device is allowed."""
flow = config_flow.AlarmDecoderFlowHandler()
flow.hass = hass
MockConfigEntry(
domain=DOMAIN,
data=connection,
).add_to_hass(hass)
result = await hass.config_... | [
"async",
"def",
"test_one_device_allowed",
"(",
"hass",
",",
"protocol",
",",
"connection",
")",
":",
"flow",
"=",
"config_flow",
".",
"AlarmDecoderFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
... | [
400,
0
] | [
429,
51
] | python | en | ['en', 'en', '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\"",
")"
] | [
23,
0
] | [
25,
57
] | python | en | ['en', 'en', 'en'] | True |
get_switch_name | (number) | Get a mock switch name. | Get a mock switch name. | def get_switch_name(number):
"""Get a mock switch name."""
return f"Mock Switch #{number}" | [
"def",
"get_switch_name",
"(",
"number",
")",
":",
"return",
"f\"Mock Switch #{number}\""
] | [
28,
0
] | [
30,
35
] | python | en | ['en', 'en', 'en'] | True |
mock_lj | (hass) | Initialize components. | Initialize components. | def mock_lj(hass):
"""Initialize components."""
with mock.patch("homeassistant.components.litejet.LiteJet") as mock_pylitejet:
mock_lj = mock_pylitejet.return_value
mock_lj.switch_pressed_callbacks = {}
mock_lj.switch_released_callbacks = {}
def on_switch_pressed(number, callba... | [
"def",
"mock_lj",
"(",
"hass",
")",
":",
"with",
"mock",
".",
"patch",
"(",
"\"homeassistant.components.litejet.LiteJet\"",
")",
"as",
"mock_pylitejet",
":",
"mock_lj",
"=",
"mock_pylitejet",
".",
"return_value",
"mock_lj",
".",
"switch_pressed_callbacks",
"=",
"{",... | [
34,
0
] | [
63,
22
] | python | en | ['de', 'en', 'en'] | False |
simulate_press | (hass, mock_lj, number) | Test to simulate a press. | Test to simulate a press. | async def simulate_press(hass, mock_lj, number):
"""Test to simulate a press."""
_LOGGER.info("*** simulate press of %d", number)
callback = mock_lj.switch_pressed_callbacks.get(number)
with mock.patch(
"homeassistant.helpers.condition.dt_util.utcnow",
return_value=mock_lj.start_time + m... | [
"async",
"def",
"simulate_press",
"(",
"hass",
",",
"mock_lj",
",",
"number",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"*** simulate press of %d\"",
",",
"number",
")",
"callback",
"=",
"mock_lj",
".",
"switch_pressed_callbacks",
".",
"get",
"(",
"number",
")"... | [
66,
0
] | [
76,
42
] | python | en | ['en', 'en', 'en'] | True |
simulate_release | (hass, mock_lj, number) | Test to simulate releasing. | Test to simulate releasing. | async def simulate_release(hass, mock_lj, number):
"""Test to simulate releasing."""
_LOGGER.info("*** simulate release of %d", number)
callback = mock_lj.switch_released_callbacks.get(number)
with mock.patch(
"homeassistant.helpers.condition.dt_util.utcnow",
return_value=mock_lj.start_t... | [
"async",
"def",
"simulate_release",
"(",
"hass",
",",
"mock_lj",
",",
"number",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"*** simulate release of %d\"",
",",
"number",
")",
"callback",
"=",
"mock_lj",
".",
"switch_released_callbacks",
".",
"get",
"(",
"number",
... | [
79,
0
] | [
89,
42
] | python | en | ['en', 'en', 'en'] | True |
simulate_time | (hass, mock_lj, delta) | Test to simulate time. | Test to simulate time. | async def simulate_time(hass, mock_lj, delta):
"""Test to simulate time."""
_LOGGER.info(
"*** simulate time change by %s: %s", delta, mock_lj.start_time + delta
)
mock_lj.last_delta = delta
with mock.patch(
"homeassistant.helpers.condition.dt_util.utcnow",
return_value=mock_... | [
"async",
"def",
"simulate_time",
"(",
"hass",
",",
"mock_lj",
",",
"delta",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"*** simulate time change by %s: %s\"",
",",
"delta",
",",
"mock_lj",
".",
"start_time",
"+",
"delta",
")",
"mock_lj",
".",
"last_delta",
"=",
... | [
92,
0
] | [
105,
58
] | python | en | ['en', 'en', 'en'] | True |
setup_automation | (hass, trigger) | Test setting up the automation. | Test setting up the automation. | async def setup_automation(hass, trigger):
"""Test setting up the automation."""
assert await setup.async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"alias": "My Test",
"trigger": trigger,
... | [
"async",
"def",
"setup_automation",
"(",
"hass",
",",
"trigger",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"[",
"{",
"\"alias\"",
":",
"\"M... | [
108,
0
] | [
123,
38
] | python | en | ['en', 'en', 'en'] | True |
test_simple | (hass, calls, mock_lj) | Test the simplest form of a LiteJet trigger. | Test the simplest form of a LiteJet trigger. | async def test_simple(hass, calls, mock_lj):
"""Test the simplest form of a LiteJet trigger."""
await setup_automation(
hass, {"platform": "litejet", "number": ENTITY_OTHER_SWITCH_NUMBER}
)
await simulate_press(hass, mock_lj, ENTITY_OTHER_SWITCH_NUMBER)
await simulate_release(hass, mock_lj,... | [
"async",
"def",
"test_simple",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
"}",
")",
"await",
"simulate_press",... | [
126,
0
] | [
135,
26
] | python | en | ['en', 'da', 'en'] | True |
test_held_more_than_short | (hass, calls, mock_lj) | Test a too short hold. | Test a too short hold. | async def test_held_more_than_short(hass, calls, mock_lj):
"""Test a too short hold."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_more_than": {"milliseconds": "200"},
},
)
await simulate... | [
"async",
"def",
"test_held_more_than_short",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_more_than\"",... | [
138,
0
] | [
152,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_more_than_long | (hass, calls, mock_lj) | Test a hold that is long enough. | Test a hold that is long enough. | async def test_held_more_than_long(hass, calls, mock_lj):
"""Test a hold that is long enough."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_more_than": {"milliseconds": "200"},
},
)
await... | [
"async",
"def",
"test_held_more_than_long",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_more_than\"",
... | [
155,
0
] | [
171,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_less_than_short | (hass, calls, mock_lj) | Test a hold that is short enough. | Test a hold that is short enough. | async def test_held_less_than_short(hass, calls, mock_lj):
"""Test a hold that is short enough."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_less_than": {"milliseconds": "200"},
},
)
awa... | [
"async",
"def",
"test_held_less_than_short",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_less_than\"",... | [
174,
0
] | [
189,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_less_than_long | (hass, calls, mock_lj) | Test a hold that is too long. | Test a hold that is too long. | async def test_held_less_than_long(hass, calls, mock_lj):
"""Test a hold that is too long."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_less_than": {"milliseconds": "200"},
},
)
await si... | [
"async",
"def",
"test_held_less_than_long",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_less_than\"",
... | [
192,
0
] | [
208,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_in_range_short | (hass, calls, mock_lj) | Test an in-range trigger with a too short hold. | Test an in-range trigger with a too short hold. | async def test_held_in_range_short(hass, calls, mock_lj):
"""Test an in-range trigger with a too short hold."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_more_than": {"milliseconds": "100"},
... | [
"async",
"def",
"test_held_in_range_short",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_more_than\"",
... | [
211,
0
] | [
226,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_in_range_just_right | (hass, calls, mock_lj) | Test an in-range trigger with a just right hold. | Test an in-range trigger with a just right hold. | async def test_held_in_range_just_right(hass, calls, mock_lj):
"""Test an in-range trigger with a just right hold."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_more_than": {"milliseconds": "100"},
... | [
"async",
"def",
"test_held_in_range_just_right",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_more_than... | [
229,
0
] | [
246,
26
] | python | en | ['en', 'en', 'en'] | True |
test_held_in_range_long | (hass, calls, mock_lj) | Test an in-range trigger with a too long hold. | Test an in-range trigger with a too long hold. | async def test_held_in_range_long(hass, calls, mock_lj):
"""Test an in-range trigger with a too long hold."""
await setup_automation(
hass,
{
"platform": "litejet",
"number": ENTITY_OTHER_SWITCH_NUMBER,
"held_more_than": {"milliseconds": "100"},
"h... | [
"async",
"def",
"test_held_in_range_long",
"(",
"hass",
",",
"calls",
",",
"mock_lj",
")",
":",
"await",
"setup_automation",
"(",
"hass",
",",
"{",
"\"platform\"",
":",
"\"litejet\"",
",",
"\"number\"",
":",
"ENTITY_OTHER_SWITCH_NUMBER",
",",
"\"held_more_than\"",
... | [
249,
0
] | [
266,
26
] | python | en | ['en', 'en', 'en'] | True |
ArgumentParser.format_help | (self) | Customized format_help
Returns:
None
| Customized format_help | def format_help(self):
"""Customized format_help
Returns:
None
"""
formatter = self._get_formatter()
# Add texts, print examples at the end (if any)
formatter.add_usage(self.usage, self._actions, self._mutually_exclusive_groups)
formatter.add_text(se... | [
"def",
"format_help",
"(",
"self",
")",
":",
"formatter",
"=",
"self",
".",
"_get_formatter",
"(",
")",
"# Add texts, print examples at the end (if any)",
"formatter",
".",
"add_usage",
"(",
"self",
".",
"usage",
",",
"self",
".",
"_actions",
",",
"self",
".",
... | [
18,
4
] | [
36,
38
] | python | en | ['en', 'en', 'en'] | False |
ArgumentParser.error | (self, message) | Customized error
Args:
message: error message from argparse
Returns:
None
| Customized error | def error(self, message):
"""Customized error
Args:
message: error message from argparse
Returns:
None
"""
args = sys.argv
# if get 'help', print help without printing errors
if '--help' in args or '-h' in args:
self.print_h... | [
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"args",
"=",
"sys",
".",
"argv",
"# if get 'help', print help without printing errors",
"if",
"'--help'",
"in",
"args",
"or",
"'-h'",
"in",
"args",
":",
"self",
".",
"print_help",
"(",
")",
"# Otherwise it... | [
38,
4
] | [
57,
82
] | python | de | ['de', 'tr', 'en'] | False |
async_setup_entry | (
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) | Set up discovered lights. | Set up discovered lights. | async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) -> None:
"""Set up discovered lights."""
devs = []
for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]:
devs.append(HassAqualinkLight(dev))
async_add_entities(devs, True) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"devs",
"=",
"[",
"]",
"for",
"dev",
"in",
"hass",
".",
"data",
"[",
"AQUALINK_DOMAIN",
"]... | [
20,
0
] | [
27,
34
] | python | en | ['en', 'da', 'en'] | True |
HassAqualinkLight.name | (self) | Return the name of the light. | Return the name of the light. | def name(self) -> str:
"""Return the name of the light."""
return self.dev.label | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"dev",
".",
"label"
] | [
34,
4
] | [
36,
29
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkLight.is_on | (self) | Return whether the light is on or off. | Return whether the light is on or off. | def is_on(self) -> bool:
"""Return whether the light is on or off."""
return self.dev.is_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"dev",
".",
"is_on"
] | [
39,
4
] | [
41,
29
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkLight.async_turn_on | (self, **kwargs) | Turn on the light.
This handles brightness and light effects for lights that do support
them.
| Turn on the light. | async def async_turn_on(self, **kwargs) -> None:
"""Turn on the light.
This handles brightness and light effects for lights that do support
them.
"""
brightness = kwargs.get(ATTR_BRIGHTNESS)
effect = kwargs.get(ATTR_EFFECT)
# For now I'm assuming lights support ... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
")",
"effect",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_EFFECT",
")",
"# For now I'm assuming lights ... | [
44,
4
] | [
62,
36
] | python | en | ['en', 'et', 'en'] | True |
HassAqualinkLight.async_turn_off | (self, **kwargs) | Turn off the light. | Turn off the light. | async def async_turn_off(self, **kwargs) -> None:
"""Turn off the light."""
await self.dev.turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"dev",
".",
"turn_off",
"(",
")"
] | [
65,
4
] | [
67,
33
] | python | en | ['en', 'zh', 'en'] | True |
HassAqualinkLight.brightness | (self) | Return current brightness of the light.
The scale needs converting between 0-100 and 0-255.
| Return current brightness of the light. | def brightness(self) -> int:
"""Return current brightness of the light.
The scale needs converting between 0-100 and 0-255.
"""
return self.dev.brightness * 255 / 100 | [
"def",
"brightness",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"dev",
".",
"brightness",
"*",
"255",
"/",
"100"
] | [
70,
4
] | [
75,
46
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkLight.effect | (self) | Return the current light effect if supported. | Return the current light effect if supported. | def effect(self) -> str:
"""Return the current light effect if supported."""
return AqualinkLightEffect(self.dev.effect).name | [
"def",
"effect",
"(",
"self",
")",
"->",
"str",
":",
"return",
"AqualinkLightEffect",
"(",
"self",
".",
"dev",
".",
"effect",
")",
".",
"name"
] | [
78,
4
] | [
80,
56
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkLight.effect_list | (self) | Return supported light effects. | Return supported light effects. | def effect_list(self) -> list:
"""Return supported light effects."""
return list(AqualinkLightEffect.__members__) | [
"def",
"effect_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"list",
"(",
"AqualinkLightEffect",
".",
"__members__",
")"
] | [
83,
4
] | [
85,
52
] | python | en | ['de', 'en', 'en'] | True |
HassAqualinkLight.supported_features | (self) | Return the list of features supported by the light. | Return the list of features supported by the light. | def supported_features(self) -> int:
"""Return the list of features supported by the light."""
if self.dev.is_dimmer:
return SUPPORT_BRIGHTNESS
if self.dev.is_color:
return SUPPORT_EFFECT
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"dev",
".",
"is_dimmer",
":",
"return",
"SUPPORT_BRIGHTNESS",
"if",
"self",
".",
"dev",
".",
"is_color",
":",
"return",
"SUPPORT_EFFECT",
"return",
"0"
] | [
88,
4
] | [
96,
16
] | python | en | ['en', 'en', 'en'] | True |
start_server_discovery | (hass) | Start a server discovery task. | Start a server discovery task. | async def start_server_discovery(hass):
"""Start a server discovery task."""
def _discovered_server(server):
asyncio.create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_DISCOVERY},
data={
CON... | [
"async",
"def",
"start_server_discovery",
"(",
"hass",
")",
":",
"def",
"_discovered_server",
"(",
"server",
")",
":",
"asyncio",
".",
"create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",... | [
122,
0
] | [
143,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up squeezebox platform from platform entry in configuration.yaml (deprecated). | Set up squeezebox platform from platform entry in configuration.yaml (deprecated). | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up squeezebox platform from platform entry in configuration.yaml (deprecated)."""
if config:
await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, dat... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"config",
":",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"con... | [
146,
0
] | [
152,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up an LMS Server from a config entry. | Set up an LMS Server from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up an LMS Server from a config entry."""
config = config_entry.data
_LOGGER.debug("Reached async_setup_entry for host=%s", config[CONF_HOST])
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
hos... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"config",
"=",
"config_entry",
".",
"data",
"_LOGGER",
".",
"debug",
"(",
"\"Reached async_setup_entry for host=%s\"",
",",
"config",
"[",
"CONF_HOST",
"]",
... | [
155,
0
] | [
248,
15
] | python | en | ['en', 'en', 'en'] | True |
SqueezeBoxEntity.__init__ | (self, player) | Initialize the SqueezeBox device. | Initialize the SqueezeBox device. | def __init__(self, player):
"""Initialize the SqueezeBox device."""
self._player = player
self._last_update = None
self._query_result = {}
self._available = True
self._remove_dispatcher = None | [
"def",
"__init__",
"(",
"self",
",",
"player",
")",
":",
"self",
".",
"_player",
"=",
"player",
"self",
".",
"_last_update",
"=",
"None",
"self",
".",
"_query_result",
"=",
"{",
"}",
"self",
".",
"_available",
"=",
"True",
"self",
".",
"_remove_dispatche... | [
258,
4
] | [
264,
38
] | python | en | ['en', 'en', 'en'] | True |
SqueezeBoxEntity.device_state_attributes | (self) | Return device-specific attributes. | Return device-specific attributes. | def device_state_attributes(self):
"""Return device-specific attributes."""
squeezebox_attr = {
attr: getattr(self, attr)
for attr in ATTR_TO_PROPERTY
if getattr(self, attr) is not None
}
return squeezebox_attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"squeezebox_attr",
"=",
"{",
"attr",
":",
"getattr",
"(",
"self",
",",
"attr",
")",
"for",
"attr",
"in",
"ATTR_TO_PROPERTY",
"if",
"getattr",
"(",
"self",
",",
"attr",
")",
"is",
"not",
"None",
"}"... | [
267,
4
] | [
275,
30
] | python | en | ['fr', 'it', 'en'] | False |
SqueezeBoxEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._player.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_player",
".",
"name"
] | [
278,
4
] | [
280,
32
] | python | en | ['en', 'en', 'en'] | True |
SqueezeBoxEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._player.player_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_player",
".",
"player_id"
] | [
283,
4
] | [
285,
37
] | python | ca | ['fr', 'ca', 'en'] | False |
SqueezeBoxEntity.available | (self) | Return True if device connected to LMS server. | Return True if device connected to LMS server. | def available(self):
"""Return True if device connected to LMS server."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
288,
4
] | [
290,
30
] | 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.