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_form_select_hub_v2 | (hass: HomeAssistantType) | Test we set up the Hub v2 correctly. | Test we set up the Hub v2 correctly. | async def test_form_select_hub_v2(hass: HomeAssistantType):
"""Test we set up the Hub v2 correctly."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"]... | [
"async",
"def",
"test_form_select_hub_v2",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
",... | [
155,
0
] | [
170,
48
] | python | en | ['en', 'zu', 'en'] | True |
test_failed_connection_plm | (hass: HomeAssistantType) | Test a failed connection with the PLM. | Test a failed connection with the PLM. | async def test_failed_connection_plm(hass: HomeAssistantType):
"""Test a failed connection with the PLM."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, PLM)
result2, _, _ = await _device_form(
hass, result["flow_id"], mock_failed_connec... | [
"async",
"def",
"test_failed_connection_plm",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
... | [
173,
0
] | [
182,
58
] | python | en | ['en', 'en', 'en'] | True |
test_failed_connection_hub | (hass: HomeAssistantType) | Test a failed connection with a Hub. | Test a failed connection with a Hub. | async def test_failed_connection_hub(hass: HomeAssistantType):
"""Test a failed connection with a Hub."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _init_form(hass, HUB2)
result2, _, _ = await _device_form(
hass, result["flow_id"], mock_failed_connect... | [
"async",
"def",
"test_failed_connection_hub",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_init_form",
"(",
"hass",
... | [
185,
0
] | [
194,
58
] | python | en | ['en', 'ga', 'en'] | True |
_import_config | (hass, config) | Run the import step. | Run the import step. | async def _import_config(hass, config):
"""Run the import step."""
with patch(PATCH_CONNECTION, new=mock_successful_connection,), patch(
PATCH_ASYNC_SETUP, return_value=True
), patch(PATCH_ASYNC_SETUP_ENTRY, return_value=True):
return await hass.config_entries.flow.async_init(
DO... | [
"async",
"def",
"_import_config",
"(",
"hass",
",",
"config",
")",
":",
"with",
"patch",
"(",
"PATCH_CONNECTION",
",",
"new",
"=",
"mock_successful_connection",
",",
")",
",",
"patch",
"(",
"PATCH_ASYNC_SETUP",
",",
"return_value",
"=",
"True",
")",
",",
"pa... | [
197,
0
] | [
204,
9
] | python | en | ['en', 'en', 'en'] | True |
test_import_plm | (hass: HomeAssistantType) | Test importing a minimum PLM config from yaml. | Test importing a minimum PLM config from yaml. | async def test_import_plm(hass: HomeAssistantType):
"""Test importing a minimum PLM config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(hass, MOCK_IMPORT_CONFIG_PLM)
assert result["type"] == "create_entry"
assert hass.config_ent... | [
"async",
"def",
"test_import_plm",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_import_config",
"(",
"hass",
",",
... | [
207,
0
] | [
216,
51
] | python | en | ['en', 'en', 'en'] | True |
_options_init_form | (hass, entry_id, step) | Run the init options form. | Run the init options form. | async def _options_init_form(hass, entry_id, step):
"""Run the init options form."""
with patch(PATCH_ASYNC_SETUP_ENTRY, return_value=True):
result = await hass.config_entries.options.async_init(entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "ini... | [
"async",
"def",
"_options_init_form",
"(",
"hass",
",",
"entry_id",
",",
"step",
")",
":",
"with",
"patch",
"(",
"PATCH_ASYNC_SETUP_ENTRY",
",",
"return_value",
"=",
"True",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"options",
"."... | [
219,
0
] | [
231,
18
] | python | en | ['en', 'en', 'en'] | True |
test_import_min_hub_v2 | (hass: HomeAssistantType) | Test importing a minimum Hub v2 config from yaml. | Test importing a minimum Hub v2 config from yaml. | async def test_import_min_hub_v2(hass: HomeAssistantType):
"""Test importing a minimum Hub v2 config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(
hass, {**MOCK_IMPORT_MINIMUM_HUB_V2, CONF_PORT: 25105, CONF_HUB_VERSION: 2}
)
... | [
"async",
"def",
"test_import_min_hub_v2",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_import_config",
"(",
"hass",
... | [
234,
0
] | [
249,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import_min_hub_v1 | (hass: HomeAssistantType) | Test importing a minimum Hub v1 config from yaml. | Test importing a minimum Hub v1 config from yaml. | async def test_import_min_hub_v1(hass: HomeAssistantType):
"""Test importing a minimum Hub v1 config from yaml."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await _import_config(
hass, {**MOCK_IMPORT_MINIMUM_HUB_V1, CONF_PORT: 9761, CONF_HUB_VERSION: 1}
)
... | [
"async",
"def",
"test_import_min_hub_v1",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"_import_config",
"(",
"hass",
... | [
252,
0
] | [
265,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import_existing | (hass: HomeAssistantType) | Test we fail on an existing config imported. | Test we fail on an existing config imported. | async def test_import_existing(hass: HomeAssistantType):
"""Test we fail on an existing config imported."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to_hass(h... | [
"async",
"def",
"test_import_existing",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V2",
",",... | [
268,
0
] | [
283,
56
] | python | en | ['en', 'en', 'en'] | True |
test_import_failed_connection | (hass: HomeAssistantType) | Test a failed connection on import. | Test a failed connection on import. | async def test_import_failed_connection(hass: HomeAssistantType):
"""Test a failed connection on import."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(PATCH_CONNECTION, new=mock_failed_connection,), patch(
PATCH_ASYNC_SETUP, return_value=True
), patch(PATC... | [
"async",
"def",
"test_import_failed_connection",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"PATCH_CONNECTION",
",",
"n... | [
286,
0
] | [
300,
47
] | python | en | ['en', 'en', 'en'] | True |
_options_form | (hass, flow_id, user_input) | Test an options form. | Test an options form. | async def _options_form(hass, flow_id, user_input):
"""Test an options form."""
with patch(PATCH_ASYNC_SETUP_ENTRY, return_value=True) as mock_setup_entry:
result = await hass.config_entries.options.async_configure(flow_id, user_input)
return result, mock_setup_entry | [
"async",
"def",
"_options_form",
"(",
"hass",
",",
"flow_id",
",",
"user_input",
")",
":",
"with",
"patch",
"(",
"PATCH_ASYNC_SETUP_ENTRY",
",",
"return_value",
"=",
"True",
")",
"as",
"mock_setup_entry",
":",
"result",
"=",
"await",
"hass",
".",
"config_entri... | [
303,
0
] | [
308,
39
] | python | en | ['en', 'en', 'en'] | True |
test_options_change_hub_config | (hass: HomeAssistantType) | Test changing Hub v2 config. | Test changing Hub v2 config. | async def test_options_change_hub_config(hass: HomeAssistantType):
"""Test changing Hub v2 config."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_options_change_hub_config",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V... | [
311,
0
] | [
335,
67
] | python | en | ['en', 'da', 'en'] | True |
test_options_add_device_override | (hass: HomeAssistantType) | Test adding a device override. | Test adding a device override. | async def test_options_add_device_override(hass: HomeAssistantType):
"""Test adding a device override."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to_hass(ha... | [
"async",
"def",
"test_options_add_device_override",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB... | [
338,
0
] | [
375,
69
] | python | en | ['es', 'en', 'en'] | True |
test_options_remove_device_override | (hass: HomeAssistantType) | Test removing a device override. | Test removing a device override. | async def test_options_remove_device_override(hass: HomeAssistantType):
"""Test removing a device override."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={
CONF_OVERRIDE: [
... | [
"async",
"def",
"test_options_remove_device_override",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_... | [
378,
0
] | [
399,
56
] | python | en | ['en', 'en', 'en'] | True |
test_options_remove_device_override_with_x10 | (hass: HomeAssistantType) | Test removing a device override when an X10 device is configured. | Test removing a device override when an X10 device is configured. | async def test_options_remove_device_override_with_x10(hass: HomeAssistantType):
"""Test removing a device override when an X10 device is configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
opt... | [
"async",
"def",
"test_options_remove_device_override_with_x10",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_US... | [
402,
0
] | [
432,
51
] | python | en | ['en', 'en', 'en'] | True |
test_options_add_x10_device | (hass: HomeAssistantType) | Test adding an X10 device. | Test adding an X10 device. | async def test_options_add_x10_device(hass: HomeAssistantType):
"""Test adding an X10 device."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to_hass(hass)
r... | [
"async",
"def",
"test_options_add_x10_device",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V2",... | [
435,
0
] | [
476,
66
] | python | en | ['en', 'lb', 'en'] | True |
test_options_remove_x10_device | (hass: HomeAssistantType) | Test removing an X10 device. | Test removing an X10 device. | async def test_options_remove_x10_device(hass: HomeAssistantType):
"""Test removing an X10 device."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={
CONF_X10: [
{
... | [
"async",
"def",
"test_options_remove_x10_device",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V... | [
479,
0
] | [
515,
51
] | python | en | ['en', 'en', 'en'] | True |
test_options_remove_x10_device_with_override | (hass: HomeAssistantType) | Test removing an X10 device when a device override is configured. | Test removing an X10 device when a device override is configured. | async def test_options_remove_x10_device_with_override(hass: HomeAssistantType):
"""Test removing an X10 device when a device override is configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
opt... | [
"async",
"def",
"test_options_remove_x10_device_with_override",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_US... | [
518,
0
] | [
556,
56
] | python | en | ['en', 'en', 'en'] | True |
test_options_dup_selection | (hass: HomeAssistantType) | Test if a duplicate selection was made in options. | Test if a duplicate selection was made in options. | async def test_options_dup_selection(hass: HomeAssistantType):
"""Test if a duplicate selection was made in options."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.a... | [
"async",
"def",
"test_options_dup_selection",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V2",
... | [
559,
0
] | [
578,
57
] | python | en | ['en', 'en', 'en'] | True |
test_options_override_bad_data | (hass: HomeAssistantType) | Test for bad data in a device override. | Test for bad data in a device override. | async def test_options_override_bad_data(hass: HomeAssistantType):
"""Test for bad data in a device override."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="abcde12345",
data={**MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2},
options={},
)
config_entry.add_to... | [
"async",
"def",
"test_options_override_bad_data",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"entry_id",
"=",
"\"abcde12345\"",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_USER_INPUT_HUB_V... | [
581,
0
] | [
602,
54
] | 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",
",... | [
22,
0
] | [
55,
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 Remote states. | Reproduce Remote states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Remote states."""
await asyncio.gather(
*(
_async_reproduce_state(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
58,
0
] | [
73,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_mock_component | (hass, entry=None) | Set up Mock Media Player. | Set up Mock Media Player. | async def setup_mock_component(hass, entry=None):
"""Set up Mock Media Player."""
if entry is None:
mock_entry = MockConfigEntry(
domain=ps4.DOMAIN, data=MOCK_DATA, version=VERSION, entry_id=MOCK_ENTRY_ID
)
else:
mock_entry = entry
mock_entry.add_to_hass(hass)
a... | [
"async",
"def",
"setup_mock_component",
"(",
"hass",
",",
"entry",
"=",
"None",
")",
":",
"if",
"entry",
"is",
"None",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"ps4",
".",
"DOMAIN",
",",
"data",
"=",
"MOCK_DATA",
",",
"version",
"="... | [
126,
0
] | [
145,
25
] | python | en | ['en', 'da', 'en'] | True |
mock_ddp_response | (hass, mock_status_data) | Mock raw UDP response from device. | Mock raw UDP response from device. | async def mock_ddp_response(hass, mock_status_data):
"""Mock raw UDP response from device."""
mock_protocol = hass.data[PS4_DATA].protocol
mock_code = mock_status_data.get("status_code")
mock_status = mock_status_data.get("status")
mock_status_header = f"{mock_code} {mock_status}"
mock_response... | [
"async",
"def",
"mock_ddp_response",
"(",
"hass",
",",
"mock_status_data",
")",
":",
"mock_protocol",
"=",
"hass",
".",
"data",
"[",
"PS4_DATA",
"]",
".",
"protocol",
"mock_code",
"=",
"mock_status_data",
".",
"get",
"(",
"\"status_code\"",
")",
"mock_status",
... | [
148,
0
] | [
158,
38
] | python | en | ['en', 'en', 'en'] | True |
test_media_player_is_setup_correctly_with_entry | (hass) | Test entity is setup correctly with entry correctly. | Test entity is setup correctly with entry correctly. | async def test_media_player_is_setup_correctly_with_entry(hass):
"""Test entity is setup correctly with entry correctly."""
mock_entity_id = await setup_mock_component(hass)
mock_state = hass.states.get(mock_entity_id).state
# Assert status updated callback is added to protocol.
assert len(hass.dat... | [
"async",
"def",
"test_media_player_is_setup_correctly_with_entry",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"mock_entity_id",
")",
".",
"state",
"# A... | [
161,
0
] | [
172,
38
] | python | en | ['en', 'zu', 'en'] | True |
test_state_standby_is_set | (hass) | Test that state is set to standby. | Test that state is set to standby. | async def test_state_standby_is_set(hass):
"""Test that state is set to standby."""
mock_entity_id = await setup_mock_component(hass)
await mock_ddp_response(hass, MOCK_STATUS_STANDBY)
assert hass.states.get(mock_entity_id).state == STATE_STANDBY | [
"async",
"def",
"test_state_standby_is_set",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"await",
"mock_ddp_response",
"(",
"hass",
",",
"MOCK_STATUS_STANDBY",
")",
"assert",
"hass",
".",
"states",
".",
"get",
... | [
175,
0
] | [
181,
65
] | python | en | ['en', 'en', 'en'] | True |
test_state_playing_is_set | (hass) | Test that state is set to playing. | Test that state is set to playing. | async def test_state_playing_is_set(hass):
"""Test that state is set to playing."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.",
"pyps4.Ps4Async.async_get_ps_store_data",
)
with patch(mock_func, return_val... | [
"async",
"def",
"test_state_playing_is_set",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.async_g... | [
184,
0
] | [
195,
65
] | python | en | ['en', 'en', 'en'] | True |
test_state_idle_is_set | (hass) | Test that state is set to idle. | Test that state is set to idle. | async def test_state_idle_is_set(hass):
"""Test that state is set to idle."""
mock_entity_id = await setup_mock_component(hass)
await mock_ddp_response(hass, MOCK_STATUS_IDLE)
assert hass.states.get(mock_entity_id).state == STATE_IDLE | [
"async",
"def",
"test_state_idle_is_set",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"await",
"mock_ddp_response",
"(",
"hass",
",",
"MOCK_STATUS_IDLE",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
... | [
198,
0
] | [
204,
62
] | python | en | ['en', 'en', 'en'] | True |
test_state_none_is_set | (hass) | Test that state is set to None. | Test that state is set to None. | async def test_state_none_is_set(hass):
"""Test that state is set to None."""
mock_entity_id = await setup_mock_component(hass)
assert hass.states.get(mock_entity_id).state == STATE_UNKNOWN | [
"async",
"def",
"test_state_none_is_set",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"mock_entity_id",
")",
".",
"state",
"==",
"STATE_UNKNOWN"
] | [
207,
0
] | [
211,
65
] | python | en | ['en', 'en', 'en'] | True |
test_media_attributes_are_fetched | (hass) | Test that media attributes are fetched. | Test that media attributes are fetched. | async def test_media_attributes_are_fetched(hass):
"""Test that media attributes are fetched."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.",
"pyps4.Ps4Async.async_get_ps_store_data",
)
# Mock result from ... | [
"async",
"def",
"test_media_attributes_are_fetched",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async... | [
214,
0
] | [
241,
69
] | python | en | ['en', 'en', 'en'] | True |
test_media_attributes_are_loaded | (hass, patch_load_json) | Test that media attributes are loaded. | Test that media attributes are loaded. | async def test_media_attributes_are_loaded(hass, patch_load_json):
"""Test that media attributes are loaded."""
mock_entity_id = await setup_mock_component(hass)
patch_load_json.return_value = {MOCK_TITLE_ID: MOCK_GAMES_DATA_LOCKED}
with patch(
"homeassistant.components.ps4.media_player."
... | [
"async",
"def",
"test_media_attributes_are_loaded",
"(",
"hass",
",",
"patch_load_json",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"patch_load_json",
".",
"return_value",
"=",
"{",
"MOCK_TITLE_ID",
":",
"MOCK_GAMES_DATA_LOCKED",... | [
244,
0
] | [
268,
69
] | python | en | ['en', 'en', 'en'] | True |
test_device_info_is_set_from_status_correctly | (hass) | Test that device info is set correctly from status update. | Test that device info is set correctly from status update. | async def test_device_info_is_set_from_status_correctly(hass):
"""Test that device info is set correctly from status update."""
mock_d_registry = mock_device_registry(hass)
with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_STANDBY):
mock_entity_id = await setup_mock_component(has... | [
"async",
"def",
"test_device_info_is_set_from_status_correctly",
"(",
"hass",
")",
":",
"mock_d_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"pyps4_2ndscreen.ps4.get_status\"",
",",
"return_value",
"=",
"MOCK_STATUS_STANDBY",
")",
":",... | [
271,
0
] | [
296,
61
] | python | en | ['en', 'en', 'en'] | True |
test_device_info_is_assummed | (hass) | Test that device info is assumed if device is unavailable. | Test that device info is assumed if device is unavailable. | async def test_device_info_is_assummed(hass):
"""Test that device info is assumed if device is unavailable."""
# Create a device registry entry with device info.
mock_d_registry = mock_device_registry(hass)
mock_d_registry.async_get_or_create(
config_entry_id=MOCK_ENTRY_ID,
name=MOCK_HOS... | [
"async",
"def",
"test_device_info_is_assummed",
"(",
"hass",
")",
":",
"# Create a device registry entry with device info.",
"mock_d_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"mock_d_registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"MOCK_ENT... | [
299,
0
] | [
332,
45
] | python | en | ['en', 'en', 'en'] | True |
test_device_info_assummed_works | (hass) | Reverse test that device info assumption works. | Reverse test that device info assumption works. | async def test_device_info_assummed_works(hass):
"""Reverse test that device info assumption works."""
mock_d_registry = mock_device_registry(hass)
mock_entity_id = await setup_mock_component(hass)
mock_state = hass.states.get(mock_entity_id).state
mock_d_entries = mock_d_registry.devices
# Ens... | [
"async",
"def",
"test_device_info_assummed_works",
"(",
"hass",
")",
":",
"mock_d_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_state",
"=",
"hass",
".",
"states",
".",
"ge... | [
335,
0
] | [
346,
29
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on | (hass) | Test that turn on service calls function. | Test that turn on service calls function. | async def test_turn_on(hass):
"""Test that turn on service calls function."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.wakeup"
)
with patch(mock_func) as mock_call:
await hass.services.... | [
"async",
"def",
"test_turn_on",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.wakeup\"",
")",
... | [
349,
0
] | [
362,
41
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off | (hass) | Test that turn off service calls function. | Test that turn off service calls function. | async def test_turn_off(hass):
"""Test that turn off service calls function."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.standby"
)
with patch(mock_func) as mock_call:
await hass.servic... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.standby\"",
")",
... | [
365,
0
] | [
378,
41
] | python | en | ['en', 'en', 'en'] | True |
test_toggle | (hass) | Test that toggle service calls function. | Test that toggle service calls function. | async def test_toggle(hass):
"""Test that toggle service calls function."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.toggle"
)
with patch(mock_func) as mock_call:
await hass.services.as... | [
"async",
"def",
"test_toggle",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.toggle\"",
")",
"... | [
381,
0
] | [
394,
41
] | python | en | ['en', 'en', 'en'] | True |
test_media_pause | (hass) | Test that media pause service calls function. | Test that media pause service calls function. | async def test_media_pause(hass):
"""Test that media pause service calls function."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.remote_control"
)
with patch(mock_func) as mock_call:
awai... | [
"async",
"def",
"test_media_pause",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.remote_control\"... | [
397,
0
] | [
410,
41
] | python | en | ['en', 'en', 'en'] | True |
test_media_stop | (hass) | Test that media stop service calls function. | Test that media stop service calls function. | async def test_media_stop(hass):
"""Test that media stop service calls function."""
mock_entity_id = await setup_mock_component(hass)
mock_func = "{}{}".format(
"homeassistant.components.ps4.media_player.", "pyps4.Ps4Async.remote_control"
)
with patch(mock_func) as mock_call:
await ... | [
"async",
"def",
"test_media_stop",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"mock_func",
"=",
"\"{}{}\"",
".",
"format",
"(",
"\"homeassistant.components.ps4.media_player.\"",
",",
"\"pyps4.Ps4Async.remote_control\""... | [
413,
0
] | [
426,
41
] | python | en | ['en', 'en', 'en'] | True |
test_select_source | (hass, patch_load_json) | Test that select source service calls function with title. | Test that select source service calls function with title. | async def test_select_source(hass, patch_load_json):
"""Test that select source service calls function with title."""
patch_load_json.return_value = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE):
mock_entity_id = await setup_mock_compone... | [
"async",
"def",
"test_select_source",
"(",
"hass",
",",
"patch_load_json",
")",
":",
"patch_load_json",
".",
"return_value",
"=",
"{",
"MOCK_TITLE_ID",
":",
"MOCK_GAMES_DATA",
"}",
"with",
"patch",
"(",
"\"pyps4_2ndscreen.ps4.get_status\"",
",",
"return_value",
"=",
... | [
429,
0
] | [
446,
41
] | python | en | ['en', 'en', 'en'] | True |
test_select_source_caps | (hass, patch_load_json) | Test that select source service calls function with upper case title. | Test that select source service calls function with upper case title. | async def test_select_source_caps(hass, patch_load_json):
"""Test that select source service calls function with upper case title."""
patch_load_json.return_value = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE):
mock_entity_id = await se... | [
"async",
"def",
"test_select_source_caps",
"(",
"hass",
",",
"patch_load_json",
")",
":",
"patch_load_json",
".",
"return_value",
"=",
"{",
"MOCK_TITLE_ID",
":",
"MOCK_GAMES_DATA",
"}",
"with",
"patch",
"(",
"\"pyps4_2ndscreen.ps4.get_status\"",
",",
"return_value",
"... | [
449,
0
] | [
469,
41
] | python | en | ['en', 'en', 'en'] | True |
test_select_source_id | (hass, patch_load_json) | Test that select source service calls function with Title ID. | Test that select source service calls function with Title ID. | async def test_select_source_id(hass, patch_load_json):
"""Test that select source service calls function with Title ID."""
patch_load_json.return_value = {MOCK_TITLE_ID: MOCK_GAMES_DATA}
with patch("pyps4_2ndscreen.ps4.get_status", return_value=MOCK_STATUS_IDLE):
mock_entity_id = await setup_mock_c... | [
"async",
"def",
"test_select_source_id",
"(",
"hass",
",",
"patch_load_json",
")",
":",
"patch_load_json",
".",
"return_value",
"=",
"{",
"MOCK_TITLE_ID",
":",
"MOCK_GAMES_DATA",
"}",
"with",
"patch",
"(",
"\"pyps4_2ndscreen.ps4.get_status\"",
",",
"return_value",
"="... | [
472,
0
] | [
489,
41
] | python | en | ['en', 'en', 'en'] | True |
test_ps4_send_command | (hass) | Test that ps4 send command service calls function. | Test that ps4 send command service calls function. | async def test_ps4_send_command(hass):
"""Test that ps4 send command service calls function."""
mock_entity_id = await setup_mock_component(hass)
with patch("pyps4_2ndscreen.ps4.Ps4Async.remote_control") as mock_call:
await hass.services.async_call(
DOMAIN,
"send_command",
... | [
"async",
"def",
"test_ps4_send_command",
"(",
"hass",
")",
":",
"mock_entity_id",
"=",
"await",
"setup_mock_component",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"pyps4_2ndscreen.ps4.Ps4Async.remote_control\"",
")",
"as",
"mock_call",
":",
"await",
"hass",
".",
"ser... | [
492,
0
] | [
504,
41
] | python | en | ['en', 'en', 'en'] | True |
test_entry_is_unloaded | (hass) | Test that entry is unloaded. | Test that entry is unloaded. | async def test_entry_is_unloaded(hass):
"""Test that entry is unloaded."""
mock_entry = MockConfigEntry(
domain=ps4.DOMAIN, data=MOCK_DATA, version=VERSION, entry_id=MOCK_ENTRY_ID
)
mock_entity_id = await setup_mock_component(hass, mock_entry)
mock_unload = await ps4.async_unload_entry(hass,... | [
"async",
"def",
"test_entry_is_unloaded",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"ps4",
".",
"DOMAIN",
",",
"data",
"=",
"MOCK_DATA",
",",
"version",
"=",
"VERSION",
",",
"entry_id",
"=",
"MOCK_ENTRY_ID",
")",
"mock_... | [
507,
0
] | [
521,
50
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Create the buienradar sensor. | Create the buienradar sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Create the buienradar sensor."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
timeframe = config[CONF_TIMEFRAME]
if None in (latitude... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"latitude",
"=",
"config",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
"config",
".",
"latitude",
")",
"longi... | [
210,
0
] | [
235,
33
] | python | en | ['en', 'ms', 'en'] | True |
BrSensor.__init__ | (self, sensor_type, client_name, coordinates) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sensor_type, client_name, coordinates):
"""Initialize the sensor."""
self.client_name = client_name
self._name = SENSOR_TYPES[sensor_type][0]
self.type = sensor_type
self._state = None
self._unit_of_measurement = SENSOR_TYPES[self.type][1]
self.... | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"client_name",
",",
"coordinates",
")",
":",
"self",
".",
"client_name",
"=",
"client_name",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
"]",
"self",
".",
"type",
... | [
241,
4
] | [
258,
34
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.uid | (self, coordinates) | Generate a unique id using coordinates and sensor type. | Generate a unique id using coordinates and sensor type. | def uid(self, coordinates):
"""Generate a unique id using coordinates and sensor type."""
# The combination of the location, name and sensor type is unique
return "{:2.6f}{:2.6f}{}".format(
coordinates[CONF_LATITUDE], coordinates[CONF_LONGITUDE], self.type
) | [
"def",
"uid",
"(",
"self",
",",
"coordinates",
")",
":",
"# The combination of the location, name and sensor type is unique",
"return",
"\"{:2.6f}{:2.6f}{}\"",
".",
"format",
"(",
"coordinates",
"[",
"CONF_LATITUDE",
"]",
",",
"coordinates",
"[",
"CONF_LONGITUDE",
"]",
... | [
260,
4
] | [
265,
9
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.data_updated | (self, data) | Update data. | Update data. | def data_updated(self, data):
"""Update data."""
if self._load_data(data) and self.hass:
self.async_write_ha_state() | [
"def",
"data_updated",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"_load_data",
"(",
"data",
")",
"and",
"self",
".",
"hass",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
268,
4
] | [
271,
39
] | python | co | ['fr', 'co', 'en'] | False |
BrSensor._load_data | (self, data) | Load the sensor with relevant data. | Load the sensor with relevant data. | def _load_data(self, data):
"""Load the sensor with relevant data."""
# Find sensor
# Check if we have a new measurement,
# otherwise we do not have to update the sensor
if self._measured == data.get(MEASURED):
return False
self._attribution = data.get(ATTRI... | [
"def",
"_load_data",
"(",
"self",
",",
"data",
")",
":",
"# Find sensor",
"# Check if we have a new measurement,",
"# otherwise we do not have to update the sensor",
"if",
"self",
".",
"_measured",
"==",
"data",
".",
"get",
"(",
"MEASURED",
")",
":",
"return",
"False"... | [
274,
4
] | [
399,
19
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self):
"""Return the attribution."""
return self._attribution | [
"def",
"attribution",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attribution"
] | [
402,
4
] | [
404,
32
] | python | en | ['en', 'ja', 'en'] | True |
BrSensor.unique_id | (self) | Return the unique id. | Return the unique id. | def unique_id(self):
"""Return the unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
407,
4
] | [
409,
30
] | python | en | ['en', 'la', 'en'] | True |
BrSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
412,
4
] | [
414,
49
] | python | en | ['en', 'mi', 'en'] | True |
BrSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
417,
4
] | [
419,
26
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
422,
4
] | [
424,
20
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.entity_picture | (self) | Weather symbol if type is symbol. | Weather symbol if type is symbol. | def entity_picture(self):
"""Weather symbol if type is symbol."""
return self._entity_picture | [
"def",
"entity_picture",
"(",
"self",
")",
":",
"return",
"self",
".",
"_entity_picture"
] | [
427,
4
] | [
429,
35
] | python | en | ['en', 'sr', 'en'] | True |
BrSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if self.type.startswith(PRECIPITATION_FORECAST):
result = {ATTR_ATTRIBUTION: self._attribution}
if self._timeframe is not None:
result[TIMEFRAME_LABEL] = "%d min" % (self._timeframe)
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
".",
"startswith",
"(",
"PRECIPITATION_FORECAST",
")",
":",
"result",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"self",
".",
"_attribution",
"}",
"if",
"self",
".",
"_timeframe",
"i... | [
432,
4
] | [
450,
21
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
453,
4
] | [
455,
40
] | python | en | ['en', 'en', 'en'] | True |
BrSensor.icon | (self) | Return possible sensor specific icon. | Return possible sensor specific icon. | def icon(self):
"""Return possible sensor specific icon."""
return SENSOR_TYPES[self.type][2] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"type",
"]",
"[",
"2",
"]"
] | [
458,
4
] | [
460,
41
] | python | en | ['en', 'it', 'en'] | True |
BrSensor.force_update | (self) | Return true for continuous sensors, false for discrete sensors. | Return true for continuous sensors, false for discrete sensors. | def force_update(self):
"""Return true for continuous sensors, false for discrete sensors."""
return self._force_update | [
"def",
"force_update",
"(",
"self",
")",
":",
"return",
"self",
".",
"_force_update"
] | [
463,
4
] | [
465,
33
] | python | en | ['en', 'ca', 'en'] | True |
async_setup | (hass, config) | Set up the emulated roku component. | Set up the emulated roku component. | async def async_setup(hass, config):
"""Set up the emulated roku component."""
conf = config.get(DOMAIN)
if conf is None:
return True
existing_servers = configured_servers(hass)
for entry in conf[CONF_SERVERS]:
if entry[CONF_NAME] not in existing_servers:
hass.async_cr... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"if",
"conf",
"is",
"None",
":",
"return",
"True",
"existing_servers",
"=",
"configured_servers",
"(",
"hass",
")",
"for",
"entry"... | [
44,
0
] | [
61,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up an emulated roku server from a config entry. | Set up an emulated roku server from a config entry. | async def async_setup_entry(hass, config_entry):
"""Set up an emulated roku server from a config entry."""
config = config_entry.data
if DOMAIN not in hass.data:
hass.data[DOMAIN] = {}
name = config[CONF_NAME]
listen_port = config[CONF_LISTEN_PORT]
host_ip = config.get(CONF_HOST_IP) or... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"config",
"=",
"config_entry",
".",
"data",
"if",
"DOMAIN",
"not",
"in",
"hass",
".",
"data",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"name",
"=",
"... | [
64,
0
] | [
90,
31
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
name = entry.data[CONF_NAME]
server = hass.data[DOMAIN].pop(name)
return await server.unload() | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"name",
"=",
"entry",
".",
"data",
"[",
"CONF_NAME",
"]",
"server",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"name",
")",
"return",
"await",
"server",
".... | [
93,
0
] | [
97,
32
] | python | en | ['en', 'es', 'en'] | True |
assert_setup_sensor | (hass, config, count=1) | Set up the sensor and assert it's been created. | Set up the sensor and assert it's been created. | async def assert_setup_sensor(hass, config, count=1):
"""Set up the sensor and assert it's been created."""
with assert_setup_component(count):
assert await async_setup_component(hass, sensor.DOMAIN, config)
await hass.async_block_till_done() | [
"async",
"def",
"assert_setup_sensor",
"(",
"hass",
",",
"config",
",",
"count",
"=",
"1",
")",
":",
"with",
"assert_setup_component",
"(",
"count",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"sensor",
".",
"DOMAIN",
",",
"config... | [
48,
0
] | [
52,
42
] | python | en | ['en', 'en', 'en'] | True |
mock_nextbus | () | Create a mock py_nextbus module. | Create a mock py_nextbus module. | def mock_nextbus():
"""Create a mock py_nextbus module."""
with patch(
"homeassistant.components.nextbus.sensor.NextBusClient"
) as NextBusClient:
yield NextBusClient | [
"def",
"mock_nextbus",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.nextbus.sensor.NextBusClient\"",
")",
"as",
"NextBusClient",
":",
"yield",
"NextBusClient"
] | [
56,
0
] | [
61,
27
] | python | en | ['en', 'ro', 'it'] | False |
mock_nextbus_predictions | (mock_nextbus) | Create a mock of NextBusClient predictions. | Create a mock of NextBusClient predictions. | def mock_nextbus_predictions(mock_nextbus):
"""Create a mock of NextBusClient predictions."""
instance = mock_nextbus.return_value
instance.get_predictions_for_multi_stops.return_value = BASIC_RESULTS
yield instance.get_predictions_for_multi_stops | [
"def",
"mock_nextbus_predictions",
"(",
"mock_nextbus",
")",
":",
"instance",
"=",
"mock_nextbus",
".",
"return_value",
"instance",
".",
"get_predictions_for_multi_stops",
".",
"return_value",
"=",
"BASIC_RESULTS",
"yield",
"instance",
".",
"get_predictions_for_multi_stops"... | [
65,
0
] | [
70,
50
] | python | en | ['en', 'en', 'en'] | True |
mock_nextbus_lists | (mock_nextbus) | Mock all list functions in nextbus to test validate logic. | Mock all list functions in nextbus to test validate logic. | def mock_nextbus_lists(mock_nextbus):
"""Mock all list functions in nextbus to test validate logic."""
instance = mock_nextbus.return_value
instance.get_agency_list.return_value = {
"agency": [{"tag": "sf-muni", "title": "San Francisco Muni"}]
}
instance.get_route_list.return_value = {
... | [
"def",
"mock_nextbus_lists",
"(",
"mock_nextbus",
")",
":",
"instance",
"=",
"mock_nextbus",
".",
"return_value",
"instance",
".",
"get_agency_list",
".",
"return_value",
"=",
"{",
"\"agency\"",
":",
"[",
"{",
"\"tag\"",
":",
"\"sf-muni\"",
",",
"\"title\"",
":"... | [
74,
0
] | [
85,
5
] | python | en | ['en', 'en', 'en'] | True |
test_valid_config | (hass, mock_nextbus, mock_nextbus_lists) | Test that sensor is set up properly with valid config. | Test that sensor is set up properly with valid config. | async def test_valid_config(hass, mock_nextbus, mock_nextbus_lists):
"""Test that sensor is set up properly with valid config."""
await assert_setup_sensor(hass, CONFIG_BASIC) | [
"async",
"def",
"test_valid_config",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
")",
":",
"await",
"assert_setup_sensor",
"(",
"hass",
",",
"CONFIG_BASIC",
")"
] | [
88,
0
] | [
90,
49
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_config | (hass, mock_nextbus, mock_nextbus_lists) | Checks that component is not setup when missing information. | Checks that component is not setup when missing information. | async def test_invalid_config(hass, mock_nextbus, mock_nextbus_lists):
"""Checks that component is not setup when missing information."""
await assert_setup_sensor(hass, CONFIG_INVALID_MISSING, count=0) | [
"async",
"def",
"test_invalid_config",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
")",
":",
"await",
"assert_setup_sensor",
"(",
"hass",
",",
"CONFIG_INVALID_MISSING",
",",
"count",
"=",
"0",
")"
] | [
93,
0
] | [
95,
68
] | python | en | ['en', 'en', 'en'] | True |
test_validate_tags | (hass, mock_nextbus, mock_nextbus_lists) | Test that additional validation against the API is successful. | Test that additional validation against the API is successful. | async def test_validate_tags(hass, mock_nextbus, mock_nextbus_lists):
"""Test that additional validation against the API is successful."""
# with self.subTest('Valid everything'):
assert nextbus.validate_tags(mock_nextbus(), VALID_AGENCY, VALID_ROUTE, VALID_STOP)
# with self.subTest('Invalid agency'):
... | [
"async",
"def",
"test_validate_tags",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
")",
":",
"# with self.subTest('Valid everything'):",
"assert",
"nextbus",
".",
"validate_tags",
"(",
"mock_nextbus",
"(",
")",
",",
"VALID_AGENCY",
",",
"VALID_ROUTE",
... | [
98,
0
] | [
111,
82
] | python | en | ['en', 'en', 'en'] | True |
test_verify_valid_state | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify all attributes are set from a valid response. | Verify all attributes are set from a valid response. | async def test_verify_valid_state(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify all attributes are set from a valid response."""
await assert_setup_sensor(hass, CONFIG_BASIC)
mock_nextbus_predictions.assert_called_once_with(
[{"stop_tag": VALID_STOP, "route_tag":... | [
"async",
"def",
"test_verify_valid_state",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"await",
"assert_setup_sensor",
"(",
"hass",
",",
"CONFIG_BASIC",
")",
"mock_nextbus_predictions",
".",
"assert_called_once_w... | [
114,
0
] | [
130,
52
] | python | en | ['en', 'en', 'en'] | True |
test_message_dict | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify that a single dict message is rendered correctly. | Verify that a single dict message is rendered correctly. | async def test_message_dict(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify that a single dict message is rendered correctly."""
mock_nextbus_predictions.return_value = {
"predictions": {
"agencyTitle": VALID_AGENCY_TITLE,
"routeTitle": VALID_RO... | [
"async",
"def",
"test_message_dict",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"mock_nextbus_predictions",
".",
"return_value",
"=",
"{",
"\"predictions\"",
":",
"{",
"\"agencyTitle\"",
":",
"VALID_AGENCY_TIT... | [
133,
0
] | [
158,
51
] | python | en | ['en', 'en', 'en'] | True |
test_message_list | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify that a list of messages are rendered correctly. | Verify that a list of messages are rendered correctly. | async def test_message_list(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify that a list of messages are rendered correctly."""
mock_nextbus_predictions.return_value = {
"predictions": {
"agencyTitle": VALID_AGENCY_TITLE,
"routeTitle": VALID_ROUT... | [
"async",
"def",
"test_message_list",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"mock_nextbus_predictions",
".",
"return_value",
"=",
"{",
"\"predictions\"",
":",
"{",
"\"agencyTitle\"",
":",
"VALID_AGENCY_TIT... | [
161,
0
] | [
186,
66
] | python | en | ['en', 'en', 'en'] | True |
test_direction_list | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify that a list of messages are rendered correctly. | Verify that a list of messages are rendered correctly. | async def test_direction_list(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify that a list of messages are rendered correctly."""
mock_nextbus_predictions.return_value = {
"predictions": {
"agencyTitle": VALID_AGENCY_TITLE,
"routeTitle": VALID_RO... | [
"async",
"def",
"test_direction_list",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"mock_nextbus_predictions",
".",
"return_value",
"=",
"{",
"\"predictions\"",
":",
"{",
"\"agencyTitle\"",
":",
"VALID_AGENCY_T... | [
189,
0
] | [
225,
55
] | python | en | ['en', 'en', 'en'] | True |
test_custom_name | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify that a custom name can be set via config. | Verify that a custom name can be set via config. | async def test_custom_name(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify that a custom name can be set via config."""
config = deepcopy(CONFIG_BASIC)
config["sensor"]["name"] = "Custom Name"
await assert_setup_sensor(hass, config)
state = hass.states.get("sensor... | [
"async",
"def",
"test_custom_name",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"config",
"=",
"deepcopy",
"(",
"CONFIG_BASIC",
")",
"config",
"[",
"\"sensor\"",
"]",
"[",
"\"name\"",
"]",
"=",
"\"Custo... | [
228,
0
] | [
237,
28
] | python | en | ['en', 'pt', 'en'] | True |
test_no_predictions | (
hass, mock_nextbus, mock_nextbus_predictions, mock_nextbus_lists
) | Verify there are no exceptions when no predictions are returned. | Verify there are no exceptions when no predictions are returned. | async def test_no_predictions(
hass, mock_nextbus, mock_nextbus_predictions, mock_nextbus_lists
):
"""Verify there are no exceptions when no predictions are returned."""
mock_nextbus_predictions.return_value = {}
await assert_setup_sensor(hass, CONFIG_BASIC)
state = hass.states.get(SENSOR_ID_SHORT... | [
"async",
"def",
"test_no_predictions",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_predictions",
",",
"mock_nextbus_lists",
")",
":",
"mock_nextbus_predictions",
".",
"return_value",
"=",
"{",
"}",
"await",
"assert_setup_sensor",
"(",
"hass",
",",
"CONFIG_BAS... | [
240,
0
] | [
250,
35
] | python | en | ['en', 'en', 'en'] | True |
test_verify_no_upcoming | (
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
) | Verify attributes are set despite no upcoming times. | Verify attributes are set despite no upcoming times. | async def test_verify_no_upcoming(
hass, mock_nextbus, mock_nextbus_lists, mock_nextbus_predictions
):
"""Verify attributes are set despite no upcoming times."""
mock_nextbus_predictions.return_value = {
"predictions": {
"agencyTitle": VALID_AGENCY_TITLE,
"routeTitle": VALID_... | [
"async",
"def",
"test_verify_no_upcoming",
"(",
"hass",
",",
"mock_nextbus",
",",
"mock_nextbus_lists",
",",
"mock_nextbus_predictions",
")",
":",
"mock_nextbus_predictions",
".",
"return_value",
"=",
"{",
"\"predictions\"",
":",
"{",
"\"agencyTitle\"",
":",
"VALID_AGEN... | [
253,
0
] | [
271,
68
] | python | en | ['en', 'pt', 'en'] | True |
setup_comp | (hass) | Set up demo component. | Set up demo component. | async def setup_comp(hass):
"""Set up demo component."""
assert await async_setup_component(
hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": DOMAIN}}
)
await hass.async_block_till_done() | [
"async",
"def",
"setup_comp",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LIGHT_DOMAIN",
",",
"{",
"LIGHT_DOMAIN",
":",
"{",
"\"platform\"",
":",
"DOMAIN",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
... | [
26,
0
] | [
31,
38
] | python | en | ['en', 'da', 'en'] | True |
test_state_attributes | (hass) | Test light state attributes. | Test light state attributes. | async def test_state_attributes(hass):
"""Test light state attributes."""
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ENTITY_LIGHT, ATTR_XY_COLOR: (0.4, 0.4), ATTR_BRIGHTNESS: 25},
blocking=True,
)
state = hass.states.get(ENTITY_LIGHT)... | [
"async",
"def",
"test_state_attributes",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LIGHT_DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_LIGHT",
",",
"ATTR_XY_COLOR",
":",
"(",
"0.4",
",",
"0.4"... | [
34,
0
] | [
88,
55
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off | (hass) | Test light turn off method. | Test light turn off method. | async def test_turn_off(hass):
"""Test light turn off method."""
await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_LIGHT}, blocking=True
)
state = hass.states.get(ENTITY_LIGHT)
assert state.state == STATE_ON
await hass.services.async_call(
L... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LIGHT_DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_LIGHT",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
... | [
91,
0
] | [
105,
35
] | python | en | ['en', 'et', 'en'] | True |
test_turn_off_without_entity_id | (hass) | Test light turn off all lights. | Test light turn off all lights. | async def test_turn_off_without_entity_id(hass):
"""Test light turn off all lights."""
await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "all"}, blocking=True
)
state = hass.states.get(ENTITY_LIGHT)
assert state.state == STATE_ON
await hass.services.async_... | [
"async",
"def",
"test_turn_off_without_entity_id",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LIGHT_DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"\"all\"",
"}",
",",
"blocking",
"=",
"True",
")",
"sta... | [
108,
0
] | [
122,
35
] | python | en | ['en', 'et', 'en'] | True |
KonnectedFlowHandler.__init__ | (self) | Initialize the Konnected flow. | Initialize the Konnected flow. | def __init__(self):
"""Initialize the Konnected flow."""
self.data = {}
self.options = OPTIONS_SCHEMA({CONF_IO: {}}) | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"data",
"=",
"{",
"}",
"self",
".",
"options",
"=",
"OPTIONS_SCHEMA",
"(",
"{",
"CONF_IO",
":",
"{",
"}",
"}",
")"
] | [
173,
4
] | [
176,
52
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_gen_config | (self, host, port) | Populate self.data based on panel status.
This will raise CannotConnect if an error occurs
| Populate self.data based on panel status. | async def async_gen_config(self, host, port):
"""Populate self.data based on panel status.
This will raise CannotConnect if an error occurs
"""
self.data[CONF_HOST] = host
self.data[CONF_PORT] = port
try:
status = await get_status(self.hass, host, port)
... | [
"async",
"def",
"async_gen_config",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"self",
".",
"data",
"[",
"CONF_HOST",
"]",
"=",
"host",
"self",
".",
"data",
"[",
"CONF_PORT",
"]",
"=",
"port",
"try",
":",
"status",
"=",
"await",
"get_status",
"... | [
178,
4
] | [
194,
13
] | python | en | ['en', 'et', 'en'] | True |
KonnectedFlowHandler.async_step_import | (self, device_config) | Import a configuration.yaml config.
This flow is triggered by `async_setup` for configured panels.
| Import a configuration.yaml config. | async def async_step_import(self, device_config):
"""Import a configuration.yaml config.
This flow is triggered by `async_setup` for configured panels.
"""
_LOGGER.debug(device_config)
# save the data and confirm connection via user step
await self.async_set_unique_id(d... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"device_config",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"device_config",
")",
"# save the data and confirm connection via user step",
"await",
"self",
".",
"async_set_unique_id",
"(",
"device_config",
"[",
"\"id\""... | [
196,
4
] | [
219,
53
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_step_import_confirm | (self, user_input=None) | Confirm the user wants to import the config entry. | Confirm the user wants to import the config entry. | async def async_step_import_confirm(self, user_input=None):
"""Confirm the user wants to import the config entry."""
if user_input is None:
return self.async_show_form(
step_id="import_confirm",
description_placeholders={"id": self.unique_id},
)
... | [
"async",
"def",
"async_step_import_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"import_confirm\"",
",",
"description_placeholders",
"=",
... | [
221,
4
] | [
241,
43
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_step_ssdp | (self, discovery_info) | Handle a discovered konnected panel.
This flow is triggered by the SSDP component. It will check if the
device is already configured and attempt to finish the config if not.
| Handle a discovered konnected panel. | async def async_step_ssdp(self, discovery_info):
"""Handle a discovered konnected panel.
This flow is triggered by the SSDP component. It will check if the
device is already configured and attempt to finish the config if not.
"""
_LOGGER.debug(discovery_info)
try:
... | [
"async",
"def",
"async_step_ssdp",
"(",
"self",
",",
"discovery_info",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"discovery_info",
")",
"try",
":",
"if",
"discovery_info",
"[",
"ATTR_UPNP_MANUFACTURER",
"]",
"!=",
"KONN_MANUFACTURER",
":",
"return",
"self",
".",
... | [
243,
4
] | [
276,
49
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_step_user | (self, user_input=None) | Connect to panel and get config. | Connect to panel and get config. | async def async_step_user(self, user_input=None):
"""Connect to panel and get config."""
errors = {}
if user_input:
# build config info and wait for user confirmation
self.data[CONF_HOST] = user_input[CONF_HOST]
self.data[CONF_PORT] = user_input[CONF_PORT]
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
":",
"# build config info and wait for user confirmation",
"self",
".",
"data",
"[",
"CONF_HOST",
"]",
"=",
"user_input",
"[",
... | [
278,
4
] | [
320,
9
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_step_confirm | (self, user_input=None) | Attempt to link with the Konnected panel.
Given a configured host, will ask the user to confirm and finalize
the connection.
| Attempt to link with the Konnected panel. | async def async_step_confirm(self, user_input=None):
"""Attempt to link with the Konnected panel.
Given a configured host, will ask the user to confirm and finalize
the connection.
"""
if user_input is None:
# abort and update an existing config entry if host info ch... | [
"async",
"def",
"async_step_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"# abort and update an existing config entry if host info changes",
"await",
"self",
".",
"async_set_unique_id",
"(",
"self",
".",
"data... | [
322,
4
] | [
353,
9
] | python | en | ['en', 'en', 'en'] | True |
KonnectedFlowHandler.async_get_options_flow | (config_entry) | Return the Options Flow. | Return the Options Flow. | def async_get_options_flow(config_entry):
"""Return the Options Flow."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
357,
4
] | [
359,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.entry = config_entry
self.model = self.entry.data[CONF_MODEL]
self.current_opt = self.entry.options or self.entry.data[CONF_DEFAULT_OPTIONS]
# as config proceeds we'll build up new ... | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"entry",
"=",
"config_entry",
"self",
".",
"model",
"=",
"self",
".",
"entry",
".",
"data",
"[",
"CONF_MODEL",
"]",
"self",
".",
"curre... | [
365,
4
] | [
376,
30
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.get_current_cfg | (self, io_type, zone) | Get the current zone config. | Get the current zone config. | def get_current_cfg(self, io_type, zone):
"""Get the current zone config."""
return next(
(
cfg
for cfg in self.current_opt.get(io_type, [])
if cfg[CONF_ZONE] == zone
),
{},
) | [
"def",
"get_current_cfg",
"(",
"self",
",",
"io_type",
",",
"zone",
")",
":",
"return",
"next",
"(",
"(",
"cfg",
"for",
"cfg",
"in",
"self",
".",
"current_opt",
".",
"get",
"(",
"io_type",
",",
"[",
"]",
")",
"if",
"cfg",
"[",
"CONF_ZONE",
"]",
"==... | [
379,
4
] | [
388,
9
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
return await self.async_step_options_io() | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"async_step_options_io",
"(",
")"
] | [
390,
4
] | [
392,
49
] | python | en | ['en', 'nl', 'en'] | True |
OptionsFlowHandler.async_step_options_io | (self, user_input=None) | Configure legacy panel IO or first half of pro IO. | Configure legacy panel IO or first half of pro IO. | async def async_step_options_io(self, user_input=None):
"""Configure legacy panel IO or first half of pro IO."""
errors = {}
current_io = self.current_opt.get(CONF_IO, {})
if user_input is not None:
# strip out disabled io and save for options cfg
for key, value ... | [
"async",
"def",
"async_step_options_io",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"current_io",
"=",
"self",
".",
"current_opt",
".",
"get",
"(",
"CONF_IO",
",",
"{",
"}",
")",
"if",
"user_input",
"is",
"not",
"No... | [
394,
4
] | [
477,
56
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_options_io_ext | (self, user_input=None) | Allow the user to configure the extended IO for pro. | Allow the user to configure the extended IO for pro. | async def async_step_options_io_ext(self, user_input=None):
"""Allow the user to configure the extended IO for pro."""
errors = {}
current_io = self.current_opt.get(CONF_IO, {})
if user_input is not None:
# strip out disabled io and save for options cfg
for key, ... | [
"async",
"def",
"async_step_options_io_ext",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"current_io",
"=",
"self",
".",
"current_opt",
".",
"get",
"(",
"CONF_IO",
",",
"{",
"}",
")",
"if",
"user_input",
"is",
"not",
... | [
479,
4
] | [
535,
56
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_options_binary | (self, user_input=None) | Allow the user to configure the IO options for binary sensors. | Allow the user to configure the IO options for binary sensors. | async def async_step_options_binary(self, user_input=None):
"""Allow the user to configure the IO options for binary sensors."""
errors = {}
if user_input is not None:
zone = {"zone": self.active_cfg}
zone.update(user_input)
self.new_opt[CONF_BINARY_SENSORS] =... | [
"async",
"def",
"async_step_options_binary",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"zone",
"=",
"{",
"\"zone\"",
":",
"self",
".",
"active_cfg",
"}",
"zone",
".",
"... | [
537,
4
] | [
606,
54
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_options_digital | (self, user_input=None) | Allow the user to configure the IO options for digital sensors. | Allow the user to configure the IO options for digital sensors. | async def async_step_options_digital(self, user_input=None):
"""Allow the user to configure the IO options for digital sensors."""
errors = {}
if user_input is not None:
zone = {"zone": self.active_cfg}
zone.update(user_input)
self.new_opt[CONF_SENSORS] = self... | [
"async",
"def",
"async_step_options_digital",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"zone",
"=",
"{",
"\"zone\"",
":",
"self",
".",
"active_cfg",
"}",
"zone",
".",
... | [
608,
4
] | [
674,
53
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_options_switch | (self, user_input=None) | Allow the user to configure the IO options for switches. | Allow the user to configure the IO options for switches. | async def async_step_options_switch(self, user_input=None):
"""Allow the user to configure the IO options for switches."""
errors = {}
if user_input is not None:
zone = {"zone": self.active_cfg}
zone.update(user_input)
del zone[CONF_MORE_STATES]
se... | [
"async",
"def",
"async_step_options_switch",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"zone",
"=",
"{",
"\"zone\"",
":",
"self",
".",
"active_cfg",
"}",
"zone",
".",
"... | [
676,
4
] | [
789,
51
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_options_misc | (self, user_input=None) | Allow the user to configure the LED behavior. | Allow the user to configure the LED behavior. | async def async_step_options_misc(self, user_input=None):
"""Allow the user to configure the LED behavior."""
errors = {}
if user_input is not None:
# config schema only does basic schema val so check url here
try:
if user_input[CONF_OVERRIDE_API_HOST]:
... | [
"async",
"def",
"async_step_options_misc",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"# config schema only does basic schema val so check url here",
"try",
":",
"if",
"user_input",
... | [
791,
4
] | [
830,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_command | (self, cmd, params=None) | Mock the Mikrotik command method. | Mock the Mikrotik command method. | def mock_command(self, cmd, params=None):
"""Mock the Mikrotik command method."""
if cmd == mikrotik.const.MIKROTIK_SERVICES[mikrotik.const.IS_WIRELESS]:
return True
if cmd == mikrotik.const.MIKROTIK_SERVICES[mikrotik.const.DHCP]:
return DHCP_DATA
if cmd == mikrotik.const.MIKROTIK_SERVIC... | [
"def",
"mock_command",
"(",
"self",
",",
"cmd",
",",
"params",
"=",
"None",
")",
":",
"if",
"cmd",
"==",
"mikrotik",
".",
"const",
".",
"MIKROTIK_SERVICES",
"[",
"mikrotik",
".",
"const",
".",
"IS_WIRELESS",
"]",
":",
"return",
"True",
"if",
"cmd",
"==... | [
17,
0
] | [
25,
13
] | python | en | ['en', 'et', 'en'] | True |
test_platform_manually_configured | (hass) | Test that nothing happens when configuring mikrotik through device tracker platform. | Test that nothing happens when configuring mikrotik through device tracker platform. | async def test_platform_manually_configured(hass):
"""Test that nothing happens when configuring mikrotik through device tracker platform."""
assert (
await async_setup_component(
hass,
device_tracker.DOMAIN,
{device_tracker.DOMAIN: {"platform": "mikrotik"}},
... | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_tracker",
".",
"DOMAIN",
",",
"{",
"device_tracker",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mikrotik\""... | [
28,
0
] | [
38,
43
] | python | en | ['en', 'en', 'en'] | True |
test_device_trackers | (hass, legacy_patchable_time) | Test device_trackers created by mikrotik. | Test device_trackers created by mikrotik. | async def test_device_trackers(hass, legacy_patchable_time):
"""Test device_trackers created by mikrotik."""
# test devices are added from wireless list only
hub = await setup_mikrotik_entry(hass)
device_1 = hass.states.get("device_tracker.device_1")
assert device_1 is not None
assert device_1... | [
"async",
"def",
"test_device_trackers",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"# test devices are added from wireless list only",
"hub",
"=",
"await",
"setup_mikrotik_entry",
"(",
"hass",
")",
"device_1",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"... | [
41,
0
] | [
83,
43
] | 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.