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_unexpected_exception | (hass) | Test we handle an unexpected exception. | Test we handle an unexpected exception. | async def test_form_unexpected_exception(hass):
"""Test we handle an unexpected exception."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch("faadelays.Airport.update", side_effect=HomeAssistantError):
result2 = aw... | [
"async",
"def",
"test_form_unexpected_exception",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}... | [
101,
0
] | [
116,
51
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Rain Bird switches over a Rain Bird controller. | Set up Rain Bird switches over a Rain Bird controller. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Rain Bird switches over a Rain Bird controller."""
if discovery_info is None:
return
controller: RainbirdController = hass.data[DATA_RAINBIRD][
discovery_info[RAINBIRD_CONTROLLER]
]
available_stations: A... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"controller",
":",
"RainbirdController",
"=",
"hass",
".",
"data",
"[",
"DATA_RAINBIRD"... | [
29,
0
] | [
83,
5
] | python | en | ['en', 'lb', 'en'] | True |
RainBirdSwitch.__init__ | (self, controller: RainbirdController, zone, time, name) | Initialize a Rain Bird Switch Device. | Initialize a Rain Bird Switch Device. | def __init__(self, controller: RainbirdController, zone, time, name):
"""Initialize a Rain Bird Switch Device."""
self._rainbird = controller
self._zone = zone
self._name = name
self._state = None
self._duration = time
self._attributes = {ATTR_DURATION: self._dura... | [
"def",
"__init__",
"(",
"self",
",",
"controller",
":",
"RainbirdController",
",",
"zone",
",",
"time",
",",
"name",
")",
":",
"self",
".",
"_rainbird",
"=",
"controller",
"self",
".",
"_zone",
"=",
"zone",
"self",
".",
"_name",
"=",
"name",
"self",
".... | [
89,
4
] | [
96,
78
] | python | en | ['en', 'pl', 'en'] | True |
RainBirdSwitch.extra_state_attributes | (self) | Return state attributes. | Return state attributes. | def extra_state_attributes(self):
"""Return state attributes."""
return self._attributes | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
99,
4
] | [
101,
31
] | python | en | ['en', 'co', 'en'] | True |
RainBirdSwitch.name | (self) | Get the name of the switch. | Get the name of the switch. | def name(self):
"""Get the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
104,
4
] | [
106,
25
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
if self._rainbird.irrigate_zone(
int(self._zone),
int(kwargs[ATTR_DURATION] if ATTR_DURATION in kwargs else self._duration),
):
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rainbird",
".",
"irrigate_zone",
"(",
"int",
"(",
"self",
".",
"_zone",
")",
",",
"int",
"(",
"kwargs",
"[",
"ATTR_DURATION",
"]",
"if",
"ATTR_DURATION",
"in",
"kw... | [
108,
4
] | [
114,
30
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
if self._rainbird.stop_irrigation():
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rainbird",
".",
"stop_irrigation",
"(",
")",
":",
"self",
".",
"_state",
"=",
"False"
] | [
116,
4
] | [
119,
31
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.update | (self) | Update switch status. | Update switch status. | def update(self):
"""Update switch status."""
self._state = self._rainbird.get_zone_state(self._zone) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_rainbird",
".",
"get_zone_state",
"(",
"self",
".",
"_zone",
")"
] | [
121,
4
] | [
123,
63
] | python | en | ['en', 'sn', 'en'] | True |
RainBirdSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
126,
4
] | [
128,
26
] | python | en | ['en', 'fy', 'en'] | True |
test_deprecated_base_class | (caplog) | Test deprecated base class. | Test deprecated base class. | def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomCover(cover.CoverDevice):
pass
CustomCover()
assert "CoverDevice is deprecated, modify CustomCover" in caplog.text | [
"def",
"test_deprecated_base_class",
"(",
"caplog",
")",
":",
"class",
"CustomCover",
"(",
"cover",
".",
"CoverDevice",
")",
":",
"pass",
"CustomCover",
"(",
")",
"assert",
"\"CoverDevice is deprecated, modify CustomCover\"",
"in",
"caplog",
".",
"text"
] | [
4,
0
] | [
11,
73
] | python | en | ['en', 'en', 'en'] | True |
prepare_tracing | () | Prepare tracing. | Prepare tracing. | def prepare_tracing():
"""Prepare tracing."""
trace.trace_get() | [
"def",
"prepare_tracing",
"(",
")",
":",
"trace",
".",
"trace_get",
"(",
")"
] | [
40,
0
] | [
42,
21
] | python | en | ['en', 'it', 'en'] | False |
compare_trigger_item | (actual_trigger, expected_trigger) | Compare trigger data description. | Compare trigger data description. | def compare_trigger_item(actual_trigger, expected_trigger):
"""Compare trigger data description."""
assert actual_trigger["description"] == expected_trigger["description"] | [
"def",
"compare_trigger_item",
"(",
"actual_trigger",
",",
"expected_trigger",
")",
":",
"assert",
"actual_trigger",
"[",
"\"description\"",
"]",
"==",
"expected_trigger",
"[",
"\"description\"",
"]"
] | [
45,
0
] | [
47,
75
] | python | en | ['sv', 'it', 'en'] | False |
compare_result_item | (key, actual, expected) | Compare an item in the result dict. | Compare an item in the result dict. | def compare_result_item(key, actual, expected):
"""Compare an item in the result dict."""
if key == "wait" and (expected.get("trigger") is not None):
assert "trigger" in actual
expected_trigger = expected.pop("trigger")
actual_trigger = actual.pop("trigger")
compare_trigger_item(... | [
"def",
"compare_result_item",
"(",
"key",
",",
"actual",
",",
"expected",
")",
":",
"if",
"key",
"==",
"\"wait\"",
"and",
"(",
"expected",
".",
"get",
"(",
"\"trigger\"",
")",
"is",
"not",
"None",
")",
":",
"assert",
"\"trigger\"",
"in",
"actual",
"expec... | [
50,
0
] | [
58,
29
] | python | en | ['en', 'en', 'en'] | True |
assert_element | (trace_element, expected_element, path) | Assert a trace element is as expected.
Note: Unused variable 'path' is passed to get helpful errors from pytest.
| Assert a trace element is as expected. | def assert_element(trace_element, expected_element, path):
"""Assert a trace element is as expected.
Note: Unused variable 'path' is passed to get helpful errors from pytest.
"""
expected_result = expected_element.get("result", {})
# Check that every item in expected_element is present and equal i... | [
"def",
"assert_element",
"(",
"trace_element",
",",
"expected_element",
",",
"path",
")",
":",
"expected_result",
"=",
"expected_element",
".",
"get",
"(",
"\"result\"",
",",
"{",
"}",
")",
"# Check that every item in expected_element is present and equal in trace_element",... | [
61,
0
] | [
90,
43
] | python | en | ['en', 'en', 'en'] | True |
assert_action_trace | (expected, expected_script_execution="finished") | Assert a trace condition sequence is as expected. | Assert a trace condition sequence is as expected. | def assert_action_trace(expected, expected_script_execution="finished"):
"""Assert a trace condition sequence is as expected."""
action_trace = trace.trace_get(clear=False)
script_execution = trace.script_execution_get()
trace.trace_clear()
expected_trace_keys = list(expected.keys())
assert list... | [
"def",
"assert_action_trace",
"(",
"expected",
",",
"expected_script_execution",
"=",
"\"finished\"",
")",
":",
"action_trace",
"=",
"trace",
".",
"trace_get",
"(",
"clear",
"=",
"False",
")",
"script_execution",
"=",
"trace",
".",
"script_execution_get",
"(",
")"... | [
93,
0
] | [
106,
56
] | python | en | ['en', 'en', 'en'] | True |
async_watch_for_action | (script_obj, message) | Watch for message in last_action. | Watch for message in last_action. | def async_watch_for_action(script_obj, message):
"""Watch for message in last_action."""
flag = asyncio.Event()
@callback
def check_action():
if script_obj.last_action and message in script_obj.last_action:
flag.set()
script_obj.change_listener = check_action
assert script_... | [
"def",
"async_watch_for_action",
"(",
"script_obj",
",",
"message",
")",
":",
"flag",
"=",
"asyncio",
".",
"Event",
"(",
")",
"@",
"callback",
"def",
"check_action",
"(",
")",
":",
"if",
"script_obj",
".",
"last_action",
"and",
"message",
"in",
"script_obj",... | [
109,
0
] | [
120,
15
] | python | en | ['en', 'en', 'en'] | True |
test_firing_event_basic | (hass, caplog) | Test the firing of events. | Test the firing of events. | async def test_firing_event_basic(hass, caplog):
"""Test the firing of events."""
event = "test_event"
context = Context()
events = async_capture_events(hass, event)
alias = "event step"
sequence = cv.SCRIPT_SCHEMA(
{"alias": alias, "event": event, "event_data": {"hello": "world"}}
... | [
"async",
"def",
"test_firing_event_basic",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"context",
"=",
"Context",
"(",
")",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"alias",
"=",
"\"event step\"",
"sequen... | [
123,
0
] | [
158,
5
] | python | en | ['en', 'en', 'en'] | True |
test_firing_event_template | (hass) | Test the firing of events. | Test the firing of events. | async def test_firing_event_template(hass):
"""Test the firing of events."""
event = "test_event"
context = Context()
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
{
"event": event,
"event_data": {
"dict": {
... | [
"async",
"def",
"test_firing_event_template",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"context",
"=",
"Context",
"(",
")",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
... | [
161,
0
] | [
218,
5
] | python | en | ['en', 'en', 'en'] | True |
test_calling_service_basic | (hass, caplog) | Test the calling of a service. | Test the calling of a service. | async def test_calling_service_basic(hass, caplog):
"""Test the calling of a service."""
context = Context()
calls = async_mock_service(hass, "test", "script")
alias = "service step"
sequence = cv.SCRIPT_SCHEMA(
{"alias": alias, "service": "test.script", "data": {"hello": "world"}}
)
... | [
"async",
"def",
"test_calling_service_basic",
"(",
"hass",
",",
"caplog",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"script\"",
")",
"alias",
"=",
"\"service step\"",
"sequence",
"="... | [
221,
0
] | [
257,
5
] | python | en | ['en', 'en', 'en'] | True |
test_calling_service_template | (hass) | Test the calling of a service. | Test the calling of a service. | async def test_calling_service_template(hass):
"""Test the calling of a service."""
context = Context()
calls = async_mock_service(hass, "test", "script")
sequence = cv.SCRIPT_SCHEMA(
{
"service_template": """
{% if True %}
test.script
{% else... | [
"async",
"def",
"test_calling_service_template",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"script\"",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"s... | [
260,
0
] | [
310,
5
] | python | en | ['en', 'en', 'en'] | True |
test_data_template_with_templated_key | (hass) | Test the calling of a service with a data_template with a templated key. | Test the calling of a service with a data_template with a templated key. | async def test_data_template_with_templated_key(hass):
"""Test the calling of a service with a data_template with a templated key."""
context = Context()
calls = async_mock_service(hass, "test", "script")
sequence = cv.SCRIPT_SCHEMA(
{"service": "test.script", "data_template": {"{{ hello_var }}... | [
"async",
"def",
"test_data_template_with_templated_key",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"script\"",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{"... | [
313,
0
] | [
349,
5
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_runs_no_wait | (hass) | Test multiple runs with no wait in script. | Test multiple runs with no wait in script. | async def test_multiple_runs_no_wait(hass):
"""Test multiple runs with no wait in script."""
logger = logging.getLogger("TEST")
calls = []
heard_event = asyncio.Event()
async def async_simulate_long_service(service):
"""Simulate a service that takes a not insignificant time."""
fire... | [
"async",
"def",
"test_multiple_runs_no_wait",
"(",
"hass",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"TEST\"",
")",
"calls",
"=",
"[",
"]",
"heard_event",
"=",
"asyncio",
".",
"Event",
"(",
")",
"async",
"def",
"async_simulate_long_service",... | [
352,
0
] | [
422,
26
] | python | en | ['en', 'en', 'en'] | True |
test_activating_scene | (hass, caplog) | Test the activation of a scene. | Test the activation of a scene. | async def test_activating_scene(hass, caplog):
"""Test the activation of a scene."""
context = Context()
calls = async_mock_service(hass, scene.DOMAIN, SERVICE_TURN_ON)
alias = "scene step"
sequence = cv.SCRIPT_SCHEMA({"alias": alias, "scene": "scene.hello"})
script_obj = script.Script(hass, se... | [
"async",
"def",
"test_activating_scene",
"(",
"hass",
",",
"caplog",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"scene",
".",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"alias",
"=",
"\"scene step\"",
"se... | [
425,
0
] | [
446,
5
] | python | en | ['en', 'en', 'en'] | True |
test_stop_no_wait | (hass, count) | Test stopping script. | Test stopping script. | async def test_stop_no_wait(hass, count):
"""Test stopping script."""
service_started_sem = asyncio.Semaphore(0)
finish_service_event = asyncio.Event()
event = "test_event"
events = async_capture_events(hass, event)
async def async_simulate_long_service(service):
"""Simulate a service t... | [
"async",
"def",
"test_stop_no_wait",
"(",
"hass",
",",
"count",
")",
":",
"service_started_sem",
"=",
"asyncio",
".",
"Semaphore",
"(",
"0",
")",
"finish_service_event",
"=",
"asyncio",
".",
"Event",
"(",
")",
"event",
"=",
"\"test_event\"",
"events",
"=",
"... | [
450,
0
] | [
497,
27
] | python | en | ['en', 'en', 'en'] | True |
test_delay_basic | (hass) | Test the delay. | Test the delay. | async def test_delay_basic(hass):
"""Test the delay."""
delay_alias = "delay step"
sequence = cv.SCRIPT_SCHEMA({"delay": {"seconds": 5}, "alias": delay_alias})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
delay_started_flag = async_watch_for_action(script_obj, delay_alias)
... | [
"async",
"def",
"test_delay_basic",
"(",
"hass",
")",
":",
"delay_alias",
"=",
"\"delay step\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"delay\"",
":",
"{",
"\"seconds\"",
":",
"5",
"}",
",",
"\"alias\"",
":",
"delay_alias",
"}",
")",
"sc... | [
500,
0
] | [
527,
5
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_runs_delay | (hass) | Test multiple runs with delay in script. | Test multiple runs with delay in script. | async def test_multiple_runs_delay(hass):
"""Test multiple runs with delay in script."""
event = "test_event"
events = async_capture_events(hass, event)
delay = timedelta(seconds=5)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event, "event_data": {"value": 1}},
{"delay":... | [
"async",
"def",
"test_multiple_runs_delay",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"5",
")",
"sequence",
"=",
"cv",
".",
... | [
530,
0
] | [
570,
44
] | python | en | ['en', 'en', 'en'] | True |
test_delay_template_ok | (hass) | Test the delay as a template. | Test the delay as a template. | async def test_delay_template_ok(hass):
"""Test the delay as a template."""
sequence = cv.SCRIPT_SCHEMA({"delay": "00:00:{{ 5 }}"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
delay_started_flag = async_watch_for_action(script_obj, "delay")
try:
hass.async_create_... | [
"async",
"def",
"test_delay_template_ok",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"delay\"",
":",
"\"00:00:{{ 5 }}\"",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"sequence",
",",
"\"Test Na... | [
573,
0
] | [
597,
5
] | python | en | ['en', 'en', 'en'] | True |
test_delay_template_invalid | (hass, caplog) | Test the delay as a template that fails. | Test the delay as a template that fails. | async def test_delay_template_invalid(hass, caplog):
"""Test the delay as a template that fails."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{"delay": "{{ invalid_delay }}"},
{"delay": {"s... | [
"async",
"def",
"test_delay_template_invalid",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",... | [
600,
0
] | [
632,
5
] | python | en | ['en', 'en', 'en'] | True |
test_delay_template_complex_ok | (hass) | Test the delay with a working complex template. | Test the delay with a working complex template. | async def test_delay_template_complex_ok(hass):
"""Test the delay with a working complex template."""
sequence = cv.SCRIPT_SCHEMA({"delay": {"seconds": "{{ 5 }}"}})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
delay_started_flag = async_watch_for_action(script_obj, "delay")
... | [
"async",
"def",
"test_delay_template_complex_ok",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"delay\"",
":",
"{",
"\"seconds\"",
":",
"\"{{ 5 }}\"",
"}",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
... | [
635,
0
] | [
658,
5
] | python | en | ['en', 'en', 'en'] | True |
test_delay_template_complex_invalid | (hass, caplog) | Test the delay with a complex template that fails. | Test the delay with a complex template that fails. | async def test_delay_template_complex_invalid(hass, caplog):
"""Test the delay with a complex template that fails."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{"delay": {"seconds": "{{ invalid_delay }... | [
"async",
"def",
"test_delay_template_complex_invalid",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"e... | [
661,
0
] | [
693,
5
] | python | en | ['en', 'en', 'en'] | True |
test_cancel_delay | (hass) | Test the cancelling while the delay is present. | Test the cancelling while the delay is present. | async def test_cancel_delay(hass):
"""Test the cancelling while the delay is present."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA([{"delay": {"seconds": 5}}, {"event": event}])
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
... | [
"async",
"def",
"test_cancel_delay",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"delay\"",
":",
"{",
"\"seconds\"... | [
696,
0
] | [
731,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wait_basic | (hass, action_type) | Test wait actions. | Test wait actions. | async def test_wait_basic(hass, action_type):
"""Test wait actions."""
wait_alias = "wait step"
action = {"alias": wait_alias}
if action_type == "template":
action["wait_template"] = "{{ states.switch.test.state == 'off' }}"
else:
action["wait_for_trigger"] = {
"platform"... | [
"async",
"def",
"test_wait_basic",
"(",
"hass",
",",
"action_type",
")",
":",
"wait_alias",
"=",
"\"wait step\"",
"action",
"=",
"{",
"\"alias\"",
":",
"wait_alias",
"}",
"if",
"action_type",
"==",
"\"template\"",
":",
"action",
"[",
"\"wait_template\"",
"]",
... | [
735,
0
] | [
788,
9
] | python | en | ['en', 'fr', 'en'] | True |
test_wait_for_trigger_variables | (hass) | Test variables are passed to wait_for_trigger action. | Test variables are passed to wait_for_trigger action. | async def test_wait_for_trigger_variables(hass):
"""Test variables are passed to wait_for_trigger action."""
context = Context()
wait_alias = "wait step"
actions = [
{
"alias": "variables",
"variables": {"seconds": 5},
},
{
"alias": wait_alias,... | [
"async",
"def",
"test_wait_for_trigger_variables",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"wait_alias",
"=",
"\"wait step\"",
"actions",
"=",
"[",
"{",
"\"alias\"",
":",
"\"variables\"",
",",
"\"variables\"",
":",
"{",
"\"seconds\"",
":",
... | [
791,
0
] | [
831,
45
] | python | en | ['en', 'en', 'en'] | True |
test_wait_basic_times_out | (hass, action_type) | Test wait actions times out when the action does not happen. | Test wait actions times out when the action does not happen. | async def test_wait_basic_times_out(hass, action_type):
"""Test wait actions times out when the action does not happen."""
wait_alias = "wait step"
action = {"alias": wait_alias}
if action_type == "template":
action["wait_template"] = "{{ states.switch.test.state == 'off' }}"
else:
a... | [
"async",
"def",
"test_wait_basic_times_out",
"(",
"hass",
",",
"action_type",
")",
":",
"wait_alias",
"=",
"\"wait step\"",
"action",
"=",
"{",
"\"alias\"",
":",
"wait_alias",
"}",
"if",
"action_type",
"==",
"\"template\"",
":",
"action",
"[",
"\"wait_template\"",... | [
835,
0
] | [
879,
9
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_runs_wait | (hass, action_type) | Test multiple runs with wait in script. | Test multiple runs with wait in script. | async def test_multiple_runs_wait(hass, action_type):
"""Test multiple runs with wait in script."""
event = "test_event"
events = async_capture_events(hass, event)
if action_type == "template":
action = {"wait_template": "{{ states.switch.test.state == 'off' }}"}
else:
action = {
... | [
"async",
"def",
"test_multiple_runs_wait",
"(",
"hass",
",",
"action_type",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"if",
"action_type",
"==",
"\"template\"",
":",
"action",
"=",
"{",
"\"... | [
883,
0
] | [
933,
44
] | python | en | ['en', 'en', 'en'] | True |
test_cancel_wait | (hass, action_type) | Test the cancelling while wait is present. | Test the cancelling while wait is present. | async def test_cancel_wait(hass, action_type):
"""Test the cancelling while wait is present."""
event = "test_event"
events = async_capture_events(hass, event)
if action_type == "template":
action = {"wait_template": "{{ states.switch.test.state == 'off' }}"}
else:
action = {
... | [
"async",
"def",
"test_cancel_wait",
"(",
"hass",
",",
"action_type",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"if",
"action_type",
"==",
"\"template\"",
":",
"action",
"=",
"{",
"\"wait_te... | [
937,
0
] | [
991,
9
] | python | en | ['en', 'en', 'en'] | True |
test_wait_template_not_schedule | (hass) | Test the wait template with correct condition. | Test the wait template with correct condition. | async def test_wait_template_not_schedule(hass):
"""Test the wait template with correct condition."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{"wait_template": "{{ states.switch.test.state == 'on' }}... | [
"async",
"def",
"test_wait_template_not_schedule",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",
":",
"even... | [
994,
0
] | [
1025,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wait_timeout | (hass, caplog, timeout_param, action_type) | Test the wait timeout option. | Test the wait timeout option. | async def test_wait_timeout(hass, caplog, timeout_param, action_type):
"""Test the wait timeout option."""
event = "test_event"
events = async_capture_events(hass, event)
if action_type == "template":
action = {"wait_template": "{{ states.switch.test.state == 'off' }}"}
else:
action ... | [
"async",
"def",
"test_wait_timeout",
"(",
"hass",
",",
"caplog",
",",
"timeout_param",
",",
"action_type",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"if",
"action_type",
"==",
"\"template\"",... | [
1032,
0
] | [
1089,
39
] | python | en | ['en', 'en', 'en'] | True |
test_wait_continue_on_timeout | (
hass, continue_on_timeout, n_events, action_type
) | Test the wait continue_on_timeout option. | Test the wait continue_on_timeout option. | async def test_wait_continue_on_timeout(
hass, continue_on_timeout, n_events, action_type
):
"""Test the wait continue_on_timeout option."""
event = "test_event"
events = async_capture_events(hass, event)
if action_type == "template":
action = {"wait_template": "{{ states.switch.test.state =... | [
"async",
"def",
"test_wait_continue_on_timeout",
"(",
"hass",
",",
"continue_on_timeout",
",",
"n_events",
",",
"action_type",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"if",
"action_type",
"==... | [
1096,
0
] | [
1155,
66
] | python | en | ['en', 'en', 'en'] | True |
test_wait_template_variables_in | (hass) | Test the wait template with input variables. | Test the wait template with input variables. | async def test_wait_template_variables_in(hass):
"""Test the wait template with input variables."""
sequence = cv.SCRIPT_SCHEMA({"wait_template": "{{ is_state(data, 'off') }}"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
wait_started_flag = async_watch_for_action(script_obj, ... | [
"async",
"def",
"test_wait_template_variables_in",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ is_state(data, 'off') }}\"",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
... | [
1158,
0
] | [
1185,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wait_template_with_utcnow | (hass) | Test the wait template with utcnow. | Test the wait template with utcnow. | async def test_wait_template_with_utcnow(hass):
"""Test the wait template with utcnow."""
sequence = cv.SCRIPT_SCHEMA({"wait_template": "{{ utcnow().hour == 12 }}"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
wait_started_flag = async_watch_for_action(script_obj, "wait")
... | [
"async",
"def",
"test_wait_template_with_utcnow",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ utcnow().hour == 12 }}\"",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"se... | [
1188,
0
] | [
1216,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wait_template_with_utcnow_no_match | (hass) | Test the wait template with utcnow that does not match. | Test the wait template with utcnow that does not match. | async def test_wait_template_with_utcnow_no_match(hass):
"""Test the wait template with utcnow that does not match."""
sequence = cv.SCRIPT_SCHEMA({"wait_template": "{{ utcnow().hour == 12 }}"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
wait_started_flag = async_watch_for_ac... | [
"async",
"def",
"test_wait_template_with_utcnow_no_match",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ utcnow().hour == 12 }}\"",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
"... | [
1219,
0
] | [
1252,
5
] | python | en | ['en', 'en', 'en'] | True |
test_wait_variables_out | (hass, mode, action_type) | Test the wait output variable. | Test the wait output variable. | async def test_wait_variables_out(hass, mode, action_type):
"""Test the wait output variable."""
event = "test_event"
events = async_capture_events(hass, event)
if action_type == "template":
action = {"wait_template": "{{ states.switch.test.state == 'off' }}"}
event_key = "completed"
... | [
"async",
"def",
"test_wait_variables_out",
"(",
"hass",
",",
"mode",
",",
"action_type",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"if",
"action_type",
"==",
"\"template\"",
":",
"action",
... | [
1257,
0
] | [
1321,
42
] | python | en | ['en', 'en', 'en'] | True |
test_wait_for_trigger_bad | (hass, caplog) | Test bad wait_for_trigger. | Test bad wait_for_trigger. | async def test_wait_for_trigger_bad(hass, caplog):
"""Test bad wait_for_trigger."""
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA(
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
),
"Test Name",
"test_domain",
)
async def a... | [
"async",
"def",
"test_wait_for_trigger_bad",
"(",
"hass",
",",
"caplog",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_for_trigger\"",
":",
"{",
"\"platform\"",
":",
"\"state\"",
",",
"\... | [
1324,
0
] | [
1351,
5
] | python | en | ['en', 'da', 'en'] | True |
test_wait_for_trigger_generated_exception | (hass, caplog) | Test bad wait_for_trigger. | Test bad wait_for_trigger. | async def test_wait_for_trigger_generated_exception(hass, caplog):
"""Test bad wait_for_trigger."""
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA(
{"wait_for_trigger": {"platform": "state", "entity_id": "sensor.abc"}}
),
"Test Name",
"test_domain",
)
... | [
"async",
"def",
"test_wait_for_trigger_generated_exception",
"(",
"hass",
",",
"caplog",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_for_trigger\"",
":",
"{",
"\"platform\"",
":",
"\"state... | [
1354,
0
] | [
1383,
5
] | python | en | ['en', 'da', 'en'] | True |
test_condition_warning | (hass, caplog) | Test warning on condition. | Test warning on condition. | async def test_condition_warning(hass, caplog):
"""Test warning on condition."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{
"condition": "numeric_state",
"entity_id": "... | [
"async",
"def",
"test_condition_warning",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",
":... | [
1386,
0
] | [
1422,
5
] | python | en | ['en', 'en', 'en'] | True |
test_condition_basic | (hass, caplog) | Test if we can use conditions in a script. | Test if we can use conditions in a script. | async def test_condition_basic(hass, caplog):
"""Test if we can use conditions in a script."""
event = "test_event"
events = async_capture_events(hass, event)
alias = "condition step"
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{
"alias": alias,
... | [
"async",
"def",
"test_condition_basic",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"alias",
"=",
"\"condition step\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
... | [
1425,
0
] | [
1478,
5
] | python | en | ['en', 'en', 'en'] | True |
test_condition_created_once | (async_from_config, hass) | Test that the conditions do not get created multiple times. | Test that the conditions do not get created multiple times. | async def test_condition_created_once(async_from_config, hass):
"""Test that the conditions do not get created multiple times."""
sequence = cv.SCRIPT_SCHEMA(
{
"condition": "template",
"value_template": '{{ states.test.entity.state == "hello" }}',
}
)
script_obj ... | [
"async",
"def",
"test_condition_created_once",
"(",
"async_from_config",
",",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"condition\"",
":",
"\"template\"",
",",
"\"value_template\"",
":",
"'{{ states.test.entity.state == \"hello\" }}'",
... | [
1482,
0
] | [
1502,
45
] | python | en | ['en', 'en', 'en'] | True |
test_condition_all_cached | (hass) | Test that multiple conditions get cached. | Test that multiple conditions get cached. | async def test_condition_all_cached(hass):
"""Test that multiple conditions get cached."""
sequence = cv.SCRIPT_SCHEMA(
[
{
"condition": "template",
"value_template": '{{ states.test.entity.state == "hello" }}',
},
{
"co... | [
"async",
"def",
"test_condition_all_cached",
"(",
"hass",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"condition\"",
":",
"\"template\"",
",",
"\"value_template\"",
":",
"'{{ states.test.entity.state == \"hello\" }}'",
",",
"}",
",",
"{",... | [
1505,
0
] | [
1525,
45
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_count | (hass, caplog, count) | Test repeat action w/ count option. | Test repeat action w/ count option. | async def test_repeat_count(hass, caplog, count):
"""Test repeat action w/ count option."""
event = "test_event"
events = async_capture_events(hass, event)
alias = "condition step"
sequence = cv.SCRIPT_SCHEMA(
{
"alias": alias,
"repeat": {
"count": co... | [
"async",
"def",
"test_repeat_count",
"(",
"hass",
",",
"caplog",
",",
"count",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"alias",
"=",
"\"condition step\"",
"sequence",
"=",
"cv",
".",
"S... | [
1529,
0
] | [
1589,
5
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_condition_warning | (hass, caplog, condition) | Test warning on repeat conditions. | Test warning on repeat conditions. | async def test_repeat_condition_warning(hass, caplog, condition):
"""Test warning on repeat conditions."""
event = "test_event"
events = async_capture_events(hass, event)
count = 0 if condition == "while" else 1
sequence = {
"repeat": {
"sequence": [
{
... | [
"async",
"def",
"test_repeat_condition_warning",
"(",
"hass",
",",
"caplog",
",",
"condition",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"count",
"=",
"0",
"if",
"condition",
"==",
"\"while... | [
1593,
0
] | [
1650,
39
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_conditional | (hass, condition, direct_template) | Test repeat action w/ while option. | Test repeat action w/ while option. | async def test_repeat_conditional(hass, condition, direct_template):
"""Test repeat action w/ while option."""
event = "test_event"
events = async_capture_events(hass, event)
count = 3
sequence = {
"repeat": {
"sequence": [
{
"event": event,
... | [
"async",
"def",
"test_repeat_conditional",
"(",
"hass",
",",
"condition",
",",
"direct_template",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"count",
"=",
"3",
"sequence",
"=",
"{",
"\"repea... | [
1655,
0
] | [
1724,
51
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_var_in_condition | (hass, condition) | Test repeat action w/ while option. | Test repeat action w/ while option. | async def test_repeat_var_in_condition(hass, condition):
"""Test repeat action w/ while option."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = {"repeat": {"sequence": {"event": event}}}
if condition == "while":
value_template = "{{ repeat.index <= 2 }}"
el... | [
"async",
"def",
"test_repeat_var_in_condition",
"(",
"hass",
",",
"condition",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"{",
"\"repeat\"",
":",
"{",
"\"sequence\"",
":",
"... | [
1728,
0
] | [
1810,
39
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_nested | (hass, variables, first_last, inside_x) | Test nested repeats. | Test nested repeats. | async def test_repeat_nested(hass, variables, first_last, inside_x):
"""Test nested repeats."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{
"event": event,
"event_data_template": {
... | [
"async",
"def",
"test_repeat_nested",
"(",
"hass",
",",
"variables",
",",
"first_last",
",",
"inside_x",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA... | [
1820,
0
] | [
1954,
39
] | python | en | ['da', 'en', 'en'] | True |
test_choose_warning | (hass, caplog) | Test warning on choose. | Test warning on choose. | async def test_choose_warning(hass, caplog):
"""Test warning on choose."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
{
"choose": [
{
"conditions": {
"condition": "numeric_s... | [
"async",
"def",
"test_choose_warning",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"choose\"",
":",
"[",... | [
1957,
0
] | [
2003,
48
] | python | en | ['en', 'jv', 'en'] | True |
test_choose | (hass, caplog, var, result) | Test choose action. | Test choose action. | async def test_choose(hass, caplog, var, result):
"""Test choose action."""
event = "test_event"
events = async_capture_events(hass, event)
alias = "choose step"
choice = {1: "choice one", 2: "choice two", 3: None}
aliases = {1: "sequence one", 2: "sequence two", 3: "default sequence"}
seque... | [
"async",
"def",
"test_choose",
"(",
"hass",
",",
"caplog",
",",
"var",
",",
"result",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"alias",
"=",
"\"choose step\"",
"choice",
"=",
"{",
"1",... | [
2007,
0
] | [
2087,
39
] | python | en | ['en', 'da', 'en'] | True |
test_multiple_runs_repeat_choose | (hass, caplog, action) | Test parallel runs with repeat & choose actions & max_runs > default. | Test parallel runs with repeat & choose actions & max_runs > default. | async def test_multiple_runs_repeat_choose(hass, caplog, action):
"""Test parallel runs with repeat & choose actions & max_runs > default."""
max_runs = script.DEFAULT_MAX + 1
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA(action),
"Test Name",
"test_domain",
scri... | [
"async",
"def",
"test_multiple_runs_repeat_choose",
"(",
"hass",
",",
"caplog",
",",
"action",
")",
":",
"max_runs",
"=",
"script",
".",
"DEFAULT_MAX",
"+",
"1",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
... | [
2098,
0
] | [
2117,
34
] | python | en | ['en', 'en', 'en'] | True |
test_last_triggered | (hass) | Test the last_triggered. | Test the last_triggered. | async def test_last_triggered(hass):
"""Test the last_triggered."""
event = "test_event"
sequence = cv.SCRIPT_SCHEMA({"event": event})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
assert script_obj.last_triggered is None
time = dt_util.utcnow()
with mock.patch("ho... | [
"async",
"def",
"test_last_triggered",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"event\"",
":",
"event",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"sequenc... | [
2120,
0
] | [
2133,
44
] | python | en | ['en', 'en', 'en'] | True |
test_propagate_error_service_not_found | (hass) | Test that a script aborts when a service is not found. | Test that a script aborts when a service is not found. | async def test_propagate_error_service_not_found(hass):
"""Test that a script aborts when a service is not found."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA([{"service": "test.script"}, {"event": event}])
script_obj = script.Script(hass, sequence, ... | [
"async",
"def",
"test_propagate_error_service_not_found",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"service\"",
":"... | [
2136,
0
] | [
2166,
74
] | python | en | ['en', 'en', 'en'] | True |
test_propagate_error_invalid_service_data | (hass) | Test that a script aborts when we send invalid service data. | Test that a script aborts when we send invalid service data. | async def test_propagate_error_invalid_service_data(hass):
"""Test that a script aborts when we send invalid service data."""
event = "test_event"
events = async_capture_events(hass, event)
calls = async_mock_service(hass, "test", "script", vol.Schema({"text": str}))
sequence = cv.SCRIPT_SCHEMA(
... | [
"async",
"def",
"test_propagate_error_invalid_service_data",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"scr... | [
2169,
0
] | [
2203,
74
] | python | en | ['en', 'en', 'en'] | True |
test_propagate_error_service_exception | (hass) | Test that a script aborts when a service throws an exception. | Test that a script aborts when a service throws an exception. | async def test_propagate_error_service_exception(hass):
"""Test that a script aborts when a service throws an exception."""
event = "test_event"
events = async_capture_events(hass, event)
@callback
def record_call(service):
"""Add recorded event to set."""
raise ValueError("BROKEN")... | [
"async",
"def",
"test_propagate_error_service_exception",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"@",
"callback",
"def",
"record_call",
"(",
"service",
")",
":",
"\"\"\"Add reco... | [
2206,
0
] | [
2244,
74
] | python | en | ['en', 'en', 'en'] | True |
test_referenced_entities | (hass) | Test referenced entities. | Test referenced entities. | async def test_referenced_entities(hass):
"""Test referenced entities."""
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA(
[
{
"service": "test.script",
"data": {"entity_id": "light.service_not_list"},
},
... | [
"async",
"def",
"test_referenced_entities",
"(",
"hass",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"service\"",
":",
"\"test.script\"",
",",
"\"data\"",
":",
"{",
"\"entity_id\"",
":"... | [
2247,
0
] | [
2301,
75
] | python | en | ['en', 'en', 'en'] | True |
test_referenced_devices | (hass) | Test referenced entities. | Test referenced entities. | async def test_referenced_devices(hass):
"""Test referenced entities."""
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA(
[
{"domain": "light", "device_id": "script-dev-id"},
{
"condition": "device",
"device_i... | [
"async",
"def",
"test_referenced_devices",
"(",
"hass",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"domain\"",
":",
"\"light\"",
",",
"\"device_id\"",
":",
"\"script-dev-id\"",
"}",
",... | [
2304,
0
] | [
2347,
73
] | python | en | ['en', 'en', 'en'] | True |
does_not_raise | () | Indicate no exception is expected. | Indicate no exception is expected. | def does_not_raise():
"""Indicate no exception is expected."""
yield | [
"def",
"does_not_raise",
"(",
")",
":",
"yield"
] | [
2351,
0
] | [
2353,
9
] | python | en | ['en', 'en', 'en'] | True |
test_script_mode_single | (hass, caplog) | Test overlapping runs with max_runs = 1. | Test overlapping runs with max_runs = 1. | async def test_script_mode_single(hass, caplog):
"""Test overlapping runs with max_runs = 1."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event, "event_data": {"value": 1}},
{"wait_template": "{{ states.switch... | [
"async",
"def",
"test_script_mode_single",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",
"... | [
2356,
0
] | [
2394,
43
] | python | en | ['en', 'en', 'en'] | True |
test_max_exceeded | (hass, caplog, max_exceeded, script_mode, max_runs) | Test max_exceeded option. | Test max_exceeded option. | async def test_max_exceeded(hass, caplog, max_exceeded, script_mode, max_runs):
"""Test max_exceeded option."""
sequence = cv.SCRIPT_SCHEMA(
{"wait_template": "{{ states.switch.test.state == 'off' }}"}
)
if max_exceeded is None:
script_obj = script.Script(
hass,
s... | [
"async",
"def",
"test_max_exceeded",
"(",
"hass",
",",
"caplog",
",",
"max_exceeded",
",",
"script_mode",
",",
"max_runs",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ states.switch.test.state == 'off' }}\"",
"}",
... | [
2401,
0
] | [
2448,
9
] | python | en | ['en', 'en', 'en'] | True |
test_script_mode_2 | (hass, caplog, script_mode, messages, last_events) | Test overlapping runs with max_runs > 1. | Test overlapping runs with max_runs > 1. | async def test_script_mode_2(hass, caplog, script_mode, messages, last_events):
"""Test overlapping runs with max_runs > 1."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event, "event_data": {"value": 1}},
{"wa... | [
"async",
"def",
"test_script_mode_2",
"(",
"hass",
",",
"caplog",
",",
"script_mode",
",",
"messages",
",",
"last_events",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
... | [
2455,
0
] | [
2516,
53
] | python | en | ['en', 'en', 'en'] | True |
test_script_mode_queued | (hass) | Test overlapping runs with script_mode = 'queued' & max_runs > 1. | Test overlapping runs with script_mode = 'queued' & max_runs > 1. | async def test_script_mode_queued(hass):
"""Test overlapping runs with script_mode = 'queued' & max_runs > 1."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event, "event_data": {"value": 1}},
{
... | [
"async",
"def",
"test_script_mode_queued",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",
":",
"event",
",... | [
2519,
0
] | [
2613,
43
] | python | en | ['en', 'en', 'en'] | True |
test_script_mode_queued_cancel | (hass) | Test canceling with a queued run. | Test canceling with a queued run. | async def test_script_mode_queued_cancel(hass):
"""Test canceling with a queued run."""
script_obj = script.Script(
hass,
cv.SCRIPT_SCHEMA({"wait_template": "{{ false }}"}),
"Test Name",
"test_domain",
script_mode="queued",
max_runs=2,
)
wait_started_flag ... | [
"async",
"def",
"test_script_mode_queued_cancel",
"(",
"hass",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ false }}\"",
"}",
")",
",",
"\"Test Name\"",
",",
"\"te... | [
2616,
0
] | [
2655,
13
] | python | en | ['en', 'en', 'en'] | True |
test_script_logging | (hass, caplog) | Test script logging. | Test script logging. | async def test_script_logging(hass, caplog):
"""Test script logging."""
script_obj = script.Script(hass, [], "Script with % Name", "test_domain")
script_obj._log("Test message with name %s", 1)
assert "Script with % Name: Test message with name 1" in caplog.text | [
"async",
"def",
"test_script_logging",
"(",
"hass",
",",
"caplog",
")",
":",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"[",
"]",
",",
"\"Script with % Name\"",
",",
"\"test_domain\"",
")",
"script_obj",
".",
"_log",
"(",
"\"Test message wit... | [
2658,
0
] | [
2663,
72
] | python | en | ['it', 'la', 'en'] | False |
test_shutdown_at | (hass, caplog) | Test stopping scripts at shutdown. | Test stopping scripts at shutdown. | async def test_shutdown_at(hass, caplog):
"""Test stopping scripts at shutdown."""
delay_alias = "delay step"
sequence = cv.SCRIPT_SCHEMA({"delay": {"seconds": 120}, "alias": delay_alias})
script_obj = script.Script(hass, sequence, "test script", "test_domain")
delay_started_flag = async_watch_for_a... | [
"async",
"def",
"test_shutdown_at",
"(",
"hass",
",",
"caplog",
")",
":",
"delay_alias",
"=",
"\"delay step\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"delay\"",
":",
"{",
"\"seconds\"",
":",
"120",
"}",
",",
"\"alias\"",
":",
"delay_alias"... | [
2666,
0
] | [
2692,
39
] | python | en | ['en', 'en', 'en'] | True |
test_shutdown_after | (hass, caplog) | Test stopping scripts at shutdown. | Test stopping scripts at shutdown. | async def test_shutdown_after(hass, caplog):
"""Test stopping scripts at shutdown."""
delay_alias = "delay step"
sequence = cv.SCRIPT_SCHEMA({"delay": {"seconds": 120}, "alias": delay_alias})
script_obj = script.Script(hass, sequence, "test script", "test_domain")
delay_started_flag = async_watch_fo... | [
"async",
"def",
"test_shutdown_after",
"(",
"hass",
",",
"caplog",
")",
":",
"delay_alias",
"=",
"\"delay step\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"delay\"",
":",
"{",
"\"seconds\"",
":",
"120",
"}",
",",
"\"alias\"",
":",
"delay_ali... | [
2695,
0
] | [
2728,
39
] | python | en | ['en', 'en', 'en'] | True |
test_update_logger | (hass, caplog) | Test updating logger. | Test updating logger. | async def test_update_logger(hass, caplog):
"""Test updating logger."""
sequence = cv.SCRIPT_SCHEMA({"event": "test_event"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
await script_obj.async_run(context=Context())
await hass.async_block_till_done()
assert script.__n... | [
"async",
"def",
"test_update_logger",
"(",
"hass",
",",
"caplog",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"event\"",
":",
"\"test_event\"",
"}",
")",
"script_obj",
"=",
"script",
".",
"Script",
"(",
"hass",
",",
"sequence",
",",
... | [
2731,
0
] | [
2747,
34
] | python | en | ['en', 'no', 'en'] | True |
test_started_action | (hass, caplog) | Test the callback of started_action. | Test the callback of started_action. | async def test_started_action(hass, caplog):
"""Test the callback of started_action."""
event = "test_event"
log_message = "The script started!"
logger = logging.getLogger("TEST")
sequence = cv.SCRIPT_SCHEMA({"event": event})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain"... | [
"async",
"def",
"test_started_action",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"log_message",
"=",
"\"The script started!\"",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"TEST\"",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHE... | [
2750,
0
] | [
2766,
37
] | python | en | ['en', 'en', 'en'] | True |
test_set_variable | (hass, caplog) | Test setting variables in scripts. | Test setting variables in scripts. | async def test_set_variable(hass, caplog):
"""Test setting variables in scripts."""
alias = "variables step"
sequence = cv.SCRIPT_SCHEMA(
[
{"alias": alias, "variables": {"variable": "value"}},
{"service": "test.script", "data": {"value": "{{ variable }}"}},
]
)
... | [
"async",
"def",
"test_set_variable",
"(",
"hass",
",",
"caplog",
")",
":",
"alias",
"=",
"\"variables step\"",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"alias\"",
":",
"alias",
",",
"\"variables\"",
":",
"{",
"\"variable\"",
":",
"\"valu... | [
2769,
0
] | [
2806,
39
] | python | en | ['nl', 'en', 'en'] | True |
test_set_redefines_variable | (hass, caplog) | Test setting variables based on their current value. | Test setting variables based on their current value. | async def test_set_redefines_variable(hass, caplog):
"""Test setting variables based on their current value."""
sequence = cv.SCRIPT_SCHEMA(
[
{"variables": {"variable": "1"}},
{"service": "test.script", "data": {"value": "{{ variable }}"}},
{"variables": {"variable":... | [
"async",
"def",
"test_set_redefines_variable",
"(",
"hass",
",",
"caplog",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"variables\"",
":",
"{",
"\"variable\"",
":",
"\"1\"",
"}",
"}",
",",
"{",
"\"service\"",
":",
"\"test.script\"... | [
2809,
0
] | [
2863,
39
] | python | en | ['en', 'en', 'en'] | True |
test_validate_action_config | (hass) | Validate action config. | Validate action config. | async def test_validate_action_config(hass):
"""Validate action config."""
configs = {
cv.SCRIPT_ACTION_CALL_SERVICE: {"service": "light.turn_on"},
cv.SCRIPT_ACTION_DELAY: {"delay": 5},
cv.SCRIPT_ACTION_WAIT_TEMPLATE: {
"wait_template": "{{ states.light.kitchen.state == 'on' ... | [
"async",
"def",
"test_validate_action_config",
"(",
"hass",
")",
":",
"configs",
"=",
"{",
"cv",
".",
"SCRIPT_ACTION_CALL_SERVICE",
":",
"{",
"\"service\"",
":",
"\"light.turn_on\"",
"}",
",",
"cv",
".",
"SCRIPT_ACTION_DELAY",
":",
"{",
"\"delay\"",
":",
"5",
... | [
2866,
0
] | [
2920,
64
] | python | en | ['en', 'en', 'it'] | True |
test_embedded_wait_for_trigger_in_automation | (hass) | Test an embedded wait for trigger. | Test an embedded wait for trigger. | async def test_embedded_wait_for_trigger_in_automation(hass):
"""Test an embedded wait for trigger."""
assert await async_setup_component(
hass,
"automation",
{
"automation": {
"trigger": {"platform": "event", "event_type": "test_event"},
"acti... | [
"async",
"def",
"test_embedded_wait_for_trigger_in_automation",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"automation\"",
",",
"{",
"\"automation\"",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform\"",
":",
"\"event\"",
",... | [
2923,
0
] | [
2974,
31
] | python | en | ['en', 'en', 'en'] | True |
TestChildDog.testChildDog | (self) | Test ChildDog | Test ChildDog | def testChildDog(self):
"""Test ChildDog"""
# FIXME: construct object with mandatory attributes with example values
# model = ChildDog() # noqa: E501
pass | [
"def",
"testChildDog",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = ChildDog() # noqa: E501",
"pass"
] | [
39,
4
] | [
43,
12
] | python | en | ['en', 'de', 'en'] | False |
async_see | (
hass: HomeAssistant,
mac: str = None,
dev_id: str = None,
host_name: str = None,
location_name: str = None,
gps: GPSType = None,
gps_accuracy=None,
battery: int = None,
attributes: dict = None,
) | Call service to notify you see device. | Call service to notify you see device. | def async_see(
hass: HomeAssistant,
mac: str = None,
dev_id: str = None,
host_name: str = None,
location_name: str = None,
gps: GPSType = None,
gps_accuracy=None,
battery: int = None,
attributes: dict = None,
):
"""Call service to notify you see device."""
data = {
ke... | [
"def",
"async_see",
"(",
"hass",
":",
"HomeAssistant",
",",
"mac",
":",
"str",
"=",
"None",
",",
"dev_id",
":",
"str",
"=",
"None",
",",
"host_name",
":",
"str",
"=",
"None",
",",
"location_name",
":",
"str",
"=",
"None",
",",
"gps",
":",
"GPSType",
... | [
24,
0
] | [
51,
75
] | python | en | ['en', 'en', 'en'] | True |
TestInlineResponseDefault.make_instance | (self, include_optional) | Test InlineResponseDefault
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test InlineResponseDefault
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | def make_instance(self, include_optional):
"""Test InlineResponseDefault
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.inline_response_default.Inlin... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"# model = petstore_api.models.inline_response_default.InlineResponseDefault() # noqa: E501",
"if",
"include_optional",
":",
"return",
"InlineResponseDefault",
"(",
"string",
"=",
"petstore_api",
".",
"mod... | [
30,
4
] | [
43,
9
] | python | en | ['en', 'nl', 'en'] | False |
TestInlineResponseDefault.testInlineResponseDefault | (self) | Test InlineResponseDefault | Test InlineResponseDefault | def testInlineResponseDefault(self):
"""Test InlineResponseDefault"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True) | [
"def",
"testInlineResponseDefault",
"(",
"self",
")",
":",
"inst_req_only",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"False",
")",
"inst_req_and_optional",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"True",
")"
] | [
45,
4
] | [
48,
73
] | python | en | ['en', 'nl', 'en'] | False |
async_setup | (hass, config) | Set up the Melissa Climate component. | Set up the Melissa Climate component. | async def async_setup(hass, config):
"""Set up the Melissa Climate component."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)
password = conf.get(CONF_PASSWORD)
api = melissa.AsyncMelissa(username=username, password=password)
await api.async_connect()
hass.data[DATA_MELISSA] = ap... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"username",
"=",
"conf",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"conf",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"api",
"=",
... | [
25,
0
] | [
35,
15
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass) | Test entry will be imported. | Test entry will be imported. | async def test_import(hass):
"""Test entry will be imported."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data={}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_IMPORT",
"}",
",",
"data",
"=",
"{",
"}",
"... | [
7,
0
] | [
13,
69
] | python | en | ['en', 'en', 'en'] | True |
test_user | (hass) | Test we can start a config flow. | Test we can start a config flow. | async def test_user(hass):
"""Test we can start a config flow."""
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" | [
"async",
"def",
"test_user",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"assert",
"result",
"[",
"\"ty... | [
16,
0
] | [
24,
38
] | python | en | ['en', 'en', 'en'] | True |
test_user_confirm | (hass) | Test we can finish a config flow. | Test we can finish a config flow. | async def test_user_confirm(hass):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["result"].data == {} | [
"async",
"def",
"test_user_confirm",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
",",
"data",
"=",
"{",
"}",... | [
27,
0
] | [
35,
38
] | python | en | ['en', 'en', 'en'] | True |
async_load_websocket_api | (hass: HomeAssistant) | Set up the websocket API. | Set up the websocket API. | def async_load_websocket_api(hass: HomeAssistant):
"""Set up the websocket API."""
websocket_api.async_register_command(hass, websocket_supervisor_event)
websocket_api.async_register_command(hass, websocket_supervisor_api)
websocket_api.async_register_command(hass, websocket_subscribe) | [
"def",
"async_load_websocket_api",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_supervisor_event",
")",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_supervisor_api... | [
40,
0
] | [
44,
67
] | python | en | ['en', 'da', 'en'] | True |
websocket_subscribe | (
hass: HomeAssistant, connection: ActiveConnection, msg: dict
) | Subscribe to supervisor events. | Subscribe to supervisor events. | async def websocket_subscribe(
hass: HomeAssistant, connection: ActiveConnection, msg: dict
):
"""Subscribe to supervisor events."""
@callback
def forward_messages(data):
"""Forward events to websocket."""
connection.send_message(websocket_api.event_message(msg[WS_ID], data))
conne... | [
"async",
"def",
"websocket_subscribe",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection",
":",
"ActiveConnection",
",",
"msg",
":",
"dict",
")",
":",
"@",
"callback",
"def",
"forward_messages",
"(",
"data",
")",
":",
"\"\"\"Forward events to websocket.\"\"\"",
... | [
50,
0
] | [
63,
69
] | python | en | ['en', 'en', 'en'] | True |
websocket_supervisor_event | (
hass: HomeAssistant, connection: ActiveConnection, msg: dict
) | Publish events from the Supervisor. | Publish events from the Supervisor. | async def websocket_supervisor_event(
hass: HomeAssistant, connection: ActiveConnection, msg: dict
):
"""Publish events from the Supervisor."""
async_dispatcher_send(hass, EVENT_SUPERVISOR_EVENT, msg[ATTR_DATA])
connection.send_result(msg[WS_ID]) | [
"async",
"def",
"websocket_supervisor_event",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection",
":",
"ActiveConnection",
",",
"msg",
":",
"dict",
")",
":",
"async_dispatcher_send",
"(",
"hass",
",",
"EVENT_SUPERVISOR_EVENT",
",",
"msg",
"[",
"ATTR_DATA",
"]",
... | [
73,
0
] | [
78,
38
] | python | en | ['en', 'en', 'en'] | True |
websocket_supervisor_api | (
hass: HomeAssistant, connection: ActiveConnection, msg: dict
) | Websocket handler to call Supervisor API. | Websocket handler to call Supervisor API. | async def websocket_supervisor_api(
hass: HomeAssistant, connection: ActiveConnection, msg: dict
):
"""Websocket handler to call Supervisor API."""
supervisor: HassIO = hass.data[DOMAIN]
try:
result = await supervisor.send_command(
msg[ATTR_ENDPOINT],
method=msg[ATTR_METH... | [
"async",
"def",
"websocket_supervisor_api",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection",
":",
"ActiveConnection",
",",
"msg",
":",
"dict",
")",
":",
"supervisor",
":",
"HassIO",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"try",
":",
"result",
"... | [
92,
0
] | [
113,
69
] | python | en | ['en', 'da', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info) | Set up the Iperf3 sensor. | Set up the Iperf3 sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info):
"""Set up the Iperf3 sensor."""
entities = [
Iperf3Sensor(iperf3_host, description)
for iperf3_host in hass.data[IPERF3_DOMAIN].values()
for description in SENSOR_TYPES
if description.key in discove... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
")",
":",
"entities",
"=",
"[",
"Iperf3Sensor",
"(",
"iperf3_host",
",",
"description",
")",
"for",
"iperf3_host",
"in",
"hass",
".",
"data",
... | [
18,
0
] | [
26,
38
] | python | en | ['en', 'ca', 'en'] | True |
Iperf3Sensor.__init__ | (self, iperf3_data, description: SensorEntityDescription) | Initialize the sensor. | Initialize the sensor. | def __init__(self, iperf3_data, description: SensorEntityDescription):
"""Initialize the sensor."""
self.entity_description = description
self._iperf3_data = iperf3_data
self._attr_name = f"{description.name} {iperf3_data.host}" | [
"def",
"__init__",
"(",
"self",
",",
"iperf3_data",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_iperf3_data",
"=",
"iperf3_data",
"self",
".",
"_attr_name",
"=",
"f\"{descripti... | [
35,
4
] | [
39,
66
] | python | en | ['en', 'en', 'en'] | True |
Iperf3Sensor.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_PROTOCOL: self._iperf3_data.protocol,
ATTR_REMOTE_HOST: self._iperf3_data.host,
ATTR_REMOTE_PORT: self._iperf3_data.port,
ATTR_VER... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"ATTR_PROTOCOL",
":",
"self",
".",
"_iperf3_data",
".",
"protocol",
",",
"ATTR_REMOTE_HOST",
":",
"self",
".",
"_iperf3_data",
".",
"host",
",",
... | [
42,
4
] | [
50,
9
] | python | en | ['en', 'en', 'en'] | True |
Iperf3Sensor.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
self.async_on_remove(
async_dispatcher_connect(
self.hass, DATA_UPDATED, self._schedule_immediate_update
)
)
state = await s... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DATA_UPDATED",
",",
"self",
".",
... | [
52,
4
] | [
65,
45
] | python | en | ['en', 'en', 'en'] | True |
Iperf3Sensor.update | (self) | Get the latest data and update the states. | Get the latest data and update the states. | def update(self):
"""Get the latest data and update the states."""
data = self._iperf3_data.data.get(self.entity_description.key)
if data is not None:
self._attr_native_value = round(data, 2) | [
"def",
"update",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_iperf3_data",
".",
"data",
".",
"get",
"(",
"self",
".",
"entity_description",
".",
"key",
")",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"_attr_native_value",
"=",
"round",... | [
67,
4
] | [
71,
52
] | python | en | ['en', 'en', 'en'] | True |
test_on_off | (hass, mock_litejet) | Test turning the switch on and off. | Test turning the switch on and off. | async def test_on_off(hass, mock_litejet):
"""Test turning the switch on and off."""
await async_init_integration(hass, use_switch=True)
assert hass.states.get(ENTITY_SWITCH).state == "off"
assert hass.states.get(ENTITY_OTHER_SWITCH).state == "off"
assert not switch.is_on(hass, ENTITY_SWITCH)
... | [
"async",
"def",
"test_on_off",
"(",
"hass",
",",
"mock_litejet",
")",
":",
"await",
"async_init_integration",
"(",
"hass",
",",
"use_switch",
"=",
"True",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_SWITCH",
")",
".",
"state",
"==",
"\"o... | [
16,
0
] | [
34,
72
] | python | en | ['en', 'en', 'en'] | True |
test_pressed_event | (hass, mock_litejet) | Test handling an event from LiteJet. | Test handling an event from LiteJet. | async def test_pressed_event(hass, mock_litejet):
"""Test handling an event from LiteJet."""
await async_init_integration(hass, use_switch=True)
# Switch 1
mock_litejet.switch_pressed_callbacks[ENTITY_SWITCH_NUMBER]()
await hass.async_block_till_done()
assert switch.is_on(hass, ENTITY_SWITCH)... | [
"async",
"def",
"test_pressed_event",
"(",
"hass",
",",
"mock_litejet",
")",
":",
"await",
"async_init_integration",
"(",
"hass",
",",
"use_switch",
"=",
"True",
")",
"# Switch 1",
"mock_litejet",
".",
"switch_pressed_callbacks",
"[",
"ENTITY_SWITCH_NUMBER",
"]",
"(... | [
37,
0
] | [
58,
61
] | python | en | ['en', 'en', 'en'] | True |
test_released_event | (hass, mock_litejet) | Test handling an event from LiteJet. | Test handling an event from LiteJet. | async def test_released_event(hass, mock_litejet):
"""Test handling an event from LiteJet."""
await async_init_integration(hass, use_switch=True)
# Initial state is on.
mock_litejet.switch_pressed_callbacks[ENTITY_OTHER_SWITCH_NUMBER]()
await hass.async_block_till_done()
assert switch.is_on(h... | [
"async",
"def",
"test_released_event",
"(",
"hass",
",",
"mock_litejet",
")",
":",
"await",
"async_init_integration",
"(",
"hass",
",",
"use_switch",
"=",
"True",
")",
"# Initial state is on.",
"mock_litejet",
".",
"switch_pressed_callbacks",
"[",
"ENTITY_OTHER_SWITCH_N... | [
61,
0
] | [
79,
62
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Binary sensor set up for Hass.io config entry. | Binary sensor set up for Hass.io config entry. | async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Binary sensor set up for Hass.io config entry."""
coordinator = hass.data[ADDONS_COORDINATOR]
entities = []
for entity_description in ENTITY_DESCRIPTIONS:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"ADDONS_COORDINATOR",... | [
26,
0
] | [
54,
32
] | python | en | ['en', 'pt', 'en'] | True |
HassioAddonBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self) -> bool:
"""Return true if the binary sensor is on."""
return self.coordinator.data[DATA_KEY_ADDONS][self._addon_slug][
self.entity_description.key
] | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"DATA_KEY_ADDONS",
"]",
"[",
"self",
".",
"_addon_slug",
"]",
"[",
"self",
".",
"entity_description",
".",
"key",
"]"
] | [
61,
4
] | [
65,
9
] | python | en | ['en', 'fy', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.