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_no_color_brightness_color_temp_white_val_if_no_topics | (hass, mqtt_mock) | Test for no RGB, brightness, color temp, effect, white val or XY. | Test for no RGB, brightness, color temp, effect, white val or XY. | async def test_no_color_brightness_color_temp_white_val_if_no_topics(hass, mqtt_mock):
"""Test for no RGB, brightness, color temp, effect, white val or XY."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
... | [
"async",
"def",
"test_no_color_brightness_color_temp_white_val_if_no_topics",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
... | [
164,
0
] | [
202,
51
] | python | en | ['en', 'en', 'en'] | True |
test_controlling_state_via_topic | (hass, mqtt_mock) | Test the controlling of the state via topic. | Test the controlling of the state via topic. | async def test_controlling_state_via_topic(hass, mqtt_mock):
"""Test the controlling of the state via topic."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"nam... | [
"async",
"def",
"test_controlling_state_via_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",... | [
205,
0
] | [
312,
59
] | python | en | ['en', 'en', 'en'] | True |
test_sending_mqtt_commands_and_optimistic | (hass, mqtt_mock) | Test the sending of command in optimistic mode. | Test the sending of command in optimistic mode. | async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
"""Test the sending of command in optimistic mode."""
fake_state = ha.State(
"light.test",
"on",
{
"brightness": 95,
"hs_color": [100, 100],
"effect": "random",
"color_te... | [
"async",
"def",
"test_sending_mqtt_commands_and_optimistic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"fake_state",
"=",
"ha",
".",
"State",
"(",
"\"light.test\"",
",",
"\"on\"",
",",
"{",
"\"brightness\"",
":",
"95",
",",
"\"hs_color\"",
":",
"[",
"100",
",",... | [
315,
0
] | [
446,
57
] | python | en | ['en', 'en', 'en'] | True |
test_sending_hs_color | (hass, mqtt_mock) | Test light.turn_on with hs color sends hs color parameters. | Test light.turn_on with hs color sends hs color parameters. | async def test_sending_hs_color(hass, mqtt_mock):
"""Test light.turn_on with hs color sends hs color parameters."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
... | [
"async",
"def",
"test_sending_hs_color",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schem... | [
449,
0
] | [
510,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sending_rgb_color_no_brightness | (hass, mqtt_mock) | Test light.turn_on with hs color sends rgb color parameters. | Test light.turn_on with hs color sends rgb color parameters. | async def test_sending_rgb_color_no_brightness(hass, mqtt_mock):
"""Test light.turn_on with hs color sends rgb color parameters."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
... | [
"async",
"def",
"test_sending_rgb_color_no_brightness",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
... | [
513,
0
] | [
563,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sending_rgb_color_with_brightness | (hass, mqtt_mock) | Test light.turn_on with hs color sends rgb color parameters. | Test light.turn_on with hs color sends rgb color parameters. | async def test_sending_rgb_color_with_brightness(hass, mqtt_mock):
"""Test light.turn_on with hs color sends rgb color parameters."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json"... | [
"async",
"def",
"test_sending_rgb_color_with_brightness",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
... | [
566,
0
] | [
632,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sending_rgb_color_with_scaled_brightness | (hass, mqtt_mock) | Test light.turn_on with hs color sends rgb color parameters. | Test light.turn_on with hs color sends rgb color parameters. | async def test_sending_rgb_color_with_scaled_brightness(hass, mqtt_mock):
"""Test light.turn_on with hs color sends rgb color parameters."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema":... | [
"async",
"def",
"test_sending_rgb_color_with_scaled_brightness",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mq... | [
635,
0
] | [
702,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sending_xy_color | (hass, mqtt_mock) | Test light.turn_on with hs color sends xy color parameters. | Test light.turn_on with hs color sends xy color parameters. | async def test_sending_xy_color(hass, mqtt_mock):
"""Test light.turn_on with hs color sends xy color parameters."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
... | [
"async",
"def",
"test_sending_xy_color",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schem... | [
705,
0
] | [
765,
5
] | python | en | ['en', 'en', 'en'] | True |
test_effect | (hass, mqtt_mock) | Test for effect being sent when included. | Test for effect being sent when included. | async def test_effect(hass, mqtt_mock):
"""Test for effect being sent when included."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"name": "test",
... | [
"async",
"def",
"test_effect",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schema\"",
":... | [
768,
0
] | [
824,
56
] | python | en | ['en', 'en', 'en'] | True |
test_flash_short_and_long | (hass, mqtt_mock) | Test for flash length being sent when included. | Test for flash length being sent when included. | async def test_flash_short_and_long(hass, mqtt_mock):
"""Test for flash length being sent when included."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"name": ... | [
"async",
"def",
"test_flash_short_and_long",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"s... | [
827,
0
] | [
866,
34
] | python | en | ['en', 'en', 'en'] | True |
test_transition | (hass, mqtt_mock) | Test for transition time being sent when included. | Test for transition time being sent when included. | async def test_transition(hass, mqtt_mock):
"""Test for transition time being sent when included."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"name": "test",... | [
"async",
"def",
"test_transition",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schema\"",
... | [
869,
0
] | [
912,
35
] | python | en | ['en', 'en', 'en'] | True |
test_brightness_scale | (hass, mqtt_mock) | Test for brightness scaling. | Test for brightness scaling. | async def test_brightness_scale(hass, mqtt_mock):
"""Test for brightness scaling."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"name": "test",
... | [
"async",
"def",
"test_brightness_scale",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schem... | [
915,
0
] | [
953,
52
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_values | (hass, mqtt_mock) | Test that invalid color/brightness/white/etc. values are ignored. | Test that invalid color/brightness/white/etc. values are ignored. | async def test_invalid_values(hass, mqtt_mock):
"""Test that invalid color/brightness/white/etc. values are ignored."""
assert await async_setup_component(
hass,
light.DOMAIN,
{
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
... | [
"async",
"def",
"test_invalid_values",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"light",
".",
"DOMAIN",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schema\... | [
956,
0
] | [
1070,
52
] | python | en | ['en', 'en', 'en'] | True |
test_availability_when_connection_lost | (hass, mqtt_mock) | Test availability after MQTT disconnection. | Test availability after MQTT disconnection. | async def test_availability_when_connection_lost(hass, mqtt_mock):
"""Test availability after MQTT disconnection."""
await help_test_availability_when_connection_lost(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_availability_when_connection_lost",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_availability_when_connection_lost",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1073,
0
] | [
1077,
5
] | python | en | ['en', 'en', 'en'] | True |
test_availability_without_topic | (hass, mqtt_mock) | Test availability without defined availability topic. | Test availability without defined availability topic. | async def test_availability_without_topic(hass, mqtt_mock):
"""Test availability without defined availability topic."""
await help_test_availability_without_topic(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_availability_without_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_availability_without_topic",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1080,
0
] | [
1084,
5
] | python | en | ['en', 'en', 'en'] | True |
test_default_availability_payload | (hass, mqtt_mock) | Test availability by default payload with defined topic. | Test availability by default payload with defined topic. | async def test_default_availability_payload(hass, mqtt_mock):
"""Test availability by default payload with defined topic."""
await help_test_default_availability_payload(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_default_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_default_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1087,
0
] | [
1091,
5
] | python | en | ['en', 'en', 'en'] | True |
test_custom_availability_payload | (hass, mqtt_mock) | Test availability by custom payload with defined topic. | Test availability by custom payload with defined topic. | async def test_custom_availability_payload(hass, mqtt_mock):
"""Test availability by custom payload with defined topic."""
await help_test_custom_availability_payload(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_custom_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_custom_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1094,
0
] | [
1098,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setting_attribute_via_mqtt_json_message | (hass, mqtt_mock) | Test the setting of attribute via MQTT with JSON payload. | Test the setting of attribute via MQTT with JSON payload. | async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock):
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_via_mqtt_json_message(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_setting_attribute_via_mqtt_json_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_setting_attribute_via_mqtt_json_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1101,
0
] | [
1105,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setting_attribute_with_template | (hass, mqtt_mock) | Test the setting of attribute via MQTT with JSON payload. | Test the setting of attribute via MQTT with JSON payload. | async def test_setting_attribute_with_template(hass, mqtt_mock):
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_with_template(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_setting_attribute_with_template",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_setting_attribute_with_template",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1108,
0
] | [
1112,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_with_json_attrs_not_dict | (hass, mqtt_mock, caplog) | Test attributes get extracted from a JSON result. | Test attributes get extracted from a JSON result. | async def test_update_with_json_attrs_not_dict(hass, mqtt_mock, caplog):
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_update_with_json_attrs_not_dict",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"await",
"help_test_update_with_json_attrs_not_dict",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")... | [
1115,
0
] | [
1119,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_with_json_attrs_bad_JSON | (hass, mqtt_mock, caplog) | Test attributes get extracted from a JSON result. | Test attributes get extracted from a JSON result. | async def test_update_with_json_attrs_bad_JSON(hass, mqtt_mock, caplog):
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_JSON(
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_update_with_json_attrs_bad_JSON",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"await",
"help_test_update_with_json_attrs_bad_JSON",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")... | [
1122,
0
] | [
1126,
5
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_update_attr | (hass, mqtt_mock, caplog) | Test update of discovered MQTTAttributes. | Test update of discovered MQTTAttributes. | async def test_discovery_update_attr(hass, mqtt_mock, caplog):
"""Test update of discovered MQTTAttributes."""
await help_test_discovery_update_attr(
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_discovery_update_attr",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"await",
"help_test_discovery_update_attr",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1129,
0
] | [
1133,
5
] | python | en | ['en', 'en', 'en'] | True |
test_unique_id | (hass, mqtt_mock) | Test unique id option only creates one light per unique_id. | Test unique id option only creates one light per unique_id. | async def test_unique_id(hass, mqtt_mock):
"""Test unique id option only creates one light per unique_id."""
config = {
light.DOMAIN: [
{
"platform": "mqtt",
"name": "Test 1",
"schema": "json",
"state_topic": "test-topic",
... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"{",
"light",
".",
"DOMAIN",
":",
"[",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"name\"",
":",
"\"Test 1\"",
",",
"\"schema\"",
":",
"\"json\"",
",",
"\"state_top... | [
1136,
0
] | [
1158,
68
] | python | en | ['en', 'fr', 'en'] | True |
test_discovery_removal | (hass, mqtt_mock, caplog) | Test removal of discovered mqtt_json lights. | Test removal of discovered mqtt_json lights. | async def test_discovery_removal(hass, mqtt_mock, caplog):
"""Test removal of discovered mqtt_json lights."""
data = '{ "name": "test",' ' "schema": "json",' ' "command_topic": "test_topic" }'
await help_test_discovery_removal(hass, mqtt_mock, caplog, light.DOMAIN, data) | [
"async",
"def",
"test_discovery_removal",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data",
"=",
"'{ \"name\": \"test\",'",
"' \"schema\": \"json\",'",
"' \"command_topic\": \"test_topic\" }'",
"await",
"help_test_discovery_removal",
"(",
"hass",
",",
"mqtt_... | [
1161,
0
] | [
1164,
82
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_update_light | (hass, mqtt_mock, caplog) | Test update of discovered light. | Test update of discovered light. | async def test_discovery_update_light(hass, mqtt_mock, caplog):
"""Test update of discovered light."""
data1 = (
'{ "name": "Beer",'
' "schema": "json",'
' "state_topic": "test_topic",'
' "command_topic": "test_topic" }'
)
data2 = (
'{ "name": "Milk",'
... | [
"async",
"def",
"test_discovery_update_light",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"(",
"'{ \"name\": \"Beer\",'",
"' \"schema\": \"json\",'",
"' \"state_topic\": \"test_topic\",'",
"' \"command_topic\": \"test_topic\" }'",
")",
"data2",
"... | [
1167,
0
] | [
1183,
5
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_update_unchanged_light | (hass, mqtt_mock, caplog) | Test update of discovered light. | Test update of discovered light. | async def test_discovery_update_unchanged_light(hass, mqtt_mock, caplog):
"""Test update of discovered light."""
data1 = (
'{ "name": "Beer",'
' "schema": "json",'
' "state_topic": "test_topic",'
' "command_topic": "test_topic" }'
)
with patch(
"homeassistant.c... | [
"async",
"def",
"test_discovery_update_unchanged_light",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"(",
"'{ \"name\": \"Beer\",'",
"' \"schema\": \"json\",'",
"' \"state_topic\": \"test_topic\",'",
"' \"command_topic\": \"test_topic\" }'",
")",
"w... | [
1186,
0
] | [
1199,
9
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_broken | (hass, mqtt_mock, caplog) | Test handling of bad discovery message. | Test handling of bad discovery message. | async def test_discovery_broken(hass, mqtt_mock, caplog):
"""Test handling of bad discovery message."""
data1 = '{ "name": "Beer" }'
data2 = (
'{ "name": "Milk",'
' "schema": "json",'
' "state_topic": "test_topic",'
' "command_topic": "test_topic" }'
)
await help_t... | [
"async",
"def",
"test_discovery_broken",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"'{ \"name\": \"Beer\" }'",
"data2",
"=",
"(",
"'{ \"name\": \"Milk\",'",
"' \"schema\": \"json\",'",
"' \"state_topic\": \"test_topic\",'",
"' \"command_topic\":... | [
1203,
0
] | [
1214,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_device_info_with_connection | (hass, mqtt_mock) | Test MQTT light device registry integration. | Test MQTT light device registry integration. | async def test_entity_device_info_with_connection(hass, mqtt_mock):
"""Test MQTT light device registry integration."""
await help_test_entity_device_info_with_connection(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_with_connection",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_with_connection",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1217,
0
] | [
1221,
5
] | python | en | ['en', 'sv', 'en'] | True |
test_entity_device_info_with_identifier | (hass, mqtt_mock) | Test MQTT light device registry integration. | Test MQTT light device registry integration. | async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT light device registry integration."""
await help_test_entity_device_info_with_identifier(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_with_identifier",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_with_identifier",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1224,
0
] | [
1228,
5
] | python | en | ['en', 'sv', 'en'] | True |
test_entity_device_info_update | (hass, mqtt_mock) | Test device registry update. | Test device registry update. | async def test_entity_device_info_update(hass, mqtt_mock):
"""Test device registry update."""
await help_test_entity_device_info_update(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_update",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_update",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1231,
0
] | [
1235,
5
] | python | en | ['fr', 'fy', 'en'] | False |
test_entity_device_info_remove | (hass, mqtt_mock) | Test device registry remove. | Test device registry remove. | async def test_entity_device_info_remove(hass, mqtt_mock):
"""Test device registry remove."""
await help_test_entity_device_info_remove(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_remove",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_remove",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1238,
0
] | [
1242,
5
] | python | en | ['fr', 'en', 'en'] | True |
test_entity_id_update_subscriptions | (hass, mqtt_mock) | Test MQTT subscriptions are managed when entity_id is updated. | Test MQTT subscriptions are managed when entity_id is updated. | async def test_entity_id_update_subscriptions(hass, mqtt_mock):
"""Test MQTT subscriptions are managed when entity_id is updated."""
await help_test_entity_id_update_subscriptions(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_id_update_subscriptions",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_id_update_subscriptions",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1245,
0
] | [
1249,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_id_update_discovery_update | (hass, mqtt_mock) | Test MQTT discovery update when entity_id is updated. | Test MQTT discovery update when entity_id is updated. | async def test_entity_id_update_discovery_update(hass, mqtt_mock):
"""Test MQTT discovery update when entity_id is updated."""
await help_test_entity_id_update_discovery_update(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_id_update_discovery_update",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_id_update_discovery_update",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
1252,
0
] | [
1256,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_debug_info_message | (hass, mqtt_mock) | Test MQTT debug info. | Test MQTT debug info. | async def test_entity_debug_info_message(hass, mqtt_mock):
"""Test MQTT debug info."""
await help_test_entity_debug_info_message(
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG, payload='{"state":"ON"}'
) | [
"async",
"def",
"test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"light",
".",
"DOMAIN",
",",
"DEFAULT_CONFIG",
",",
"payload",
"=",
"'{\"state\":\"ON\"}'",
... | [
1259,
0
] | [
1263,
5
] | python | es | ['es', 'mt', 'it'] | False |
test_max_mireds | (hass, mqtt_mock) | Test setting min_mireds and max_mireds. | Test setting min_mireds and max_mireds. | async def test_max_mireds(hass, mqtt_mock):
"""Test setting min_mireds and max_mireds."""
config = {
light.DOMAIN: {
"platform": "mqtt",
"schema": "json",
"name": "test",
"command_topic": "test_max_mireds/set",
"color_temp": True,
"... | [
"async",
"def",
"test_max_mireds",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"schema\"",
":",
"\"json\"",
",",
"\"name\"",
":",
"\"test\"",
",",
"\"command_topic\"",... | [
1266,
0
] | [
1284,
52
] | python | en | ['en', 'en', 'en'] | True |
JsonValidator.__init__ | (self, jsondata) | Initialize JSON validator. | Initialize JSON validator. | def __init__(self, jsondata):
"""Initialize JSON validator."""
self.jsondata = jsondata | [
"def",
"__init__",
"(",
"self",
",",
"jsondata",
")",
":",
"self",
".",
"jsondata",
"=",
"jsondata"
] | [
144,
4
] | [
146,
32
] | python | en | ['en', 'zu', 'it'] | False |
JsonValidator.__eq__ | (self, other) | Compare JSON data. | Compare JSON data. | def __eq__(self, other):
"""Compare JSON data."""
return json.loads(self.jsondata) == json.loads(other) | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"jsondata",
")",
"==",
"json",
".",
"loads",
"(",
"other",
")"
] | [
148,
4
] | [
150,
61
] | python | en | ['en', 'it', 'en'] | True |
test_sensor_platform | (hass, aioclient_mock) | Test sensor platform. | Test sensor platform. | async def test_sensor_platform(hass, aioclient_mock):
"""Test sensor platform."""
aioclient_mock.get(
TEST_SYSTEM_URL,
text=TEST_SYSTEM_DATA,
)
aioclient_mock.get(
TEST_SET_URL,
text=TEST_SET_RESPONSE,
)
await add_mock_config(hass)
registry = await hass.help... | [
"async",
"def",
"test_sensor_platform",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"TEST_SYSTEM_URL",
",",
"text",
"=",
"TEST_SYSTEM_DATA",
",",
")",
"aioclient_mock",
".",
"get",
"(",
"TEST_SET_URL",
",",
"text",
"=",
"TE... | [
20,
0
] | [
125,
55
] | python | en | ['en', 'ru', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Logitech Harmony Hub component. | Set up the Logitech Harmony Hub component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Logitech Harmony Hub component."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
18,
0
] | [
22,
15
] | python | en | ['en', 'haw', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Logitech Harmony Hub from a config entry. | Set up Logitech Harmony Hub from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Logitech Harmony Hub from a config entry."""
# As there currently is no way to import options from yaml
# when setting up a config entry, we fallback to adding
# the options to the config entry and pull them out here if
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"# As there currently is no way to import options from yaml",
"# when setting up a config entry, we fallback to adding",
"# the options to the config entry and pull them ... | [
25,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
_update_listener | (hass: HomeAssistant, entry: ConfigEntry) | Handle options update. | Handle options update. | async def _update_listener(hass: HomeAssistant, entry: ConfigEntry):
"""Handle options update."""
async_dispatcher_send(
hass, f"{HARMONY_OPTIONS_UPDATE}-{entry.unique_id}", entry.options
) | [
"async",
"def",
"_update_listener",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"async_dispatcher_send",
"(",
"hass",
",",
"f\"{HARMONY_OPTIONS_UPDATE}-{entry.unique_id}\"",
",",
"entry",
".",
"options",
")"
] | [
75,
0
] | [
79,
5
] | python | en | ['en', 'nl', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
82,
0
] | [
100,
20
] | python | en | ['en', 'es', 'en'] | True |
async_get_service | (hass, config, discovery_info=None) | Return the notify service. | Return the notify service. | async def async_get_service(hass, config, discovery_info=None):
"""Return the notify service."""
url = f"{config.get(CONF_HOST)}:{config.get(CONF_PORT)}"
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
encr... | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"url",
"=",
"f\"{config.get(CONF_HOST)}:{config.get(CONF_PORT)}\"",
"username",
"=",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"c... | [
44,
0
] | [
71,
51
] | python | en | ['en', 'en', 'en'] | True |
KodiNotificationService.__init__ | (self, hass, url, auth=None) | Initialize the service. | Initialize the service. | def __init__(self, hass, url, auth=None):
"""Initialize the service."""
self._url = url
kwargs = {"timeout": DEFAULT_TIMEOUT, "session": async_get_clientsession(hass)}
if auth is not None:
kwargs["auth"] = auth
self._server = jsonrpc_async.Server(self._url, **kwarg... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"url",
",",
"auth",
"=",
"None",
")",
":",
"self",
".",
"_url",
"=",
"url",
"kwargs",
"=",
"{",
"\"timeout\"",
":",
"DEFAULT_TIMEOUT",
",",
"\"session\"",
":",
"async_get_clientsession",
"(",
"hass",
")",... | [
77,
4
] | [
86,
64
] | python | en | ['en', 'en', 'en'] | True |
KodiNotificationService.async_send_message | (self, message="", **kwargs) | Send a message to Kodi. | Send a message to Kodi. | async def async_send_message(self, message="", **kwargs):
"""Send a message to Kodi."""
try:
data = kwargs.get(ATTR_DATA) or {}
displaytime = int(data.get(ATTR_DISPLAYTIME, 10000))
icon = data.get(ATTR_ICON, "info")
title = kwargs.get(ATTR_TITLE, ATTR_TIT... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"or",
"{",
"}",
"displaytime",
"=",
"int",
"(",
"data",
".",
"g... | [
88,
4
] | [
99,
73
] | python | en | ['en', 'mk', 'en'] | True |
ConfigFlow.__init__ | (self) | Initialize the config flow. | Initialize the config flow. | def __init__(self):
"""Initialize the config flow."""
self.data_schema = vol.Schema({vol.Required(CONF_ZIP_CODE): str}) | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_ZIP_CODE",
")",
":",
"str",
"}",
")"
] | [
17,
4
] | [
19,
73
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the start of the config flow. | Handle the start of the config flow. | async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
if not user_input:
return self.async_show_form(step_id="user", data_schema=self.data_schema)
await self.async_set_unique_id(user_input[CONF_ZIP_CODE])
self._abort_if_unique_id_config... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"not",
"user_input",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"self",
".",
"data_schema",
")",
"... | [
21,
4
] | [
40,
88
] | python | en | ['en', 'en', 'en'] | True |
patch_product_identify | (path=None, **kwargs) | Patch the blebox_uniapi Products class. | Patch the blebox_uniapi Products class. | def patch_product_identify(path=None, **kwargs):
"""Patch the blebox_uniapi Products class."""
if path is None:
path = "homeassistant.components.blebox.Products"
patcher = patch(path, mock.DEFAULT, blebox_uniapi.products.Products, True, True)
products_class = patcher.start()
products_class.a... | [
"def",
"patch_product_identify",
"(",
"path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"\"homeassistant.components.blebox.Products\"",
"patcher",
"=",
"patch",
"(",
"path",
",",
"mock",
".",
"DEFAULT",
","... | [
15,
0
] | [
22,
25
] | python | en | ['en', 'en', 'en'] | True |
setup_product_mock | (category, feature_mocks, path=None) | Mock a product returning the given features. | Mock a product returning the given features. | def setup_product_mock(category, feature_mocks, path=None):
"""Mock a product returning the given features."""
product_mock = mock.create_autospec(
blebox_uniapi.box.Box, True, True, features=None
)
type(product_mock).features = PropertyMock(return_value={category: feature_mocks})
for feat... | [
"def",
"setup_product_mock",
"(",
"category",
",",
"feature_mocks",
",",
"path",
"=",
"None",
")",
":",
"product_mock",
"=",
"mock",
".",
"create_autospec",
"(",
"blebox_uniapi",
".",
"box",
".",
"Box",
",",
"True",
",",
"True",
",",
"features",
"=",
"None... | [
25,
0
] | [
37,
23
] | python | en | ['en', 'en', 'en'] | True |
mock_only_feature | (spec, **kwargs) | Mock just the feature, without the product setup. | Mock just the feature, without the product setup. | def mock_only_feature(spec, **kwargs):
"""Mock just the feature, without the product setup."""
return mock.create_autospec(spec, True, True, **kwargs) | [
"def",
"mock_only_feature",
"(",
"spec",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"mock",
".",
"create_autospec",
"(",
"spec",
",",
"True",
",",
"True",
",",
"*",
"*",
"kwargs",
")"
] | [
40,
0
] | [
42,
59
] | python | en | ['en', 'en', 'en'] | True |
mock_feature | (category, spec, **kwargs) | Mock a feature along with whole product setup. | Mock a feature along with whole product setup. | def mock_feature(category, spec, **kwargs):
"""Mock a feature along with whole product setup."""
feature_mock = mock_only_feature(spec, **kwargs)
feature_mock.async_update = AsyncMock()
product = setup_product_mock(category, [feature_mock])
type(feature_mock.product).name = PropertyMock(return_valu... | [
"def",
"mock_feature",
"(",
"category",
",",
"spec",
",",
"*",
"*",
"kwargs",
")",
":",
"feature_mock",
"=",
"mock_only_feature",
"(",
"spec",
",",
"*",
"*",
"kwargs",
")",
"feature_mock",
".",
"async_update",
"=",
"AsyncMock",
"(",
")",
"product",
"=",
... | [
45,
0
] | [
58,
23
] | python | en | ['en', 'en', 'en'] | True |
mock_config | (ip_address="172.100.123.4") | Return a Mock of the HA entity config. | Return a Mock of the HA entity config. | def mock_config(ip_address="172.100.123.4"):
"""Return a Mock of the HA entity config."""
return MockConfigEntry(domain=DOMAIN, data={CONF_HOST: ip_address, CONF_PORT: 80}) | [
"def",
"mock_config",
"(",
"ip_address",
"=",
"\"172.100.123.4\"",
")",
":",
"return",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"ip_address",
",",
"CONF_PORT",
":",
"80",
"}",
")"
] | [
61,
0
] | [
63,
86
] | python | en | ['en', 'en', 'en'] | True |
config_fixture | () | Create hass config fixture. | Create hass config fixture. | def config_fixture():
"""Create hass config fixture."""
return {DOMAIN: {CONF_HOST: "172.100.123.4", CONF_PORT: 80}} | [
"def",
"config_fixture",
"(",
")",
":",
"return",
"{",
"DOMAIN",
":",
"{",
"CONF_HOST",
":",
"\"172.100.123.4\"",
",",
"CONF_PORT",
":",
"80",
"}",
"}"
] | [
67,
0
] | [
69,
64
] | python | en | ['en', 'en', 'en'] | True |
feature_fixture | (request) | Return an entity wrapper from given fixture name. | Return an entity wrapper from given fixture name. | def feature_fixture(request):
"""Return an entity wrapper from given fixture name."""
return request.getfixturevalue(request.param) | [
"def",
"feature_fixture",
"(",
"request",
")",
":",
"return",
"request",
".",
"getfixturevalue",
"(",
"request",
".",
"param",
")"
] | [
73,
0
] | [
75,
49
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entities | (hass, config, entity_ids) | Return configured entries with the given entity ids. | Return configured entries with the given entity ids. | async def async_setup_entities(hass, config, entity_ids):
"""Return configured entries with the given entity ids."""
config_entry = mock_config()
config_entry.add_to_hass(hass)
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
entity_registry = await h... | [
"async",
"def",
"async_setup_entities",
"(",
"hass",
",",
"config",
",",
"entity_ids",
")",
":",
"config_entry",
"=",
"mock_config",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"... | [
78,
0
] | [
87,
77
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entity | (hass, config, entity_id) | Return a configured entry with the given entity_id. | Return a configured entry with the given entity_id. | async def async_setup_entity(hass, config, entity_id):
"""Return a configured entry with the given entity_id."""
return (await async_setup_entities(hass, config, [entity_id]))[0] | [
"async",
"def",
"async_setup_entity",
"(",
"hass",
",",
"config",
",",
"entity_id",
")",
":",
"return",
"(",
"await",
"async_setup_entities",
"(",
"hass",
",",
"config",
",",
"[",
"entity_id",
"]",
")",
")",
"[",
"0",
"]"
] | [
90,
0
] | [
93,
69
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass, hass_config, async_add_entities, discovery_info=None
) | Set up the LCN switch platform. | Set up the LCN switch platform. | async def async_setup_platform(
hass, hass_config, async_add_entities, discovery_info=None
):
"""Set up the LCN switch platform."""
if discovery_info is None:
return
devices = []
for config in discovery_info:
address, connection_id = config[CONF_ADDRESS]
addr = pypck.lcn_add... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"hass_config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"devices",
"=",
"[",
"]",
"for",
"config",
"in",
"discovery_i... | [
11,
0
] | [
33,
31
] | python | en | ['en', 'da', 'en'] | True |
LcnOutputSwitch.__init__ | (self, config, address_connection) | Initialize the LCN switch. | Initialize the LCN switch. | def __init__(self, config, address_connection):
"""Initialize the LCN switch."""
super().__init__(config, address_connection)
self.output = pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self._is_on = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"OutputPort",
"[",
"config",
... | [
39,
4
] | [
45,
26
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputSwitch.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.output) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"output",
")"
] | [
47,
4
] | [
50,
82
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputSwitch.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self):
"""Return True if entity is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
53,
4
] | [
55,
26
] | python | en | ['en', 'cy', 'en'] | True |
LcnOutputSwitch.async_turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
self._is_on = True
self.address_connection.dim_output(self.output.value, 100, 0)
self.async_write_ha_state() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"True",
"self",
".",
"address_connection",
".",
"dim_output",
"(",
"self",
".",
"output",
".",
"value",
",",
"100",
",",
"0",
")",
"self",
".... | [
57,
4
] | [
61,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputSwitch.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
self._is_on = False
self.address_connection.dim_output(self.output.value, 0, 0)
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"False",
"self",
".",
"address_connection",
".",
"dim_output",
"(",
"self",
".",
"output",
".",
"value",
",",
"0",
",",
"0",
")",
"self",
".... | [
63,
4
] | [
67,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputSwitch.input_received | (self, input_obj) | Set switch state when LCN input object (command) is received. | Set switch state when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set switch state when LCN input object (command) is received."""
if (
not isinstance(input_obj, pypck.inputs.ModStatusOutput)
or input_obj.get_output_id() != self.output.value
):
return
self._is_on = input_obj.g... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusOutput",
")",
"or",
"input_obj",
".",
"get_output_id",
"(",
")",
"!=",
"self",
".",
"output",
... | [
69,
4
] | [
78,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelaySwitch.__init__ | (self, config, address_connection) | Initialize the LCN switch. | Initialize the LCN switch. | def __init__(self, config, address_connection):
"""Initialize the LCN switch."""
super().__init__(config, address_connection)
self.output = pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self._is_on = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"RelayPort",
"[",
"config",
... | [
84,
4
] | [
90,
26
] | python | en | ['en', 'en', 'en'] | True |
LcnRelaySwitch.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.output) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"output",
")"
] | [
92,
4
] | [
95,
82
] | python | en | ['en', 'en', 'en'] | True |
LcnRelaySwitch.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self):
"""Return True if entity is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
98,
4
] | [
100,
26
] | python | en | ['en', 'cy', 'en'] | True |
LcnRelaySwitch.async_turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
self._is_on = True
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON
self.address_connection.control_relays(states)
self.async_writ... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"True",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"RelayStateModifier",
".",
"NOCHANGE",
"]",
"*",
"8",
"states",
"[",
"self",
".",
... | [
102,
4
] | [
109,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelaySwitch.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
self._is_on = False
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF
self.address_connection.control_relays(states)
self.async_... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"False",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"RelayStateModifier",
".",
"NOCHANGE",
"]",
"*",
"8",
"states",
"[",
"self",
".",
... | [
111,
4
] | [
118,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelaySwitch.input_received | (self, input_obj) | Set switch state when LCN input object (command) is received. | Set switch state when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set switch state when LCN input object (command) is received."""
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
self._is_on = input_obj.get_state(self.output.value)
self.async_write_ha_state() | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusRelays",
")",
":",
"return",
"self",
".",
"_is_on",
"=",
"input_obj",
".",
"get_state",
"(",
"self",
... | [
120,
4
] | [
126,
35
] | python | en | ['en', 'en', 'en'] | True |
create_lightbulb_service | (accessory) | Define lightbulb characteristics. | Define lightbulb characteristics. | def create_lightbulb_service(accessory):
"""Define lightbulb characteristics."""
service = accessory.add_service(ServicesTypes.LIGHTBULB, name=LIGHT_BULB_NAME)
on_char = service.add_char(CharacteristicsTypes.ON)
on_char.value = 0
brightness = service.add_char(CharacteristicsTypes.BRIGHTNESS)
b... | [
"def",
"create_lightbulb_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"LIGHTBULB",
",",
"name",
"=",
"LIGHT_BULB_NAME",
")",
"on_char",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes... | [
18,
0
] | [
28,
18
] | python | en | ['en', 'bg', 'en'] | True |
create_lightbulb_service_with_hs | (accessory) | Define a lightbulb service with hue + saturation. | Define a lightbulb service with hue + saturation. | def create_lightbulb_service_with_hs(accessory):
"""Define a lightbulb service with hue + saturation."""
service = create_lightbulb_service(accessory)
hue = service.add_char(CharacteristicsTypes.HUE)
hue.value = 0
saturation = service.add_char(CharacteristicsTypes.SATURATION)
saturation.value ... | [
"def",
"create_lightbulb_service_with_hs",
"(",
"accessory",
")",
":",
"service",
"=",
"create_lightbulb_service",
"(",
"accessory",
")",
"hue",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"HUE",
")",
"hue",
".",
"value",
"=",
"0",
"satura... | [
31,
0
] | [
41,
18
] | python | en | ['en', 'en', 'en'] | True |
create_lightbulb_service_with_color_temp | (accessory) | Define a lightbulb service with color temp. | Define a lightbulb service with color temp. | def create_lightbulb_service_with_color_temp(accessory):
"""Define a lightbulb service with color temp."""
service = create_lightbulb_service(accessory)
color_temp = service.add_char(CharacteristicsTypes.COLOR_TEMPERATURE)
color_temp.value = 0
return service | [
"def",
"create_lightbulb_service_with_color_temp",
"(",
"accessory",
")",
":",
"service",
"=",
"create_lightbulb_service",
"(",
"accessory",
")",
"color_temp",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"COLOR_TEMPERATURE",
")",
"color_temp",
"."... | [
44,
0
] | [
51,
18
] | python | en | ['en', 'ro', 'en'] | True |
test_switch_change_light_state | (hass, utcnow) | Test that we can turn a HomeKit light on and off again. | Test that we can turn a HomeKit light on and off again. | async def test_switch_change_light_state(hass, utcnow):
"""Test that we can turn a HomeKit light on and off again."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
await hass.services.async_call(
"light",
"turn_on",
{"entity_id": "light.testdevice", "br... | [
"async",
"def",
"test_switch_change_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"\"light\"",
... | [
54,
0
] | [
73,
54
] | python | en | ['en', 'en', 'en'] | True |
test_switch_change_light_state_color_temp | (hass, utcnow) | Test that we can turn change color_temp. | Test that we can turn change color_temp. | async def test_switch_change_light_state_color_temp(hass, utcnow):
"""Test that we can turn change color_temp."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
await hass.services.async_call(
"light",
"turn_on",
{"entity_id": "light.testdevice",... | [
"async",
"def",
"test_switch_change_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"... | [
76,
0
] | [
88,
64
] | python | en | ['en', 'en', 'en'] | True |
test_switch_read_light_state | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_read_light_state(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert state.state... | [
"async",
"def",
"test_switch_read_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"# Initial state is that the light is off",
"state",
"=",
"await",
"helper",
... | [
91,
0
] | [
112,
31
] | python | en | ['en', 'en', 'en'] | True |
test_switch_push_light_state | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_push_light_state(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
# Initial state is that the light is off
state = hass.states.get(LIGHT_BULB_ENTITY_ID)
assert state.s... | [
"async",
"def",
"test_switch_push_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"# Initial state is that the light is off",
"state",
"=",
"hass",
".",
"state... | [
115,
0
] | [
141,
31
] | python | en | ['en', 'en', 'en'] | True |
test_switch_read_light_state_color_temp | (hass, utcnow) | Test that we can read the color_temp of a light accessory. | Test that we can read the color_temp of a light accessory. | async def test_switch_read_light_state_color_temp(hass, utcnow):
"""Test that we can read the color_temp of a light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
a... | [
"async",
"def",
"test_switch_read_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"awa... | [
144,
0
] | [
160,
48
] | python | en | ['en', 'en', 'en'] | True |
test_switch_push_light_state_color_temp | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_push_light_state_color_temp(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = hass.states.get(LIGHT_BULB_ENTITY_ID)... | [
"async",
"def",
"test_switch_push_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"has... | [
163,
0
] | [
183,
48
] | python | en | ['en', 'en', 'en'] | True |
test_light_becomes_unavailable_but_recovers | (hass, utcnow) | Test transition to and from unavailable state. | Test transition to and from unavailable state. | async def test_light_becomes_unavailable_but_recovers(hass, utcnow):
"""Test transition to and from unavailable state."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert sta... | [
"async",
"def",
"test_light_becomes_unavailable_but_recovers",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
... | [
186,
0
] | [
208,
48
] | python | en | ['en', 'en', 'en'] | True |
test_light_unloaded | (hass, utcnow) | Test entity and HKDevice are correctly unloaded. | Test entity and HKDevice are correctly unloaded. | async def test_light_unloaded(hass, utcnow):
"""Test entity and HKDevice are correctly unloaded."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert state.state == "off"
... | [
"async",
"def",
"test_light_unloaded",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"await",
"helper",
"... | [
211,
0
] | [
227,
44
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Smarty Fan Platform. | Set up the Smarty Fan Platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Smarty Fan Platform."""
smarty = hass.data[DOMAIN]["api"]
name = hass.data[DOMAIN]["name"]
async_add_entities([SmartyFan(name, smarty)], True) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"smarty",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"api\"",
"]",
"name",
"=",
"hass",
".",
"data",
"[... | [
25,
0
] | [
30,
55
] | python | en | ['en', 'cs', 'en'] | True |
SmartyFan.__init__ | (self, name, smarty) | Initialize the entity. | Initialize the entity. | def __init__(self, name, smarty):
"""Initialize the entity."""
self._name = name
self._speed = SPEED_OFF
self._state = None
self._smarty = smarty | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"smarty",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_speed",
"=",
"SPEED_OFF",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_smarty",
"=",
"smarty"
] | [
36,
4
] | [
41,
29
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.should_poll | (self) | Do not poll. | Do not poll. | def should_poll(self):
"""Do not poll."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
44,
4
] | [
46,
20
] | python | en | ['en', 'lb', 'en'] | True |
SmartyFan.name | (self) | Return the name of the fan. | Return the name of the fan. | def name(self):
"""Return the name of the fan."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
49,
4
] | [
51,
25
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return "mdi:air-conditioner" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:air-conditioner\""
] | [
54,
4
] | [
56,
36
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_SET_SPEED | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_SET_SPEED"
] | [
59,
4
] | [
61,
32
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.speed_list | (self) | List of available fan modes. | List of available fan modes. | def speed_list(self):
"""List of available fan modes."""
return SPEED_LIST | [
"def",
"speed_list",
"(",
"self",
")",
":",
"return",
"SPEED_LIST"
] | [
64,
4
] | [
66,
25
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.is_on | (self) | Return state of the fan. | Return state of the fan. | def is_on(self):
"""Return state of the fan."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
69,
4
] | [
71,
26
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.speed | (self) | Return speed of the fan. | Return speed of the fan. | def speed(self) -> str:
"""Return speed of the fan."""
return self._speed | [
"def",
"speed",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_speed"
] | [
74,
4
] | [
76,
26
] | python | en | ['en', 'fy', 'en'] | True |
SmartyFan.set_speed | (self, speed: str) | Set the speed of the fan. | Set the speed of the fan. | def set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
_LOGGER.debug("Set the fan speed to %s", speed)
if speed == SPEED_OFF:
self.turn_off()
else:
self._smarty.set_fan_speed(SPEED_TO_MODE.get(speed))
self._speed = speed
s... | [
"def",
"set_speed",
"(",
"self",
",",
"speed",
":",
"str",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set the fan speed to %s\"",
",",
"speed",
")",
"if",
"speed",
"==",
"SPEED_OFF",
":",
"self",
".",
"turn_off",
"(",
")",
"else",
":",
"s... | [
78,
4
] | [
86,
30
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan.turn_on | (self, speed=None, **kwargs) | Turn on the fan. | Turn on the fan. | def turn_on(self, speed=None, **kwargs):
"""Turn on the fan."""
_LOGGER.debug("Turning on fan. Speed is %s", speed)
if speed is None:
if self._smarty.turn_on(SPEED_TO_MODE.get(self._speed)):
self._state = True
self._speed = SPEED_MEDIUM
else:
... | [
"def",
"turn_on",
"(",
"self",
",",
"speed",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turning on fan. Speed is %s\"",
",",
"speed",
")",
"if",
"speed",
"is",
"None",
":",
"if",
"self",
".",
"_smarty",
".",
"turn_... | [
88,
4
] | [
100,
39
] | python | en | ['en', 'fy', 'en'] | True |
SmartyFan.turn_off | (self, **kwargs) | Turn off the fan. | Turn off the fan. | def turn_off(self, **kwargs):
"""Turn off the fan."""
_LOGGER.debug("Turning off fan")
if self._smarty.turn_off():
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turning off fan\"",
")",
"if",
"self",
".",
"_smarty",
".",
"turn_off",
"(",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"schedule_updat... | [
102,
4
] | [
108,
39
] | python | en | ['en', 'fy', 'en'] | True |
SmartyFan.async_added_to_hass | (self) | Call to update fan. | Call to update fan. | async def async_added_to_hass(self):
"""Call to update fan."""
async_dispatcher_connect(self.hass, SIGNAL_UPDATE_SMARTY, self._update_callback) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_SMARTY",
",",
"self",
".",
"_update_callback",
")"
] | [
110,
4
] | [
112,
88
] | python | en | ['en', 'en', 'en'] | True |
SmartyFan._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
115,
4
] | [
117,
49
] | python | en | ['en', 'sn', 'en'] | True |
SmartyFan.update | (self) | Update state. | Update state. | def update(self):
"""Update state."""
_LOGGER.debug("Updating state")
result = self._smarty.fan_speed
if result:
self._speed = SPEED_MAPPING[result]
_LOGGER.debug("Speed is %s, Mode is %s", self._speed, result)
self._state = True
else:
... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating state\"",
")",
"result",
"=",
"self",
".",
"_smarty",
".",
"fan_speed",
"if",
"result",
":",
"self",
".",
"_speed",
"=",
"SPEED_MAPPING",
"[",
"result",
"]",
"_LOGGER",
"."... | [
119,
4
] | [
128,
31
] | python | en | ['en', 'co', 'en'] | False |
validate_digit | (value, start, end) | validate if a digit is valid | validate if a digit is valid | def validate_digit(value, start, end):
'''validate if a digit is valid'''
if not str(value).isdigit() or int(value) < start or int(value) > end:
raise ValueError('value (%s) must be a digit from %s to %s' % (value, start, end)) | [
"def",
"validate_digit",
"(",
"value",
",",
"start",
",",
"end",
")",
":",
"if",
"not",
"str",
"(",
"value",
")",
".",
"isdigit",
"(",
")",
"or",
"int",
"(",
"value",
")",
"<",
"start",
"or",
"int",
"(",
"value",
")",
">",
"end",
":",
"raise",
... | [
13,
0
] | [
16,
90
] | python | en | ['en', 'en', 'en'] | True |
validate_file | (path) | validate if a file exist | validate if a file exist | def validate_file(path):
'''validate if a file exist'''
if not os.path.exists(path):
raise FileNotFoundError('%s is not a valid file path' % path) | [
"def",
"validate_file",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"FileNotFoundError",
"(",
"'%s is not a valid file path'",
"%",
"path",
")"
] | [
18,
0
] | [
21,
69
] | python | en | ['en', 'en', 'en'] | True |
validate_dispatcher | (args) | validate if the dispatcher of the experiment supports importing data | validate if the dispatcher of the experiment supports importing data | def validate_dispatcher(args):
'''validate if the dispatcher of the experiment supports importing data'''
experiment_id = get_config_filename(args)
experiment_config = Config(experiment_id, Experiments().get_all_experiments()[experiment_id]['logDir']).get_config()
if experiment_config.get('tuner') and e... | [
"def",
"validate_dispatcher",
"(",
"args",
")",
":",
"experiment_id",
"=",
"get_config_filename",
"(",
"args",
")",
"experiment_config",
"=",
"Config",
"(",
"experiment_id",
",",
"Experiments",
"(",
")",
".",
"get_all_experiments",
"(",
")",
"[",
"experiment_id",
... | [
23,
0
] | [
39,
19
] | python | en | ['en', 'en', 'en'] | True |
load_search_space | (path) | load search space content | load search space content | def load_search_space(path):
'''load search space content'''
content = json.dumps(get_json_content(path))
if not content:
raise ValueError('searchSpace file should not be empty')
return content | [
"def",
"load_search_space",
"(",
"path",
")",
":",
"content",
"=",
"json",
".",
"dumps",
"(",
"get_json_content",
"(",
"path",
")",
")",
"if",
"not",
"content",
":",
"raise",
"ValueError",
"(",
"'searchSpace file should not be empty'",
")",
"return",
"content"
] | [
41,
0
] | [
46,
18
] | python | en | ['sv', 'en', 'en'] | True |
get_query_type | (key) | get update query type | get update query type | def get_query_type(key):
'''get update query type'''
if key == 'trialConcurrency':
return '?update_type=TRIAL_CONCURRENCY'
if key == 'maxExecDuration':
return '?update_type=MAX_EXEC_DURATION'
if key == 'searchSpace':
return '?update_type=SEARCH_SPACE'
if key == 'maxTrialNum':... | [
"def",
"get_query_type",
"(",
"key",
")",
":",
"if",
"key",
"==",
"'trialConcurrency'",
":",
"return",
"'?update_type=TRIAL_CONCURRENCY'",
"if",
"key",
"==",
"'maxExecDuration'",
":",
"return",
"'?update_type=MAX_EXEC_DURATION'",
"if",
"key",
"==",
"'searchSpace'",
":... | [
48,
0
] | [
57,
43
] | python | en | ['es', 'nl', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.