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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
CPPMDeviceScanner.get_device_name | (self, device) | Retrieve device name. | Retrieve device name. | def get_device_name(self, device):
"""Retrieve device name."""
name = next(
(result["name"] for result in self.results if result["mac"] == device), None
)
return name | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"name",
"=",
"next",
"(",
"(",
"result",
"[",
"\"name\"",
"]",
"for",
"result",
"in",
"self",
".",
"results",
"if",
"result",
"[",
"\"mac\"",
"]",
"==",
"device",
")",
",",
"None",
")",
... | [
59,
4
] | [
64,
19
] | python | en | ['fr', 'sk', 'en'] | False |
CPPMDeviceScanner.get_cppm_data | (self) | Retrieve data from Aruba Clearpass and return parsed result. | Retrieve data from Aruba Clearpass and return parsed result. | def get_cppm_data(self):
"""Retrieve data from Aruba Clearpass and return parsed result."""
endpoints = self._cppm.get_endpoints(100)["_embedded"]["items"]
devices = []
for item in endpoints:
if self._cppm.online_status(item["mac_address"]):
device = {"mac": i... | [
"def",
"get_cppm_data",
"(",
"self",
")",
":",
"endpoints",
"=",
"self",
".",
"_cppm",
".",
"get_endpoints",
"(",
"100",
")",
"[",
"\"_embedded\"",
"]",
"[",
"\"items\"",
"]",
"devices",
"=",
"[",
"]",
"for",
"item",
"in",
"endpoints",
":",
"if",
"self... | [
66,
4
] | [
77,
30
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_base_class | (caplog) | Test deprecated base class. | Test deprecated base class. | def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomLock(lock.LockDevice):
pass
CustomLock()
assert "LockDevice is deprecated, modify CustomLock" in caplog.text | [
"def",
"test_deprecated_base_class",
"(",
"caplog",
")",
":",
"class",
"CustomLock",
"(",
"lock",
".",
"LockDevice",
")",
":",
"pass",
"CustomLock",
"(",
")",
"assert",
"\"LockDevice is deprecated, modify CustomLock\"",
"in",
"caplog",
".",
"text"
] | [
4,
0
] | [
11,
71
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
if cur_state is None:
_LOGGE... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistantType",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",... | [
72,
0
] | [
127,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce Light states. | Reproduce Light states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Light states."""
await asyncio.gather(
*(
_async_reproduce_state(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
130,
0
] | [
145,
5
] | python | en | ['en', 'en', 'en'] | True |
check_attr_equal | (
attr1: MappingProxyType, attr2: MappingProxyType, attr_str: str
) | Return true if the given attributes are equal. | Return true if the given attributes are equal. | def check_attr_equal(
attr1: MappingProxyType, attr2: MappingProxyType, attr_str: str
) -> bool:
"""Return true if the given attributes are equal."""
return attr1.get(attr_str) == attr2.get(attr_str) | [
"def",
"check_attr_equal",
"(",
"attr1",
":",
"MappingProxyType",
",",
"attr2",
":",
"MappingProxyType",
",",
"attr_str",
":",
"str",
")",
"->",
"bool",
":",
"return",
"attr1",
".",
"get",
"(",
"attr_str",
")",
"==",
"attr2",
".",
"get",
"(",
"attr_str",
... | [
148,
0
] | [
152,
53
] | python | en | ['en', 'en', 'en'] | True |
save_scores_to_file | (intermediate_scores, intermediate_best_scores, out_file) |
Save statistics of every trial to a log file for generating reports.
|
Save statistics of every trial to a log file for generating reports.
| def save_scores_to_file(intermediate_scores, intermediate_best_scores, out_file):
"""
Save statistics of every trial to a log file for generating reports.
"""
with open(out_file, 'w') as f:
f.write('ntrials,trial_score,best_score\n')
for i, (trial_score, best_score) in enumerate(zip(int... | [
"def",
"save_scores_to_file",
"(",
"intermediate_scores",
",",
"intermediate_best_scores",
",",
"out_file",
")",
":",
"with",
"open",
"(",
"out_file",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'ntrials,trial_score,best_score\\n'",
")",
"for",
"i"... | [
34,
0
] | [
41,
70
] | python | en | ['en', 'error', 'th'] | False |
test_bad_credentials | (hass) | Test when provided credentials are rejected. | Test when provided credentials are rejected. | async def test_bad_credentials(hass):
"""Test when provided credentials are rejected."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
as... | [
"async",
"def",
"test_bad_credentials",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flo... | [
51,
0
] | [
81,
67
] | python | en | ['en', 'en', 'en'] | True |
test_bad_hostname | (hass) | Test when an invalid address is provided. | Test when an invalid address is provided. | async def test_bad_hostname(hass):
"""Test when an invalid address is provided."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert r... | [
"async",
"def",
"test_bad_hostname",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",... | [
84,
0
] | [
118,
57
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_exception | (hass) | Test when an unknown exception is encountered. | Test when an unknown exception is encountered. | async def test_unknown_exception(hass):
"""Test when an unknown exception is encountered."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
... | [
"async",
"def",
"test_unknown_exception",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"f... | [
121,
0
] | [
147,
44
] | python | en | ['en', 'en', 'en'] | True |
test_no_servers_found | (hass) | Test when no servers are on an account. | Test when no servers are on an account. | async def test_no_servers_found(hass):
"""Test when no servers are on an account."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
asser... | [
"async",
"def",
"test_no_servers_found",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"fl... | [
150,
0
] | [
180,
55
] | python | en | ['en', 'en', 'en'] | True |
test_single_available_server | (hass) | Test creating an entry with one server available. | Test creating an entry with one server available. | async def test_single_available_server(hass):
"""Test creating an entry with one server available."""
mock_plex_server = MockPlexServer()
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_single_available_server",
"(",
"hass",
")",
":",
"mock_plex_server",
"=",
"MockPlexServer",
"(",
")",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result... | [
183,
0
] | [
220,
75
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_servers_with_selection | (hass) | Test creating an entry with multiple servers available. | Test creating an entry with multiple servers available. | async def test_multiple_servers_with_selection(hass):
"""Test creating an entry with multiple servers available."""
mock_plex_server = MockPlexServer()
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flo... | [
"async",
"def",
"test_multiple_servers_with_selection",
"(",
"hass",
")",
":",
"mock_plex_server",
"=",
"MockPlexServer",
"(",
")",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
... | [
223,
0
] | [
269,
75
] | python | en | ['en', 'en', 'en'] | True |
test_adding_last_unconfigured_server | (hass) | Test automatically adding last unconfigured server when multiple servers on account. | Test automatically adding last unconfigured server when multiple servers on account. | async def test_adding_last_unconfigured_server(hass):
"""Test automatically adding last unconfigured server when multiple servers on account."""
mock_plex_server = MockPlexServer()
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
MockConfi... | [
"async",
"def",
"test_adding_last_unconfigured_server",
"(",
"hass",
")",
":",
"mock_plex_server",
"=",
"MockPlexServer",
"(",
")",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
... | [
272,
0
] | [
319,
75
] | python | en | ['en', 'en', 'en'] | True |
test_all_available_servers_configured | (hass) | Test when all available servers are already configured. | Test when all available servers are already configured. | async def test_all_available_servers_configured(hass):
"""Test when all available servers are already configured."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
MockConfigEntry(
domain=DOMAIN,
data={
CONF_SERVER... | [
"async",
"def",
"test_all_available_servers_configured",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",... | [
322,
0
] | [
367,
51
] | python | en | ['en', 'en', 'en'] | True |
test_option_flow | (hass, entry, mock_plex_server) | Test config options flow selection. | Test config options flow selection. | async def test_option_flow(hass, entry, mock_plex_server):
"""Test config options flow selection."""
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED
result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "tes... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
",",
"entry",
",",
"mock_plex_server",
")",
":",
"assert",
"len",
"(",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
")",
"==",
"1",
"assert",
"entry",
".",
"state",
"==",
"ENTRY_S... | [
370,
0
] | [
399,
5
] | python | en | ['en', 'en', 'en'] | True |
test_missing_option_flow | (hass, entry, mock_plex_server) | Test config options flow selection when no options stored. | Test config options flow selection when no options stored. | async def test_missing_option_flow(hass, entry, mock_plex_server):
"""Test config options flow selection when no options stored."""
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED
result = await hass.config_entries.options.async_init(
entry.en... | [
"async",
"def",
"test_missing_option_flow",
"(",
"hass",
",",
"entry",
",",
"mock_plex_server",
")",
":",
"assert",
"len",
"(",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
")",
"==",
"1",
"assert",
"entry",
".",
"state",
"==",
... | [
402,
0
] | [
431,
5
] | python | en | ['en', 'en', 'en'] | True |
test_option_flow_new_users_available | (
hass, caplog, entry, mock_websocket, setup_plex_server
) | Test config options multiselect defaults when new Plex users are seen. | Test config options multiselect defaults when new Plex users are seen. | async def test_option_flow_new_users_available(
hass, caplog, entry, mock_websocket, setup_plex_server
):
"""Test config options multiselect defaults when new Plex users are seen."""
OPTIONS_OWNER_ONLY = copy.deepcopy(DEFAULT_OPTIONS)
OPTIONS_OWNER_ONLY[MP_DOMAIN][CONF_MONITORED_USERS] = {"Owner": {"ena... | [
"async",
"def",
"test_option_flow_new_users_available",
"(",
"hass",
",",
"caplog",
",",
"entry",
",",
"mock_websocket",
",",
"setup_plex_server",
")",
":",
"OPTIONS_OWNER_ONLY",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_OPTIONS",
")",
"OPTIONS_OWNER_ONLY",
"[",
"... | [
434,
0
] | [
467,
52
] | python | en | ['en', 'en', 'en'] | True |
test_external_timed_out | (hass) | Test when external flow times out. | Test when external flow times out. | async def test_external_timed_out(hass):
"""Test when external flow times out."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert r... | [
"async",
"def",
"test_external_timed_out",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"... | [
470,
0
] | [
497,
58
] | python | en | ['en', 'en', 'en'] | True |
test_callback_view | (hass, aiohttp_client) | Test callback view. | Test callback view. | async def test_callback_view(hass, aiohttp_client):
"""Test callback view."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert resul... | [
"async",
"def",
"test_callback_view",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"result",
"=",
"await",
"hass",
".",
"confi... | [
500,
0
] | [
526,
33
] | python | en | ['en', 'en', 'en'] | True |
test_manual_config | (hass) | Test creating via manual configuration. | Test creating via manual configuration. | async def test_manual_config(hass):
"""Test creating via manual configuration."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
class WrongCertValidaitionException(requests.exceptions.SSLError):
"""Mock the exception showing an unmatc... | [
"async",
"def",
"test_manual_config",
"(",
"hass",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"class",
"WrongCertValidaitionException",
"(",
"requests",
".",
"excep... | [
529,
0
] | [
663,
71
] | python | en | ['nl', 'sm', 'en'] | False |
test_manual_config_with_token | (hass) | Test creating via manual configuration with only token. | Test creating via manual configuration with only token. | async def test_manual_config_with_token(hass):
"""Test creating via manual configuration with only token."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": "user", "show_advanced_options": True}
)
assert result["type"] == "form"
assert result["st... | [
"async",
"def",
"test_manual_config_with_token",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\"",
",",
"\... | [
666,
0
] | [
701,
71
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_limited_credentials | (hass, entry, setup_plex_server) | Test setup with a user with limited permissions. | Test setup with a user with limited permissions. | async def test_setup_with_limited_credentials(hass, entry, setup_plex_server):
"""Test setup with a user with limited permissions."""
with patch.object(
MockPlexServer, "systemAccounts", side_effect=plexapi.exceptions.Unauthorized
) as mock_accounts:
mock_plex_server = await setup_plex_serve... | [
"async",
"def",
"test_setup_with_limited_credentials",
"(",
"hass",
",",
"entry",
",",
"setup_plex_server",
")",
":",
"with",
"patch",
".",
"object",
"(",
"MockPlexServer",
",",
"\"systemAccounts\"",
",",
"side_effect",
"=",
"plexapi",
".",
"exceptions",
".",
"Una... | [
704,
0
] | [
718,
44
] | python | en | ['en', 'en', 'en'] | True |
test_integration_discovery | (hass) | Test integration self-discovery. | Test integration self-discovery. | async def test_integration_discovery(hass):
"""Test integration self-discovery."""
mock_gdm = MockGDM()
with patch("homeassistant.components.plex.config_flow.GDM", return_value=mock_gdm):
await config_flow.async_discover(hass)
flows = hass.config_entries.flow.async_progress()
assert len(f... | [
"async",
"def",
"test_integration_discovery",
"(",
"hass",
")",
":",
"mock_gdm",
"=",
"MockGDM",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.plex.config_flow.GDM\"",
",",
"return_value",
"=",
"mock_gdm",
")",
":",
"await",
"config_flow",
".",
"async_... | [
721,
0
] | [
740,
36
] | python | en | ['en', 'en', 'en'] | True |
test_trigger_reauth | (hass, entry, mock_plex_server, mock_websocket) | Test setup and reauthorization of a Plex token. | Test setup and reauthorization of a Plex token. | async def test_trigger_reauth(hass, entry, mock_plex_server, mock_websocket):
"""Test setup and reauthorization of a Plex token."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
assert entry.state == ENTRY_STATE_LOADED
with patch.object(... | [
"async",
"def",
"test_trigger_reauth",
"(",
"hass",
",",
"entry",
",",
"mock_plex_server",
",",
"mock_websocket",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"asse... | [
743,
0
] | [
790,
74
] | python | en | ['en', 'en', 'en'] | True |
validate_apps | (config: ConfigType) | Validate CONF_APPS is only used when CONF_DEVICE_CLASS == DEVICE_CLASS_TV. | Validate CONF_APPS is only used when CONF_DEVICE_CLASS == DEVICE_CLASS_TV. | def validate_apps(config: ConfigType) -> ConfigType:
"""Validate CONF_APPS is only used when CONF_DEVICE_CLASS == DEVICE_CLASS_TV."""
if (
config.get(CONF_APPS) is not None
and config[CONF_DEVICE_CLASS] != DEVICE_CLASS_TV
):
raise vol.Invalid(
f"'{CONF_APPS}' can only be ... | [
"def",
"validate_apps",
"(",
"config",
":",
"ConfigType",
")",
"->",
"ConfigType",
":",
"if",
"(",
"config",
".",
"get",
"(",
"CONF_APPS",
")",
"is",
"not",
"None",
"and",
"config",
"[",
"CONF_DEVICE_CLASS",
"]",
"!=",
"DEVICE_CLASS_TV",
")",
":",
"raise",... | [
22,
0
] | [
32,
17
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Component setup, run import config flow for each entry in config. | Component setup, run import config flow for each entry in config. | async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Component setup, run import config flow for each entry in config."""
if DOMAIN in config:
for entry in config[DOMAIN]:
hass.async_create_task(
hass.config_entries.flow.async_init(
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"if",
"DOMAIN",
"in",
"config",
":",
"for",
"entry",
"in",
"config",
"[",
"DOMAIN",
"]",
":",
"hass",
".",
"async_create_task",
... | [
43,
0
] | [
53,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, config_entry: ConfigEntry) | Load the saved entities. | Load the saved entities. | async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
"""Load the saved entities."""
hass.data.setdefault(DOMAIN, {})
if (
CONF_APPS not in hass.data[DOMAIN]
and config_entry.data[CONF_DEVICE_CLASS] == DEVICE_CLASS_TV
):
coordinator = VizioApps... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"if",
"(",
"CONF_APPS",
"not",
"in",
"... | [
56,
0
] | [
73,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (
hass: HomeAssistantType, config_entry: ConfigEntry
) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(
hass: HomeAssistantType, config_entry: ConfigEntry
) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(config_entry, platform)
for platform in PLATFO... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
... | [
76,
0
] | [
101,
20
] | python | en | ['en', 'es', 'en'] | True |
VizioAppsDataUpdateCoordinator.__init__ | (self, hass: HomeAssistantType) | Initialize. | Initialize. | def __init__(self, hass: HomeAssistantType) -> None:
"""Initialize."""
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_interval=timedelta(days=1),
update_method=self._async_update_data,
)
self.data = APPS | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"_LOGGER",
",",
"name",
"=",
"DOMAIN",
",",
"update_interval",
"=",
"timedelta",
"(",
"days",
"=",
"1",... | [
107,
4
] | [
116,
24
] | python | en | ['en', 'en', 'it'] | False |
VizioAppsDataUpdateCoordinator._async_update_data | (self) | Update data via library. | Update data via library. | async def _async_update_data(self) -> List[Dict[str, Any]]:
"""Update data via library."""
data = await gen_apps_list_from_url(session=async_get_clientsession(self.hass))
if not data:
raise UpdateFailed
return sorted(data, key=lambda app: app["name"]) | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"data",
"=",
"await",
"gen_apps_list_from_url",
"(",
"session",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
")",
... | [
118,
4
] | [
123,
56
] | python | en | ['fr', 'en', 'en'] | True |
test_form_user | (hass) | Test we get the form. | Test we get the form. | async def test_form_user(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["e... | [
"async",
"def",
"test_form_user",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
18,
0
] | [
54,
54
] | python | en | ['en', 'en', 'en'] | True |
test_form_import | (hass) | Test import from existing config. | Test import from existing config. | async def test_form_import(hass):
"""Test import from existing config."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.opentherm_gw.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.o... | [
"async",
"def",
"test_form_import",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.opentherm_gw.async_setup\"",
",",
"return_... | [
57,
0
] | [
88,
54
] | python | en | ['en', 'en', 'en'] | True |
test_form_duplicate_entries | (hass) | Test duplicate device or id errors. | Test duplicate device or id errors. | async def test_form_duplicate_entries(hass):
"""Test duplicate device or id errors."""
flow1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
flow2 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.... | [
"async",
"def",
"test_form_duplicate_entries",
"(",
"hass",
")",
":",
"flow1",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
... | [
91,
0
] | [
132,
54
] | python | en | ['ro', 'en', 'en'] | True |
test_form_connection_timeout | (hass) | Test we handle connection timeout. | Test we handle connection timeout. | async def test_form_connection_timeout(hass):
"""Test we handle connection timeout."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"pyotgw.pyotgw.connect", side_effect=(asyncio.TimeoutError)
) as mock_conne... | [
"async",
"def",
"test_form_connection_timeout",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",... | [
135,
0
] | [
151,
44
] | python | en | ['en', 'en', 'en'] | True |
test_form_connection_error | (hass) | Test we handle serial connection error. | Test we handle serial connection error. | async def test_form_connection_error(hass):
"""Test we handle serial connection error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch("pyotgw.pyotgw.connect", side_effect=(SerialException)) as mock_connect:
resu... | [
"async",
"def",
"test_form_connection_error",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
... | [
154,
0
] | [
167,
44
] | python | en | ['de', 'en', 'en'] | True |
test_options_form | (hass) | Test the options form. | Test the options form. | async def test_options_form(hass):
"""Test the options form."""
entry = MockConfigEntry(
domain=DOMAIN,
title="Mock Gateway",
data={
CONF_NAME: "Mock Gateway",
CONF_DEVICE: "/dev/null",
CONF_ID: "mock_gateway",
},
options={},
)
... | [
"async",
"def",
"test_options_form",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"Mock Gateway\"",
",",
"data",
"=",
"{",
"CONF_NAME",
":",
"\"Mock Gateway\"",
",",
"CONF_DEVICE",
":",
"\"/dev/null... | [
170,
0
] | [
209,
50
] | python | en | ['en', 'en', 'en'] | True |
MinecraftServerConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
host = None
port = DEFAULT_PORT
# Split address at last occurrence of ':'.
address_left, separator, address_right = user_input[... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"host",
"=",
"None",
"port",
"=",
"DEFAULT_PORT",
"# Split address at last occurrence of ':'.",
"ad... | [
26,
4
] | [
124,
57
] | python | en | ['en', 'en', 'en'] | True |
MinecraftServerConfigFlow._show_config_form | (self, user_input=None, errors=None) | Show the setup form to the user. | Show the setup form to the user. | def _show_config_form(self, user_input=None, errors=None):
"""Show the setup form to the user."""
if user_input is None:
user_input = {}
return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{
vol.Required(
... | [
"def",
"_show_config_form",
"(",
"self",
",",
"user_input",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"user_input",
"=",
"{",
"}",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
... | [
126,
4
] | [
144,
9
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_credentials | (hass) | Test for invalid credentials. | Test for invalid credentials. | async def test_invalid_credentials(hass):
"""Test for invalid credentials."""
with requests_mock.Mocker() as mock_req:
url = re.compile(API_URL + "devicetypes")
mock_req.get(url, text="{}", status_code=401)
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
await ha... | [
"async",
"def",
"test_invalid_credentials",
"(",
"hass",
")",
":",
"with",
"requests_mock",
".",
"Mocker",
"(",
")",
"as",
"mock_req",
":",
"url",
"=",
"re",
".",
"compile",
"(",
"API_URL",
"+",
"\"devicetypes\"",
")",
"mock_req",
".",
"get",
"(",
"url",
... | [
32,
0
] | [
39,
51
] | python | en | ['en', 'en', 'en'] | True |
test_valid_credentials | (hass) | Test for valid credentials. | Test for valid credentials. | async def test_valid_credentials(hass):
"""Test for valid credentials."""
with requests_mock.Mocker() as mock_req:
url1 = re.compile(API_URL + "devicetypes")
mock_req.get(url1, text='{"data":[{"id":"fake_type"}]}', status_code=200)
url2 = re.compile(API_URL + "devicetypes/fake_type/devi... | [
"async",
"def",
"test_valid_credentials",
"(",
"hass",
")",
":",
"with",
"requests_mock",
".",
"Mocker",
"(",
")",
"as",
"mock_req",
":",
"url1",
"=",
"re",
".",
"compile",
"(",
"API_URL",
"+",
"\"devicetypes\"",
")",
"mock_req",
".",
"get",
"(",
"url1",
... | [
42,
0
] | [
60,
52
] | python | en | ['en', 'en', 'en'] | True |
test_a1_sensor_setup | (hass) | Test a successful e-Sensor setup. | Test a successful e-Sensor setup. | async def test_a1_sensor_setup(hass):
"""Test a successful e-Sensor setup."""
device = get_device("Bedroom")
mock_api = device.get_mock_api()
mock_api.check_sensors_raw.return_value = {
"temperature": 27.4,
"humidity": 59.3,
"air_quality": 3,
"light": 2,
"noise": ... | [
"async",
"def",
"test_a1_sensor_setup",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Bedroom\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors_raw",
".",
"return_value",
"=",
"{",
"\"temperature\"",... | [
9,
0
] | [
44,
5
] | python | en | ['en', 'sm', 'en'] | True |
test_a1_sensor_update | (hass) | Test a successful e-Sensor update. | Test a successful e-Sensor update. | async def test_a1_sensor_update(hass):
"""Test a successful e-Sensor update."""
device = get_device("Bedroom")
mock_api = device.get_mock_api()
mock_api.check_sensors_raw.return_value = {
"temperature": 22.4,
"humidity": 47.3,
"air_quality": 3,
"light": 2,
"noise"... | [
"async",
"def",
"test_a1_sensor_update",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Bedroom\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors_raw",
".",
"return_value",
"=",
"{",
"\"temperature\""... | [
47,
0
] | [
93,
5
] | python | en | ['en', 'co', 'en'] | True |
test_rm_pro_sensor_setup | (hass) | Test a successful RM pro sensor setup. | Test a successful RM pro sensor setup. | async def test_rm_pro_sensor_setup(hass):
"""Test a successful RM pro sensor setup."""
device = get_device("Office")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 18.2}
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass)
... | [
"async",
"def",
"test_rm_pro_sensor_setup",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Office\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperature\"",
... | [
96,
0
] | [
119,
73
] | python | cs | ['cs', 'ro', 'en'] | False |
test_rm_pro_sensor_update | (hass) | Test a successful RM pro sensor update. | Test a successful RM pro sensor update. | async def test_rm_pro_sensor_update(hass):
"""Test a successful RM pro sensor update."""
device = get_device("Office")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 25.7}
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass)
... | [
"async",
"def",
"test_rm_pro_sensor_update",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Office\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperature\"",... | [
122,
0
] | [
150,
73
] | python | co | ['es', 'co', 'en'] | False |
test_rm_mini3_no_sensor | (hass) | Test we do not set up sensors for RM mini 3. | Test we do not set up sensors for RM mini 3. | async def test_rm_mini3_no_sensor(hass):
"""Test we do not set up sensors for RM mini 3."""
device = get_device("Entrance")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 0}
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass... | [
"async",
"def",
"test_rm_mini3_no_sensor",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Entrance\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperature\"",... | [
153,
0
] | [
170,
28
] | python | en | ['en', 'no', 'en'] | True |
test_rm4_pro_hts2_sensor_setup | (hass) | Test a successful RM4 pro sensor setup with HTS2 cable. | Test a successful RM4 pro sensor setup with HTS2 cable. | async def test_rm4_pro_hts2_sensor_setup(hass):
"""Test a successful RM4 pro sensor setup with HTS2 cable."""
device = get_device("Garage")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 22.5, "humidity": 43.7}
device_registry = mock_device_registry(hass)
... | [
"async",
"def",
"test_rm4_pro_hts2_sensor_setup",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Garage\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperatur... | [
173,
0
] | [
199,
5
] | python | en | ['en', 'en', 'en'] | True |
test_rm4_pro_hts2_sensor_update | (hass) | Test a successful RM4 pro sensor update with HTS2 cable. | Test a successful RM4 pro sensor update with HTS2 cable. | async def test_rm4_pro_hts2_sensor_update(hass):
"""Test a successful RM4 pro sensor update with HTS2 cable."""
device = get_device("Garage")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 16.7, "humidity": 34.1}
device_registry = mock_device_registry(hass)
... | [
"async",
"def",
"test_rm4_pro_hts2_sensor_update",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Garage\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperatu... | [
202,
0
] | [
233,
5
] | python | en | ['en', 'en', 'en'] | True |
test_rm4_pro_no_sensor | (hass) | Test we do not set up sensors for RM4 pro without HTS2 cable. | Test we do not set up sensors for RM4 pro without HTS2 cable. | async def test_rm4_pro_no_sensor(hass):
"""Test we do not set up sensors for RM4 pro without HTS2 cable."""
device = get_device("Garage")
mock_api = device.get_mock_api()
mock_api.check_sensors.return_value = {"temperature": 0, "humidity": 0}
device_registry = mock_device_registry(hass)
entity_... | [
"async",
"def",
"test_rm4_pro_no_sensor",
"(",
"hass",
")",
":",
"device",
"=",
"get_device",
"(",
"\"Garage\"",
")",
"mock_api",
"=",
"device",
".",
"get_mock_api",
"(",
")",
"mock_api",
".",
"check_sensors",
".",
"return_value",
"=",
"{",
"\"temperature\"",
... | [
236,
0
] | [
253,
28
] | python | en | ['en', 'en', 'en'] | True |
async_setup_test_fixture | (hass, mock_get_station, initial_value) | Create a dummy config entry for testing polling. | Create a dummy config entry for testing polling. | async def async_setup_test_fixture(hass, mock_get_station, initial_value):
"""Create a dummy config entry for testing polling."""
mock_get_station.return_value = initial_value
entry = MockConfigEntry(
version=1,
domain="eafm",
entry_id="VikingRecorder1234",
data={"station": ... | [
"async",
"def",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"initial_value",
")",
":",
"mock_get_station",
".",
"return_value",
"=",
"initial_value",
"entry",
"=",
"MockConfigEntry",
"(",
"version",
"=",
"1",
",",
"domain",
"=",
"\"eafm\... | [
23,
0
] | [
53,
22
] | python | en | ['en', 'en', 'en'] | True |
test_reading_measures_not_list | (hass, mock_get_station) |
Test that a measure can be a dict not a list.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/751110
|
Test that a measure can be a dict not a list. | async def test_reading_measures_not_list(hass, mock_get_station):
"""
Test that a measure can be a dict not a list.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/751110
"""
_ = await async_setup_test_fixture(
hass,
mock_get_station,
{
"label":... | [
"async",
"def",
"test_reading_measures_not_list",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"_",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"{",
"\"@... | [
56,
0
] | [
79,
29
] | python | en | ['en', 'error', 'th'] | False |
test_reading_no_unit | (hass, mock_get_station) |
Test that a sensor functions even if its unit is not known.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/L0410
|
Test that a sensor functions even if its unit is not known. | async def test_reading_no_unit(hass, mock_get_station):
"""
Test that a sensor functions even if its unit is not known.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/L0410
"""
_ = await async_setup_test_fixture(
hass,
mock_get_station,
{
"labe... | [
"async",
"def",
"test_reading_no_unit",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"_",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
"{",
"\"@id\... | [
82,
0
] | [
107,
29
] | python | en | ['en', 'error', 'th'] | False |
test_ignore_invalid_latest_reading | (hass, mock_get_station) |
Test that a sensor functions even if its unit is not known.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/L0410
|
Test that a sensor functions even if its unit is not known. | async def test_ignore_invalid_latest_reading(hass, mock_get_station):
"""
Test that a sensor functions even if its unit is not known.
E.g. https://environment.data.gov.uk/flood-monitoring/id/stations/L0410
"""
_ = await async_setup_test_fixture(
hass,
mock_get_station,
{
... | [
"async",
"def",
"test_ignore_invalid_latest_reading",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"_",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
... | [
110,
0
] | [
146,
29
] | python | en | ['en', 'error', 'th'] | False |
test_reading_unavailable | (hass, mock_get_station, exception) | Test that a sensor is marked as unavailable if there is a connection error. | Test that a sensor is marked as unavailable if there is a connection error. | async def test_reading_unavailable(hass, mock_get_station, exception):
"""Test that a sensor is marked as unavailable if there is a connection error."""
_, poll = await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
... | [
"async",
"def",
"test_reading_unavailable",
"(",
"hass",
",",
"mock_get_station",
",",
"exception",
")",
":",
"_",
",",
"poll",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"... | [
150,
0
] | [
176,
39
] | python | en | ['en', 'en', 'en'] | True |
test_recover_from_failure | (hass, mock_get_station, exception) | Test that a sensor recovers from failures. | Test that a sensor recovers from failures. | async def test_recover_from_failure(hass, mock_get_station, exception):
"""Test that a sensor recovers from failures."""
_, poll = await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
{
... | [
"async",
"def",
"test_recover_from_failure",
"(",
"hass",
",",
"mock_get_station",
",",
"exception",
")",
":",
"_",
",",
"poll",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\... | [
180,
0
] | [
226,
30
] | python | en | ['en', 'en', 'en'] | True |
test_reading_is_sampled | (hass, mock_get_station) | Test that a sensor is added and polled. | Test that a sensor is added and polled. | async def test_reading_is_sampled(hass, mock_get_station):
"""Test that a sensor is added and polled."""
await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
{
"@id": "really-long-unique... | [
"async",
"def",
"test_reading_is_sampled",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
"{",
"\"@id\"",
":",
... | [
229,
0
] | [
253,
60
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_readings_are_sampled | (hass, mock_get_station) | Test that multiple sensors are added and polled. | Test that multiple sensors are added and polled. | async def test_multiple_readings_are_sampled(hass, mock_get_station):
"""Test that multiple sensors are added and polled."""
await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
{
"@id":... | [
"async",
"def",
"test_multiple_readings_are_sampled",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
"{",
"\"@id\... | [
256,
0
] | [
294,
60
] | python | en | ['en', 'en', 'en'] | True |
test_ignore_no_latest_reading | (hass, mock_get_station) | Test that a measure is ignored if it has no latest reading. | Test that a measure is ignored if it has no latest reading. | async def test_ignore_no_latest_reading(hass, mock_get_station):
"""Test that a measure is ignored if it has no latest reading."""
await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
{
... | [
"async",
"def",
"test_ignore_no_latest_reading",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
"{",
"\"@id\"",
... | [
297,
0
] | [
333,
24
] | python | en | ['en', 'en', 'en'] | True |
test_mark_existing_as_unavailable_if_no_latest | (hass, mock_get_station) | Test that a measure is marked as unavailable if it has no latest reading. | Test that a measure is marked as unavailable if it has no latest reading. | async def test_mark_existing_as_unavailable_if_no_latest(hass, mock_get_station):
"""Test that a measure is marked as unavailable if it has no latest reading."""
_, poll = await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures":... | [
"async",
"def",
"test_mark_existing_as_unavailable_if_no_latest",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"_",
",",
"poll",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"... | [
336,
0
] | [
399,
29
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass, mock_get_station) | Test being able to unload an entry. | Test being able to unload an entry. | async def test_unload_entry(hass, mock_get_station):
"""Test being able to unload an entry."""
entry, _ = await async_setup_test_fixture(
hass,
mock_get_station,
{
"label": "My station",
"measures": [
{
"@id": "really-long-uniqu... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"mock_get_station",
")",
":",
"entry",
",",
"_",
"=",
"await",
"async_setup_test_fixture",
"(",
"hass",
",",
"mock_get_station",
",",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"measures\"",
":",
"[",
... | [
402,
0
] | [
431,
69
] | python | en | ['en', 'en', 'en'] | True |
find_pretrained_model | (src_lang: str, tgt_lang: str) | Find models that can accept src_lang as input and return tgt_lang as output. | Find models that can accept src_lang as input and return tgt_lang as output. | def find_pretrained_model(src_lang: str, tgt_lang: str) -> List[str]:
"""Find models that can accept src_lang as input and return tgt_lang as output."""
prefix = "Helsinki-NLP/opus-mt-"
api = HfApi()
model_list = api.model_list()
model_ids = [x.modelId for x in model_list if x.modelId.startswith("He... | [
"def",
"find_pretrained_model",
"(",
"src_lang",
":",
"str",
",",
"tgt_lang",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"prefix",
"=",
"\"Helsinki-NLP/opus-mt-\"",
"api",
"=",
"HfApi",
"(",
")",
"model_list",
"=",
"api",
".",
"model_list",
"(",
... | [
62,
0
] | [
72,
19
] | python | en | ['en', 'en', 'en'] | True |
convert_opus_name_to_hf_name | (x) | For OPUS-MT-Train/ DEPRECATED | For OPUS-MT-Train/ DEPRECATED | def convert_opus_name_to_hf_name(x):
"""For OPUS-MT-Train/ DEPRECATED"""
for substr, grp_name in GROUPS:
x = x.replace(substr, grp_name)
return x.replace("+", "_") | [
"def",
"convert_opus_name_to_hf_name",
"(",
"x",
")",
":",
"for",
"substr",
",",
"grp_name",
"in",
"GROUPS",
":",
"x",
"=",
"x",
".",
"replace",
"(",
"substr",
",",
"grp_name",
")",
"return",
"x",
".",
"replace",
"(",
"\"+\"",
",",
"\"_\"",
")"
] | [
160,
0
] | [
164,
30
] | python | en | ['en', 'en', 'pt'] | True |
convert_hf_name_to_opus_name | (hf_model_name) |
Relies on the assumption that there are no language codes like pt_br in models that are not in GROUP_TO_OPUS_NAME.
|
Relies on the assumption that there are no language codes like pt_br in models that are not in GROUP_TO_OPUS_NAME.
| def convert_hf_name_to_opus_name(hf_model_name):
"""
Relies on the assumption that there are no language codes like pt_br in models that are not in GROUP_TO_OPUS_NAME.
"""
hf_model_name = remove_prefix(hf_model_name, ORG_NAME)
if hf_model_name in GROUP_TO_OPUS_NAME:
opus_w_prefix = GROUP_TO_... | [
"def",
"convert_hf_name_to_opus_name",
"(",
"hf_model_name",
")",
":",
"hf_model_name",
"=",
"remove_prefix",
"(",
"hf_model_name",
",",
"ORG_NAME",
")",
"if",
"hf_model_name",
"in",
"GROUP_TO_OPUS_NAME",
":",
"opus_w_prefix",
"=",
"GROUP_TO_OPUS_NAME",
"[",
"hf_model_n... | [
167,
0
] | [
176,
51
] | python | en | ['en', 'error', 'th'] | False |
write_model_card | (
hf_model_name: str,
repo_root=DEFAULT_REPO,
save_dir=Path("marian_converted"),
dry_run=False,
extra_metadata={},
) |
Copy the most recent model's readme section from opus, and add metadata. upload command: aws s3 sync model_card_dir
s3://models.huggingface.co/bert/Helsinki-NLP/ --dryrun
|
Copy the most recent model's readme section from opus, and add metadata. upload command: aws s3 sync model_card_dir
s3://models.huggingface.co/bert/Helsinki-NLP/ --dryrun
| def write_model_card(
hf_model_name: str,
repo_root=DEFAULT_REPO,
save_dir=Path("marian_converted"),
dry_run=False,
extra_metadata={},
) -> str:
"""
Copy the most recent model's readme section from opus, and add metadata. upload command: aws s3 sync model_card_dir
s3://models.huggingface... | [
"def",
"write_model_card",
"(",
"hf_model_name",
":",
"str",
",",
"repo_root",
"=",
"DEFAULT_REPO",
",",
"save_dir",
"=",
"Path",
"(",
"\"marian_converted\"",
")",
",",
"dry_run",
"=",
"False",
",",
"extra_metadata",
"=",
"{",
"}",
",",
")",
"->",
"str",
"... | [
204,
0
] | [
270,
28
] | python | en | ['en', 'error', 'th'] | False |
convert_all_sentencepiece_models | (model_list=None, repo_path=None, dest_dir=Path("marian_converted")) | Requires 300GB | Requires 300GB | def convert_all_sentencepiece_models(model_list=None, repo_path=None, dest_dir=Path("marian_converted")):
"""Requires 300GB"""
save_dir = Path("marian_ckpt")
dest_dir = Path(dest_dir)
dest_dir.mkdir(exist_ok=True)
save_paths = []
if model_list is None:
model_list: list = make_registry(re... | [
"def",
"convert_all_sentencepiece_models",
"(",
"model_list",
"=",
"None",
",",
"repo_path",
"=",
"None",
",",
"dest_dir",
"=",
"Path",
"(",
"\"marian_converted\"",
")",
")",
":",
"save_dir",
"=",
"Path",
"(",
"\"marian_ckpt\"",
")",
"dest_dir",
"=",
"Path",
"... | [
290,
0
] | [
307,
21
] | python | en | ['en', 'la', 'pt'] | False |
_parse_readme | (lns) | Get link and metadata from opus model card equivalent. | Get link and metadata from opus model card equivalent. | def _parse_readme(lns):
"""Get link and metadata from opus model card equivalent."""
subres = {}
for ln in [x.strip() for x in lns]:
if not ln.startswith("*"):
continue
ln = ln[1:].strip()
for k in ["download", "dataset", "models", "model", "pre-processing"]:
... | [
"def",
"_parse_readme",
"(",
"lns",
")",
":",
"subres",
"=",
"{",
"}",
"for",
"ln",
"in",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"lns",
"]",
":",
"if",
"not",
"ln",
".",
"startswith",
"(",
"\"*\"",
")",
":",
"continue",
"ln",
"=",
... | [
337,
0
] | [
357,
17
] | python | en | ['en', 'en', 'en'] | True |
_assert_tensors_equal | (a, b, atol=1e-12, prefix="") | If tensors not close, or a and b arent both tensors, raise a nice Assertion error. | If tensors not close, or a and b arent both tensors, raise a nice Assertion error. | def _assert_tensors_equal(a, b, atol=1e-12, prefix=""):
"""If tensors not close, or a and b arent both tensors, raise a nice Assertion error."""
if a is None and b is None:
return True
try:
if tf.debugging.assert_near(a, b, atol=atol):
return True
raise
except Excepti... | [
"def",
"_assert_tensors_equal",
"(",
"a",
",",
"b",
",",
"atol",
"=",
"1e-12",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
":",
"return",
"True",
"try",
":",
"if",
"tf",
".",
"debugging",
".",
"assert_ne... | [
311,
0
] | [
323,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up AirVisual sensors based on a config entry. | Set up AirVisual sensors based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up AirVisual sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id]
if config_entry.data[CONF_INTEGRATION_TYPE] == INTEGRATION_TYPE_GEOGRAPHY:
sensors = [
Ai... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"if",
"config_entr... | [
89,
0
] | [
113,
37
] | python | en | ['en', 'en', 'en'] | True |
AirVisualGeographySensor.__init__ | (self, coordinator, config_entry, kind, name, icon, unit, locale) | Initialize. | Initialize. | def __init__(self, coordinator, config_entry, kind, name, icon, unit, locale):
"""Initialize."""
super().__init__(coordinator)
self._attrs.update(
{
ATTR_CITY: config_entry.data.get(CONF_CITY),
ATTR_STATE: config_entry.data.get(CONF_STATE),
... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"config_entry",
",",
"kind",
",",
"name",
",",
"icon",
",",
"unit",
",",
"locale",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_attrs",
".",
"update",
"... | [
119,
4
] | [
136,
25
] | python | en | ['en', 'en', 'it'] | False |
AirVisualGeographySensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
try:
return self.coordinator.last_update_success and bool(
self.coordinator.data["current"]["pollution"]
)
except KeyError:
return False | [
"def",
"available",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"bool",
"(",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"current\"",
"]",
"[",
"\"pollution\"",
"]",
")",
"except",
"KeyErr... | [
139,
4
] | [
146,
24
] | python | en | ['en', 'en', 'en'] | True |
AirVisualGeographySensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return f"{GEOGRAPHY_SENSOR_LOCALES[self._locale]} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{GEOGRAPHY_SENSOR_LOCALES[self._locale]} {self._name}\""
] | [
149,
4
] | [
151,
71
] | python | en | ['en', 'ig', 'en'] | True |
AirVisualGeographySensor.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
154,
4
] | [
156,
26
] | python | en | ['en', 'en', 'en'] | True |
AirVisualGeographySensor.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._config_entry.unique_id}_{self._locale}_{self._kind}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._config_entry.unique_id}_{self._locale}_{self._kind}\""
] | [
159,
4
] | [
161,
76
] | python | en | ['en', 'en', 'en'] | True |
AirVisualGeographySensor.update_from_latest_data | (self) | Update the entity from the latest data. | Update the entity from the latest data. | def update_from_latest_data(self):
"""Update the entity from the latest data."""
try:
data = self.coordinator.data["current"]["pollution"]
except KeyError:
return
if self._kind == SENSOR_KIND_LEVEL:
aqi = data[f"aqi{self._locale}"]
[level]... | [
"def",
"update_from_latest_data",
"(",
"self",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"current\"",
"]",
"[",
"\"pollution\"",
"]",
"except",
"KeyError",
":",
"return",
"if",
"self",
".",
"_kind",
"==",
"SENSOR_KI... | [
164,
4
] | [
202,
53
] | python | en | ['en', 'en', 'en'] | True |
AirVisualNodeProSensor.__init__ | (self, coordinator, kind, name, device_class, unit) | Initialize. | Initialize. | def __init__(self, coordinator, kind, name, device_class, unit):
"""Initialize."""
super().__init__(coordinator)
self._device_class = device_class
self._kind = kind
self._name = name
self._state = None
self._unit = unit | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"kind",
",",
"name",
",",
"device_class",
",",
"unit",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_device_class",
"=",
"device_class",
"self",
".",
"_kind"... | [
208,
4
] | [
216,
25
] | python | en | ['en', 'en', 'it'] | False |
AirVisualNodeProSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
219,
4
] | [
221,
33
] | python | en | ['en', 'en', 'en'] | True |
AirVisualNodeProSensor.device_info | (self) | Return device registry information for this entity. | Return device registry information for this entity. | def device_info(self):
"""Return device registry information for this entity."""
return {
"identifiers": {(DOMAIN, self.coordinator.data["serial_number"])},
"name": self.coordinator.data["settings"]["node_name"],
"manufacturer": "AirVisual",
"model": f'{se... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"serial_number\"",
"]",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"coordinator",
".",
"data",
... | [
224,
4
] | [
235,
9
] | python | en | ['en', 'en', 'en'] | True |
AirVisualNodeProSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
node_name = self.coordinator.data["settings"]["node_name"]
return f"{node_name} Node/Pro: {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"node_name",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"settings\"",
"]",
"[",
"\"node_name\"",
"]",
"return",
"f\"{node_name} Node/Pro: {self._name}\""
] | [
238,
4
] | [
241,
52
] | python | en | ['en', 'ig', 'en'] | True |
AirVisualNodeProSensor.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
244,
4
] | [
246,
26
] | python | en | ['en', 'en', 'en'] | True |
AirVisualNodeProSensor.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self.coordinator.data['serial_number']}_{self._kind}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.coordinator.data['serial_number']}_{self._kind}\""
] | [
249,
4
] | [
251,
71
] | python | en | ['en', 'en', 'en'] | True |
AirVisualNodeProSensor.update_from_latest_data | (self) | Update the entity from the latest data. | Update the entity from the latest data. | def update_from_latest_data(self):
"""Update the entity from the latest data."""
if self._kind == SENSOR_KIND_BATTERY_LEVEL:
self._state = self.coordinator.data["status"]["battery"]
elif self._kind == SENSOR_KIND_HUMIDITY:
self._state = self.coordinator.data["measurements... | [
"def",
"update_from_latest_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kind",
"==",
"SENSOR_KIND_BATTERY_LEVEL",
":",
"self",
".",
"_state",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"status\"",
"]",
"[",
"\"battery\"",
"]",
"elif",
"self",... | [
254,
4
] | [
261,
84
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up a BleBox entry. | Set up a BleBox entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox entry."""
create_blebox_entities(
hass, config_entry, async_add_entities, BleBoxLightEntity, "lights"
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"create_blebox_entities",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
",",
"BleBoxLightEntity",
",",
"\"lights\"",
")"
] | [
26,
0
] | [
31,
5
] | python | en | ['en', 'hu', 'en'] | True |
BleBoxLightEntity.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
white = SUPPORT_WHITE_VALUE if self._feature.supports_white else 0
color = SUPPORT_COLOR if self._feature.supports_color else 0
brightness = SUPPORT_BRIGHTNESS if self._feature.supports_brightness else 0
return white ... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"white",
"=",
"SUPPORT_WHITE_VALUE",
"if",
"self",
".",
"_feature",
".",
"supports_white",
"else",
"0",
"color",
"=",
"SUPPORT_COLOR",
"if",
"self",
".",
"_feature",
".",
"supports_color",
"else",
"0",
"brigh... | [
38,
4
] | [
43,
41
] | python | en | ['en', 'en', 'en'] | True |
BleBoxLightEntity.is_on | (self) | Return if light is on. | Return if light is on. | def is_on(self):
"""Return if light is on."""
return self._feature.is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_feature",
".",
"is_on"
] | [
46,
4
] | [
48,
34
] | python | en | ['en', 'et', 'en'] | True |
BleBoxLightEntity.brightness | (self) | Return the name. | Return the name. | def brightness(self):
"""Return the name."""
return self._feature.brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_feature",
".",
"brightness"
] | [
51,
4
] | [
53,
39
] | python | en | ['en', 'ig', 'en'] | True |
BleBoxLightEntity.white_value | (self) | Return the white value. | Return the white value. | def white_value(self):
"""Return the white value."""
return self._feature.white_value | [
"def",
"white_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_feature",
".",
"white_value"
] | [
56,
4
] | [
58,
40
] | python | en | ['en', 'no', 'en'] | True |
BleBoxLightEntity.hs_color | (self) | Return the hue and saturation. | Return the hue and saturation. | def hs_color(self):
"""Return the hue and saturation."""
rgbw_hex = self._feature.rgbw_hex
if rgbw_hex is None:
return None
rgb = rgb_hex_to_rgb_list(rgbw_hex)[0:3]
return color_RGB_to_hs(*rgb) | [
"def",
"hs_color",
"(",
"self",
")",
":",
"rgbw_hex",
"=",
"self",
".",
"_feature",
".",
"rgbw_hex",
"if",
"rgbw_hex",
"is",
"None",
":",
"return",
"None",
"rgb",
"=",
"rgb_hex_to_rgb_list",
"(",
"rgbw_hex",
")",
"[",
"0",
":",
"3",
"]",
"return",
"col... | [
61,
4
] | [
68,
36
] | python | en | ['en', 'en', 'en'] | True |
BleBoxLightEntity.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
white = kwargs.get(ATTR_WHITE_VALUE)
hs_color = kwargs.get(ATTR_HS_COLOR)
brightness = kwargs.get(ATTR_BRIGHTNESS)
feature = self._feature
value = feature.sensible_on_value
if brightness is not N... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"white",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_WHITE_VALUE",
")",
"hs_color",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_HS_COLOR",
")",
"brightness",
"=",
"kwargs",
".",
"get",
... | [
70,
4
] | [
95,
13
] | python | en | ['en', 'et', 'en'] | True |
BleBoxLightEntity.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._feature.async_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_feature",
".",
"async_off",
"(",
")"
] | [
97,
4
] | [
99,
39
] | python | en | ['en', 'zh', 'en'] | True |
test_entity_registry | (hass) | Tests that the devices are registered in the entity registry. | Tests that the devices are registered in the entity registry. | async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, BINARY_SENSOR_DOMAIN)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
entry = entity_registry.async_get("binary_sensor.front_door")
assert e... | [
"async",
"def",
"test_entity_registry",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
")",
"entity_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"entry",
... | [
17,
0
] | [
23,
64
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass) | Test the binary sensor attributes are correct. | Test the binary sensor attributes are correct. | async def test_attributes(hass):
"""Test the binary sensor attributes are correct."""
await setup_platform(hass, BINARY_SENSOR_DOMAIN)
state = hass.states.get("binary_sensor.front_door")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
assert state.at... | [
"async",
"def",
"test_attributes",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"BINARY_SENSOR_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"binary_sensor.front_door\"",
")",
"assert",
"state",
".",
"state",
"=="... | [
26,
0
] | [
38,
73
] | python | en | ['en', 'it', 'en'] | True |
_fix_input_types | (zone_input) | Convert necessary keys to int.
Since ConfigFlow inputs of type int cannot default to an empty string, we collect the values below as
strings and then convert them to ints.
| Convert necessary keys to int. | def _fix_input_types(zone_input):
"""Convert necessary keys to int.
Since ConfigFlow inputs of type int cannot default to an empty string, we collect the values below as
strings and then convert them to ints.
"""
for key in [CONF_ZONE_LOOP, CONF_RELAY_ADDR, CONF_RELAY_CHAN]:
if key in zone... | [
"def",
"_fix_input_types",
"(",
"zone_input",
")",
":",
"for",
"key",
"in",
"[",
"CONF_ZONE_LOOP",
",",
"CONF_RELAY_ADDR",
",",
"CONF_RELAY_CHAN",
"]",
":",
"if",
"key",
"in",
"zone_input",
":",
"zone_input",
"[",
"key",
"]",
"=",
"int",
"(",
"zone_input",
... | [
324,
0
] | [
335,
21
] | python | en | ['en', 'mg', 'en'] | True |
_device_already_added | (current_entries, user_input, protocol) | Determine if entry has already been added to HA. | Determine if entry has already been added to HA. | def _device_already_added(current_entries, user_input, protocol):
"""Determine if entry has already been added to HA."""
user_host = user_input.get(CONF_HOST)
user_port = user_input.get(CONF_PORT)
user_path = user_input.get(CONF_DEVICE_PATH)
user_baud = user_input.get(CONF_DEVICE_BAUD)
for entr... | [
"def",
"_device_already_added",
"(",
"current_entries",
",",
"user_input",
",",
"protocol",
")",
":",
"user_host",
"=",
"user_input",
".",
"get",
"(",
"CONF_HOST",
")",
"user_port",
"=",
"user_input",
".",
"get",
"(",
"CONF_PORT",
")",
"user_path",
"=",
"user_... | [
338,
0
] | [
359,
16
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderFlowHandler.__init__ | (self) | Initialize AlarmDecoder ConfigFlow. | Initialize AlarmDecoder ConfigFlow. | def __init__(self):
"""Initialize AlarmDecoder ConfigFlow."""
self.protocol = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"protocol",
"=",
"None"
] | [
53,
4
] | [
55,
28
] | python | en | ['en', 'sr', 'it'] | False |
AlarmDecoderFlowHandler.async_get_options_flow | (config_entry) | Get the options flow for AlarmDecoder. | Get the options flow for AlarmDecoder. | def async_get_options_flow(config_entry):
"""Get the options flow for AlarmDecoder."""
return AlarmDecoderOptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"AlarmDecoderOptionsFlowHandler",
"(",
"config_entry",
")"
] | [
59,
4
] | [
61,
59
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
if user_input is not None:
self.protocol = user_input[CONF_PROTOCOL]
return await self.async_step_protocol()
return self.async_show_form(
step_id="user",
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"protocol",
"=",
"user_input",
"[",
"CONF_PROTOCOL",
"]",
"return",
"await",
"self",
".",
"async_step_protoco... | [
63,
4
] | [
78,
9
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderFlowHandler.async_step_protocol | (self, user_input=None) | Handle AlarmDecoder protocol setup. | Handle AlarmDecoder protocol setup. | async def async_step_protocol(self, user_input=None):
"""Handle AlarmDecoder protocol setup."""
errors = {}
if user_input is not None:
if _device_already_added(
self._async_current_entries(), user_input, self.protocol
):
return self.async_a... | [
"async",
"def",
"async_step_protocol",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"_device_already_added",
"(",
"self",
".",
"_async_current_entries",
"(",
")",
",",
"... | [
80,
4
] | [
137,
9
] | python | en | ['en', 'ceb', 'en'] | True |
AlarmDecoderOptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize AlarmDecoder options flow. | Initialize AlarmDecoder options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize AlarmDecoder options flow."""
self.arm_options = config_entry.options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS)
self.zone_options = config_entry.options.get(
OPTIONS_ZONES, DEFAULT_ZONE_OPTIONS
)
... | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"arm_options",
"=",
"config_entry",
".",
"options",
".",
"get",
"(",
"OPTIONS_ARM",
",",
"DEFAULT_ARM_OPTIONS",
")",
"self",
".",
"zone_optio... | [
143,
4
] | [
149,
33
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderOptionsFlowHandler.async_step_init | (self, user_input=None) | Manage the options. | Manage the options. | async def async_step_init(self, user_input=None):
"""Manage the options."""
if user_input is not None:
if user_input[EDIT_KEY] == EDIT_SETTINGS:
return await self.async_step_arm_settings()
if user_input[EDIT_KEY] == EDIT_ZONES:
return await self.as... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"user_input",
"[",
"EDIT_KEY",
"]",
"==",
"EDIT_SETTINGS",
":",
"return",
"await",
"self",
".",
"async_step_arm_sett... | [
151,
4
] | [
168,
9
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderOptionsFlowHandler.async_step_arm_settings | (self, user_input=None) | Arming options form. | Arming options form. | async def async_step_arm_settings(self, user_input=None):
"""Arming options form."""
if user_input is not None:
return self.async_create_entry(
title="",
data={OPTIONS_ARM: user_input, OPTIONS_ZONES: self.zone_options},
)
return self.async... | [
"async",
"def",
"async_step_arm_settings",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"{",
"OPTIONS_ARM",
":... | [
170,
4
] | [
195,
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.