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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ElkArea.async_alarm_arm_vacation | (self, code=None) | Send arm vacation command. | Send arm vacation command. | async def async_alarm_arm_vacation(self, code=None):
"""Send arm vacation command."""
self._element.arm(ArmLevel.ARMED_VACATION.value, int(code)) | [
"async",
"def",
"async_alarm_arm_vacation",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"arm",
"(",
"ArmLevel",
".",
"ARMED_VACATION",
".",
"value",
",",
"int",
"(",
"code",
")",
")"
] | [
250,
4
] | [
252,
67
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_display_message | (self, clear, beep, timeout, line1, line2) | Display a message on all keypads for the area. | Display a message on all keypads for the area. | async def async_display_message(self, clear, beep, timeout, line1, line2):
"""Display a message on all keypads for the area."""
self._element.display_message(clear, beep, timeout, line1, line2) | [
"async",
"def",
"async_display_message",
"(",
"self",
",",
"clear",
",",
"beep",
",",
"timeout",
",",
"line1",
",",
"line2",
")",
":",
"self",
".",
"_element",
".",
"display_message",
"(",
"clear",
",",
"beep",
",",
"timeout",
",",
"line1",
",",
"line2",... | [
254,
4
] | [
256,
73
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_bypass | (self, code=None) | Bypass all zones in area. | Bypass all zones in area. | async def async_bypass(self, code=None):
"""Bypass all zones in area."""
self._element.bypass(code) | [
"async",
"def",
"async_bypass",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"bypass",
"(",
"code",
")"
] | [
258,
4
] | [
260,
34
] | python | en | ['en', 'en', 'en'] | True |
ElkArea.async_clear_bypass | (self, code=None) | Clear bypass for all zones in area. | Clear bypass for all zones in area. | async def async_clear_bypass(self, code=None):
"""Clear bypass for all zones in area."""
self._element.clear_bypass(code) | [
"async",
"def",
"async_clear_bypass",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"self",
".",
"_element",
".",
"clear_bypass",
"(",
"code",
")"
] | [
262,
4
] | [
264,
40
] | python | en | ['en', 'en', 'en'] | True |
_fail | (message) | Exit nonzero with the given error message. | Exit nonzero with the given error message. | def _fail(message):
"""Exit nonzero with the given error message."""
sys.exit(message) | [
"def",
"_fail",
"(",
"message",
")",
":",
"sys",
".",
"exit",
"(",
"message",
")"
] | [
30,
0
] | [
32,
21
] | python | en | ['en', 'en', 'en'] | True |
parse_args | () | Parse command line args. | Parse command line args. | def parse_args():
"""Parse command line args."""
parser = argparse.ArgumentParser(
description="Validate of add new CloudWatch log configs.",
epilog="If neither --input-json nor --input-file are used, this script will validate the existing config."
)
add_group = parser.add_mutually_exclu... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Validate of add new CloudWatch log configs.\"",
",",
"epilog",
"=",
"\"If neither --input-json nor --input-file are used, this script will validate the existing config.... | [
35,
0
] | [
48,
30
] | python | en | ['en', 'fr', 'en'] | True |
get_input_json | (args) | Either load the input JSON data from a file, or returned the JSON parsed on the CLI. | Either load the input JSON data from a file, or returned the JSON parsed on the CLI. | def get_input_json(args):
"""Either load the input JSON data from a file, or returned the JSON parsed on the CLI."""
if args.input_file:
with args.input_file:
return json.load(args.input_file)
else:
return args.input_json | [
"def",
"get_input_json",
"(",
"args",
")",
":",
"if",
"args",
".",
"input_file",
":",
"with",
"args",
".",
"input_file",
":",
"return",
"json",
".",
"load",
"(",
"args",
".",
"input_file",
")",
"else",
":",
"return",
"args",
".",
"input_json"
] | [
51,
0
] | [
57,
30
] | python | en | ['en', 'en', 'en'] | True |
_read_json_at | (path) | Read the JSON file at path. | Read the JSON file at path. | def _read_json_at(path):
"""Read the JSON file at path."""
try:
with open(path) as input_file:
return json.load(input_file)
except FileNotFoundError:
_fail("No file exists at {}".format(path))
except ValueError:
_fail("File at {} contains invalid JSON".format(path)) | [
"def",
"_read_json_at",
"(",
"path",
")",
":",
"try",
":",
"with",
"open",
"(",
"path",
")",
"as",
"input_file",
":",
"return",
"json",
".",
"load",
"(",
"input_file",
")",
"except",
"FileNotFoundError",
":",
"_fail",
"(",
"\"No file exists at {}\"",
".",
... | [
60,
0
] | [
68,
62
] | python | en | ['en', 'en', 'en'] | True |
_read_schema | () | Read the schema for the CloudWatch log configs file. | Read the schema for the CloudWatch log configs file. | def _read_schema():
"""Read the schema for the CloudWatch log configs file."""
return _read_json_at(SCHEMA_PATH) | [
"def",
"_read_schema",
"(",
")",
":",
"return",
"_read_json_at",
"(",
"SCHEMA_PATH",
")"
] | [
71,
0
] | [
73,
37
] | python | en | ['en', 'en', 'en'] | True |
_read_log_configs | () | Read the current version of the CloudWatch log configs file, cloudwatch_log_files.json. | Read the current version of the CloudWatch log configs file, cloudwatch_log_files.json. | def _read_log_configs():
"""Read the current version of the CloudWatch log configs file, cloudwatch_log_files.json."""
return _read_json_at(LOG_CONFIGS_PATH) | [
"def",
"_read_log_configs",
"(",
")",
":",
"return",
"_read_json_at",
"(",
"LOG_CONFIGS_PATH",
")"
] | [
76,
0
] | [
78,
42
] | python | en | ['en', 'en', 'en'] | True |
_validate_json_schema | (input_json) | Ensure the structure of input_json matches the schema. | Ensure the structure of input_json matches the schema. | def _validate_json_schema(input_json):
"""Ensure the structure of input_json matches the schema."""
schema = _read_schema()
try:
jsonschema.validate(input_json, schema)
except jsonschema.exceptions.ValidationError as validation_err:
_fail(str(validation_err)) | [
"def",
"_validate_json_schema",
"(",
"input_json",
")",
":",
"schema",
"=",
"_read_schema",
"(",
")",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"input_json",
",",
"schema",
")",
"except",
"jsonschema",
".",
"exceptions",
".",
"ValidationError",
"as",
"va... | [
81,
0
] | [
87,
34
] | python | en | ['en', 'en', 'en'] | True |
_validate_timestamp_keys | (input_json) | Ensure the timestamp_format_key values in input_json's log_configs entries are valid. | Ensure the timestamp_format_key values in input_json's log_configs entries are valid. | def _validate_timestamp_keys(input_json):
"""Ensure the timestamp_format_key values in input_json's log_configs entries are valid."""
valid_keys = set()
for config in (input_json, _read_log_configs()):
valid_keys |= set(config.get("timestamp_formats").keys())
for log_config in input_json.get("lo... | [
"def",
"_validate_timestamp_keys",
"(",
"input_json",
")",
":",
"valid_keys",
"=",
"set",
"(",
")",
"for",
"config",
"in",
"(",
"input_json",
",",
"_read_log_configs",
"(",
")",
")",
":",
"valid_keys",
"|=",
"set",
"(",
"config",
".",
"get",
"(",
"\"timest... | [
90,
0
] | [
106,
13
] | python | en | ['en', 'en', 'en'] | True |
_get_duplicate_values | (seq) | Get the duplicate values in seq. | Get the duplicate values in seq. | def _get_duplicate_values(seq):
"""Get the duplicate values in seq."""
counter = collections.Counter(seq)
return [value for value, count in counter.items() if count > 1] | [
"def",
"_get_duplicate_values",
"(",
"seq",
")",
":",
"counter",
"=",
"collections",
".",
"Counter",
"(",
"seq",
")",
"return",
"[",
"value",
"for",
"value",
",",
"count",
"in",
"counter",
".",
"items",
"(",
")",
"if",
"count",
">",
"1",
"]"
] | [
109,
0
] | [
112,
67
] | python | en | ['en', 'en', 'en'] | True |
_validate_log_config_fields_uniqueness | (input_json) | Ensure that each entry in input_json's log_configs list has a unique log_stream_name and file_path. | Ensure that each entry in input_json's log_configs list has a unique log_stream_name and file_path. | def _validate_log_config_fields_uniqueness(input_json):
"""Ensure that each entry in input_json's log_configs list has a unique log_stream_name and file_path."""
unique_fields = ("log_stream_name", "file_path")
for field in unique_fields:
duplicates = _get_duplicate_values([config.get(field) for con... | [
"def",
"_validate_log_config_fields_uniqueness",
"(",
"input_json",
")",
":",
"unique_fields",
"=",
"(",
"\"log_stream_name\"",
",",
"\"file_path\"",
")",
"for",
"field",
"in",
"unique_fields",
":",
"duplicates",
"=",
"_get_duplicate_values",
"(",
"[",
"config",
".",
... | [
115,
0
] | [
125,
13
] | python | en | ['en', 'en', 'en'] | True |
validate_json | (input_json=None) | Ensure the structure of input_json matches that of the file it will be added to. | Ensure the structure of input_json matches that of the file it will be added to. | def validate_json(input_json=None):
"""Ensure the structure of input_json matches that of the file it will be added to."""
if input_json is None:
input_json = _read_log_configs()
_validate_json_schema(input_json)
_validate_timestamp_keys(input_json)
_validate_log_config_fields_uniqueness(inp... | [
"def",
"validate_json",
"(",
"input_json",
"=",
"None",
")",
":",
"if",
"input_json",
"is",
"None",
":",
"input_json",
"=",
"_read_log_configs",
"(",
")",
"_validate_json_schema",
"(",
"input_json",
")",
"_validate_timestamp_keys",
"(",
"input_json",
")",
"_valida... | [
128,
0
] | [
134,
54
] | python | en | ['en', 'en', 'en'] | True |
_write_log_configs | (log_configs) | Write log_configs back to the CloudWatch log configs file. | Write log_configs back to the CloudWatch log configs file. | def _write_log_configs(log_configs):
"""Write log_configs back to the CloudWatch log configs file."""
log_configs_path = os.environ.get("CW_LOGS_CONFIGS_PATH", DEFAULT_LOG_CONFIGS_PATH)
with open(log_configs_path, "w") as log_configs_file:
json.dump(log_configs, log_configs_file, indent=2) | [
"def",
"_write_log_configs",
"(",
"log_configs",
")",
":",
"log_configs_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"CW_LOGS_CONFIGS_PATH\"",
",",
"DEFAULT_LOG_CONFIGS_PATH",
")",
"with",
"open",
"(",
"log_configs_path",
",",
"\"w\"",
")",
"as",
"log_conf... | [
137,
0
] | [
141,
58
] | python | en | ['en', 'en', 'en'] | True |
write_validated_json | (input_json) | Write validated JSON back to the CloudWatch log configs file. | Write validated JSON back to the CloudWatch log configs file. | def write_validated_json(input_json):
"""Write validated JSON back to the CloudWatch log configs file."""
log_configs = _read_log_configs()
log_configs["log_configs"].extend(input_json.get("log_configs"))
# NOTICE: the input JSON's timestamp_formats dict is the one that is
# updated, so that those ... | [
"def",
"write_validated_json",
"(",
"input_json",
")",
":",
"log_configs",
"=",
"_read_log_configs",
"(",
")",
"log_configs",
"[",
"\"log_configs\"",
"]",
".",
"extend",
"(",
"input_json",
".",
"get",
"(",
"\"log_configs\"",
")",
")",
"# NOTICE: the input JSON's tim... | [
144,
0
] | [
152,
35
] | python | en | ['en', 'en', 'en'] | True |
create_backup | () | Create a backup of the file at LOG_CONFIGS_PATH. | Create a backup of the file at LOG_CONFIGS_PATH. | def create_backup():
"""Create a backup of the file at LOG_CONFIGS_PATH."""
shutil.copyfile(LOG_CONFIGS_PATH, LOG_CONFIGS_BAK_PATH) | [
"def",
"create_backup",
"(",
")",
":",
"shutil",
".",
"copyfile",
"(",
"LOG_CONFIGS_PATH",
",",
"LOG_CONFIGS_BAK_PATH",
")"
] | [
155,
0
] | [
157,
59
] | python | en | ['en', 'en', 'en'] | True |
restore_backup | () | Replace the file at LOG_CONFIGS_PATH with the backup that was created in create_backup. | Replace the file at LOG_CONFIGS_PATH with the backup that was created in create_backup. | def restore_backup():
"""Replace the file at LOG_CONFIGS_PATH with the backup that was created in create_backup."""
shutil.move(LOG_CONFIGS_BAK_PATH, LOG_CONFIGS_PATH) | [
"def",
"restore_backup",
"(",
")",
":",
"shutil",
".",
"move",
"(",
"LOG_CONFIGS_BAK_PATH",
",",
"LOG_CONFIGS_PATH",
")"
] | [
160,
0
] | [
162,
55
] | python | en | ['en', 'en', 'en'] | True |
remove_backup | () | Remove the backup created by create_backup. | Remove the backup created by create_backup. | def remove_backup():
"""Remove the backup created by create_backup."""
try:
os.remove(LOG_CONFIGS_BAK_PATH)
except FileNotFoundError:
pass | [
"def",
"remove_backup",
"(",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"LOG_CONFIGS_BAK_PATH",
")",
"except",
"FileNotFoundError",
":",
"pass"
] | [
165,
0
] | [
170,
12
] | python | en | ['en', 'en', 'en'] | True |
main | () | Run the script. | Run the script. | def main():
"""Run the script."""
args = parse_args()
create_backup()
try:
if args.input_file or args.input_json:
input_json = get_input_json(args)
validate_json(input_json)
write_validated_json(input_json)
validate_json()
except Exception:
... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"create_backup",
"(",
")",
"try",
":",
"if",
"args",
".",
"input_file",
"or",
"args",
".",
"input_json",
":",
"input_json",
"=",
"get_input_json",
"(",
"args",
")",
"validate_json",
"(",
... | [
173,
0
] | [
186,
23
] | python | en | ['en', 'co', 'en'] | True |
check_sha1 | (filename, sha1_hash) | Check whether the sha1 hash of the file content matches the expected hash.
Parameters
----------
filename : str
Path to the file.
sha1_hash : str
Expected sha1 hash in hexadecimal digits.
Returns
-------
bool
Whether the file content matches the expected hash.
| Check whether the sha1 hash of the file content matches the expected hash.
Parameters
----------
filename : str
Path to the file.
sha1_hash : str
Expected sha1 hash in hexadecimal digits.
Returns
-------
bool
Whether the file content matches the expected hash.
| def check_sha1(filename, sha1_hash):
"""Check whether the sha1 hash of the file content matches the expected hash.
Parameters
----------
filename : str
Path to the file.
sha1_hash : str
Expected sha1 hash in hexadecimal digits.
Returns
-------
bool
Whether the fil... | [
"def",
"check_sha1",
"(",
"filename",
",",
"sha1_hash",
")",
":",
"sha1",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"while",
"True",
":",
"data",
"=",
"f",
".",
"read",
"(",
"1048576",... | [
8,
0
] | [
31,
50
] | python | en | ['en', 'en', 'en'] | True |
download | (url, path=None, overwrite=False, sha1_hash=None) | Download an given URL
Parameters
----------
url : str
URL to download
path : str, optional
Destination path to store downloaded file. By default stores to the
current directory with same name as in url.
overwrite : bool, optional
Whether to overwrite destination file ... | Download an given URL
Parameters
----------
url : str
URL to download
path : str, optional
Destination path to store downloaded file. By default stores to the
current directory with same name as in url.
overwrite : bool, optional
Whether to overwrite destination file ... | def download(url, path=None, overwrite=False, sha1_hash=None):
"""Download an given URL
Parameters
----------
url : str
URL to download
path : str, optional
Destination path to store downloaded file. By default stores to the
current directory with same name as in url.
ove... | [
"def",
"download",
"(",
"url",
",",
"path",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"sha1_hash",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"fname",
"=",
"url",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"else",
"... | [
33,
0
] | [
89,
16
] | 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",... | [
31,
0
] | [
42,
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)
sequence = cv.SCRIPT_SCHEMA({"event": event, "event_data": {"hello": "world"}})
script_obj = script.Script(
hass, sequenc... | [
"async",
"def",
"test_firing_event_basic",
"(",
"hass",
",",
"caplog",
")",
":",
"event",
"=",
"\"test_event\"",
"context",
"=",
"Context",
"(",
")",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_S... | [
45,
0
] | [
63,
58
] | 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",
"(",
... | [
66,
0
] | [
105,
5
] | python | en | ['en', 'en', 'en'] | True |
test_calling_service_basic | (hass) | Test the calling of a service. | Test the calling of a service. | async def test_calling_service_basic(hass):
"""Test the calling of a service."""
context = Context()
calls = async_mock_service(hass, "test", "script")
sequence = cv.SCRIPT_SCHEMA({"service": "test.script", "data": {"hello": "world"}})
script_obj = script.Script(hass, sequence, "Test Name", "test_d... | [
"async",
"def",
"test_calling_service_basic",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"script\"",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"serv... | [
108,
0
] | [
121,
48
] | 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... | [
124,
0
] | [
155,
48
] | 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",
"(",
"{"... | [
158,
0
] | [
175,
35
] | 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",... | [
178,
0
] | [
248,
26
] | python | en | ['en', 'en', 'en'] | True |
test_activating_scene | (hass) | Test the activation of a scene. | Test the activation of a scene. | async def test_activating_scene(hass):
"""Test the activation of a scene."""
context = Context()
calls = async_mock_service(hass, scene.DOMAIN, SERVICE_TURN_ON)
sequence = cv.SCRIPT_SCHEMA({"scene": "scene.hello"})
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
await sc... | [
"async",
"def",
"test_activating_scene",
"(",
"hass",
")",
":",
"context",
"=",
"Context",
"(",
")",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"scene",
".",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
... | [
251,
0
] | [
264,
61
] | 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",
"=",
"... | [
268,
0
] | [
315,
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... | [
318,
0
] | [
339,
45
] | 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",
".",
... | [
342,
0
] | [
382,
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... | [
385,
0
] | [
403,
40
] | 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\"",... | [
406,
0
] | [
430,
27
] | 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",
... | [
433,
0
] | [
450,
40
] | 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... | [
453,
0
] | [
477,
27
] | 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\"... | [
480,
0
] | [
508,
31
] | 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\"",
"]",
... | [
512,
0
] | [
543,
45
] | python | en | ['en', 'fr', '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",
"=",
"{",
"\"... | [
547,
0
] | [
597,
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... | [
601,
0
] | [
640,
31
] | 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... | [
643,
0
] | [
661,
27
] | 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\"",... | [
668,
0
] | [
710,
50
] | 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",
"==... | [
717,
0
] | [
755,
38
] | 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",
",",
... | [
758,
0
] | [
779,
40
] | 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",
... | [
784,
0
] | [
848,
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\"",
",",
"\... | [
851,
0
] | [
872,
52
] | python | en | ['en', 'da', 'en'] | True |
test_condition_basic | (hass) | Test if we can use conditions in a script. | Test if we can use conditions in a script. | async def test_condition_basic(hass):
"""Test if we can use conditions in a script."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
[
{"event": event},
{
"condition": "template",
"value_templa... | [
"async",
"def",
"test_condition_basic",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"event\"",
":",
"event",
"}",
... | [
875,
0
] | [
902,
27
] | 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\" }}'",
... | [
906,
0
] | [
926,
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\" }}'",
",",
"}",
",",
"{",... | [
929,
0
] | [
949,
45
] | python | en | ['en', 'en', 'en'] | True |
test_repeat_count | (hass) | Test repeat action w/ count option. | Test repeat action w/ count option. | async def test_repeat_count(hass):
"""Test repeat action w/ count option."""
event = "test_event"
events = async_capture_events(hass, event)
count = 3
sequence = cv.SCRIPT_SCHEMA(
{
"repeat": {
"count": count,
"sequence": {
"ev... | [
"async",
"def",
"test_repeat_count",
"(",
"hass",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"count",
"=",
"3",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"repeat\"",
":",
... | [
952,
0
] | [
982,
61
] | 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... | [
987,
0
] | [
1056,
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":
sequence["repeat"]["while"] = {
"cond... | [
"async",
"def",
"test_repeat_var_in_condition",
"(",
"hass",
",",
"condition",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"{",
"\"repeat\"",
":",
"{",
"\"sequence\"",
":",
"... | [
1060,
0
] | [
1086,
27
] | 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... | [
1096,
0
] | [
1187,
9
] | python | en | ['da', 'en', 'en'] | True |
test_choose | (hass, var, result) | Test choose action. | Test choose action. | async def test_choose(hass, var, result):
"""Test choose action."""
event = "test_event"
events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA(
{
"choose": [
{
"conditions": {
"condition": "template",
... | [
"async",
"def",
"test_choose",
"(",
"hass",
",",
"var",
",",
"result",
")",
":",
"event",
"=",
"\"test_event\"",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"event",
")",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"{",
"\"choose\"",
":"... | [
1191,
0
] | [
1219,
45
] | 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",
"(",
... | [
1230,
0
] | [
1249,
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... | [
1252,
0
] | [
1265,
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\"",
":"... | [
1268,
0
] | [
1279,
36
] | 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... | [
1282,
0
] | [
1297,
36
] | 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... | [
1300,
0
] | [
1319,
36
] | 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\"",
":"... | [
1322,
0
] | [
1361,
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\"",
"}",
",... | [
1364,
0
] | [
1383,
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"
] | [
1387,
0
] | [
1389,
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\"",
"... | [
1392,
0
] | [
1430,
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' }}\"",
"}",
... | [
1437,
0
] | [
1484,
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",
... | [
1491,
0
] | [
1552,
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",
",... | [
1555,
0
] | [
1649,
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... | [
1652,
0
] | [
1691,
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... | [
1694,
0
] | [
1699,
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"... | [
1702,
0
] | [
1723,
81
] | 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... | [
1726,
0
] | [
1754,
9
] | 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",
",",
... | [
1757,
0
] | [
1773,
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... | [
1776,
0
] | [
1792,
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."""
sequence = cv.SCRIPT_SCHEMA(
[
{"variables": {"variable": "value"}},
{"service": "test.script", "data": {"value": "{{ variable }}"}},
]
)
script_obj = script.Script(hass, sequence,... | [
"async",
"def",
"test_set_variable",
"(",
"hass",
",",
"caplog",
")",
":",
"sequence",
"=",
"cv",
".",
"SCRIPT_SCHEMA",
"(",
"[",
"{",
"\"variables\"",
":",
"{",
"\"variable\"",
":",
"\"value\"",
"}",
"}",
",",
"{",
"\"service\"",
":",
"\"test.script\"",
"... | [
1795,
0
] | [
1810,
49
] | 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\"... | [
1813,
0
] | [
1831,
43
] | 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",
... | [
1834,
0
] | [
1888,
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\"",
",... | [
1891,
0
] | [
1942,
31
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Perform the setup for Xiaomi devices. | Perform the setup for Xiaomi devices. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Perform the setup for Xiaomi devices."""
entities = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
for entity in gateway.devices["binary_sensor"]:
model = entity["model"]
if model in ["motion", "... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"gateway",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"GATEWAYS_KEY",
"]",
"[",
"config_entry",
".",
"entry_id",
... | [
28,
0
] | [
126,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiBinarySensor.__init__ | (self, device, name, xiaomi_hub, data_key, device_class, config_entry) | Initialize the XiaomiSmokeSensor. | Initialize the XiaomiSmokeSensor. | def __init__(self, device, name, xiaomi_hub, data_key, device_class, config_entry):
"""Initialize the XiaomiSmokeSensor."""
self._data_key = data_key
self._device_class = device_class
self._should_poll = False
self._density = 0
super().__init__(device, name, xiaomi_hub, c... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"name",
",",
"xiaomi_hub",
",",
"data_key",
",",
"device_class",
",",
"config_entry",
")",
":",
"self",
".",
"_data_key",
"=",
"data_key",
"self",
".",
"_device_class",
"=",
"device_class",
"self",
".",
"... | [
132,
4
] | [
138,
64
] | python | en | ['en', 'el-Latn', 'en'] | True |
XiaomiBinarySensor.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return self._should_poll | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"self",
".",
"_should_poll"
] | [
141,
4
] | [
143,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self):
"""Return true if sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
146,
4
] | [
148,
26
] | python | en | ['en', 'et', 'en'] | True |
XiaomiBinarySensor.device_class | (self) | Return the class of binary sensor. | Return the class of binary sensor. | def device_class(self):
"""Return the class of binary sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
151,
4
] | [
153,
33
] | python | en | ['en', 'ku', 'en'] | True |
XiaomiBinarySensor.update | (self) | Update the sensor state. | Update the sensor state. | def update(self):
"""Update the sensor state."""
_LOGGER.debug("Updating xiaomi sensor (%s) by polling", self._sid)
self._get_from_hub(self._sid) | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating xiaomi sensor (%s) by polling\"",
",",
"self",
".",
"_sid",
")",
"self",
".",
"_get_from_hub",
"(",
"self",
".",
"_sid",
")"
] | [
155,
4
] | [
158,
37
] | python | en | ['en', 'co', 'en'] | True |
XiaomiNatgasSensor.__init__ | (self, device, xiaomi_hub, config_entry) | Initialize the XiaomiSmokeSensor. | Initialize the XiaomiSmokeSensor. | def __init__(self, device, xiaomi_hub, config_entry):
"""Initialize the XiaomiSmokeSensor."""
self._density = None
super().__init__(
device, "Natgas Sensor", xiaomi_hub, "alarm", "gas", config_entry
) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_density",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"\"Natgas Sensor\"",
",",
"xiaomi_hub",
",",
"\"alarm\"",
",",
... | [
164,
4
] | [
169,
9
] | python | en | ['en', 'el-Latn', 'en'] | True |
XiaomiNatgasSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_DENSITY: self._density}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_DENSITY",
":",
"self",
".",
"_density",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
172,
4
] | [
176,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiNatgasSensor.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if DENSITY in data:
self._density = int(data.get(DENSITY))
value = data.get(self._data_key)
if value is None:
return False
if value in ("1", "2"):
if self._state:
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"if",
"DENSITY",
"in",
"data",
":",
"self",
".",
"_density",
"=",
"int",
"(",
"data",
".",
"get",
"(",
"DENSITY",
")",
")",
"value",
"=",
"data",
".",
"get",
"(",
"self",
"... | [
178,
4
] | [
196,
24
] | python | en | ['en', 'de', 'en'] | True |
XiaomiMotionSensor.__init__ | (self, device, hass, xiaomi_hub, config_entry) | Initialize the XiaomiMotionSensor. | Initialize the XiaomiMotionSensor. | def __init__(self, device, hass, xiaomi_hub, config_entry):
"""Initialize the XiaomiMotionSensor."""
self._hass = hass
self._no_motion_since = 0
self._unsub_set_no_motion = None
if "proto" not in device or int(device["proto"][0:1]) == 1:
data_key = "status"
el... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"hass",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_no_motion_since",
"=",
"0",
"self",
".",
"_unsub_set_no_motion",
"=",
"None",
"if",
"\"proto\"",... | [
202,
4
] | [
213,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiMotionSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_NO_MOTION_SINCE: self._no_motion_since}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_NO_MOTION_SINCE",
":",
"self",
".",
"_no_motion_since",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
216,
4
] | [
220,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiMotionSensor._async_set_no_motion | (self, now) | Set state to False. | Set state to False. | def _async_set_no_motion(self, now):
"""Set state to False."""
self._unsub_set_no_motion = None
self._state = False
self.async_write_ha_state() | [
"def",
"_async_set_no_motion",
"(",
"self",
",",
"now",
")",
":",
"self",
".",
"_unsub_set_no_motion",
"=",
"None",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
223,
4
] | [
227,
35
] | python | en | ['en', 'haw', 'en'] | True |
XiaomiMotionSensor.parse_data | (self, data, raw_data) | Parse data sent by gateway.
Polling (proto v1, firmware version 1.4.1_159.0143)
>> { "cmd":"read","sid":"158..."}
<< {'model': 'motion', 'sid': '158...', 'short_id': 26331,
'cmd': 'read_ack', 'data': '{"voltage":3005}'}
Multicast messages (proto v1, firmware version 1.4.1_... | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway.
Polling (proto v1, firmware version 1.4.1_159.0143)
>> { "cmd":"read","sid":"158..."}
<< {'model': 'motion', 'sid': '158...', 'short_id': 26331,
'cmd': 'read_ack', 'data': '{"voltage":3005}'}
Mult... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"if",
"raw_data",
"[",
"\"cmd\"",
"]",
"==",
"\"heartbeat\"",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Skipping heartbeat of the motion sensor. \"",
"\"It can introduce an incorrect state because of ... | [
229,
4
] | [
287,
23
] | python | en | ['en', 'de', 'en'] | True |
XiaomiDoorSensor.__init__ | (self, device, xiaomi_hub, config_entry) | Initialize the XiaomiDoorSensor. | Initialize the XiaomiDoorSensor. | def __init__(self, device, xiaomi_hub, config_entry):
"""Initialize the XiaomiDoorSensor."""
self._open_since = 0
if "proto" not in device or int(device["proto"][0:1]) == 1:
data_key = "status"
else:
data_key = "window_status"
super().__init__(
... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_open_since",
"=",
"0",
"if",
"\"proto\"",
"not",
"in",
"device",
"or",
"int",
"(",
"device",
"[",
"\"proto\"",
"]",
"[",
"0",
":",
"1",
"]... | [
293,
4
] | [
307,
9
] | python | en | ['en', 'eu', 'en'] | True |
XiaomiDoorSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_OPEN_SINCE: self._open_since}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_OPEN_SINCE",
":",
"self",
".",
"_open_since",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
310,
4
] | [
314,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDoorSensor.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
self._should_poll = False
if NO_CLOSE in data: # handle push from the hub
self._open_since = data[NO_CLOSE]
return True
value = data.get(self._data_key)
if value is None:
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"self",
".",
"_should_poll",
"=",
"False",
"if",
"NO_CLOSE",
"in",
"data",
":",
"# handle push from the hub",
"self",
".",
"_open_since",
"=",
"data",
"[",
"NO_CLOSE",
"]",
"return",
... | [
316,
4
] | [
338,
24
] | python | en | ['en', 'de', 'en'] | True |
XiaomiWaterLeakSensor.__init__ | (self, device, xiaomi_hub, config_entry) | Initialize the XiaomiWaterLeakSensor. | Initialize the XiaomiWaterLeakSensor. | def __init__(self, device, xiaomi_hub, config_entry):
"""Initialize the XiaomiWaterLeakSensor."""
if "proto" not in device or int(device["proto"][0:1]) == 1:
data_key = "status"
else:
data_key = "wleak_status"
super().__init__(
device,
"Wat... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"if",
"\"proto\"",
"not",
"in",
"device",
"or",
"int",
"(",
"device",
"[",
"\"proto\"",
"]",
"[",
"0",
":",
"1",
"]",
")",
"==",
"1",
":",
"data_key",
... | [
344,
4
] | [
357,
9
] | python | en | ['en', 'fy', 'en'] | True |
XiaomiWaterLeakSensor.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
self._should_poll = False
value = data.get(self._data_key)
if value is None:
return False
if value == "leak":
self._should_poll = True
if self._state:
ret... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"self",
".",
"_should_poll",
"=",
"False",
"value",
"=",
"data",
".",
"get",
"(",
"self",
".",
"_data_key",
")",
"if",
"value",
"is",
"None",
":",
"return",
"False",
"if",
"val... | [
359,
4
] | [
377,
24
] | python | en | ['en', 'de', 'en'] | True |
XiaomiSmokeSensor.__init__ | (self, device, xiaomi_hub, config_entry) | Initialize the XiaomiSmokeSensor. | Initialize the XiaomiSmokeSensor. | def __init__(self, device, xiaomi_hub, config_entry):
"""Initialize the XiaomiSmokeSensor."""
self._density = 0
super().__init__(
device, "Smoke Sensor", xiaomi_hub, "alarm", "smoke", config_entry
) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_density",
"=",
"0",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"\"Smoke Sensor\"",
",",
"xiaomi_hub",
",",
"\"alarm\"",
",",
"\"s... | [
383,
4
] | [
388,
9
] | python | en | ['en', 'el-Latn', 'en'] | True |
XiaomiSmokeSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_DENSITY: self._density}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_DENSITY",
":",
"self",
".",
"_density",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
391,
4
] | [
395,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiSmokeSensor.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if DENSITY in data:
self._density = int(data.get(DENSITY))
value = data.get(self._data_key)
if value is None:
return False
if value in ("1", "2"):
if self._state:
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"if",
"DENSITY",
"in",
"data",
":",
"self",
".",
"_density",
"=",
"int",
"(",
"data",
".",
"get",
"(",
"DENSITY",
")",
")",
"value",
"=",
"data",
".",
"get",
"(",
"self",
"... | [
397,
4
] | [
414,
24
] | python | en | ['en', 'de', 'en'] | True |
XiaomiVibration.__init__ | (self, device, name, data_key, xiaomi_hub, config_entry) | Initialize the XiaomiVibration. | Initialize the XiaomiVibration. | def __init__(self, device, name, data_key, xiaomi_hub, config_entry):
"""Initialize the XiaomiVibration."""
self._last_action = None
super().__init__(device, name, xiaomi_hub, data_key, None, config_entry) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"name",
",",
"data_key",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_last_action",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"name",
",",
"xiaomi_hub",
... | [
420,
4
] | [
423,
80
] | 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.