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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WiLightFan.percentage | (self) | Return the current speed percentage. | Return the current speed percentage. | def percentage(self) -> int | None:
"""Return the current speed percentage."""
if (
"direction" in self._status
and self._status["direction"] == WL_DIRECTION_OFF
):
return 0
wl_speed = self._status.get("speed")
if wl_speed is None:
... | [
"def",
"percentage",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"(",
"\"direction\"",
"in",
"self",
".",
"_status",
"and",
"self",
".",
"_status",
"[",
"\"direction\"",
"]",
"==",
"WL_DIRECTION_OFF",
")",
":",
"return",
"0",
"wl_speed",
"=",
... | [
80,
4
] | [
91,
82
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.speed_count | (self) | Return the number of speeds the fan supports. | Return the number of speeds the fan supports. | def speed_count(self) -> int:
"""Return the number of speeds the fan supports."""
return len(ORDERED_NAMED_FAN_SPEEDS) | [
"def",
"speed_count",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"ORDERED_NAMED_FAN_SPEEDS",
")"
] | [
94,
4
] | [
96,
44
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.current_direction | (self) | Return the current direction of the fan. | Return the current direction of the fan. | def current_direction(self) -> str:
"""Return the current direction of the fan."""
if (
"direction" in self._status
and self._status["direction"] != WL_DIRECTION_OFF
):
self._direction = self._status["direction"]
return self._direction | [
"def",
"current_direction",
"(",
"self",
")",
"->",
"str",
":",
"if",
"(",
"\"direction\"",
"in",
"self",
".",
"_status",
"and",
"self",
".",
"_status",
"[",
"\"direction\"",
"]",
"!=",
"WL_DIRECTION_OFF",
")",
":",
"self",
".",
"_direction",
"=",
"self",
... | [
99,
4
] | [
106,
30
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.async_turn_on | (
self,
speed: str = None,
percentage: int = None,
preset_mode: str = None,
**kwargs,
) | Turn on the fan. | Turn on the fan. | async def async_turn_on(
self,
speed: str = None,
percentage: int = None,
preset_mode: str = None,
**kwargs,
) -> None:
"""Turn on the fan."""
if percentage is None:
await self._client.set_fan_direction(self._index, self._direction)
else:
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
",",
"percentage",
":",
"int",
"=",
"None",
",",
"preset_mode",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
"->",
"None",
":",
"if",
"percentage",
... | [
108,
4
] | [
119,
55
] | python | en | ['en', 'fy', 'en'] | True |
WiLightFan.async_set_percentage | (self, percentage: int) | Set the speed of the fan. | Set the speed of the fan. | async def async_set_percentage(self, percentage: int):
"""Set the speed of the fan."""
if percentage == 0:
await self._client.set_fan_direction(self._index, WL_DIRECTION_OFF)
return
if (
"direction" in self._status
and self._status["direction"] == ... | [
"async",
"def",
"async_set_percentage",
"(",
"self",
",",
"percentage",
":",
"int",
")",
":",
"if",
"percentage",
"==",
"0",
":",
"await",
"self",
".",
"_client",
".",
"set_fan_direction",
"(",
"self",
".",
"_index",
",",
"WL_DIRECTION_OFF",
")",
"return",
... | [
121,
4
] | [
132,
63
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.async_set_direction | (self, direction: str) | Set the direction of the fan. | Set the direction of the fan. | async def async_set_direction(self, direction: str):
"""Set the direction of the fan."""
wl_direction = WL_DIRECTION_REVERSE
if direction == DIRECTION_FORWARD:
wl_direction = WL_DIRECTION_FORWARD
await self._client.set_fan_direction(self._index, wl_direction) | [
"async",
"def",
"async_set_direction",
"(",
"self",
",",
"direction",
":",
"str",
")",
":",
"wl_direction",
"=",
"WL_DIRECTION_REVERSE",
"if",
"direction",
"==",
"DIRECTION_FORWARD",
":",
"wl_direction",
"=",
"WL_DIRECTION_FORWARD",
"await",
"self",
".",
"_client",
... | [
134,
4
] | [
139,
71
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.async_turn_off | (self, **kwargs) | Turn the fan off. | Turn the fan off. | async def async_turn_off(self, **kwargs):
"""Turn the fan off."""
await self._client.set_fan_direction(self._index, WL_DIRECTION_OFF) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_client",
".",
"set_fan_direction",
"(",
"self",
".",
"_index",
",",
"WL_DIRECTION_OFF",
")"
] | [
141,
4
] | [
143,
75
] | python | en | ['en', 'fy', 'en'] | True |
test_duplicate_error | (hass) | Test that errors are shown when duplicates are added. | Test that errors are shown when duplicates are added. | async def test_duplicate_error(hass):
"""Test that errors are shown when duplicates are added."""
conf = {
CONF_USERNAME: "user@host.com",
CONF_PASSWORD: "123abc",
}
MockConfigEntry(domain=DOMAIN, unique_id="user@host.com", data=conf).add_to_hass(
hass
)
result = await ... | [
"async",
"def",
"test_duplicate_error",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_USERNAME",
":",
"\"user@host.com\"",
",",
"CONF_PASSWORD",
":",
"\"123abc\"",
",",
"}",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"user@host.co... | [
13,
0
] | [
29,
51
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_credentials | (hass) | Test that invalid credentials key throws an error. | Test that invalid credentials key throws an error. | async def test_invalid_credentials(hass):
"""Test that invalid credentials key throws an error."""
conf = {
CONF_USERNAME: "user@host.com",
CONF_PASSWORD: "123abc",
}
with patch(
"homeassistant.components.tile.config_flow.async_login",
side_effect=TileError,
):
... | [
"async",
"def",
"test_invalid_credentials",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_USERNAME",
":",
"\"user@host.com\"",
",",
"CONF_PASSWORD",
":",
"\"123abc\"",
",",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.tile.config_flow.async_login\"",
",",
"... | [
32,
0
] | [
47,
59
] | python | en | ['en', 'en', 'en'] | True |
test_step_import | (hass) | Test that the import step works. | Test that the import step works. | async def test_step_import(hass):
"""Test that the import step works."""
conf = {
CONF_USERNAME: "user@host.com",
CONF_PASSWORD: "123abc",
}
with patch(
"homeassistant.components.tile.async_setup_entry", return_value=True
), patch("homeassistant.components.tile.config_flow.a... | [
"async",
"def",
"test_step_import",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_USERNAME",
":",
"\"user@host.com\"",
",",
"CONF_PASSWORD",
":",
"\"123abc\"",
",",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.tile.async_setup_entry\"",
",",
"return_value",... | [
50,
0
] | [
68,
9
] | python | en | ['en', 'en', 'en'] | True |
test_step_user | (hass) | Test that the user step works. | Test that the user step works. | async def test_step_user(hass):
"""Test that the user step works."""
conf = {
CONF_USERNAME: "user@host.com",
CONF_PASSWORD: "123abc",
}
with patch(
"homeassistant.components.tile.async_setup_entry", return_value=True
), patch("homeassistant.components.tile.config_flow.async... | [
"async",
"def",
"test_step_user",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_USERNAME",
":",
"\"user@host.com\"",
",",
"CONF_PASSWORD",
":",
"\"123abc\"",
",",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.tile.async_setup_entry\"",
",",
"return_value",
... | [
71,
0
] | [
95,
9
] | python | en | ['en', 'en', 'en'] | True |
test_status_documentation | () |
Here we test the examples in the documentation automatically using doctest
. We set up an environment which is similar to what a rule writer might
see - a '/usr/bin/find /sys/devices/pci0000:00 -mindepth 8 -maxdepth 8' command
output that has been passed in as a parameter to the rule declaration.
|
Here we test the examples in the documentation automatically using doctest
. We set up an environment which is similar to what a rule writer might
see - a '/usr/bin/find /sys/devices/pci0000:00 -mindepth 8 -maxdepth 8' command
output that has been passed in as a parameter to the rule declaration.
| def test_status_documentation():
"""
Here we test the examples in the documentation automatically using doctest
. We set up an environment which is similar to what a rule writer might
see - a '/usr/bin/find /sys/devices/pci0000:00 -mindepth 8 -maxdepth 8' command
output that has been passed in as a ... | [
"def",
"test_status_documentation",
"(",
")",
":",
"env",
"=",
"{",
"'pd'",
":",
"PCIPaths",
"(",
"context_wrap",
"(",
"INPUT_GOOD",
")",
")",
"}",
"failed",
",",
"total",
"=",
"doctest",
".",
"testmod",
"(",
"pci_rport_target_disk_paths",
",",
"globs",
"=",... | [
51,
0
] | [
60,
22
] | python | en | ['en', 'error', 'th'] | False |
test_status_exp | () |
Here test the examples cause expections
|
Here test the examples cause expections
| def test_status_exp():
"""
Here test the examples cause expections
"""
with pytest.raises(SkipException) as sc1:
PCIPaths(context_wrap(''))
assert "Input content is empty" in str(sc1) | [
"def",
"test_status_exp",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"SkipException",
")",
"as",
"sc1",
":",
"PCIPaths",
"(",
"context_wrap",
"(",
"''",
")",
")",
"assert",
"\"Input content is empty\"",
"in",
"str",
"(",
"sc1",
")"
] | [
63,
0
] | [
69,
47
] | python | en | ['en', 'error', 'th'] | False |
test_status_exp2 | () |
Here test the examples cause expections
|
Here test the examples cause expections
| def test_status_exp2():
"""
Here test the examples cause expections
"""
with pytest.raises(ParseException) as sc1:
PCIPaths(context_wrap(INPUT_BAD))
assert "No useful data parsed in line" in str(sc1) | [
"def",
"test_status_exp2",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ParseException",
")",
"as",
"sc1",
":",
"PCIPaths",
"(",
"context_wrap",
"(",
"INPUT_BAD",
")",
")",
"assert",
"\"No useful data parsed in line\"",
"in",
"str",
"(",
"sc1",
")"
] | [
72,
0
] | [
78,
54
] | python | en | ['en', 'error', 'th'] | False |
mock_batch_timeout | (hass, monkeypatch) | Mock the event bus listener and the batch timeout for tests. | Mock the event bus listener and the batch timeout for tests. | def mock_batch_timeout(hass, monkeypatch):
"""Mock the event bus listener and the batch timeout for tests."""
hass.bus.listen = MagicMock()
monkeypatch.setattr(
f"{INFLUX_PATH}.InfluxThread.batch_timeout",
Mock(return_value=0),
) | [
"def",
"mock_batch_timeout",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"hass",
".",
"bus",
".",
"listen",
"=",
"MagicMock",
"(",
")",
"monkeypatch",
".",
"setattr",
"(",
"f\"{INFLUX_PATH}.InfluxThread.batch_timeout\"",
",",
"Mock",
"(",
"return_value",
"=",
"0"... | [
38,
0
] | [
44,
5
] | python | en | ['en', 'en', 'en'] | True |
mock_client_fixture | (request) | Patch the InfluxDBClient object with mock for version under test. | Patch the InfluxDBClient object with mock for version under test. | def mock_client_fixture(request):
"""Patch the InfluxDBClient object with mock for version under test."""
if request.param == influxdb.API_VERSION_2:
client_target = f"{INFLUX_CLIENT_PATH}V2"
else:
client_target = INFLUX_CLIENT_PATH
with patch(client_target) as client:
yield cli... | [
"def",
"mock_client_fixture",
"(",
"request",
")",
":",
"if",
"request",
".",
"param",
"==",
"influxdb",
".",
"API_VERSION_2",
":",
"client_target",
"=",
"f\"{INFLUX_CLIENT_PATH}V2\"",
"else",
":",
"client_target",
"=",
"INFLUX_CLIENT_PATH",
"with",
"patch",
"(",
... | [
48,
0
] | [
56,
20
] | python | en | ['en', 'en', 'en'] | True |
get_mock_call_fixture | (request) | Get version specific lambda to make write API call mock. | Get version specific lambda to make write API call mock. | def get_mock_call_fixture(request):
"""Get version specific lambda to make write API call mock."""
def v2_call(body, precision):
data = {"bucket": DEFAULT_BUCKET, "record": body}
if precision is not None:
data["write_precision"] = precision
return call(**data)
if requ... | [
"def",
"get_mock_call_fixture",
"(",
"request",
")",
":",
"def",
"v2_call",
"(",
"body",
",",
"precision",
")",
":",
"data",
"=",
"{",
"\"bucket\"",
":",
"DEFAULT_BUCKET",
",",
"\"record\"",
":",
"body",
"}",
"if",
"precision",
"is",
"not",
"None",
":",
... | [
60,
0
] | [
74,
76
] | python | en | ['en', 'jv', 'en'] | True |
_get_write_api_mock_v1 | (mock_influx_client) | Return the write api mock for the V1 client. | Return the write api mock for the V1 client. | def _get_write_api_mock_v1(mock_influx_client):
"""Return the write api mock for the V1 client."""
return mock_influx_client.return_value.write_points | [
"def",
"_get_write_api_mock_v1",
"(",
"mock_influx_client",
")",
":",
"return",
"mock_influx_client",
".",
"return_value",
".",
"write_points"
] | [
77,
0
] | [
79,
55
] | python | en | ['en', 'no', 'en'] | True |
_get_write_api_mock_v2 | (mock_influx_client) | Return the write api mock for the V2 client. | Return the write api mock for the V2 client. | def _get_write_api_mock_v2(mock_influx_client):
"""Return the write api mock for the V2 client."""
return mock_influx_client.return_value.write_api.return_value.write | [
"def",
"_get_write_api_mock_v2",
"(",
"mock_influx_client",
")",
":",
"return",
"mock_influx_client",
".",
"return_value",
".",
"write_api",
".",
"return_value",
".",
"write"
] | [
82,
0
] | [
84,
71
] | python | en | ['en', 'no', 'en'] | True |
test_setup_config_full | (hass, mock_client, config_ext, get_write_api) | Test the setup with full configuration. | Test the setup with full configuration. | async def test_setup_config_full(hass, mock_client, config_ext, get_write_api):
"""Test the setup with full configuration."""
config = {
"influxdb": {
"host": "host",
"port": 123,
"database": "db",
"max_retries": 4,
"ssl": "False",
}
... | [
"async",
"def",
"test_setup_config_full",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"\"host\"",
":",
"\"host\"",
",",
"\"port\"",
":",
"123",
",",
"\"database\"",
":",
"\... | [
113,
0
] | [
130,
53
] | python | en | ['en', 'en', 'en'] | True |
test_setup_config_ssl | (
hass, mock_client, config_base, config_ext, expected_client_args
) | Test the setup with various verify_ssl values. | Test the setup with various verify_ssl values. | async def test_setup_config_ssl(
hass, mock_client, config_base, config_ext, expected_client_args
):
"""Test the setup with various verify_ssl values."""
config = {"influxdb": config_base.copy()}
config["influxdb"].update(config_ext)
with patch("os.access", return_value=True), patch(
"os.pa... | [
"async",
"def",
"test_setup_config_ssl",
"(",
"hass",
",",
"mock_client",
",",
"config_base",
",",
"config_ext",
",",
"expected_client_args",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"config_base",
".",
"copy",
"(",
")",
"}",
"config",
"[",
"\"influx... | [
249,
0
] | [
264,
83
] | python | en | ['en', 'en', 'en'] | True |
test_setup_minimal_config | (hass, mock_client, config_ext, get_write_api) | Test the setup with minimal configuration and defaults. | Test the setup with minimal configuration and defaults. | async def test_setup_minimal_config(hass, mock_client, config_ext, get_write_api):
"""Test the setup with minimal configuration and defaults."""
config = {"influxdb": {}}
config["influxdb"].update(config_ext)
assert await async_setup_component(hass, influxdb.DOMAIN, config)
await hass.async_block_t... | [
"async",
"def",
"test_setup_minimal_config",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"}",
"}",
"config",
"[",
"\"influxdb\"",
"]",
".",
"update",
"(",
"config_ext",
")"... | [
275,
0
] | [
284,
53
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_config | (hass, mock_client, config_ext, get_write_api) | Test the setup with invalid config or config options specified for wrong version. | Test the setup with invalid config or config options specified for wrong version. | async def test_invalid_config(hass, mock_client, config_ext, get_write_api):
"""Test the setup with invalid config or config options specified for wrong version."""
config = {"influxdb": {}}
config["influxdb"].update(config_ext)
assert not await async_setup_component(hass, influxdb.DOMAIN, config) | [
"async",
"def",
"test_invalid_config",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"}",
"}",
"config",
"[",
"\"influxdb\"",
"]",
".",
"update",
"(",
"config_ext",
")",
"a... | [
320,
0
] | [
325,
73
] | python | en | ['en', 'en', 'en'] | True |
_setup | (hass, mock_influx_client, config_ext, get_write_api) | Prepare client for next test and return event handler method. | Prepare client for next test and return event handler method. | async def _setup(hass, mock_influx_client, config_ext, get_write_api):
"""Prepare client for next test and return event handler method."""
config = {
"influxdb": {
"host": "host",
"exclude": {"entities": ["fake.excluded"], "domains": ["another_fake"]},
}
}
config[... | [
"async",
"def",
"_setup",
"(",
"hass",
",",
"mock_influx_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"\"host\"",
":",
"\"host\"",
",",
"\"exclude\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.ex... | [
328,
0
] | [
342,
50
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener. | Test the event listener. | async def test_event_listener(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
# map of HA State to valid influxdb [state, value] fields
valid = {
"1": [None, 1],
... | [
"async",
"def",
"test_event_listener",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
"... | [
363,
0
] | [
428,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_no_units | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener for missing units. | Test the event listener for missing units. | async def test_event_listener_no_units(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener for missing units."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
for unit in (None, ""):
if unit:
attrs = {"unit_of_meas... | [
"async",
"def",
"test_event_listener_no_units",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_... | [
449,
0
] | [
482,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_inf | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with large or invalid numbers. | Test the event listener with large or invalid numbers. | async def test_event_listener_inf(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with large or invalid numbers."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
attrs = {"bignumstring": "9" * 999, "nonumstring": "nan"}
state ... | [
"async",
"def",
"test_event_listener_inf",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",... | [
503,
0
] | [
531,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_states | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against ignored states. | Test the event listener against ignored states. | async def test_event_listener_states(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against ignored states."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
for state_state in (1, "unknown", "", "unavailable"):
state = Ma... | [
"async",
"def",
"test_event_listener_states",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_ap... | [
552,
0
] | [
584,
30
] | python | en | ['en', 'en', 'en'] | True |
execute_filter_test | (hass, tests, handler_method, write_api, get_mock_call) | Execute all tests for a given filtering test. | Execute all tests for a given filtering test. | def execute_filter_test(hass, tests, handler_method, write_api, get_mock_call):
"""Execute all tests for a given filtering test."""
for test in tests:
domain, entity_id = split_entity_id(test.id)
state = MagicMock(
state=1,
domain=domain,
entity_id=test.id,
... | [
"def",
"execute_filter_test",
"(",
"hass",
",",
"tests",
",",
"handler_method",
",",
"write_api",
",",
"get_mock_call",
")",
":",
"for",
"test",
"in",
"tests",
":",
"domain",
",",
"entity_id",
"=",
"split_entity_id",
"(",
"test",
".",
"id",
")",
"state",
"... | [
587,
0
] | [
615,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a denylist. | Test the event listener against a denylist. | async def test_event_listener_denylist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a denylist."""
config = {"exclude": {"entities": ["fake.denylisted"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, c... | [
"async",
"def",
"test_event_listener_denylist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.denylisted\"",
"]",
"}",
",",... | [
636,
0
] | [
649,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist_domain | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain denylist. | Test the event listener against a domain denylist. | async def test_event_listener_denylist_domain(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain denylist."""
config = {"exclude": {"domains": ["another_fake"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock... | [
"async",
"def",
"test_event_listener_denylist_domain",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"another_fake\"",
"]",
"}",
"... | [
670,
0
] | [
683,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist_glob | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a glob denylist. | Test the event listener against a glob denylist. | async def test_event_listener_denylist_glob(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a glob denylist."""
config = {"exclude": {"entity_globs": ["*.excluded_*"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, moc... | [
"async",
"def",
"test_event_listener_denylist_glob",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.excluded_*\"",
"]",
"}",
... | [
704,
0
] | [
717,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against an allowlist. | Test the event listener against an allowlist. | async def test_event_listener_allowlist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against an allowlist."""
config = {"include": {"entities": ["fake.included"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, ... | [
"async",
"def",
"test_event_listener_allowlist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.included\"",
"]",
"}",
",",
... | [
738,
0
] | [
751,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist_domain | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain allowlist. | Test the event listener against a domain allowlist. | async def test_event_listener_allowlist_domain(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain allowlist."""
config = {"include": {"domains": ["fake"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_clien... | [
"async",
"def",
"test_event_listener_allowlist_domain",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
"}",
",",
"... | [
772,
0
] | [
785,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist_glob | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a glob allowlist. | Test the event listener against a glob allowlist. | async def test_event_listener_allowlist_glob(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a glob allowlist."""
config = {"include": {"entity_globs": ["*.included_*"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, m... | [
"async",
"def",
"test_event_listener_allowlist_glob",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.included_*\"",
"]",
"}",... | [
806,
0
] | [
819,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_filtered_allowlist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against an allowlist filtered by denylist. | Test the event listener against an allowlist filtered by denylist. | async def test_event_listener_filtered_allowlist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against an allowlist filtered by denylist."""
config = {
"include": {
"domains": ["fake"],
"entities": ["another_fake.included"],
... | [
"async",
"def",
"test_event_listener_filtered_allowlist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
",",
"\"ent... | [
840,
0
] | [
869,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_filtered_denylist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain/glob denylist with an entity id allowlist. | Test the event listener against a domain/glob denylist with an entity id allowlist. | async def test_event_listener_filtered_denylist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain/glob denylist with an entity id allowlist."""
config = {
"include": {"entities": ["another_fake.included", "fake.excluded_pass"]},
"excl... | [
"async",
"def",
"test_event_listener_filtered_denylist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"another_fake.included\"",
","... | [
890,
0
] | [
909,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_invalid_type | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when an attribute has an invalid type. | Test the event listener when an attribute has an invalid type. | async def test_event_listener_invalid_type(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when an attribute has an invalid type."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
# map of HA State to valid influxdb [state, value] ... | [
"async",
"def",
"test_event_listener_invalid_type",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_wr... | [
930,
0
] | [
983,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_default_measurement | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with a default measurement. | Test the event listener with a default measurement. | async def test_event_listener_default_measurement(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with a default measurement."""
config = {"default_measurement": "state"}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get... | [
"async",
"def",
"test_event_listener_default_measurement",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"default_measurement\"",
":",
"\"state\"",
"}",
"config",
".",
"update",
"(",
... | [
1004,
0
] | [
1033,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_unit_of_measurement_field | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener for unit of measurement field. | Test the event listener for unit of measurement field. | async def test_event_listener_unit_of_measurement_field(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener for unit of measurement field."""
config = {"override_measurement": "state"}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, c... | [
"async",
"def",
"test_event_listener_unit_of_measurement_field",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"override_measurement\"",
":",
"\"state\"",
"}",
"config",
".",
"update",
... | [
1054,
0
] | [
1084,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_tags_attributes | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when some attributes should be tags. | Test the event listener when some attributes should be tags. | async def test_event_listener_tags_attributes(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when some attributes should be tags."""
config = {"tags_attributes": ["friendly_fake"]}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, ... | [
"async",
"def",
"test_event_listener_tags_attributes",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"tags_attributes\"",
":",
"[",
"\"friendly_fake\"",
"]",
"}",
"config",
".",
"upd... | [
1105,
0
] | [
1139,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_component_override_measurement | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_component_override_measurement(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"component_config": {
"sensor.fake_humidity": {"override_measurement": "humidity"}
}... | [
"async",
"def",
"test_event_listener_component_override_measurement",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"component_config\"",
":",
"{",
"\"sensor.fake_humidity\"",
":",
"{",
... | [
1160,
0
] | [
1205,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_component_measurement_attr | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with a different measurement_attr. | Test the event listener with a different measurement_attr. | async def test_event_listener_component_measurement_attr(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with a different measurement_attr."""
config = {
"measurement_attr": "domain__device_class",
"component_config": {
"sensor.fake_humi... | [
"async",
"def",
"test_event_listener_component_measurement_attr",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"measurement_attr\"",
":",
"\"domain__device_class\"",
",",
"\"component_confi... | [
1226,
0
] | [
1278,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_ignore_attributes | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_ignore_attributes(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"ignore_attributes": ["ignore"],
"component_config": {
"sensor.fake_humidity": {"ignore_attribute... | [
"async",
"def",
"test_event_listener_ignore_attributes",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"ignore_attributes\"",
":",
"[",
"\"ignore\"",
"]",
",",
"\"component_config\"",
... | [
1299,
0
] | [
1366,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_ignore_attributes_overlapping_entities | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_ignore_attributes_overlapping_entities(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"component_config": {"sensor.fake": {"override_measurement": "units"}},
"component_confi... | [
"async",
"def",
"test_event_listener_ignore_attributes_overlapping_entities",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"component_config\"",
":",
"{",
"\"sensor.fake\"",
":",
"{",
"... | [
1387,
0
] | [
1420,
26
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_scheduled_write | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener retries after a write failure. | Test the event listener retries after a write failure. | async def test_event_listener_scheduled_write(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener retries after a write failure."""
config = {"max_retries": 1}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get_write_api)
... | [
"async",
"def",
"test_event_listener_scheduled_write",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"max_retries\"",
":",
"1",
"}",
"config",
".",
"update",
"(",
"config_ext",
")"... | [
1441,
0
] | [
1473,
36
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_backlog_full | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener drops old events when backlog gets full. | Test the event listener drops old events when backlog gets full. | async def test_event_listener_backlog_full(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener drops old events when backlog gets full."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
state = MagicMock(
state=1,
domai... | [
"async",
"def",
"test_event_listener_backlog_full",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_wr... | [
1494,
0
] | [
1521,
57
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_attribute_name_conflict | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when an attribute conflicts with another field. | Test the event listener when an attribute conflicts with another field. | async def test_event_listener_attribute_name_conflict(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when an attribute conflicts with another field."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
attrs = {"value": "value_str"}
... | [
"async",
"def",
"test_event_listener_attribute_name_conflict",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
","... | [
1542,
0
] | [
1570,
53
] | python | en | ['en', 'en', 'en'] | True |
test_connection_failure_on_startup | (
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
) | Test the event listener when it fails to connect to Influx on startup. | Test the event listener when it fails to connect to Influx on startup. | async def test_connection_failure_on_startup(
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
):
"""Test the event listener when it fails to connect to Influx on startup."""
write_api = get_write_api(mock_client)
write_api.side_effect = test_exception
config = {"i... | [
"async",
"def",
"test_connection_failure_on_startup",
"(",
"hass",
",",
"caplog",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"test_exception",
")",
":",
"write_api",
"=",
"get_write_api",
"(",
"mock_client",
")",
"write_a... | [
1614,
0
] | [
1631,
43
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_inputs_error | (
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
) |
Test the event listener when influx returns invalid inputs on write.
The difference in error handling in this case is that we do not sleep
and try again, if an input is invalid it is logged and dropped.
Note that this shouldn't actually occur, if its possible for the current
code to send an inval... |
Test the event listener when influx returns invalid inputs on write. | async def test_invalid_inputs_error(
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
):
"""
Test the event listener when influx returns invalid inputs on write.
The difference in error handling in this case is that we do not sleep
and try again, if an input is in... | [
"async",
"def",
"test_invalid_inputs_error",
"(",
"hass",
",",
"caplog",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"test_exception",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
... | [
1654,
0
] | [
1690,
33
] | python | en | ['en', 'error', 'th'] | False |
test_precision | (
hass, mock_client, config_ext, get_write_api, get_mock_call, precision
) | Test the precision setup. | Test the precision setup. | async def test_precision(
hass, mock_client, config_ext, get_write_api, get_mock_call, precision
):
"""Test the precision setup."""
config = {
"precision": precision,
}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get_write_api)
value = "1.9"
... | [
"async",
"def",
"test_precision",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"precision",
")",
":",
"config",
"=",
"{",
"\"precision\"",
":",
"precision",
",",
"}",
"config",
".",
"update",
"(",
"conf... | [
1755,
0
] | [
1791,
26
] | python | en | ['en', 'pt', 'en'] | True |
async_setup_ingress_view | (hass: HomeAssistant, host: str) | Auth setup. | Auth setup. | def async_setup_ingress_view(hass: HomeAssistant, host: str):
"""Auth setup."""
websession = hass.helpers.aiohttp_client.async_get_clientsession()
hassio_ingress = HassIOIngress(host, websession)
hass.http.register_view(hassio_ingress) | [
"def",
"async_setup_ingress_view",
"(",
"hass",
":",
"HomeAssistant",
",",
"host",
":",
"str",
")",
":",
"websession",
"=",
"hass",
".",
"helpers",
".",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
")",
"hassio_ingress",
"=",
"HassIOIngress",
"(",
"hos... | [
22,
0
] | [
27,
43
] | python | en | ['en', 'haw', 'en'] | False |
_init_header | (request: web.Request, token: str) | Create initial header. | Create initial header. | def _init_header(request: web.Request, token: str) -> CIMultiDict | dict[str, str]:
"""Create initial header."""
headers = {}
# filter flags
for name, value in request.headers.items():
if name in (
hdrs.CONTENT_LENGTH,
hdrs.CONTENT_ENCODING,
hdrs.TRANSFER_ENC... | [
"def",
"_init_header",
"(",
"request",
":",
"web",
".",
"Request",
",",
"token",
":",
"str",
")",
"->",
"CIMultiDict",
"|",
"dict",
"[",
"str",
",",
"str",
"]",
":",
"headers",
"=",
"{",
"}",
"# filter flags",
"for",
"name",
",",
"value",
"in",
"requ... | [
161,
0
] | [
210,
18
] | python | en | ['en', 'gd', 'en'] | True |
_response_header | (response: aiohttp.ClientResponse) | Create response header. | Create response header. | def _response_header(response: aiohttp.ClientResponse) -> dict[str, str]:
"""Create response header."""
headers = {}
for name, value in response.headers.items():
if name in (
hdrs.TRANSFER_ENCODING,
hdrs.CONTENT_LENGTH,
hdrs.CONTENT_TYPE,
hdrs.CONTENT... | [
"def",
"_response_header",
"(",
"response",
":",
"aiohttp",
".",
"ClientResponse",
")",
"->",
"dict",
"[",
"str",
",",
"str",
"]",
":",
"headers",
"=",
"{",
"}",
"for",
"name",
",",
"value",
"in",
"response",
".",
"headers",
".",
"items",
"(",
")",
"... | [
213,
0
] | [
227,
18
] | python | en | ['en', 'be', 'en'] | True |
_is_websocket | (request: web.Request) | Return True if request is a websocket. | Return True if request is a websocket. | def _is_websocket(request: web.Request) -> bool:
"""Return True if request is a websocket."""
headers = request.headers
if (
"upgrade" in headers.get(hdrs.CONNECTION, "").lower()
and headers.get(hdrs.UPGRADE, "").lower() == "websocket"
):
return True
return False | [
"def",
"_is_websocket",
"(",
"request",
":",
"web",
".",
"Request",
")",
"->",
"bool",
":",
"headers",
"=",
"request",
".",
"headers",
"if",
"(",
"\"upgrade\"",
"in",
"headers",
".",
"get",
"(",
"hdrs",
".",
"CONNECTION",
",",
"\"\"",
")",
".",
"lower"... | [
230,
0
] | [
239,
16
] | python | en | ['en', 'fy', 'en'] | True |
_websocket_forward | (ws_from, ws_to) | Handle websocket message directly. | Handle websocket message directly. | async def _websocket_forward(ws_from, ws_to):
"""Handle websocket message directly."""
try:
async for msg in ws_from:
if msg.type == aiohttp.WSMsgType.TEXT:
await ws_to.send_str(msg.data)
elif msg.type == aiohttp.WSMsgType.BINARY:
await ws_to.send_... | [
"async",
"def",
"_websocket_forward",
"(",
"ws_from",
",",
"ws_to",
")",
":",
"try",
":",
"async",
"for",
"msg",
"in",
"ws_from",
":",
"if",
"msg",
".",
"type",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"TEXT",
":",
"await",
"ws_to",
".",
"send_str",
"("... | [
242,
0
] | [
257,
56
] | python | en | ['en', 'xh', 'en'] | True |
HassIOIngress.__init__ | (self, host: str, websession: aiohttp.ClientSession) | Initialize a Hass.io ingress view. | Initialize a Hass.io ingress view. | def __init__(self, host: str, websession: aiohttp.ClientSession) -> None:
"""Initialize a Hass.io ingress view."""
self._host = host
self._websession = websession | [
"def",
"__init__",
"(",
"self",
",",
"host",
":",
"str",
",",
"websession",
":",
"aiohttp",
".",
"ClientSession",
")",
"->",
"None",
":",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_websession",
"=",
"websession"
] | [
37,
4
] | [
40,
37
] | python | en | ['en', 'en', 'en'] | True |
HassIOIngress._create_url | (self, token: str, path: str) | Create URL to service. | Create URL to service. | def _create_url(self, token: str, path: str) -> str:
"""Create URL to service."""
return f"http://{self._host}/ingress/{token}/{path}" | [
"def",
"_create_url",
"(",
"self",
",",
"token",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"str",
":",
"return",
"f\"http://{self._host}/ingress/{token}/{path}\""
] | [
42,
4
] | [
44,
60
] | python | en | ['en', 'en', 'en'] | True |
HassIOIngress._handle | (
self, request: web.Request, token: str, path: str
) | Route data to Hass.io ingress service. | Route data to Hass.io ingress service. | async def _handle(
self, request: web.Request, token: str, path: str
) -> web.Response | web.StreamResponse | web.WebSocketResponse:
"""Route data to Hass.io ingress service."""
try:
# Websocket
if _is_websocket(request):
return await self._handle_webs... | [
"async",
"def",
"_handle",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
",",
"token",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"web",
".",
"Response",
"|",
"web",
".",
"StreamResponse",
"|",
"web",
".",
"WebSocketResponse",
":",
"t... | [
46,
4
] | [
61,
40
] | python | en | ['en', 'en', 'en'] | True |
HassIOIngress._handle_websocket | (
self, request: web.Request, token: str, path: str
) | Ingress route for websocket. | Ingress route for websocket. | async def _handle_websocket(
self, request: web.Request, token: str, path: str
) -> web.WebSocketResponse:
"""Ingress route for websocket."""
if hdrs.SEC_WEBSOCKET_PROTOCOL in request.headers:
req_protocols = [
str(proto.strip())
for proto in reque... | [
"async",
"def",
"_handle_websocket",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
",",
"token",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"web",
".",
"WebSocketResponse",
":",
"if",
"hdrs",
".",
"SEC_WEBSOCKET_PROTOCOL",
"in",
"request",
... | [
70,
4
] | [
112,
24
] | python | en | ['en', 'da', 'en'] | True |
HassIOIngress._handle_request | (
self, request: web.Request, token: str, path: str
) | Ingress route for request. | Ingress route for request. | async def _handle_request(
self, request: web.Request, token: str, path: str
) -> web.Response | web.StreamResponse:
"""Ingress route for request."""
url = self._create_url(token, path)
source_header = _init_header(request, token)
async with self._websession.request(
... | [
"async",
"def",
"_handle_request",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
",",
"token",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"web",
".",
"Response",
"|",
"web",
".",
"StreamResponse",
":",
"url",
"=",
"self",
".",
"_creat... | [
114,
4
] | [
158,
27
] | python | en | ['en', 'en', 'en'] | True |
test_recorder_pool | () | Test RecorderPool gives the same connection in the creating thread. | Test RecorderPool gives the same connection in the creating thread. | def test_recorder_pool():
"""Test RecorderPool gives the same connection in the creating thread."""
engine = create_engine("sqlite://", poolclass=RecorderPool)
get_session = sessionmaker(bind=engine)
connections = []
def _get_connection_twice():
session = get_session()
connections... | [
"def",
"test_recorder_pool",
"(",
")",
":",
"engine",
"=",
"create_engine",
"(",
"\"sqlite://\"",
",",
"poolclass",
"=",
"RecorderPool",
")",
"get_session",
"=",
"sessionmaker",
"(",
"bind",
"=",
"engine",
")",
"connections",
"=",
"[",
"]",
"def",
"_get_connec... | [
9,
0
] | [
33,
43
] | python | en | ['en', 'en', 'en'] | True |
TestAdditionalPropertiesBoolean.testAdditionalPropertiesBoolean | (self) | Test AdditionalPropertiesBoolean | Test AdditionalPropertiesBoolean | def testAdditionalPropertiesBoolean(self):
"""Test AdditionalPropertiesBoolean"""
# can make model without additional properties
model = AdditionalPropertiesBoolean()
# can make one with additional properties
model = AdditionalPropertiesBoolean(some_key=True)
assert mode... | [
"def",
"testAdditionalPropertiesBoolean",
"(",
"self",
")",
":",
"# can make model without additional properties",
"model",
"=",
"AdditionalPropertiesBoolean",
"(",
")",
"# can make one with additional properties",
"model",
"=",
"AdditionalPropertiesBoolean",
"(",
"some_key",
"="... | [
29,
4
] | [
40,
64
] | python | en | ['en', 'lb', 'en'] | False |
async_describe_on_off_states | (
hass: HomeAssistant, registry: GroupIntegrationRegistry
) | Describe group on off states. | Describe group on off states. | def async_describe_on_off_states(
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states(
{STATE_CLEANING, STATE_ON, STATE_RETURNING, STATE_ERROR}, STATE_OFF
) | [
"def",
"async_describe_on_off_states",
"(",
"hass",
":",
"HomeAssistant",
",",
"registry",
":",
"GroupIntegrationRegistry",
")",
"->",
"None",
":",
"registry",
".",
"on_off_states",
"(",
"{",
"STATE_CLEANING",
",",
"STATE_ON",
",",
"STATE_RETURNING",
",",
"STATE_ERR... | [
11,
0
] | [
17,
5
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions | (hass, push_registration) | Test we get the expected actions from a mobile_app. | Test we get the expected actions from a mobile_app. | async def test_get_actions(hass, push_registration):
"""Test we get the expected actions from a mobile_app."""
webhook_id = push_registration["webhook_id"]
device_id = hass.data[DOMAIN][DATA_DEVICES][webhook_id].id
assert await async_get_device_automations(hass, "action", device_id) == [
{"doma... | [
"async",
"def",
"test_get_actions",
"(",
"hass",
",",
"push_registration",
")",
":",
"webhook_id",
"=",
"push_registration",
"[",
"\"webhook_id\"",
"]",
"device_id",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_DEVICES",
"]",
"[",
"webhook_id",
"]"... | [
8,
0
] | [
20,
42
] | python | en | ['en', 'en', 'en'] | True |
test_action | (hass, push_registration) | Test for turn_on and turn_off actions. | Test for turn_on and turn_off actions. | async def test_action(hass, push_registration):
"""Test for turn_on and turn_off actions."""
webhook_id = push_registration["webhook_id"]
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"trigger": ... | [
"async",
"def",
"test_action",
"(",
"hass",
",",
"push_registration",
")",
":",
"webhook_id",
"=",
"push_registration",
"[",
"\"webhook_id\"",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
... | [
23,
0
] | [
67,
5
] | python | en | ['en', 'en', 'en'] | True |
vera_component_factory | () | Return a factory for initializing the vera component. | Return a factory for initializing the vera component. | def vera_component_factory():
"""Return a factory for initializing the vera component."""
with patch("pyvera.VeraController") as vera_controller_class_mock:
yield ComponentFactory(vera_controller_class_mock) | [
"def",
"vera_component_factory",
"(",
")",
":",
"with",
"patch",
"(",
"\"pyvera.VeraController\"",
")",
"as",
"vera_controller_class_mock",
":",
"yield",
"ComponentFactory",
"(",
"vera_controller_class_mock",
")"
] | [
11,
0
] | [
14,
58
] | python | en | ['en', 'en', 'en'] | True |
mock_controller_client | () | Mock a successful client. | Mock a successful client. | def mock_controller_client():
"""Mock a successful client."""
with patch(
"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient",
update=False,
) as service_mock:
service_mock.return_value.get_data.return_value = {
"station_code": TEST_STATION_CODE
... | [
"def",
"mock_controller_client",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient\"",
",",
"update",
"=",
"False",
",",
")",
"as",
"service_mock",
":",
"service_mock",
".",
"return_value",
".",
"get_data",
".... | [
15,
0
] | [
26,
26
] | python | en | ['en', 'en', 'en'] | True |
mock_setup | () | Prevent setup. | Prevent setup. | def mock_setup():
"""Prevent setup."""
with patch(
"homeassistant.components.meteoclimatic.async_setup_entry",
return_value=True,
):
yield | [
"def",
"mock_setup",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteoclimatic.async_setup_entry\"",
",",
"return_value",
"=",
"True",
",",
")",
":",
"yield"
] | [
30,
0
] | [
36,
13
] | python | en | ['en', 'pt', 'en'] | False |
test_user | (hass, client) | Test user config. | Test user config. | async def test_user(hass, client):
"""Test user config."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
# test with all provided
result = awa... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"client",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"assert",
"resu... | [
39,
0
] | [
56,
65
] | python | en | ['en', 'da', 'en'] | True |
test_not_found | (hass) | Test when we have the station code is not found. | Test when we have the station code is not found. | async def test_not_found(hass):
"""Test when we have the station code is not found."""
with patch(
"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient.weather_at_station",
side_effect=StationNotFound(TEST_STATION_CODE),
):
result = await hass.config_entries.flow.a... | [
"async",
"def",
"test_not_found",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient.weather_at_station\"",
",",
"side_effect",
"=",
"StationNotFound",
"(",
"TEST_STATION_CODE",
")",
",",
")",
":",
"result"... | [
59,
0
] | [
72,
54
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_error | (hass) | Test when we have an unknown error fetching station data. | Test when we have an unknown error fetching station data. | async def test_unknown_error(hass):
"""Test when we have an unknown error fetching station data."""
with patch(
"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient.weather_at_station",
side_effect=MeteoclimaticError,
):
result = await hass.config_entries.flow.asyn... | [
"async",
"def",
"test_unknown_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteoclimatic.config_flow.MeteoclimaticClient.weather_at_station\"",
",",
"side_effect",
"=",
"MeteoclimaticError",
",",
")",
":",
"result",
"=",
"await",
"hass",
... | [
75,
0
] | [
87,
44
] | python | en | ['en', 'en', 'en'] | True |
action_trace_append | (variables, path) | Append a TraceElement to trace[path]. | Append a TraceElement to trace[path]. | def action_trace_append(variables, path):
"""Append a TraceElement to trace[path]."""
trace_element = TraceElement(variables, path)
trace_append_element(trace_element, ACTION_TRACE_NODE_MAX_LEN)
return trace_element | [
"def",
"action_trace_append",
"(",
"variables",
",",
"path",
")",
":",
"trace_element",
"=",
"TraceElement",
"(",
"variables",
",",
"path",
")",
"trace_append_element",
"(",
"trace_element",
",",
"ACTION_TRACE_NODE_MAX_LEN",
")",
"return",
"trace_element"
] | [
137,
0
] | [
141,
24
] | python | en | ['en', 'en', 'en'] | True |
trace_action | (hass, script_run, stop, variables) | Trace action execution. | Trace action execution. | async def trace_action(hass, script_run, stop, variables):
"""Trace action execution."""
path = trace_path_get()
trace_element = action_trace_append(variables, path)
trace_stack_push(trace_stack_cv, trace_element)
trace_id = trace_id_get()
if trace_id:
key = trace_id[0]
run_id =... | [
"async",
"def",
"trace_action",
"(",
"hass",
",",
"script_run",
",",
"stop",
",",
"variables",
")",
":",
"path",
"=",
"trace_path_get",
"(",
")",
"trace_element",
"=",
"action_trace_append",
"(",
"variables",
",",
"path",
")",
"trace_stack_push",
"(",
"trace_s... | [
145,
0
] | [
204,
39
] | python | en | ['es', 'en', 'en'] | True |
make_script_schema | (schema, default_script_mode, extra=vol.PREVENT_EXTRA) | Make a schema for a component that uses the script helper. | Make a schema for a component that uses the script helper. | def make_script_schema(schema, default_script_mode, extra=vol.PREVENT_EXTRA):
"""Make a schema for a component that uses the script helper."""
return vol.Schema(
{
**schema,
vol.Optional(CONF_MODE, default=default_script_mode): vol.In(
SCRIPT_MODE_CHOICES
... | [
"def",
"make_script_schema",
"(",
"schema",
",",
"default_script_mode",
",",
"extra",
"=",
"vol",
".",
"PREVENT_EXTRA",
")",
":",
"return",
"vol",
".",
"Schema",
"(",
"{",
"*",
"*",
"schema",
",",
"vol",
".",
"Optional",
"(",
"CONF_MODE",
",",
"default",
... | [
207,
0
] | [
223,
5
] | python | en | ['en', 'en', 'en'] | True |
async_validate_actions_config | (
hass: HomeAssistant, actions: list[ConfigType]
) | Validate a list of actions. | Validate a list of actions. | async def async_validate_actions_config(
hass: HomeAssistant, actions: list[ConfigType]
) -> list[ConfigType]:
"""Validate a list of actions."""
return await asyncio.gather(
*(async_validate_action_config(hass, action) for action in actions)
) | [
"async",
"def",
"async_validate_actions_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"actions",
":",
"list",
"[",
"ConfigType",
"]",
")",
"->",
"list",
"[",
"ConfigType",
"]",
":",
"return",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"(",
"async_valida... | [
236,
0
] | [
242,
5
] | python | en | ['en', 'en', 'en'] | True |
async_validate_action_config | (
hass: HomeAssistant, config: ConfigType
) | Validate config. | Validate config. | async def async_validate_action_config(
hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
action_type = cv.determine_script_action(config)
if action_type in STATIC_VALIDATION_ACTION_TYPES:
pass
elif action_type == cv.SCRIPT_ACTION_DEVICE_AUTOMATION:
pl... | [
"async",
"def",
"async_validate_action_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"ConfigType",
":",
"action_type",
"=",
"cv",
".",
"determine_script_action",
"(",
"config",
")",
"if",
"action_type",
"in",
"STATIC_VALI... | [
245,
0
] | [
294,
17
] | python | en | ['en', 'la', 'it'] | False |
_async_stop_scripts_after_shutdown | (hass, point_in_time) | Stop running Script objects started after shutdown. | Stop running Script objects started after shutdown. | async def _async_stop_scripts_after_shutdown(hass, point_in_time):
"""Stop running Script objects started after shutdown."""
running_scripts = [
script for script in hass.data[DATA_SCRIPTS] if script["instance"].is_running
]
if running_scripts:
names = ", ".join([script["instance"].name ... | [
"async",
"def",
"_async_stop_scripts_after_shutdown",
"(",
"hass",
",",
"point_in_time",
")",
":",
"running_scripts",
"=",
"[",
"script",
"for",
"script",
"in",
"hass",
".",
"data",
"[",
"DATA_SCRIPTS",
"]",
"if",
"script",
"[",
"\"instance\"",
"]",
".",
"is_r... | [
873,
0
] | [
886,
9
] | python | en | ['da', 'en', 'en'] | True |
_async_stop_scripts_at_shutdown | (hass, event) | Stop running Script objects started before shutdown. | Stop running Script objects started before shutdown. | async def _async_stop_scripts_at_shutdown(hass, event):
"""Stop running Script objects started before shutdown."""
async_call_later(
hass, _SHUTDOWN_MAX_WAIT, partial(_async_stop_scripts_after_shutdown, hass)
)
running_scripts = [
script
for script in hass.data[DATA_SCRIPTS]
... | [
"async",
"def",
"_async_stop_scripts_at_shutdown",
"(",
"hass",
",",
"event",
")",
":",
"async_call_later",
"(",
"hass",
",",
"_SHUTDOWN_MAX_WAIT",
",",
"partial",
"(",
"_async_stop_scripts_after_shutdown",
",",
"hass",
")",
")",
"running_scripts",
"=",
"[",
"script... | [
889,
0
] | [
905,
9
] | python | en | ['en', 'en', 'en'] | True |
_referenced_extract_ids | (data: dict[str, Any], key: str, found: set[str]) | Extract referenced IDs. | Extract referenced IDs. | def _referenced_extract_ids(data: dict[str, Any], key: str, found: set[str]) -> None:
"""Extract referenced IDs."""
if not data:
return
item_ids = data.get(key)
if item_ids is None or isinstance(item_ids, template.Template):
return
if isinstance(item_ids, str):
found.add(i... | [
"def",
"_referenced_extract_ids",
"(",
"data",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
",",
"key",
":",
"str",
",",
"found",
":",
"set",
"[",
"str",
"]",
")",
"->",
"None",
":",
"if",
"not",
"data",
":",
"return",
"item_ids",
"=",
"data",
".",
... | [
911,
0
] | [
925,
30
] | python | en | ['en', 'en', 'en'] | True |
breakpoint_clear | (hass, key, run_id, node) | Clear a breakpoint. | Clear a breakpoint. | def breakpoint_clear(hass, key, run_id, node):
"""Clear a breakpoint."""
run_id = run_id or RUN_ID_ANY
breakpoints = hass.data[DATA_SCRIPT_BREAKPOINTS]
if key not in breakpoints or run_id not in breakpoints[key]:
return
breakpoints[key][run_id].discard(node) | [
"def",
"breakpoint_clear",
"(",
"hass",
",",
"key",
",",
"run_id",
",",
"node",
")",
":",
"run_id",
"=",
"run_id",
"or",
"RUN_ID_ANY",
"breakpoints",
"=",
"hass",
".",
"data",
"[",
"DATA_SCRIPT_BREAKPOINTS",
"]",
"if",
"key",
"not",
"in",
"breakpoints",
"o... | [
1347,
0
] | [
1353,
42
] | python | en | ['en', 'en', 'en'] | True |
breakpoint_clear_all | (hass: HomeAssistant) | Clear all breakpoints. | Clear all breakpoints. | def breakpoint_clear_all(hass: HomeAssistant) -> None:
"""Clear all breakpoints."""
hass.data[DATA_SCRIPT_BREAKPOINTS] = {} | [
"def",
"breakpoint_clear_all",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"hass",
".",
"data",
"[",
"DATA_SCRIPT_BREAKPOINTS",
"]",
"=",
"{",
"}"
] | [
1357,
0
] | [
1359,
43
] | python | en | ['en', 'en', 'en'] | True |
breakpoint_set | (hass, key, run_id, node) | Set a breakpoint. | Set a breakpoint. | def breakpoint_set(hass, key, run_id, node):
"""Set a breakpoint."""
run_id = run_id or RUN_ID_ANY
breakpoints = hass.data[DATA_SCRIPT_BREAKPOINTS]
if key not in breakpoints:
breakpoints[key] = {}
if run_id not in breakpoints[key]:
breakpoints[key][run_id] = set()
breakpoints[key... | [
"def",
"breakpoint_set",
"(",
"hass",
",",
"key",
",",
"run_id",
",",
"node",
")",
":",
"run_id",
"=",
"run_id",
"or",
"RUN_ID_ANY",
"breakpoints",
"=",
"hass",
".",
"data",
"[",
"DATA_SCRIPT_BREAKPOINTS",
"]",
"if",
"key",
"not",
"in",
"breakpoints",
":",... | [
1363,
0
] | [
1371,
38
] | python | en | ['en', 'en', 'en'] | True |
breakpoint_list | (hass: HomeAssistant) | List breakpoints. | List breakpoints. | def breakpoint_list(hass: HomeAssistant) -> list[dict[str, Any]]:
"""List breakpoints."""
breakpoints = hass.data[DATA_SCRIPT_BREAKPOINTS]
return [
{"key": key, "run_id": run_id, "node": node}
for key in breakpoints
for run_id in breakpoints[key]
for node in breakpoints[key]... | [
"def",
"breakpoint_list",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"breakpoints",
"=",
"hass",
".",
"data",
"[",
"DATA_SCRIPT_BREAKPOINTS",
"]",
"return",
"[",
"{",
"\"key\"",
":",
"key",
... | [
1375,
0
] | [
1384,
5
] | python | en | ['en', 'fy', 'en'] | False |
debug_continue | (hass, key, run_id) | Continue execution of a halted script. | Continue execution of a halted script. | def debug_continue(hass, key, run_id):
"""Continue execution of a halted script."""
# Clear any wildcard breakpoint
breakpoint_clear(hass, key, run_id, NODE_ANY)
signal = SCRIPT_DEBUG_CONTINUE_STOP.format(key, run_id)
async_dispatcher_send(hass, signal, "continue") | [
"def",
"debug_continue",
"(",
"hass",
",",
"key",
",",
"run_id",
")",
":",
"# Clear any wildcard breakpoint",
"breakpoint_clear",
"(",
"hass",
",",
"key",
",",
"run_id",
",",
"NODE_ANY",
")",
"signal",
"=",
"SCRIPT_DEBUG_CONTINUE_STOP",
".",
"format",
"(",
"key"... | [
1388,
0
] | [
1394,
51
] | python | en | ['en', 'en', 'en'] | True |
debug_step | (hass, key, run_id) | Single step a halted script. | Single step a halted script. | def debug_step(hass, key, run_id):
"""Single step a halted script."""
# Set a wildcard breakpoint
breakpoint_set(hass, key, run_id, NODE_ANY)
signal = SCRIPT_DEBUG_CONTINUE_STOP.format(key, run_id)
async_dispatcher_send(hass, signal, "continue") | [
"def",
"debug_step",
"(",
"hass",
",",
"key",
",",
"run_id",
")",
":",
"# Set a wildcard breakpoint",
"breakpoint_set",
"(",
"hass",
",",
"key",
",",
"run_id",
",",
"NODE_ANY",
")",
"signal",
"=",
"SCRIPT_DEBUG_CONTINUE_STOP",
".",
"format",
"(",
"key",
",",
... | [
1398,
0
] | [
1404,
51
] | python | en | ['en', 'en', 'en'] | True |
debug_stop | (hass, key, run_id) | Stop execution of a running or halted script. | Stop execution of a running or halted script. | def debug_stop(hass, key, run_id):
"""Stop execution of a running or halted script."""
signal = SCRIPT_DEBUG_CONTINUE_STOP.format(key, run_id)
async_dispatcher_send(hass, signal, "stop") | [
"def",
"debug_stop",
"(",
"hass",
",",
"key",
",",
"run_id",
")",
":",
"signal",
"=",
"SCRIPT_DEBUG_CONTINUE_STOP",
".",
"format",
"(",
"key",
",",
"run_id",
")",
"async_dispatcher_send",
"(",
"hass",
",",
"signal",
",",
"\"stop\"",
")"
] | [
1408,
0
] | [
1411,
47
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun.async_run | (self) | Run script. | Run script. | async def async_run(self) -> None:
"""Run script."""
try:
self._log("Running %s", self._script.running_description)
for self._step, self._action in enumerate(self._script.sequence):
if self._stop.is_set():
script_execution_set("cancelled")
... | [
"async",
"def",
"async_run",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"self",
".",
"_log",
"(",
"\"Running %s\"",
",",
"self",
".",
"_script",
".",
"running_description",
")",
"for",
"self",
".",
"_step",
",",
"self",
".",
"_action",
"in",
"enu... | [
344,
4
] | [
361,
26
] | python | en | ['ro', 'ms', 'en'] | False |
_ScriptRun.async_stop | (self) | Stop script run. | Stop script run. | async def async_stop(self) -> None:
"""Stop script run."""
self._stop.set()
await self._stopped.wait() | [
"async",
"def",
"async_stop",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_stop",
".",
"set",
"(",
")",
"await",
"self",
".",
"_stopped",
".",
"wait",
"(",
")"
] | [
385,
4
] | [
388,
34
] | python | de | ['de', 'ms', 'en'] | False |
_ScriptRun._async_delay_step | (self) | Handle delay. | Handle delay. | async def _async_delay_step(self):
"""Handle delay."""
delay = self._get_pos_time_period_template(CONF_DELAY)
self._step_log(f"delay {delay}")
delay = delay.total_seconds()
self._changed()
trace_set_result(delay=delay, done=False)
try:
async with asy... | [
"async",
"def",
"_async_delay_step",
"(",
"self",
")",
":",
"delay",
"=",
"self",
".",
"_get_pos_time_period_template",
"(",
"CONF_DELAY",
")",
"self",
".",
"_step_log",
"(",
"f\"delay {delay}\"",
")",
"delay",
"=",
"delay",
".",
"total_seconds",
"(",
")",
"se... | [
439,
4
] | [
452,
52
] | python | en | ['it', 'es', 'en'] | False |
_ScriptRun._async_wait_template_step | (self) | Handle a wait template. | Handle a wait template. | async def _async_wait_template_step(self):
"""Handle a wait template."""
if CONF_TIMEOUT in self._action:
timeout = self._get_pos_time_period_template(CONF_TIMEOUT).total_seconds()
else:
timeout = None
self._step_log("wait template", timeout)
self._varia... | [
"async",
"def",
"_async_wait_template_step",
"(",
"self",
")",
":",
"if",
"CONF_TIMEOUT",
"in",
"self",
".",
"_action",
":",
"timeout",
"=",
"self",
".",
"_get_pos_time_period_template",
"(",
"CONF_TIMEOUT",
")",
".",
"total_seconds",
"(",
")",
"else",
":",
"t... | [
454,
4
] | [
504,
19
] | python | en | ['en', 'fr', 'en'] | True |
_ScriptRun._async_run_long_action | (self, long_task: asyncio.Task) | Run a long task while monitoring for stop request. | Run a long task while monitoring for stop request. | async def _async_run_long_action(self, long_task: asyncio.Task) -> None:
"""Run a long task while monitoring for stop request."""
async def async_cancel_long_task() -> None:
# Stop long task and wait for it to finish.
long_task.cancel()
with suppress(Exception):
... | [
"async",
"def",
"_async_run_long_action",
"(",
"self",
",",
"long_task",
":",
"asyncio",
".",
"Task",
")",
"->",
"None",
":",
"async",
"def",
"async_cancel_long_task",
"(",
")",
"->",
"None",
":",
"# Stop long task and wait for it to finish.",
"long_task",
".",
"c... | [
506,
4
] | [
537,
42
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_call_service_step | (self) | Call the service specified in the action. | Call the service specified in the action. | async def _async_call_service_step(self):
"""Call the service specified in the action."""
self._step_log("call service")
params = service.async_prepare_call_from_config(
self._hass, self._action, self._variables
)
running_script = (
params[CONF_DOMAIN] =... | [
"async",
"def",
"_async_call_service_step",
"(",
"self",
")",
":",
"self",
".",
"_step_log",
"(",
"\"call service\"",
")",
"params",
"=",
"service",
".",
"async_prepare_call_from_config",
"(",
"self",
".",
"_hass",
",",
"self",
".",
"_action",
",",
"self",
"."... | [
539,
4
] | [
573,
55
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_device_step | (self) | Perform the device automation specified in the action. | Perform the device automation specified in the action. | async def _async_device_step(self):
"""Perform the device automation specified in the action."""
self._step_log("device automation")
platform = await device_automation.async_get_device_automation_platform(
self._hass, self._action[CONF_DOMAIN], "action"
)
await platfo... | [
"async",
"def",
"_async_device_step",
"(",
"self",
")",
":",
"self",
".",
"_step_log",
"(",
"\"device automation\"",
")",
"platform",
"=",
"await",
"device_automation",
".",
"async_get_device_automation_platform",
"(",
"self",
".",
"_hass",
",",
"self",
".",
"_act... | [
575,
4
] | [
583,
9
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_scene_step | (self) | Activate the scene specified in the action. | Activate the scene specified in the action. | async def _async_scene_step(self):
"""Activate the scene specified in the action."""
self._step_log("activate scene")
trace_set_result(scene=self._action[CONF_SCENE])
await self._hass.services.async_call(
scene.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID:... | [
"async",
"def",
"_async_scene_step",
"(",
"self",
")",
":",
"self",
".",
"_step_log",
"(",
"\"activate scene\"",
")",
"trace_set_result",
"(",
"scene",
"=",
"self",
".",
"_action",
"[",
"CONF_SCENE",
"]",
")",
"await",
"self",
".",
"_hass",
".",
"services",
... | [
585,
4
] | [
595,
9
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_event_step | (self) | Fire an event. | Fire an event. | async def _async_event_step(self):
"""Fire an event."""
self._step_log(self._action.get(CONF_ALIAS, self._action[CONF_EVENT]))
event_data = {}
for conf in (CONF_EVENT_DATA, CONF_EVENT_DATA_TEMPLATE):
if conf not in self._action:
continue
try:
... | [
"async",
"def",
"_async_event_step",
"(",
"self",
")",
":",
"self",
".",
"_step_log",
"(",
"self",
".",
"_action",
".",
"get",
"(",
"CONF_ALIAS",
",",
"self",
".",
"_action",
"[",
"CONF_EVENT",
"]",
")",
")",
"event_data",
"=",
"{",
"}",
"for",
"conf",... | [
597,
4
] | [
617,
9
] | python | en | ['en', 'lb', 'en'] | True |
_ScriptRun._async_condition_step | (self) | Test if condition is matching. | Test if condition is matching. | async def _async_condition_step(self):
"""Test if condition is matching."""
self._script.last_action = self._action.get(
CONF_ALIAS, self._action[CONF_CONDITION]
)
cond = await self._async_get_condition(self._action)
try:
trace_element = trace_stack_top(tr... | [
"async",
"def",
"_async_condition_step",
"(",
"self",
")",
":",
"self",
".",
"_script",
".",
"last_action",
"=",
"self",
".",
"_action",
".",
"get",
"(",
"CONF_ALIAS",
",",
"self",
".",
"_action",
"[",
"CONF_CONDITION",
"]",
")",
"cond",
"=",
"await",
"s... | [
619,
4
] | [
637,
29
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_repeat_step | (self) | Repeat a sequence. | Repeat a sequence. | async def _async_repeat_step(self):
"""Repeat a sequence."""
description = self._action.get(CONF_ALIAS, "sequence")
repeat = self._action[CONF_REPEAT]
saved_repeat_vars = self._variables.get("repeat")
def set_repeat_var(iteration, count=None):
repeat_vars = {"first"... | [
"async",
"def",
"_async_repeat_step",
"(",
"self",
")",
":",
"description",
"=",
"self",
".",
"_action",
".",
"get",
"(",
"CONF_ALIAS",
",",
"\"sequence\"",
")",
"repeat",
"=",
"self",
".",
"_action",
"[",
"CONF_REPEAT",
"]",
"saved_repeat_vars",
"=",
"self"... | [
661,
4
] | [
738,
41
] | python | en | ['en', 'en', 'it'] | True |
_ScriptRun._async_choose_step | (self) | Choose a sequence. | Choose a sequence. | async def _async_choose_step(self) -> None:
"""Choose a sequence."""
# pylint: disable=protected-access
choose_data = await self._script._async_get_choose_data(self._step)
with trace_path("choose"):
for idx, (conditions, script) in enumerate(choose_data["choices"]):
... | [
"async",
"def",
"_async_choose_step",
"(",
"self",
")",
"->",
"None",
":",
"# pylint: disable=protected-access",
"choose_data",
"=",
"await",
"self",
".",
"_script",
".",
"_async_get_choose_data",
"(",
"self",
".",
"_step",
")",
"with",
"trace_path",
"(",
"\"choos... | [
740,
4
] | [
760,
68
] | python | en | ['en', 'en', 'en'] | True |
_ScriptRun._async_wait_for_trigger_step | (self) | Wait for a trigger event. | Wait for a trigger event. | async def _async_wait_for_trigger_step(self):
"""Wait for a trigger event."""
if CONF_TIMEOUT in self._action:
timeout = self._get_pos_time_period_template(CONF_TIMEOUT).total_seconds()
else:
timeout = None
self._step_log("wait for trigger", timeout)
var... | [
"async",
"def",
"_async_wait_for_trigger_step",
"(",
"self",
")",
":",
"if",
"CONF_TIMEOUT",
"in",
"self",
".",
"_action",
":",
"timeout",
"=",
"self",
".",
"_get_pos_time_period_template",
"(",
"CONF_TIMEOUT",
")",
".",
"total_seconds",
"(",
")",
"else",
":",
... | [
762,
4
] | [
815,
29
] | 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.