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_flow_import_no_h264 | (hass) | Test that config flow fails when no MAC available. | Test that config flow fails when no MAC available. | async def test_flow_import_no_h264(hass):
"""Test that config flow fails when no MAC available."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera, with_h264=False)
result = await hass.config_entri... | [
"async",
"def",
"test_flow_import_no_h264",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
",",
"with_h264",
"=",
"False",
... | [
481,
0
] | [
501,
44
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_onvif_api_error | (hass) | Test that config flow fails when ONVIF API fails. | Test that config flow fails when ONVIF API fails. | async def test_flow_import_onvif_api_error(hass):
"""Test that config flow fails when ONVIF API fails."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera)
mock_onvif_camera.create_devicemgmt_service... | [
"async",
"def",
"test_flow_import_onvif_api_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
")",
"mock_onvif_camera",
".... | [
504,
0
] | [
527,
48
] | python | en | ['en', 'fr', 'en'] | True |
test_flow_import_onvif_auth_error | (hass) | Test that config flow fails when ONVIF API fails. | Test that config flow fails when ONVIF API fails. | async def test_flow_import_onvif_auth_error(hass):
"""Test that config flow fails when ONVIF API fails."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera)
mock_onvif_camera.create_devicemgmt_servic... | [
"async",
"def",
"test_flow_import_onvif_auth_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
")",
"mock_onvif_camera",
"... | [
530,
0
] | [
554,
59
] | python | en | ['en', 'fr', 'en'] | True |
test_option_flow | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow(hass):
"""Test config flow options."""
entry = await setup_onvif_integration(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "onvif_devices"
result = aw... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_onvif_integration",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"options",
".",
"async_init",
"(",
"entry",
".",
"entry_id",
")",
"asse... | [
557,
0
] | [
578,
5
] | python | en | ['en', 'fr', 'en'] | True |
register_trait | (trait) | Decorate a function to register a trait. | Decorate a function to register a trait. | def register_trait(trait):
"""Decorate a function to register a trait."""
TRAITS.append(trait)
return trait | [
"def",
"register_trait",
"(",
"trait",
")",
":",
"TRAITS",
".",
"append",
"(",
"trait",
")",
"return",
"trait"
] | [
140,
0
] | [
143,
16
] | python | en | ['en', 'en', 'en'] | True |
_google_temp_unit | (units) | Return Google temperature unit. | Return Google temperature unit. | def _google_temp_unit(units):
"""Return Google temperature unit."""
if units == TEMP_FAHRENHEIT:
return "F"
return "C" | [
"def",
"_google_temp_unit",
"(",
"units",
")",
":",
"if",
"units",
"==",
"TEMP_FAHRENHEIT",
":",
"return",
"\"F\"",
"return",
"\"C\""
] | [
146,
0
] | [
150,
14
] | python | en | ['es', 'la', 'en'] | False |
_next_selected | (items: List[str], selected: Optional[str]) | Return the next item in a item list starting at given value.
If selected is missing in items, None is returned
| Return the next item in a item list starting at given value. | def _next_selected(items: List[str], selected: Optional[str]) -> Optional[str]:
"""Return the next item in a item list starting at given value.
If selected is missing in items, None is returned
"""
try:
index = items.index(selected)
except ValueError:
return None
next_item = 0 ... | [
"def",
"_next_selected",
"(",
"items",
":",
"List",
"[",
"str",
"]",
",",
"selected",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"try",
":",
"index",
"=",
"items",
".",
"index",
"(",
"selected",
")",
"except",
"V... | [
153,
0
] | [
164,
27
] | python | en | ['en', 'en', 'en'] | True |
_verify_pin_challenge | (data, state, challenge) | Verify a pin challenge. | Verify a pin challenge. | def _verify_pin_challenge(data, state, challenge):
"""Verify a pin challenge."""
if not data.config.should_2fa(state):
return
if not data.config.secure_devices_pin:
raise SmartHomeError(ERR_CHALLENGE_NOT_SETUP, "Challenge is not set up")
if not challenge:
raise ChallengeNeeded(C... | [
"def",
"_verify_pin_challenge",
"(",
"data",
",",
"state",
",",
"challenge",
")",
":",
"if",
"not",
"data",
".",
"config",
".",
"should_2fa",
"(",
"state",
")",
":",
"return",
"if",
"not",
"data",
".",
"config",
".",
"secure_devices_pin",
":",
"raise",
"... | [
1779,
0
] | [
1792,
58
] | python | en | ['en', 'ht', 'en'] | True |
_verify_ack_challenge | (data, state, challenge) | Verify an ack challenge. | Verify an ack challenge. | def _verify_ack_challenge(data, state, challenge):
"""Verify an ack challenge."""
if not data.config.should_2fa(state):
return
if not challenge or not challenge.get("ack"):
raise ChallengeNeeded(CHALLENGE_ACK_NEEDED) | [
"def",
"_verify_ack_challenge",
"(",
"data",
",",
"state",
",",
"challenge",
")",
":",
"if",
"not",
"data",
".",
"config",
".",
"should_2fa",
"(",
"state",
")",
":",
"return",
"if",
"not",
"challenge",
"or",
"not",
"challenge",
".",
"get",
"(",
"\"ack\""... | [
1795,
0
] | [
1800,
51
] | python | en | ['en', 'en', 'en'] | True |
_Trait.might_2fa | (domain, features, device_class) | Return if the trait might ask for 2FA. | Return if the trait might ask for 2FA. | def might_2fa(domain, features, device_class):
"""Return if the trait might ask for 2FA."""
return False | [
"def",
"might_2fa",
"(",
"domain",
",",
"features",
",",
"device_class",
")",
":",
"return",
"False"
] | [
173,
4
] | [
175,
20
] | python | en | ['en', 'en', 'en'] | True |
_Trait.__init__ | (self, hass, state, config) | Initialize a trait for a state. | Initialize a trait for a state. | def __init__(self, hass, state, config):
"""Initialize a trait for a state."""
self.hass = hass
self.state = state
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"state",
",",
"config",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"state",
"=",
"state",
"self",
".",
"config",
"=",
"config"
] | [
177,
4
] | [
181,
28
] | python | en | ['en', 'en', 'en'] | True |
_Trait.sync_attributes | (self) | Return attributes for a sync request. | Return attributes for a sync request. | def sync_attributes(self):
"""Return attributes for a sync request."""
raise NotImplementedError | [
"def",
"sync_attributes",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
183,
4
] | [
185,
33
] | python | en | ['en', 'en', 'en'] | True |
_Trait.query_attributes | (self) | Return the attributes of this trait for this entity. | Return the attributes of this trait for this entity. | def query_attributes(self):
"""Return the attributes of this trait for this entity."""
raise NotImplementedError | [
"def",
"query_attributes",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
187,
4
] | [
189,
33
] | python | en | ['en', 'en', 'en'] | True |
_Trait.can_execute | (self, command, params) | Test if command can be executed. | Test if command can be executed. | def can_execute(self, command, params):
"""Test if command can be executed."""
return command in self.commands | [
"def",
"can_execute",
"(",
"self",
",",
"command",
",",
"params",
")",
":",
"return",
"command",
"in",
"self",
".",
"commands"
] | [
191,
4
] | [
193,
39
] | python | en | ['en', 'en', 'en'] | True |
_Trait.execute | (self, command, data, params, challenge) | Execute a trait command. | Execute a trait command. | async def execute(self, command, data, params, challenge):
"""Execute a trait command."""
raise NotImplementedError | [
"async",
"def",
"execute",
"(",
"self",
",",
"command",
",",
"data",
",",
"params",
",",
"challenge",
")",
":",
"raise",
"NotImplementedError"
] | [
195,
4
] | [
197,
33
] | python | fr | ['fr', 'fr', 'en'] | True |
denonavr_connect_fixture | () | Mock denonavr connection and entry setup. | Mock denonavr connection and entry setup. | def denonavr_connect_fixture():
"""Mock denonavr connection and entry setup."""
with patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR._update_input_func_list",
return_value=True,
), patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR._get_receiver... | [
"def",
"denonavr_connect_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.denonavr.receiver.denonavr.DenonAVR._update_input_func_list\"",
",",
"return_value",
"=",
"True",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.denonavr.receiver.denonav... | [
36,
0
] | [
77,
13
] | python | en | ['en', 'da', 'en'] | True |
test_config_flow_manual_host_success | (hass) |
Successful flow manually initialized by the user.
Host specified.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_host_success(hass):
"""
Successful flow manually initialized by the user.
Host specified.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert re... | [
"async",
"def",
"test_config_flow_manual_host_success",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER"... | [
80,
0
] | [
108,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_discover_1_success | (hass) |
Successful flow manually initialized by the user.
Without the host specified and 1 receiver discovered.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_discover_1_success(hass):
"""
Successful flow manually initialized by the user.
Without the host specified and 1 receiver discovered.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
a... | [
"async",
"def",
"test_config_flow_manual_discover_1_success",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE... | [
111,
0
] | [
143,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_discover_2_success | (hass) |
Successful flow manually initialized by the user.
Without the host specified and 2 receiver discovered.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_discover_2_success(hass):
"""
Successful flow manually initialized by the user.
Without the host specified and 2 receiver discovered.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
a... | [
"async",
"def",
"test_config_flow_manual_discover_2_success",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE... | [
146,
0
] | [
187,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_discover_error | (hass) |
Failed flow manually initialized by the user.
Without the host specified and no receiver discovered.
|
Failed flow manually initialized by the user. | async def test_config_flow_manual_discover_error(hass):
"""
Failed flow manually initialized by the user.
Without the host specified and no receiver discovered.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert r... | [
"async",
"def",
"test_config_flow_manual_discover_error",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USE... | [
190,
0
] | [
215,
58
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_no_serial | (hass) |
Successful flow manually initialized by the user.
Host specified and an error getting the serial number.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_host_no_serial(hass):
"""
Successful flow manually initialized by the user.
Host specified and an error getting the serial number.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
asse... | [
"async",
"def",
"test_config_flow_manual_host_no_serial",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USE... | [
218,
0
] | [
250,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_no_mac | (hass) |
Successful flow manually initialized by the user.
Host specified and an error getting the mac address.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_host_no_mac(hass):
"""
Successful flow manually initialized by the user.
Host specified and an error getting the mac address.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert re... | [
"async",
"def",
"test_config_flow_manual_host_no_mac",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",... | [
253,
0
] | [
285,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_no_serial_no_mac | (hass) |
Successful flow manually initialized by the user.
Host specified and an error getting the serial number and mac address.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_host_no_serial_no_mac(hass):
"""
Successful flow manually initialized by the user.
Host specified and an error getting the serial number and mac address.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURC... | [
"async",
"def",
"test_config_flow_manual_host_no_serial_no_mac",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOU... | [
288,
0
] | [
323,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_no_serial_no_mac_exception | (hass) |
Successful flow manually initialized by the user.
Host specified and an error getting the serial number and exception getting mac address.
|
Successful flow manually initialized by the user. | async def test_config_flow_manual_host_no_serial_no_mac_exception(hass):
"""
Successful flow manually initialized by the user.
Host specified and an error getting the serial number and exception getting mac address.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"s... | [
"async",
"def",
"test_config_flow_manual_host_no_serial_no_mac_exception",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
"... | [
326,
0
] | [
361,
5
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_connection_error | (hass) |
Failed flow manually initialized by the user.
Host specified and a connection error.
|
Failed flow manually initialized by the user. | async def test_config_flow_manual_host_connection_error(hass):
"""
Failed flow manually initialized by the user.
Host specified and a connection error.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["ty... | [
"async",
"def",
"test_config_flow_manual_host_connection_error",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOU... | [
364,
0
] | [
391,
47
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_manual_host_no_device_info | (hass) |
Failed flow manually initialized by the user.
Host specified and no device info (due to receiver power off).
|
Failed flow manually initialized by the user. | async def test_config_flow_manual_host_no_device_info(hass):
"""
Failed flow manually initialized by the user.
Host specified and no device info (due to receiver power off).
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
... | [
"async",
"def",
"test_config_flow_manual_host_no_device_info",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURC... | [
394,
0
] | [
418,
47
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_ssdp | (hass) | Successful flow initialized by ssdp discovery. | Successful flow initialized by ssdp discovery. | async def test_config_flow_ssdp(hass):
"""Successful flow initialized by ssdp discovery."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
ssdp.ATTR_UPNP_MANUFACTURER: TEST_MANUFACTURER,
ssdp.ATTR... | [
"async",
"def",
"test_config_flow_ssdp",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_SSDP",
"}",
",",... | [
421,
0
] | [
451,
5
] | python | en | ['en', 'en', 'en'] | True |
test_config_flow_ssdp_not_denon | (hass) |
Failed flow initialized by ssdp discovery.
Not supported manufacturer.
|
Failed flow initialized by ssdp discovery. | async def test_config_flow_ssdp_not_denon(hass):
"""
Failed flow initialized by ssdp discovery.
Not supported manufacturer.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
ssdp.ATTR_UPNP_MANUF... | [
"async",
"def",
"test_config_flow_ssdp_not_denon",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_SSDP",
"... | [
454,
0
] | [
472,
58
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_ssdp_missing_info | (hass) |
Failed flow initialized by ssdp discovery.
Missing information.
|
Failed flow initialized by ssdp discovery. | async def test_config_flow_ssdp_missing_info(hass):
"""
Failed flow initialized by ssdp discovery.
Missing information.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
ssdp.ATTR_UPNP_MANUFACTU... | [
"async",
"def",
"test_config_flow_ssdp_missing_info",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_SSDP",
... | [
475,
0
] | [
491,
53
] | python | en | ['en', 'error', 'th'] | False |
test_config_flow_ssdp_ignored_model | (hass) |
Failed flow initialized by ssdp discovery.
Model in the ignored models list.
|
Failed flow initialized by ssdp discovery. | async def test_config_flow_ssdp_ignored_model(hass):
"""
Failed flow initialized by ssdp discovery.
Model in the ignored models list.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
ssdp.ATTR_... | [
"async",
"def",
"test_config_flow_ssdp_ignored_model",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_SSDP",... | [
494,
0
] | [
512,
58
] | python | en | ['en', 'error', 'th'] | False |
test_options_flow | (hass) | Test specifying non default settings using options flow. | Test specifying non default settings using options flow. | async def test_options_flow(hass):
"""Test specifying non default settings using options flow."""
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_UNIQUE_ID,
data={
CONF_HOST: TEST_HOST,
CONF_MAC: TEST_MAC,
CONF_MODEL: TEST_MODEL,
... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"TEST_UNIQUE_ID",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"TEST_HOST",
",",
"CONF_MAC",
":",
"TEST_MAC",
... | [
515,
0
] | [
550,
5
] | python | en | ['en', 'en', 'en'] | True |
test_config_flow_manual_host_no_serial_double_config | (hass) |
Failed flow manually initialized by the user twice.
Host specified and an error getting the serial number.
|
Failed flow manually initialized by the user twice. | async def test_config_flow_manual_host_no_serial_double_config(hass):
"""
Failed flow manually initialized by the user twice.
Host specified and an error getting the serial number.
"""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}... | [
"async",
"def",
"test_config_flow_manual_host_no_serial_double_config",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",... | [
553,
0
] | [
605,
51
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the EnOcean light platform. | Set up the EnOcean light platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the EnOcean light platform."""
sender_id = config.get(CONF_SENDER_ID)
dev_name = config.get(CONF_NAME)
dev_id = config.get(CONF_ID)
add_entities([EnOceanLight(sender_id, dev_id, dev_name)]) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sender_id",
"=",
"config",
".",
"get",
"(",
"CONF_SENDER_ID",
")",
"dev_name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"dev_i... | [
30,
0
] | [
36,
61
] | python | en | ['en', 'da', 'en'] | True |
EnOceanLight.__init__ | (self, sender_id, dev_id, dev_name) | Initialize the EnOcean light source. | Initialize the EnOcean light source. | def __init__(self, sender_id, dev_id, dev_name):
"""Initialize the EnOcean light source."""
super().__init__(dev_id, dev_name)
self._on_state = False
self._brightness = 50
self._sender_id = sender_id | [
"def",
"__init__",
"(",
"self",
",",
"sender_id",
",",
"dev_id",
",",
"dev_name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"dev_id",
",",
"dev_name",
")",
"self",
".",
"_on_state",
"=",
"False",
"self",
".",
"_brightness",
"=",
"50",
"self",
... | [
42,
4
] | [
47,
35
] | python | en | ['en', 'en', 'en'] | True |
EnOceanLight.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self):
"""Return the name of the device if any."""
return self.dev_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"dev_name"
] | [
50,
4
] | [
52,
28
] | python | en | ['en', 'en', 'en'] | True |
EnOceanLight.brightness | (self) | Brightness of the light.
This method is optional. Removing it indicates to Home Assistant
that brightness is not supported for this light.
| Brightness of the light. | def brightness(self):
"""Brightness of the light.
This method is optional. Removing it indicates to Home Assistant
that brightness is not supported for this light.
"""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
55,
4
] | [
61,
31
] | python | en | ['en', 'ky', 'en'] | True |
EnOceanLight.is_on | (self) | If light is on. | If light is on. | def is_on(self):
"""If light is on."""
return self._on_state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_on_state"
] | [
64,
4
] | [
66,
29
] | python | en | ['en', 'en', 'en'] | True |
EnOceanLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_ENOCEAN | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_ENOCEAN"
] | [
69,
4
] | [
71,
30
] | python | en | ['da', 'en', 'en'] | True |
EnOceanLight.turn_on | (self, **kwargs) | Turn the light source on or sets a specific dimmer value. | Turn the light source on or sets a specific dimmer value. | def turn_on(self, **kwargs):
"""Turn the light source on or sets a specific dimmer value."""
brightness = kwargs.get(ATTR_BRIGHTNESS)
if brightness is not None:
self._brightness = brightness
bval = math.floor(self._brightness / 256.0 * 100.0)
if bval == 0:
... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
")",
"if",
"brightness",
"is",
"not",
"None",
":",
"self",
".",
"_brightness",
"=",
"brightness",
"bval",
"=",
"math",
".... | [
73,
4
] | [
86,
29
] | python | en | ['en', 'en', 'en'] | True |
EnOceanLight.turn_off | (self, **kwargs) | Turn the light source off. | Turn the light source off. | def turn_off(self, **kwargs):
"""Turn the light source off."""
command = [0xA5, 0x02, 0x00, 0x01, 0x09]
command.extend(self._sender_id)
command.extend([0x00])
self.send_command(command, [], 0x01)
self._on_state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"command",
"=",
"[",
"0xA5",
",",
"0x02",
",",
"0x00",
",",
"0x01",
",",
"0x09",
"]",
"command",
".",
"extend",
"(",
"self",
".",
"_sender_id",
")",
"command",
".",
"extend",
"(",
... | [
88,
4
] | [
94,
30
] | python | en | ['en', 'en', 'en'] | True |
EnOceanLight.value_changed | (self, packet) | Update the internal state of this device.
Dimmer devices like Eltako FUD61 send telegram in different RORGs.
We only care about the 4BS (0xA5).
| Update the internal state of this device. | def value_changed(self, packet):
"""Update the internal state of this device.
Dimmer devices like Eltako FUD61 send telegram in different RORGs.
We only care about the 4BS (0xA5).
"""
if packet.data[0] == 0xA5 and packet.data[1] == 0x02:
val = packet.data[2]
... | [
"def",
"value_changed",
"(",
"self",
",",
"packet",
")",
":",
"if",
"packet",
".",
"data",
"[",
"0",
"]",
"==",
"0xA5",
"and",
"packet",
".",
"data",
"[",
"1",
"]",
"==",
"0x02",
":",
"val",
"=",
"packet",
".",
"data",
"[",
"2",
"]",
"self",
".... | [
96,
4
] | [
106,
43
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, flash_briefing_config) | Activate Alexa component. | Activate Alexa component. | def async_setup(hass, flash_briefing_config):
"""Activate Alexa component."""
hass.http.register_view(AlexaFlashBriefingView(hass, flash_briefing_config)) | [
"def",
"async_setup",
"(",
"hass",
",",
"flash_briefing_config",
")",
":",
"hass",
".",
"http",
".",
"register_view",
"(",
"AlexaFlashBriefingView",
"(",
"hass",
",",
"flash_briefing_config",
")",
")"
] | [
35,
0
] | [
37,
80
] | python | ca | ['ro', 'ca', 'en'] | False |
AlexaFlashBriefingView.__init__ | (self, hass, flash_briefings) | Initialize Alexa view. | Initialize Alexa view. | def __init__(self, hass, flash_briefings):
"""Initialize Alexa view."""
super().__init__()
self.flash_briefings = copy.deepcopy(flash_briefings)
template.attach(hass, self.flash_briefings) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"flash_briefings",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"flash_briefings",
"=",
"copy",
".",
"deepcopy",
"(",
"flash_briefings",
")",
"template",
".",
"attach",
"(",
"hass"... | [
47,
4
] | [
51,
51
] | python | en | ['ro', 'pl', 'en'] | False |
AlexaFlashBriefingView.get | (self, request, briefing_id) | Handle Alexa Flash Briefing request. | Handle Alexa Flash Briefing request. | def get(self, request, briefing_id):
"""Handle Alexa Flash Briefing request."""
_LOGGER.debug("Received Alexa flash briefing request for: %s", briefing_id)
if request.query.get(API_PASSWORD) is None:
err = "No password provided for Alexa flash briefing: %s"
_LOGGER.error... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"briefing_id",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Received Alexa flash briefing request for: %s\"",
",",
"briefing_id",
")",
"if",
"request",
".",
"query",
".",
"get",
"(",
"API_PASSWORD",
")",
"is",
"Non... | [
54,
4
] | [
121,
34
] | python | en | ['ro', 'es', 'en'] | False |
async_get_registry | (hass: HomeAssistantType) | Return area registry instance. | Return area registry instance. | async def async_get_registry(hass: HomeAssistantType) -> AreaRegistry:
"""Return area registry instance."""
reg_or_evt = hass.data.get(DATA_REGISTRY)
if not reg_or_evt:
evt = hass.data[DATA_REGISTRY] = Event()
reg = AreaRegistry(hass)
await reg.async_load()
hass.data[DATA_... | [
"async",
"def",
"async_get_registry",
"(",
"hass",
":",
"HomeAssistantType",
")",
"->",
"AreaRegistry",
":",
"reg_or_evt",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_REGISTRY",
")",
"if",
"not",
"reg_or_evt",
":",
"evt",
"=",
"hass",
".",
"data",
"["... | [
147,
0
] | [
166,
41
] | python | en | ['en', 'da', 'en'] | True |
AreaRegistry.__init__ | (self, hass: HomeAssistantType) | Initialize the area registry. | Initialize the area registry. | def __init__(self, hass: HomeAssistantType) -> None:
"""Initialize the area registry."""
self.hass = hass
self.areas: MutableMapping[str, AreaEntry] = {}
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"areas",
":",
"MutableMapping",
"[",
"str",
",",
"AreaEntry",
"]",
"=",
"{",
"}",
"self",
".",
"_store",
"="... | [
31,
4
] | [
35,
78
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry.async_get_area | (self, area_id: str) | Get all areas. | Get all areas. | def async_get_area(self, area_id: str) -> Optional[AreaEntry]:
"""Get all areas."""
return self.areas.get(area_id) | [
"def",
"async_get_area",
"(",
"self",
",",
"area_id",
":",
"str",
")",
"->",
"Optional",
"[",
"AreaEntry",
"]",
":",
"return",
"self",
".",
"areas",
".",
"get",
"(",
"area_id",
")"
] | [
38,
4
] | [
40,
38
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry.async_list_areas | (self) | Get all areas. | Get all areas. | def async_list_areas(self) -> Iterable[AreaEntry]:
"""Get all areas."""
return self.areas.values() | [
"def",
"async_list_areas",
"(",
"self",
")",
"->",
"Iterable",
"[",
"AreaEntry",
"]",
":",
"return",
"self",
".",
"areas",
".",
"values",
"(",
")"
] | [
43,
4
] | [
45,
34
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry.async_create | (self, name: str) | Create a new area. | Create a new area. | def async_create(self, name: str) -> AreaEntry:
"""Create a new area."""
if self._async_is_registered(name):
raise ValueError("Name is already in use")
area = AreaEntry()
self.areas[area.id] = area
created = self._async_update(area.id, name=name)
self.hass.... | [
"def",
"async_create",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"AreaEntry",
":",
"if",
"self",
".",
"_async_is_registered",
"(",
"name",
")",
":",
"raise",
"ValueError",
"(",
"\"Name is already in use\"",
")",
"area",
"=",
"AreaEntry",
"(",
")",
"... | [
48,
4
] | [
62,
22
] | python | en | ['en', 'sm', 'en'] | True |
AreaRegistry.async_delete | (self, area_id: str) | Delete area. | Delete area. | async def async_delete(self, area_id: str) -> None:
"""Delete area."""
device_registry, entity_registry = await gather(
self.hass.helpers.device_registry.async_get_registry(),
self.hass.helpers.entity_registry.async_get_registry(),
)
device_registry.async_clear_ar... | [
"async",
"def",
"async_delete",
"(",
"self",
",",
"area_id",
":",
"str",
")",
"->",
"None",
":",
"device_registry",
",",
"entity_registry",
"=",
"await",
"gather",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"... | [
64,
4
] | [
79,
34
] | python | en | ['en', 'it', 'en'] | False |
AreaRegistry.async_update | (self, area_id: str, name: str) | Update name of area. | Update name of area. | def async_update(self, area_id: str, name: str) -> AreaEntry:
"""Update name of area."""
updated = self._async_update(area_id, name)
self.hass.bus.async_fire(
EVENT_AREA_REGISTRY_UPDATED, {"action": "update", "area_id": area_id}
)
return updated | [
"def",
"async_update",
"(",
"self",
",",
"area_id",
":",
"str",
",",
"name",
":",
"str",
")",
"->",
"AreaEntry",
":",
"updated",
"=",
"self",
".",
"_async_update",
"(",
"area_id",
",",
"name",
")",
"self",
".",
"hass",
".",
"bus",
".",
"async_fire",
... | [
82,
4
] | [
88,
22
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry._async_update | (self, area_id: str, name: str) | Update name of area. | Update name of area. | def _async_update(self, area_id: str, name: str) -> AreaEntry:
"""Update name of area."""
old = self.areas[area_id]
changes = {}
if name == old.name:
return old
if self._async_is_registered(name):
raise ValueError("Name is already in use")
chan... | [
"def",
"_async_update",
"(",
"self",
",",
"area_id",
":",
"str",
",",
"name",
":",
"str",
")",
"->",
"AreaEntry",
":",
"old",
"=",
"self",
".",
"areas",
"[",
"area_id",
"]",
"changes",
"=",
"{",
"}",
"if",
"name",
"==",
"old",
".",
"name",
":",
"... | [
91,
4
] | [
107,
18
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry._async_is_registered | (self, name: str) | Check if a name is currently registered. | Check if a name is currently registered. | def _async_is_registered(self, name: str) -> Optional[AreaEntry]:
"""Check if a name is currently registered."""
for area in self.areas.values():
if name == area.name:
return area
return None | [
"def",
"_async_is_registered",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Optional",
"[",
"AreaEntry",
"]",
":",
"for",
"area",
"in",
"self",
".",
"areas",
".",
"values",
"(",
")",
":",
"if",
"name",
"==",
"area",
".",
"name",
":",
"return",
... | [
110,
4
] | [
115,
19
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry.async_load | (self) | Load the area registry. | Load the area registry. | async def async_load(self) -> None:
"""Load the area registry."""
data = await self._store.async_load()
areas: MutableMapping[str, AreaEntry] = OrderedDict()
if data is not None:
for area in data["areas"]:
areas[area["id"]] = AreaEntry(name=area["name"], id=... | [
"async",
"def",
"async_load",
"(",
"self",
")",
"->",
"None",
":",
"data",
"=",
"await",
"self",
".",
"_store",
".",
"async_load",
"(",
")",
"areas",
":",
"MutableMapping",
"[",
"str",
",",
"AreaEntry",
"]",
"=",
"OrderedDict",
"(",
")",
"if",
"data",
... | [
117,
4
] | [
127,
26
] | python | en | ['en', 'en', 'en'] | True |
AreaRegistry.async_schedule_save | (self) | Schedule saving the area registry. | Schedule saving the area registry. | def async_schedule_save(self) -> None:
"""Schedule saving the area registry."""
self._store.async_delay_save(self._data_to_save, SAVE_DELAY) | [
"def",
"async_schedule_save",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_store",
".",
"async_delay_save",
"(",
"self",
".",
"_data_to_save",
",",
"SAVE_DELAY",
")"
] | [
130,
4
] | [
132,
68
] | python | en | ['en', 'nl', 'en'] | True |
AreaRegistry._data_to_save | (self) | Return data of area registry to store in a file. | Return data of area registry to store in a file. | def _data_to_save(self) -> Dict[str, List[Dict[str, Optional[str]]]]:
"""Return data of area registry to store in a file."""
data = {}
data["areas"] = [
{"name": entry.name, "id": entry.id} for entry in self.areas.values()
]
return data | [
"def",
"_data_to_save",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Dict",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
"]",
"]",
"]",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"\"areas\"",
"]",
"=",
"[",
"{",
"\"name\"",
":"... | [
135,
4
] | [
143,
19
] | python | en | ['en', 'en', 'en'] | True |
problem2_5 | () | Simulates rolling a die 10 times. | Simulates rolling a die 10 times. | def problem2_5():
""" Simulates rolling a die 10 times."""
# Setting the seed makes the random numbers always the same
# This is to make the auto-grader's job easier.
random.seed(171) # don't remove when you submit for grading
for i in range(10):
print(random.randint(1, 6)) | [
"def",
"problem2_5",
"(",
")",
":",
"# Setting the seed makes the random numbers always the same",
"# This is to make the auto-grader's job easier.",
"random",
".",
"seed",
"(",
"171",
")",
"# don't remove when you submit for grading",
"for",
"i",
"in",
"range",
"(",
"10",
")... | [
33,
0
] | [
39,
35
] | python | en | ['af', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
) | Set up Notion sensors based on a config entry. | Set up Notion sensors based on a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
):
"""Set up Notion sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]
sensor_list = []
for task_id, task in coordinator.data["tasks"].items():
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR",
"]",
"[",
"e... | [
44,
0
] | [
70,
35
] | python | en | ['en', 'da', 'en'] | True |
NotionBinarySensor._async_update_from_latest_data | (self) | Fetch new state data for the sensor. | Fetch new state data for the sensor. | def _async_update_from_latest_data(self) -> None:
"""Fetch new state data for the sensor."""
task = self.coordinator.data["tasks"][self._task_id]
if "value" in task["status"]:
self._state = task["status"]["value"]
elif task["task_type"] == SENSOR_BATTERY:
self._s... | [
"def",
"_async_update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"task",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"tasks\"",
"]",
"[",
"self",
".",
"_task_id",
"]",
"if",
"\"value\"",
"in",
"task",
"[",
"\"status\"",
"]",
":",
"s... | [
77,
4
] | [
84,
60
] | python | en | ['en', 'en', 'en'] | True |
NotionBinarySensor.is_on | (self) | Return whether the sensor is on or off. | Return whether the sensor is on or off. | def is_on(self) -> bool:
"""Return whether the sensor is on or off."""
task = self.coordinator.data["tasks"][self._task_id]
if task["task_type"] == SENSOR_BATTERY:
return self._state == "critical"
if task["task_type"] in (
SENSOR_DOOR,
SENSOR_GARAGE_D... | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"task",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"tasks\"",
"]",
"[",
"self",
".",
"_task_id",
"]",
"if",
"task",
"[",
"\"task_type\"",
"]",
"==",
"SENSOR_BATTERY",
":",
"return",
"self",... | [
87,
4
] | [
107,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Denon platform. | Set up the Denon platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Denon platform."""
denon = DenonDevice(config[CONF_NAME], config[CONF_HOST])
if denon.update():
add_entities([denon]) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"denon",
"=",
"DenonDevice",
"(",
"config",
"[",
"CONF_NAME",
"]",
",",
"config",
"[",
"CONF_HOST",
"]",
")",
"if",
"denon",
".",
"upd... | [
80,
0
] | [
85,
29
] | python | en | ['en', 'da', 'en'] | True |
DenonDevice.__init__ | (self, name, host) | Initialize the Denon device. | Initialize the Denon device. | def __init__(self, name, host):
"""Initialize the Denon device."""
self._name = name
self._host = host
self._pwstate = "PWSTANDBY"
self._volume = 0
# Initial value 60dB, changed if we get a MVMAX
self._volume_max = 60
self._source_list = NORMAL_INPUTS.copy... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"host",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_pwstate",
"=",
"\"PWSTANDBY\"",
"self",
".",
"_volume",
"=",
"0",
"# Initial value 60dB, changed if we ... | [
91,
4
] | [
105,
41
] | python | en | ['en', 'it', 'en'] | True |
DenonDevice.telnet_request | (cls, telnet, command, all_lines=False) | Execute `command` and return the response. | Execute `command` and return the response. | def telnet_request(cls, telnet, command, all_lines=False):
"""Execute `command` and return the response."""
_LOGGER.debug("Sending: %s", command)
telnet.write(command.encode("ASCII") + b"\r")
lines = []
while True:
line = telnet.read_until(b"\r", timeout=0.2)
... | [
"def",
"telnet_request",
"(",
"cls",
",",
"telnet",
",",
"command",
",",
"all_lines",
"=",
"False",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Sending: %s\"",
",",
"command",
")",
"telnet",
".",
"write",
"(",
"command",
".",
"encode",
"(",
"\"ASCII\"",
"... | [
137,
4
] | [
151,
40
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.telnet_command | (self, command) | Establish a telnet connection and sends `command`. | Establish a telnet connection and sends `command`. | def telnet_command(self, command):
"""Establish a telnet connection and sends `command`."""
telnet = telnetlib.Telnet(self._host)
_LOGGER.debug("Sending: %s", command)
telnet.write(command.encode("ASCII") + b"\r")
telnet.read_very_eager() # skip response
telnet.close() | [
"def",
"telnet_command",
"(",
"self",
",",
"command",
")",
":",
"telnet",
"=",
"telnetlib",
".",
"Telnet",
"(",
"self",
".",
"_host",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Sending: %s\"",
",",
"command",
")",
"telnet",
".",
"write",
"(",
"command",
".",
... | [
153,
4
] | [
159,
22
] | python | en | ['en', 'fr', 'en'] | True |
DenonDevice.update | (self) | Get the latest details from the device. | Get the latest details from the device. | def update(self):
"""Get the latest details from the device."""
try:
telnet = telnetlib.Telnet(self._host)
except OSError:
return False
if self._should_setup_sources:
self._setup_sources(telnet)
self._should_setup_sources = False
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"telnet",
"=",
"telnetlib",
".",
"Telnet",
"(",
"self",
".",
"_host",
")",
"except",
"OSError",
":",
"return",
"False",
"if",
"self",
".",
"_should_setup_sources",
":",
"self",
".",
"_setup_sources",
"(... | [
161,
4
] | [
202,
19
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.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._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
205,
4
] | [
207,
25
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
if self._pwstate == "PWSTANDBY":
return STATE_OFF
if self._pwstate == "PWON":
return STATE_ON
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pwstate",
"==",
"\"PWSTANDBY\"",
":",
"return",
"STATE_OFF",
"if",
"self",
".",
"_pwstate",
"==",
"\"PWON\"",
":",
"return",
"STATE_ON",
"return",
"None"
] | [
210,
4
] | [
217,
19
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
return self._volume / self._volume_max | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume",
"/",
"self",
".",
"_volume_max"
] | [
220,
4
] | [
222,
46
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.is_volume_muted | (self) | Return boolean if volume is currently muted. | Return boolean if volume is currently muted. | def is_volume_muted(self):
"""Return boolean if volume is currently muted."""
return self._muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_muted"
] | [
225,
4
] | [
227,
26
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.source_list | (self) | Return the list of available input sources. | Return the list of available input sources. | def source_list(self):
"""Return the list of available input sources."""
return sorted(list(self._source_list)) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"list",
"(",
"self",
".",
"_source_list",
")",
")"
] | [
230,
4
] | [
232,
46
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.media_title | (self) | Return the current media info. | Return the current media info. | def media_title(self):
"""Return the current media info."""
return self._mediainfo | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_mediainfo"
] | [
235,
4
] | [
237,
30
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
if self._mediasource in MEDIA_MODES.values():
return SUPPORT_DENON | SUPPORT_MEDIA_MODES
return SUPPORT_DENON | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mediasource",
"in",
"MEDIA_MODES",
".",
"values",
"(",
")",
":",
"return",
"SUPPORT_DENON",
"|",
"SUPPORT_MEDIA_MODES",
"return",
"SUPPORT_DENON"
] | [
240,
4
] | [
244,
28
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.source | (self) | Return the current input source. | Return the current input source. | def source(self):
"""Return the current input source."""
for pretty_name, name in self._source_list.items():
if self._mediasource == name:
return pretty_name | [
"def",
"source",
"(",
"self",
")",
":",
"for",
"pretty_name",
",",
"name",
"in",
"self",
".",
"_source_list",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_mediasource",
"==",
"name",
":",
"return",
"pretty_name"
] | [
247,
4
] | [
251,
34
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self.telnet_command("PWSTANDBY") | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"PWSTANDBY\"",
")"
] | [
253,
4
] | [
255,
40
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.volume_up | (self) | Volume up media player. | Volume up media player. | def volume_up(self):
"""Volume up media player."""
self.telnet_command("MVUP") | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"MVUP\"",
")"
] | [
257,
4
] | [
259,
35
] | python | en | ['en', 'no', 'en'] | True |
DenonDevice.volume_down | (self) | Volume down media player. | Volume down media player. | def volume_down(self):
"""Volume down media player."""
self.telnet_command("MVDOWN") | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"MVDOWN\"",
")"
] | [
261,
4
] | [
263,
37
] | python | en | ['en', 'sl', 'en'] | True |
DenonDevice.set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
self.telnet_command(f"MV{round(volume * self._volume_max):02}") | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"self",
".",
"telnet_command",
"(",
"f\"MV{round(volume * self._volume_max):02}\"",
")"
] | [
265,
4
] | [
267,
71
] | python | en | ['fr', 'zu', 'en'] | False |
DenonDevice.mute_volume | (self, mute) | Mute (true) or unmute (false) media player. | Mute (true) or unmute (false) media player. | def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
mute_status = "ON" if mute else "OFF"
self.telnet_command(f"MU{mute_status})") | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"mute_status",
"=",
"\"ON\"",
"if",
"mute",
"else",
"\"OFF\"",
"self",
".",
"telnet_command",
"(",
"f\"MU{mute_status})\"",
")"
] | [
269,
4
] | [
272,
48
] | python | en | ['en', 'la', 'it'] | False |
DenonDevice.media_play | (self) | Play media player. | Play media player. | def media_play(self):
"""Play media player."""
self.telnet_command("NS9A") | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"NS9A\"",
")"
] | [
274,
4
] | [
276,
35
] | python | en | ['fr', 'en', 'en'] | True |
DenonDevice.media_pause | (self) | Pause media player. | Pause media player. | def media_pause(self):
"""Pause media player."""
self.telnet_command("NS9B") | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"NS9B\"",
")"
] | [
278,
4
] | [
280,
35
] | python | en | ['fr', 'en', 'en'] | True |
DenonDevice.media_stop | (self) | Pause media player. | Pause media player. | def media_stop(self):
"""Pause media player."""
self.telnet_command("NS9C") | [
"def",
"media_stop",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"NS9C\"",
")"
] | [
282,
4
] | [
284,
35
] | python | en | ['fr', 'en', 'en'] | True |
DenonDevice.media_next_track | (self) | Send the next track command. | Send the next track command. | def media_next_track(self):
"""Send the next track command."""
self.telnet_command("NS9D") | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"NS9D\"",
")"
] | [
286,
4
] | [
288,
35
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.media_previous_track | (self) | Send the previous track command. | Send the previous track command. | def media_previous_track(self):
"""Send the previous track command."""
self.telnet_command("NS9E") | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"NS9E\"",
")"
] | [
290,
4
] | [
292,
35
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.turn_on | (self) | Turn the media player on. | Turn the media player on. | def turn_on(self):
"""Turn the media player on."""
self.telnet_command("PWON") | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"telnet_command",
"(",
"\"PWON\"",
")"
] | [
294,
4
] | [
296,
35
] | python | en | ['en', 'en', 'en'] | True |
DenonDevice.select_source | (self, source) | Select input source. | Select input source. | def select_source(self, source):
"""Select input source."""
self.telnet_command(f"SI{self._source_list.get(source)}") | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"telnet_command",
"(",
"f\"SI{self._source_list.get(source)}\"",
")"
] | [
298,
4
] | [
300,
65
] | python | en | ['fr', 'su', 'en'] | False |
test_config_entry_not_ready | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test the Roku configuration entry not ready. | Test the Roku configuration entry not ready. | async def test_config_entry_not_ready(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the Roku configuration entry not ready."""
entry = await setup_integration(hass, aioclient_mock, error=True)
assert entry.state == ENTRY_STATE_SETUP_RETRY | [
"async",
"def",
"test_config_entry_not_ready",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"entry",
"=",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"error",
"=",
"Tru... | [
14,
0
] | [
20,
49
] | python | en | ['en', 'en', 'en'] | True |
test_unload_config_entry | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test the Roku configuration entry unloading. | Test the Roku configuration entry unloading. | async def test_unload_config_entry(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the Roku configuration entry unloading."""
with patch(
"homeassistant.components.roku.media_player.async_setup_entry",
return_value=True,
), patch(
"homeassistant.c... | [
"async",
"def",
"test_unload_config_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.roku.media_player.async_setup_entry\"",
",",
"return_value",
"=",
... | [
23,
0
] | [
43,
48
] | python | en | ['en', 'en', 'en'] | True |
DataProvider.name | () | Return name of the dataset | Return name of the dataset | def name():
""" Return name of the dataset """
raise NotImplementedError | [
"def",
"name",
"(",
")",
":",
"raise",
"NotImplementedError"
] | [
16,
4
] | [
18,
33
] | python | en | ['en', 'no', 'en'] | True |
DataProvider.data_shape | (self) | Return shape as python list of one data entry | Return shape as python list of one data entry | def data_shape(self):
""" Return shape as python list of one data entry """
raise NotImplementedError | [
"def",
"data_shape",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
21,
4
] | [
23,
33
] | python | en | ['en', 'en', 'en'] | True |
DataProvider.n_classes | (self) | Return `int` of num classes | Return `int` of num classes | def n_classes(self):
""" Return `int` of num classes """
raise NotImplementedError | [
"def",
"n_classes",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
26,
4
] | [
28,
33
] | python | en | ['en', 'la', 'en'] | True |
DataProvider.save_path | (self) | local path to save the data | local path to save the data | def save_path(self):
""" local path to save the data """
raise NotImplementedError | [
"def",
"save_path",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
31,
4
] | [
33,
33
] | python | en | ['en', 'en', 'en'] | True |
DataProvider.data_url | (self) | link to download the data | link to download the data | def data_url(self):
""" link to download the data """
raise NotImplementedError | [
"def",
"data_url",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
36,
4
] | [
38,
33
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the LlamaLab Automate notification service. | Get the LlamaLab Automate notification service. | def get_service(hass, config, discovery_info=None):
"""Get the LlamaLab Automate notification service."""
secret = config.get(CONF_API_KEY)
recipient = config.get(CONF_TO)
device = config.get(CONF_DEVICE)
return AutomateNotificationService(secret, recipient, device) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"secret",
"=",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"recipient",
"=",
"config",
".",
"get",
"(",
"CONF_TO",
")",
"device",
"=",
"config",
".",
"g... | [
30,
0
] | [
36,
65
] | python | en | ['en', 'en', 'en'] | True |
AutomateNotificationService.__init__ | (self, secret, recipient, device=None) | Initialize the service. | Initialize the service. | def __init__(self, secret, recipient, device=None):
"""Initialize the service."""
self._secret = secret
self._recipient = recipient
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"secret",
",",
"recipient",
",",
"device",
"=",
"None",
")",
":",
"self",
".",
"_secret",
"=",
"secret",
"self",
".",
"_recipient",
"=",
"recipient",
"self",
".",
"_device",
"=",
"device"
] | [
42,
4
] | [
46,
29
] | python | en | ['en', 'en', 'en'] | True |
AutomateNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
# Extract params from data dict
data = dict(kwargs.get(ATTR_DATA) or {})
priority = data.get(ATTR_PRIORITY, "normal").lower()
_LOGGER.debug(
"Sending to: %s, %s, prio: %s", self._recipient... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract params from data dict",
"data",
"=",
"dict",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"or",
"{",
"}",
")",
"priority",
"=",
"data",
... | [
48,
4
] | [
69,
64
] | python | en | ['en', 'en', 'en'] | True |
validate_mqtt_vacuum | (value) | Validate MQTT vacuum schema. | Validate MQTT vacuum schema. | def validate_mqtt_vacuum(value):
"""Validate MQTT vacuum schema."""
schemas = {LEGACY: PLATFORM_SCHEMA_LEGACY, STATE: PLATFORM_SCHEMA_STATE}
return schemas[value[CONF_SCHEMA]](value) | [
"def",
"validate_mqtt_vacuum",
"(",
"value",
")",
":",
"schemas",
"=",
"{",
"LEGACY",
":",
"PLATFORM_SCHEMA_LEGACY",
",",
"STATE",
":",
"PLATFORM_SCHEMA_STATE",
"}",
"return",
"schemas",
"[",
"value",
"[",
"CONF_SCHEMA",
"]",
"]",
"(",
"value",
")"
] | [
22,
0
] | [
25,
45
] | python | de | ['de', 'la', 'it'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up MQTT vacuum through configuration.yaml. | Set up MQTT vacuum through configuration.yaml. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up MQTT vacuum through configuration.yaml."""
await async_setup_reload_service(hass, MQTT_DOMAIN, PLATFORMS)
await _async_setup_entity(config, async_add_entities, discovery_info) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"MQTT_DOMAIN",
",",
"PLATFORMS",
")",
"await",
"_async_setup_entity"... | [
33,
0
] | [
36,
73
] | python | en | ['en', 'la', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT vacuum dynamically through MQTT discovery. | Set up MQTT vacuum dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT vacuum dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add a MQTT vacuum."""
discovery_data = discovery_payload.discovery_data
try:
config ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add a MQTT vacuum.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
"."... | [
39,
0
] | [
56,
5
] | python | en | ['en', 'vi', 'en'] | True |
_async_setup_entity | (
config, async_add_entities, config_entry, discovery_data=None
) | Set up the MQTT vacuum. | Set up the MQTT vacuum. | async def _async_setup_entity(
config, async_add_entities, config_entry, discovery_data=None
):
"""Set up the MQTT vacuum."""
setup_entity = {LEGACY: async_setup_entity_legacy, STATE: async_setup_entity_state}
await setup_entity[config[CONF_SCHEMA]](
config, async_add_entities, config_entry, dis... | [
"async",
"def",
"_async_setup_entity",
"(",
"config",
",",
"async_add_entities",
",",
"config_entry",
",",
"discovery_data",
"=",
"None",
")",
":",
"setup_entity",
"=",
"{",
"LEGACY",
":",
"async_setup_entity_legacy",
",",
"STATE",
":",
"async_setup_entity_state",
"... | [
59,
0
] | [
66,
5
] | python | en | ['en', 'ca', 'en'] | True |
test_mapping_integrity | () | Test ensures the map dicts have proper integrity. | Test ensures the map dicts have proper integrity. | async def test_mapping_integrity():
"""Test ensures the map dicts have proper integrity."""
for capability, maps in sensor.CAPABILITY_TO_SENSORS.items():
assert capability in CAPABILITIES, capability
for sensor_map in maps:
assert sensor_map.attribute in ATTRIBUTES, sensor_map.attrib... | [
"async",
"def",
"test_mapping_integrity",
"(",
")",
":",
"for",
"capability",
",",
"maps",
"in",
"sensor",
".",
"CAPABILITY_TO_SENSORS",
".",
"items",
"(",
")",
":",
"assert",
"capability",
"in",
"CAPABILITIES",
",",
"capability",
"for",
"sensor_map",
"in",
"m... | [
22,
0
] | [
31,
42
] | 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.