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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_get_actions | (
hass: HomeAssistant, device_id: str
) | List device actions for Water Heater devices. | List device actions for Water Heater devices. | async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Water Heater devices."""
registry = await entity_registry.async_get_registry(hass)
actions = []
for entry in entity_registry.async_entries_for_device(registry, device_id):
... | [
"async",
"def",
"async_get_actions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass"... | [
30,
0
] | [
50,
18
] | python | en | ['fr', 'en', 'en'] | True |
async_call_action_from_config | (
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
) | Execute a device action. | Execute a device action. | async def async_call_action_from_config(
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
) -> None:
"""Execute a device action."""
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
if config[CONF_TYPE] == "turn_on":
service = SERVICE_TURN_ON
elif config[CON... | [
"async",
"def",
"async_call_action_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
",",
"variables",
":",
"dict",
",",
"context",
":",
"Context",
"|",
"None",
")",
"->",
"None",
":",
"service_data",
"=",
"{",
"ATTR_ENTITY_ID",
":... | [
53,
0
] | [
66,
5
] | python | en | ['ro', 'en', 'en'] | True |
test_camera_setup | (hass: HomeAssistant) | Test turning the light on. | Test turning the light on. | async def test_camera_setup(hass: HomeAssistant) -> None:
"""Test turning the light on."""
client = create_mock_client()
await setup_test_config_entry(hass, hyperion_client=client)
# Verify switch is on (as per TEST_COMPONENTS above).
entity_state = hass.states.get(TEST_CAMERA_ENTITY_ID)
asser... | [
"async",
"def",
"test_camera_setup",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"await",
"setup_test_config_entry",
"(",
"hass",
",",
"hyperion_client",
"=",
"client",
")",
"# Verify switch is on (as per... | [
54,
0
] | [
63,
39
] | python | en | ['en', 'en', 'en'] | True |
test_camera_image | (hass: HomeAssistant) | Test retrieving a single camera image. | Test retrieving a single camera image. | async def test_camera_image(hass: HomeAssistant) -> None:
"""Test retrieving a single camera image."""
client = create_mock_client()
client.async_send_image_stream_start = AsyncMock(return_value=True)
client.async_send_image_stream_stop = AsyncMock(return_value=True)
await setup_test_config_entry(h... | [
"async",
"def",
"test_camera_image",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_image_stream_start",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"client",
".",... | [
66,
0
] | [
82,
56
] | python | en | ['en', 'pt', 'en'] | True |
test_camera_invalid_image | (hass: HomeAssistant) | Test retrieving a single invalid camera image. | Test retrieving a single invalid camera image. | async def test_camera_invalid_image(hass: HomeAssistant) -> None:
"""Test retrieving a single invalid camera image."""
client = create_mock_client()
client.async_send_image_stream_start = AsyncMock(return_value=True)
client.async_send_image_stream_stop = AsyncMock(return_value=True)
await setup_tes... | [
"async",
"def",
"test_camera_invalid_image",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_image_stream_start",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"client"... | [
85,
0
] | [
114,
70
] | python | en | ['en', 'pt', 'en'] | True |
test_camera_image_failed_start_stream_call | (hass: HomeAssistant) | Test retrieving a single camera image with failed start stream call. | Test retrieving a single camera image with failed start stream call. | async def test_camera_image_failed_start_stream_call(hass: HomeAssistant) -> None:
"""Test retrieving a single camera image with failed start stream call."""
client = create_mock_client()
client.async_send_image_stream_start = AsyncMock(return_value=False)
await setup_test_config_entry(hass, hyperion_c... | [
"async",
"def",
"test_camera_image_failed_start_stream_call",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_image_stream_start",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"False",... | [
117,
0
] | [
128,
57
] | python | en | ['en', 'en', 'en'] | True |
test_camera_stream | (hass: HomeAssistant) | Test retrieving a camera stream. | Test retrieving a camera stream. | async def test_camera_stream(hass: HomeAssistant) -> None:
"""Test retrieving a camera stream."""
client = create_mock_client()
client.async_send_image_stream_start = AsyncMock(return_value=True)
client.async_send_image_stream_stop = AsyncMock(return_value=True)
request = Mock()
async def fake... | [
"async",
"def",
"test_camera_stream",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_image_stream_start",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"client",
"."... | [
131,
0
] | [
165,
48
] | python | en | ['en', 'pt', 'en'] | True |
test_camera_stream_failed_start_stream_call | (hass: HomeAssistant) | Test retrieving a camera stream with failed start stream call. | Test retrieving a camera stream with failed start stream call. | async def test_camera_stream_failed_start_stream_call(hass: HomeAssistant) -> None:
"""Test retrieving a camera stream with failed start stream call."""
client = create_mock_client()
client.async_send_image_stream_start = AsyncMock(return_value=False)
await setup_test_config_entry(hass, hyperion_client... | [
"async",
"def",
"test_camera_stream_failed_start_stream_call",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_image_stream_start",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"False"... | [
168,
0
] | [
179,
57
] | python | en | ['en', 'pt', 'en'] | True |
test_device_info | (hass: HomeAssistant) | Verify device information includes expected details. | Verify device information includes expected details. | async def test_device_info(hass: HomeAssistant) -> None:
"""Verify device information includes expected details."""
client = create_mock_client()
register_test_entity(
hass,
CAMERA_DOMAIN,
TYPE_HYPERION_CAMERA,
TEST_CAMERA_ENTITY_ID,
)
await setup_test_config_entry(h... | [
"async",
"def",
"test_device_info",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"register_test_entity",
"(",
"hass",
",",
"CAMERA_DOMAIN",
",",
"TYPE_HYPERION_CAMERA",
",",
"TEST_CAMERA_ENTITY_ID",
",",
... | [
182,
0
] | [
210,
56
] | python | en | ['es', 'en', 'en'] | True |
get_form | (
hass: HomeAssistant, gatway_type: ConfGatewayType, expected_step_id: str
) | Get a form for the given gateway type. | Get a form for the given gateway type. | async def get_form(
hass: HomeAssistant, gatway_type: ConfGatewayType, expected_step_id: str
) -> FlowResult:
"""Get a form for the given gateway type."""
await setup.async_setup_component(hass, "persistent_notification", {})
stepuser = await hass.config_entries.flow.async_init(
DOMAIN, context=... | [
"async",
"def",
"get_form",
"(",
"hass",
":",
"HomeAssistant",
",",
"gatway_type",
":",
"ConfGatewayType",
",",
"expected_step_id",
":",
"str",
")",
"->",
"FlowResult",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notificati... | [
32,
0
] | [
51,
17
] | python | en | ['en', 'en', 'en'] | True |
test_config_mqtt | (hass: HomeAssistant, mqtt: None) | Test configuring a mqtt gateway. | Test configuring a mqtt gateway. | async def test_config_mqtt(hass: HomeAssistant, mqtt: None) -> None:
"""Test configuring a mqtt gateway."""
step = await get_form(hass, CONF_GATEWAY_TYPE_MQTT, "gw_mqtt")
flow_id = step["flow_id"]
with patch(
"homeassistant.components.mysensors.async_setup", return_value=True
) as mock_setu... | [
"async",
"def",
"test_config_mqtt",
"(",
"hass",
":",
"HomeAssistant",
",",
"mqtt",
":",
"None",
")",
"->",
"None",
":",
"step",
"=",
"await",
"get_form",
"(",
"hass",
",",
"CONF_GATEWAY_TYPE_MQTT",
",",
"\"gw_mqtt\"",
")",
"flow_id",
"=",
"step",
"[",
"\"... | [
54,
0
] | [
89,
48
] | python | en | ['en', 'lb', 'it'] | False |
test_missing_mqtt | (hass: HomeAssistant) | Test configuring a mqtt gateway without mqtt integration setup. | Test configuring a mqtt gateway without mqtt integration setup. | async def test_missing_mqtt(hass: HomeAssistant) -> None:
"""Test configuring a mqtt gateway without mqtt integration setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_... | [
"async",
"def",
"test_missing_mqtt",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_en... | [
92,
0
] | [
107,
56
] | python | en | ['en', 'lb', 'it'] | False |
test_config_serial | (hass: HomeAssistant) | Test configuring a gateway via serial. | Test configuring a gateway via serial. | async def test_config_serial(hass: HomeAssistant) -> None:
"""Test configuring a gateway via serial."""
step = await get_form(hass, CONF_GATEWAY_TYPE_SERIAL, "gw_serial")
flow_id = step["flow_id"]
with patch( # mock is_serial_port because otherwise the test will be platform dependent (/dev/ttyACMx vs ... | [
"async",
"def",
"test_config_serial",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"step",
"=",
"await",
"get_form",
"(",
"hass",
",",
"CONF_GATEWAY_TYPE_SERIAL",
",",
"\"gw_serial\"",
")",
"flow_id",
"=",
"step",
"[",
"\"flow_id\"",
"]",
"with",... | [
110,
0
] | [
147,
48
] | python | en | ['en', 'gd', 'en'] | True |
test_config_tcp | (hass: HomeAssistant) | Test configuring a gateway via tcp. | Test configuring a gateway via tcp. | async def test_config_tcp(hass: HomeAssistant) -> None:
"""Test configuring a gateway via tcp."""
step = await get_form(hass, CONF_GATEWAY_TYPE_TCP, "gw_tcp")
flow_id = step["flow_id"]
with patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_value=True
), patch(
... | [
"async",
"def",
"test_config_tcp",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"step",
"=",
"await",
"get_form",
"(",
"hass",
",",
"CONF_GATEWAY_TYPE_TCP",
",",
"\"gw_tcp\"",
")",
"flow_id",
"=",
"step",
"[",
"\"flow_id\"",
"]",
"with",
"patch... | [
150,
0
] | [
184,
48
] | python | en | ['en', 'gd', 'en'] | True |
test_fail_to_connect | (hass: HomeAssistant) | Test configuring a gateway via tcp. | Test configuring a gateway via tcp. | async def test_fail_to_connect(hass: HomeAssistant) -> None:
"""Test configuring a gateway via tcp."""
step = await get_form(hass, CONF_GATEWAY_TYPE_TCP, "gw_tcp")
flow_id = step["flow_id"]
with patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_value=False
), patch... | [
"async",
"def",
"test_fail_to_connect",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"step",
"=",
"await",
"get_form",
"(",
"hass",
",",
"CONF_GATEWAY_TYPE_TCP",
",",
"\"gw_tcp\"",
")",
"flow_id",
"=",
"step",
"[",
"\"flow_id\"",
"]",
"with",
"... | [
187,
0
] | [
216,
48
] | python | en | ['en', 'gd', 'en'] | True |
test_config_invalid | (
hass: HomeAssistant,
mqtt: None,
gateway_type: ConfGatewayType,
expected_step_id: str,
user_input: dict[str, Any],
err_field: str,
err_string: str,
) | Perform a test that is expected to generate an error. | Perform a test that is expected to generate an error. | async def test_config_invalid(
hass: HomeAssistant,
mqtt: None,
gateway_type: ConfGatewayType,
expected_step_id: str,
user_input: dict[str, Any],
err_field: str,
err_string: str,
) -> None:
"""Perform a test that is expected to generate an error."""
step = await get_form(hass, gatewa... | [
"async",
"def",
"test_config_invalid",
"(",
"hass",
":",
"HomeAssistant",
",",
"mqtt",
":",
"None",
",",
"gateway_type",
":",
"ConfGatewayType",
",",
"expected_step_id",
":",
"str",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
",",
"err_field... | [
361,
0
] | [
398,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass: HomeAssistant, mqtt: None, user_input: dict) | Test importing a gateway. | Test importing a gateway. | async def test_import(hass: HomeAssistant, mqtt: None, user_input: dict) -> None:
"""Test importing a gateway."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("sys.platform", "win32"), patch(
"homeassistant.components.mysensors.config_flow.try_connect", return_v... | [
"async",
"def",
"test_import",
"(",
"hass",
":",
"HomeAssistant",
",",
"mqtt",
":",
"None",
",",
"user_input",
":",
"dict",
")",
"->",
"None",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}"... | [
442,
0
] | [
457,
43
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate | (
hass: HomeAssistant,
mqtt: None,
first_input: dict,
second_input: dict,
expected_result: tuple[str, str] | None,
) | Test duplicate detection. | Test duplicate detection. | async def test_duplicate(
hass: HomeAssistant,
mqtt: None,
first_input: dict,
second_input: dict,
expected_result: tuple[str, str] | None,
) -> None:
"""Test duplicate detection."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch("sys.platform", "win32"... | [
"async",
"def",
"test_duplicate",
"(",
"hass",
":",
"HomeAssistant",
",",
"mqtt",
":",
"None",
",",
"first_input",
":",
"dict",
",",
"second_input",
":",
"dict",
",",
"expected_result",
":",
"tuple",
"[",
"str",
",",
"str",
"]",
"|",
"None",
",",
")",
... | [
732,
0
] | [
758,
57
] | python | en | ['ro', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
31,
0
] | [
33,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
37,
0
] | [
39,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
43,
0
] | [
45,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_conditions | (hass, device_reg, entity_reg, enable_custom_integrations) | Test we get the expected conditions from a sensor. | Test we get the expected conditions from a sensor. | async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integrations):
"""Test we get the expected conditions from a sensor."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(has... | [
"async",
"def",
"test_get_conditions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
... | [
48,
0
] | [
84,
44
] | python | en | ['en', 'en', 'en'] | True |
test_get_conditions_no_state | (hass, device_reg, entity_reg) | Test we get the expected conditions from a sensor. | Test we get the expected conditions from a sensor. | async def test_get_conditions_no_state(hass, device_reg, entity_reg):
"""Test we get the expected conditions from a sensor."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_i... | [
"async",
"def",
"test_get_conditions_no_state",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass... | [
87,
0
] | [
122,
44
] | python | en | ['en', 'en', 'en'] | True |
test_get_condition_capabilities | (
hass,
device_reg,
entity_reg,
set_state,
device_class_reg,
device_class_state,
unit_reg,
unit_state,
) | Test we get the expected capabilities from a sensor condition. | Test we get the expected capabilities from a sensor condition. | async def test_get_condition_capabilities(
hass,
device_reg,
entity_reg,
set_state,
device_class_reg,
device_class_state,
unit_reg,
unit_state,
):
"""Test we get the expected capabilities from a sensor condition."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platfo... | [
"async",
"def",
"test_get_condition_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"set_state",
",",
"device_class_reg",
",",
"device_class_state",
",",
"unit_reg",
",",
"unit_state",
",",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
... | [
132,
0
] | [
189,
52
] | python | en | ['en', 'en', 'en'] | True |
test_get_condition_capabilities_none | (
hass, device_reg, entity_reg, enable_custom_integrations
) | Test we get the expected capabilities from a sensor condition. | Test we get the expected capabilities from a sensor condition. | async def test_get_condition_capabilities_none(
hass, device_reg, entity_reg, enable_custom_integrations
):
"""Test we get the expected capabilities from a sensor condition."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
config_entry = MockConfigEntry(domain="test", data={... | [
"async",
"def",
"test_get_condition_capabilities_none",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init... | [
192,
0
] | [
227,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_state_not_above_below | (
hass, calls, caplog, enable_custom_integrations
) | Test for bad value conditions. | Test for bad value conditions. | async def test_if_state_not_above_below(
hass, calls, caplog, enable_custom_integrations
):
"""Test for bad value conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.a... | [
"async",
"def",
"test_if_state_not_above_below",
"(",
"hass",
",",
"calls",
",",
"caplog",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",... | [
230,
0
] | [
263,
69
] | python | en | ['en', 'en', 'en'] | True |
test_if_state_above | (hass, calls, enable_custom_integrations) | Test for value conditions. | Test for value conditions. | async def test_if_state_above(hass, calls, enable_custom_integrations):
"""Test for value conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_state_above",
"(",
"hass",
",",
"calls",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"as... | [
266,
0
] | [
321,
57
] | python | en | ['en', 'en', 'en'] | True |
test_if_state_below | (hass, calls, enable_custom_integrations) | Test for value conditions. | Test for value conditions. | async def test_if_state_below(hass, calls, enable_custom_integrations):
"""Test for value conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_state_below",
"(",
"hass",
",",
"calls",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"as... | [
324,
0
] | [
379,
57
] | python | en | ['en', 'en', 'en'] | True |
test_if_state_between | (hass, calls, enable_custom_integrations) | Test for value conditions. | Test for value conditions. | async def test_if_state_between(hass, calls, enable_custom_integrations):
"""Test for value conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_state_between",
"(",
"hass",
",",
"calls",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"... | [
382,
0
] | [
449,
57
] | python | en | ['en', 'en', 'en'] | True |
test_ws_get_notifications | (hass, hass_ws_client) | Test websocket endpoint for retrieving persistent notifications. | Test websocket endpoint for retrieving persistent notifications. | async def test_ws_get_notifications(hass, hass_ws_client):
"""Test websocket endpoint for retrieving persistent notifications."""
await async_setup_component(hass, pn.DOMAIN, {})
client = await hass_ws_client(hass)
await client.send_json({"id": 5, "type": "persistent_notification/get"})
msg = awai... | [
"async",
"def",
"test_ws_get_notifications",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"pn",
".",
"DOMAIN",
",",
"{",
"}",
")",
"client",
"=",
"await",
"hass_ws_client",
"(",
"hass",
")",
"await",
"clie... | [
141,
0
] | [
188,
34
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.setup_method | (self, method) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self, method):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
setup_component(self.hass, pn.DOMAIN, {}) | [
"def",
"setup_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"setup_component",
"(",
"self",
".",
"hass",
",",
"pn",
".",
"DOMAIN",
",",
"{",
"}",
")"
] | [
11,
4
] | [
14,
49
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.teardown_method | (self, method) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self, method):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
16,
4
] | [
18,
24
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create | (self) | Test creating notification without title or notification id. | Test creating notification without title or notification id. | def test_create(self):
"""Test creating notification without title or notification id."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "Hello World {{ 1 + 1 ... | [
"def",
"test_create",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
"(",
"pn",
... | [
20,
4
] | [
43,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create_notification_id | (self) | Ensure overwrites existing notification with same id. | Ensure overwrites existing notification with same id. | def test_create_notification_id(self):
"""Ensure overwrites existing notification with same id."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "test", notif... | [
"def",
"test_create_notification_id",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
45,
4
] | [
75,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create_template_error | (self) | Ensure we output templates if contain error. | Ensure we output templates if contain error. | def test_create_template_error(self):
"""Ensure we output templates if contain error."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "{{ message + 1 }}", "{... | [
"def",
"test_create_template_error",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
77,
4
] | [
97,
29
] | python | en | ['eu', 'en', 'en'] | True |
TestPersistentNotification.test_dismiss_notification | (self) | Ensure removal of specific notification. | Ensure removal of specific notification. | def test_dismiss_notification(self):
"""Ensure removal of specific notification."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "test", notification_id="Bee... | [
"def",
"test_dismiss_notification",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
99,
4
] | [
115,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_mark_read | (self) | Ensure notification is marked as Read. | Ensure notification is marked as Read. | def test_mark_read(self):
"""Ensure notification is marked as Read."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(notifications) == 0
pn.create(self.hass, "test", notification_id="Beer 2")
self.hass.block_till_done()
entity_id = "persistent_no... | [
"def",
"test_mark_read",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"notifications",
")",
"==",
"0",
"pn",
".",
"create",
"(",
"self... | [
117,
4
] | [
138,
29
] | python | en | ['en', 'en', 'en'] | True |
parse_uri | (uri) | Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
| Parses a URI using the regex given in Appendix B of RFC 3986. | def parse_uri(uri):
"""Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
"""
groups = URI.match(uri).groups()
return (groups[1], groups[3], groups[4], groups[6], groups[8]) | [
"def",
"parse_uri",
"(",
"uri",
")",
":",
"groups",
"=",
"URI",
".",
"match",
"(",
"uri",
")",
".",
"groups",
"(",
")",
"return",
"(",
"groups",
"[",
"1",
"]",
",",
"groups",
"[",
"3",
"]",
",",
"groups",
"[",
"4",
"]",
",",
"groups",
"[",
"6... | [
20,
0
] | [
26,
66
] | python | en | ['en', 'en', 'en'] | True |
CacheController._urlnorm | (cls, uri) | Normalize the URL to create a safe key for the cache | Normalize the URL to create a safe key for the cache | def _urlnorm(cls, uri):
"""Normalize the URL to create a safe key for the cache"""
(scheme, authority, path, query, fragment) = parse_uri(uri)
if not scheme or not authority:
raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
scheme = scheme.lower()
au... | [
"def",
"_urlnorm",
"(",
"cls",
",",
"uri",
")",
":",
"(",
"scheme",
",",
"authority",
",",
"path",
",",
"query",
",",
"fragment",
")",
"=",
"parse_uri",
"(",
"uri",
")",
"if",
"not",
"scheme",
"or",
"not",
"authority",
":",
"raise",
"Exception",
"(",... | [
42,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
CacheController.cached_request | (self, request) |
Return a cached response if it exists in the cache, otherwise
return False.
|
Return a cached response if it exists in the cache, otherwise
return False.
| def cached_request(self, request):
"""
Return a cached response if it exists in the cache, otherwise
return False.
"""
cache_url = self.cache_url(request.url)
logger.debug('Looking up "%s" in the cache', cache_url)
cc = self.parse_cache_control(request.headers)
... | [
"def",
"cached_request",
"(",
"self",
",",
"request",
")",
":",
"cache_url",
"=",
"self",
".",
"cache_url",
"(",
"request",
".",
"url",
")",
"logger",
".",
"debug",
"(",
"'Looking up \"%s\" in the cache'",
",",
"cache_url",
")",
"cc",
"=",
"self",
".",
"pa... | [
119,
4
] | [
228,
20
] | python | en | ['en', 'error', 'th'] | False |
CacheController.cache_response | (self, request, response, body=None, status_codes=None) |
Algorithm for caching requests.
This assumes a requests Response object.
|
Algorithm for caching requests. | def cache_response(self, request, response, body=None, status_codes=None):
"""
Algorithm for caching requests.
This assumes a requests Response object.
"""
# From httplib2: Don't cache 206's since we aren't going to
# handle byte range requests
cac... | [
"def",
"cache_response",
"(",
"self",
",",
"request",
",",
"response",
",",
"body",
"=",
"None",
",",
"status_codes",
"=",
"None",
")",
":",
"# From httplib2: Don't cache 206's since we aren't going to",
"# handle byte range requests",
"cacheable_status_codes",... | [
246,
4
] | [
335,
21
] | python | en | ['en', 'error', 'th'] | False |
CacheController.update_cached_response | (self, request, response) | On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one.
This should only ever be called when we've sent an ETag and
gotten a 304 as the response.
| On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one. | def update_cached_response(self, request, response):
"""On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one.
This should only ever be called when we've sent an ETag and
gotten a 304 as the response.
"""
cache_url =... | [
"def",
"update_cached_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"cache_url",
"=",
"self",
".",
"cache_url",
"(",
"request",
".",
"url",
")",
"cached_response",
"=",
"self",
".",
"serializer",
".",
"loads",
"(",
"request",
",",
"sel... | [
337,
4
] | [
375,
30
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) | Set up the uptime sensor platform. | Set up the uptime sensor platform. | async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the uptime sensor platform."""
name = config[CONF_NAME]
async_add_entities([UptimeSensor(name)], True) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
"discovery_info",
":",
"DiscoveryInfoType",
"|",
"None",
"=",
"None",
",",
")",
"->",
"None",
... | [
32,
0
] | [
41,
50
] | python | en | ['en', 'da', 'en'] | True |
UptimeSensor.__init__ | (self, name: str) | Initialize the uptime sensor. | Initialize the uptime sensor. | def __init__(self, name: str) -> None:
"""Initialize the uptime sensor."""
self._attr_name: str = name
self._attr_device_class: str = DEVICE_CLASS_TIMESTAMP
self._attr_should_poll: bool = False
self._attr_native_value: str = dt_util.now().isoformat() | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_attr_name",
":",
"str",
"=",
"name",
"self",
".",
"_attr_device_class",
":",
"str",
"=",
"DEVICE_CLASS_TIMESTAMP",
"self",
".",
"_attr_should_poll",
":",
"bool"... | [
47,
4
] | [
52,
64
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.spawn_client | (self, nick, ident='null', host='null', realhost=None, modes=set(),
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
manipulatable=False) |
Spawns a new client with the given options.
Note: No nick collision / valid nickname checks are done here; it is
up to plugins to make sure they don't introduce anything invalid.
|
Spawns a new client with the given options. | def spawn_client(self, nick, ident='null', host='null', realhost=None, modes=set(),
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
manipulatable=False):
"""
Spawns a new client with the given options.
Note: No nick collision / valid nickname ... | [
"def",
"spawn_client",
"(",
"self",
",",
"nick",
",",
"ident",
"=",
"'null'",
",",
"host",
"=",
"'null'",
",",
"realhost",
"=",
"None",
",",
"modes",
"=",
"set",
"(",
")",
",",
"server",
"=",
"None",
",",
"ip",
"=",
"'0.0.0.0'",
",",
"realname",
"=... | [
102,
4
] | [
159,
16
] | python | en | ['en', 'error', 'th'] | False |
UnrealProtocol.join | (self, client, channel) | Joins a PyLink client to a channel. | Joins a PyLink client to a channel. | def join(self, client, channel):
"""Joins a PyLink client to a channel."""
if not self.is_internal_client(client):
raise LookupError('No such PyLink client exists.')
# Forward this on to SJOIN, as using JOIN in Unreal S2S seems to cause TS corruption bugs.
# This seems to be... | [
"def",
"join",
"(",
"self",
",",
"client",
",",
"channel",
")",
":",
"if",
"not",
"self",
".",
"is_internal_client",
"(",
"client",
")",
":",
"raise",
"LookupError",
"(",
"'No such PyLink client exists.'",
")",
"# Forward this on to SJOIN, as using JOIN in Unreal S2S ... | [
161,
4
] | [
172,
57
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.sjoin | (self, server, channel, users, ts=None, modes=set()) | Sends an SJOIN for a group of users to a channel.
The sender should always be a server (SID). TS is optional, and defaults
to the one we've stored in the channel state if not given.
<users> is a list of (prefix mode, UID) pairs:
Example uses:
sjoin('100', '#test', [('', '10... | Sends an SJOIN for a group of users to a channel. | def sjoin(self, server, channel, users, ts=None, modes=set()):
"""Sends an SJOIN for a group of users to a channel.
The sender should always be a server (SID). TS is optional, and defaults
to the one we've stored in the channel state if not given.
<users> is a list of (prefix mode, UID)... | [
"def",
"sjoin",
"(",
"self",
",",
"server",
",",
"channel",
",",
"users",
",",
"ts",
"=",
"None",
",",
"modes",
"=",
"set",
"(",
")",
")",
":",
"# <- :001 SJOIN 1444361345 #test :*@+1JJAAAAAB %2JJAAAA4C 1JJAAAADS",
"server",
"=",
"server",
"or",
"self",
".",
... | [
174,
4
] | [
249,
56
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol._ping_uplink | (self) | Sends a PING to the uplink. | Sends a PING to the uplink. | def _ping_uplink(self):
"""Sends a PING to the uplink."""
if self.sid and self.uplink:
self._send_with_prefix(self.sid, 'PING %s %s' % (self.get_friendly_name(self.sid), self.get_friendly_name(self.uplink))) | [
"def",
"_ping_uplink",
"(",
"self",
")",
":",
"if",
"self",
".",
"sid",
"and",
"self",
".",
"uplink",
":",
"self",
".",
"_send_with_prefix",
"(",
"self",
".",
"sid",
",",
"'PING %s %s'",
"%",
"(",
"self",
".",
"get_friendly_name",
"(",
"self",
".",
"si... | [
251,
4
] | [
254,
132
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.mode | (self, numeric, target, modes, ts=None) |
Sends mode changes from a PyLink client/server. The mode list should be
a list of (mode, arg) tuples, i.e. the format of utils.parse_modes() output.
|
Sends mode changes from a PyLink client/server. The mode list should be
a list of (mode, arg) tuples, i.e. the format of utils.parse_modes() output.
| def mode(self, numeric, target, modes, ts=None):
"""
Sends mode changes from a PyLink client/server. The mode list should be
a list of (mode, arg) tuples, i.e. the format of utils.parse_modes() output.
"""
# <- :unreal.midnight.vpn MODE #test +ntCo GL 1444361345
if (not ... | [
"def",
"mode",
"(",
"self",
",",
"numeric",
",",
"target",
",",
"modes",
",",
"ts",
"=",
"None",
")",
":",
"# <- :unreal.midnight.vpn MODE #test +ntCo GL 1444361345",
"if",
"(",
"not",
"self",
".",
"is_internal_client",
"(",
"numeric",
")",
")",
"and",
"(",
... | [
256,
4
] | [
312,
69
] | python | en | ['en', 'error', 'th'] | False |
UnrealProtocol.set_server_ban | (self, source, duration, user='*', host='*', reason='User banned') |
Sets a server ban.
|
Sets a server ban.
| def set_server_ban(self, source, duration, user='*', host='*', reason='User banned'):
"""
Sets a server ban.
"""
# Permanent:
# <- :unreal.midnight.vpn TKL + G ident host.net james!james@localhost 0 1500303745 :no reason
# Temporary:
# <- :unreal.midnight.vpn TKL ... | [
"def",
"set_server_ban",
"(",
"self",
",",
"source",
",",
"duration",
",",
"user",
"=",
"'*'",
",",
"host",
"=",
"'*'",
",",
"reason",
"=",
"'User banned'",
")",
":",
"# Permanent:",
"# <- :unreal.midnight.vpn TKL + G ident host.net james!james@localhost 0 1500303745 :n... | [
314,
4
] | [
332,
157
] | python | en | ['en', 'error', 'th'] | False |
UnrealProtocol.update_client | (self, target, field, text) | Updates the ident, host, or realname of any connected client. | Updates the ident, host, or realname of any connected client. | def update_client(self, target, field, text):
"""Updates the ident, host, or realname of any connected client."""
field = field.upper()
if field not in ('IDENT', 'HOST', 'REALNAME', 'GECOS'):
raise NotImplementedError("Changing field %r of a client is "
... | [
"def",
"update_client",
"(",
"self",
",",
"target",
",",
"field",
",",
"text",
")",
":",
"field",
"=",
"field",
".",
"upper",
"(",
")",
"if",
"field",
"not",
"in",
"(",
"'IDENT'",
",",
"'HOST'",
",",
"'REALNAME'",
",",
"'GECOS'",
")",
":",
"raise",
... | [
334,
4
] | [
375,
73
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.knock | (self, numeric, target, text) | Sends a KNOCK from a PyLink client. | Sends a KNOCK from a PyLink client. | def knock(self, numeric, target, text):
"""Sends a KNOCK from a PyLink client."""
# KNOCKs in UnrealIRCd are actually just specially formatted NOTICEs,
# sent to all ops in a channel.
# <- :unreal.midnight.vpn NOTICE @#test :[Knock] by GL|!gl@hidden-1C620195 (test)
assert self.is... | [
"def",
"knock",
"(",
"self",
",",
"numeric",
",",
"target",
",",
"text",
")",
":",
"# KNOCKs in UnrealIRCd are actually just specially formatted NOTICEs,",
"# sent to all ops in a channel.",
"# <- :unreal.midnight.vpn NOTICE @#test :[Knock] by GL|!gl@hidden-1C620195 (test)",
"assert",
... | [
377,
4
] | [
385,
70
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.post_connect | (self) | Initializes a connection to a server. | Initializes a connection to a server. | def post_connect(self):
"""Initializes a connection to a server."""
ts = self.start_ts
self.prefixmodes = {'q': '~', 'a': '&', 'o': '@', 'h': '%', 'v': '+'}
# Track usages of legacy (Unreal 3.2) nicks.
self.legacy_uidgen = PUIDGenerator('U32user')
f = self.send
... | [
"def",
"post_connect",
"(",
"self",
")",
":",
"ts",
"=",
"self",
".",
"start_ts",
"self",
".",
"prefixmodes",
"=",
"{",
"'q'",
":",
"'~'",
",",
"'a'",
":",
"'&'",
",",
"'o'",
":",
"'@'",
",",
"'h'",
":",
"'%'",
",",
"'v'",
":",
"'+'",
"}",
"# T... | [
389,
4
] | [
443,
53
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_eos | (self, numeric, command, args) | EOS is used to denote end of burst. | EOS is used to denote end of burst. | def handle_eos(self, numeric, command, args):
"""EOS is used to denote end of burst."""
self.servers[numeric].has_eob = True
if numeric == self.uplink:
self.connected.set()
return {} | [
"def",
"handle_eos",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"self",
".",
"servers",
"[",
"numeric",
"]",
".",
"has_eob",
"=",
"True",
"if",
"numeric",
"==",
"self",
".",
"uplink",
":",
"self",
".",
"connected",
".",
"set"... | [
445,
4
] | [
450,
17
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_server | (self, numeric, command, args) | Handles the SERVER command, which is used for both authentication and
introducing legacy (non-SID) servers. | Handles the SERVER command, which is used for both authentication and
introducing legacy (non-SID) servers. | def handle_server(self, numeric, command, args):
"""Handles the SERVER command, which is used for both authentication and
introducing legacy (non-SID) servers."""
# <- SERVER unreal.midnight.vpn 1 :U3999-Fhin6OoEM UnrealIRCd test server
sname = args[0]
if self.uplink not in self.... | [
"def",
"handle_server",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- SERVER unreal.midnight.vpn 1 :U3999-Fhin6OoEM UnrealIRCd test server",
"sname",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"uplink",
"not",
"in",
"self",
".",
"... | [
526,
4
] | [
564,
64
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_protoctl | (self, numeric, command, args) | Handles protocol negotiation. | Handles protocol negotiation. | def handle_protoctl(self, numeric, command, args):
"""Handles protocol negotiation."""
# Make a list of all our capability names.
self.caps += [arg.split('=')[0] for arg in args]
# Unreal 4.0.x:
# <- PROTOCTL NOQUIT NICKv2 SJOIN SJOIN2 UMODE2 VL SJ3 TKLEXT TKLEXT2 NICKIP ESVID
... | [
"def",
"handle_protoctl",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# Make a list of all our capability names.",
"self",
".",
"caps",
"+=",
"[",
"arg",
".",
"split",
"(",
"'='",
")",
"[",
"0",
"]",
"for",
"arg",
"in",
"args",
"... | [
566,
4
] | [
599,
53
] | python | es | ['es', 'es', 'en'] | True |
UnrealProtocol.handle_join | (self, numeric, command, args) | Handles the UnrealIRCd JOIN command. | Handles the UnrealIRCd JOIN command. | def handle_join(self, numeric, command, args):
"""Handles the UnrealIRCd JOIN command."""
# <- :GL JOIN #pylink,#test
if args[0] == '0':
# /join 0; part the user from all channels
oldchans = self.users[numeric].channels.copy()
log.debug('(%s) Got /join 0 from ... | [
"def",
"handle_join",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :GL JOIN #pylink,#test",
"if",
"args",
"[",
"0",
"]",
"==",
"'0'",
":",
"# /join 0; part the user from all channels",
"oldchans",
"=",
"self",
".",
"users",
"[",
"n... | [
601,
4
] | [
622,
77
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_sjoin | (self, numeric, command, args) | Handles the UnrealIRCd SJOIN command. | Handles the UnrealIRCd SJOIN command. | def handle_sjoin(self, numeric, command, args):
"""Handles the UnrealIRCd SJOIN command."""
# <- :001 SJOIN 1444361345 #test :001AAAAAA @001AAAAAB +001AAAAAC
# <- :001 SJOIN 1483250129 #services +nt :+001OR9V02 @*~001DH6901 &*!*@test "*!*@blah.blah '*!*@yes.no
channel = args[1]
c... | [
"def",
"handle_sjoin",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :001 SJOIN 1444361345 #test :001AAAAAA @001AAAAAB +001AAAAAC",
"# <- :001 SJOIN 1483250129 #services +nt :+001OR9V02 @*~001DH6901 &*!*@test \"*!*@blah.blah '*!*@yes.no",
"channel",
"=",
"... | [
624,
4
] | [
704,
56
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_nick | (self, numeric, command, args) | Handles NICK changes, and legacy NICK introductions from pre-4.0 servers. | Handles NICK changes, and legacy NICK introductions from pre-4.0 servers. | def handle_nick(self, numeric, command, args):
"""Handles NICK changes, and legacy NICK introductions from pre-4.0 servers."""
if len(args) > 2:
# Handle legacy NICK introduction here.
# I don't want to rewrite all the user introduction stuff, so I'll just reorder the arguments
... | [
"def",
"handle_nick",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"2",
":",
"# Handle legacy NICK introduction here.",
"# I don't want to rewrite all the user introduction stuff, so I'll just reorder the arguments"... | [
706,
4
] | [
742,
62
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol._check_cloak_change | (self, uid, parsedmodes) |
Checks whether +x/-x was set in the mode query, and changes the
hostname of the user given to or from their cloaked host if True.
|
Checks whether +x/-x was set in the mode query, and changes the
hostname of the user given to or from their cloaked host if True.
| def _check_cloak_change(self, uid, parsedmodes):
"""
Checks whether +x/-x was set in the mode query, and changes the
hostname of the user given to or from their cloaked host if True.
"""
userobj = self.users[uid]
final_modes = userobj.modes
oldhost = userobj.host... | [
"def",
"_check_cloak_change",
"(",
"self",
",",
"uid",
",",
"parsedmodes",
")",
":",
"userobj",
"=",
"self",
".",
"users",
"[",
"uid",
"]",
"final_modes",
"=",
"userobj",
".",
"modes",
"oldhost",
"=",
"userobj",
".",
"host",
"if",
"(",
"(",
"'+x'",
","... | [
787,
4
] | [
819,
68
] | python | en | ['en', 'error', 'th'] | False |
UnrealProtocol.handle_svsmode | (self, numeric, command, args) | Handles SVSMODE, used by services for setting user modes on others. | Handles SVSMODE, used by services for setting user modes on others. | def handle_svsmode(self, numeric, command, args):
"""Handles SVSMODE, used by services for setting user modes on others."""
# <- :source SVSMODE target +usermodes
target = self._get_UID(args[0])
return self._handle_umode(target, self.parse_modes(target, args[1:])) | [
"def",
"handle_svsmode",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :source SVSMODE target +usermodes",
"target",
"=",
"self",
".",
"_get_UID",
"(",
"args",
"[",
"0",
"]",
")",
"return",
"self",
".",
"_handle_umode",
"(",
"targ... | [
821,
4
] | [
826,
77
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_svs2mode | (self, sender, command, args) |
Handles SVS2MODE, which sets services login information on the given target.
|
Handles SVS2MODE, which sets services login information on the given target.
| def handle_svs2mode(self, sender, command, args):
"""
Handles SVS2MODE, which sets services login information on the given target.
"""
# In a nutshell: check for the +d argument: if it's an integer, ignore
# it and set the user's account name to their nick. Otherwise, treat the
... | [
"def",
"handle_svs2mode",
"(",
"self",
",",
"sender",
",",
"command",
",",
"args",
")",
":",
"# In a nutshell: check for the +d argument: if it's an integer, ignore",
"# it and set the user's account name to their nick. Otherwise, treat the",
"# parameter as the new account name (this is... | [
828,
4
] | [
903,
95
] | python | en | ['en', 'error', 'th'] | False |
UnrealProtocol._handle_umode | (self, target, parsedmodes) | Internal helper function to parse umode changes. | Internal helper function to parse umode changes. | def _handle_umode(self, target, parsedmodes):
"""Internal helper function to parse umode changes."""
if not parsedmodes:
return
self.apply_modes(target, parsedmodes)
self._check_oper_status_change(target, parsedmodes)
self._check_cloak_change(target, parsedmodes)
... | [
"def",
"_handle_umode",
"(",
"self",
",",
"target",
",",
"parsedmodes",
")",
":",
"if",
"not",
"parsedmodes",
":",
"return",
"self",
".",
"apply_modes",
"(",
"target",
",",
"parsedmodes",
")",
"self",
".",
"_check_oper_status_change",
"(",
"target",
",",
"pa... | [
905,
4
] | [
915,
55
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_umode2 | (self, source, command, args) | Handles UMODE2, used to set user modes on oneself. | Handles UMODE2, used to set user modes on oneself. | def handle_umode2(self, source, command, args):
"""Handles UMODE2, used to set user modes on oneself."""
# <- :GL UMODE2 +W
target = self._get_UID(source)
return self._handle_umode(target, self.parse_modes(target, args)) | [
"def",
"handle_umode2",
"(",
"self",
",",
"source",
",",
"command",
",",
"args",
")",
":",
"# <- :GL UMODE2 +W",
"target",
"=",
"self",
".",
"_get_UID",
"(",
"source",
")",
"return",
"self",
".",
"_handle_umode",
"(",
"target",
",",
"self",
".",
"parse_mod... | [
917,
4
] | [
921,
73
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_topic | (self, numeric, command, args) | Handles the TOPIC command. | Handles the TOPIC command. | def handle_topic(self, numeric, command, args):
"""Handles the TOPIC command."""
# <- GL TOPIC #services GL 1444699395 :weeee
# <- TOPIC #services devel.relay 1452399682 :test
channel = args[0]
topic = args[-1]
setter = args[1]
ts = args[2]
oldtopic = sel... | [
"def",
"handle_topic",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- GL TOPIC #services GL 1444699395 :weeee",
"# <- TOPIC #services devel.relay 1452399682 :test",
"channel",
"=",
"args",
"[",
"0",
"]",
"topic",
"=",
"args",
"[",
"-",
"1"... | [
923,
4
] | [
937,
37
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_setident | (self, numeric, command, args) | Handles SETIDENT, used for self ident changes. | Handles SETIDENT, used for self ident changes. | def handle_setident(self, numeric, command, args):
"""Handles SETIDENT, used for self ident changes."""
# <- :70MAAAAAB SETIDENT test
self.users[numeric].ident = newident = args[0]
return {'target': numeric, 'newident': newident} | [
"def",
"handle_setident",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :70MAAAAAB SETIDENT test",
"self",
".",
"users",
"[",
"numeric",
"]",
".",
"ident",
"=",
"newident",
"=",
"args",
"[",
"0",
"]",
"return",
"{",
"'target'",
... | [
939,
4
] | [
943,
56
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_sethost | (self, numeric, command, args) | Handles CHGHOST, used for self hostname changes. | Handles CHGHOST, used for self hostname changes. | def handle_sethost(self, numeric, command, args):
"""Handles CHGHOST, used for self hostname changes."""
# <- :70MAAAAAB SETIDENT some.host
self.users[numeric].host = newhost = args[0]
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
# target.
self.... | [
"def",
"handle_sethost",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :70MAAAAAB SETIDENT some.host",
"self",
".",
"users",
"[",
"numeric",
"]",
".",
"host",
"=",
"newhost",
"=",
"args",
"[",
"0",
"]",
"# When SETHOST or CHGHOST is... | [
945,
4
] | [
954,
54
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_setname | (self, numeric, command, args) | Handles SETNAME, used for self real name/gecos changes. | Handles SETNAME, used for self real name/gecos changes. | def handle_setname(self, numeric, command, args):
"""Handles SETNAME, used for self real name/gecos changes."""
# <- :70MAAAAAB SETNAME :afdsafasf
self.users[numeric].realname = newgecos = args[0]
return {'target': numeric, 'newgecos': newgecos} | [
"def",
"handle_setname",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :70MAAAAAB SETNAME :afdsafasf",
"self",
".",
"users",
"[",
"numeric",
"]",
".",
"realname",
"=",
"newgecos",
"=",
"args",
"[",
"0",
"]",
"return",
"{",
"'tar... | [
956,
4
] | [
960,
56
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_chgident | (self, numeric, command, args) | Handles CHGIDENT, used for denoting ident changes. | Handles CHGIDENT, used for denoting ident changes. | def handle_chgident(self, numeric, command, args):
"""Handles CHGIDENT, used for denoting ident changes."""
# <- :GL CHGIDENT GL test
target = self._get_UID(args[0])
self.users[target].ident = newident = args[1]
return {'target': target, 'newident': newident} | [
"def",
"handle_chgident",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :GL CHGIDENT GL test",
"target",
"=",
"self",
".",
"_get_UID",
"(",
"args",
"[",
"0",
"]",
")",
"self",
".",
"users",
"[",
"target",
"]",
".",
"ident",
... | [
962,
4
] | [
967,
55
] | python | en | ['da', 'en', 'en'] | True |
UnrealProtocol.handle_chghost | (self, numeric, command, args) | Handles CHGHOST, used for denoting hostname changes. | Handles CHGHOST, used for denoting hostname changes. | def handle_chghost(self, numeric, command, args):
"""Handles CHGHOST, used for denoting hostname changes."""
# <- :GL CHGHOST GL some.host
target = self._get_UID(args[0])
self.users[target].host = newhost = args[1]
# When SETHOST or CHGHOST is used, modes +xt are implicitly set ... | [
"def",
"handle_chghost",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :GL CHGHOST GL some.host",
"target",
"=",
"self",
".",
"_get_UID",
"(",
"args",
"[",
"0",
"]",
")",
"self",
".",
"users",
"[",
"target",
"]",
".",
"host",
... | [
969,
4
] | [
979,
53
] | python | en | ['da', 'en', 'en'] | True |
UnrealProtocol.handle_chgname | (self, numeric, command, args) | Handles CHGNAME, used for denoting real name/gecos changes. | Handles CHGNAME, used for denoting real name/gecos changes. | def handle_chgname(self, numeric, command, args):
"""Handles CHGNAME, used for denoting real name/gecos changes."""
# <- :GL CHGNAME GL :afdsafasf
target = self._get_UID(args[0])
self.users[target].realname = newgecos = args[1]
return {'target': target, 'newgecos': newgecos} | [
"def",
"handle_chgname",
"(",
"self",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"# <- :GL CHGNAME GL :afdsafasf",
"target",
"=",
"self",
".",
"_get_UID",
"(",
"args",
"[",
"0",
"]",
")",
"self",
".",
"users",
"[",
"target",
"]",
".",
"realna... | [
981,
4
] | [
986,
55
] | python | en | ['en', 'en', 'en'] | True |
UnrealProtocol.handle_tsctl | (self, source, command, args) | Handles /TSCTL alltime requests. | Handles /TSCTL alltime requests. | def handle_tsctl(self, source, command, args):
"""Handles /TSCTL alltime requests."""
# <- :GL TSCTL alltime
if args[0] == 'alltime':
self._send_with_prefix(self.sid, 'NOTICE %s :*** Server=%s time()=%d' % (source, self.hostname(), time.time())) | [
"def",
"handle_tsctl",
"(",
"self",
",",
"source",
",",
"command",
",",
"args",
")",
":",
"# <- :GL TSCTL alltime",
"if",
"args",
"[",
"0",
"]",
"==",
"'alltime'",
":",
"self",
".",
"_send_with_prefix",
"(",
"self",
".",
"sid",
",",
"'NOTICE %s :*** Server=%... | [
988,
4
] | [
993,
123
] | python | en | ['en', 'nl', 'en'] | True |
setup_integration | (hass) | Set up the integration. | Set up the integration. | async def setup_integration(hass):
"""Set up the integration."""
assert await async_setup_component(
hass, "energy", {"recorder": {"db_url": "sqlite://"}}
)
await hass.async_block_till_done() | [
"async",
"def",
"setup_integration",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"energy\"",
",",
"{",
"\"recorder\"",
":",
"{",
"\"db_url\"",
":",
"\"sqlite://\"",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_ti... | [
32,
0
] | [
37,
38
] | python | en | ['en', 'da', 'en'] | True |
test_cost_sensor_no_states | (hass, hass_storage) | Test sensors are created. | Test sensors are created. | async def test_cost_sensor_no_states(hass, hass_storage) -> None:
"""Test sensors are created."""
energy_data = data.EnergyManager.default_preferences()
energy_data["energy_sources"].append(
{
"type": "grid",
"flow_from": [
{
"stat_energy_f... | [
"async",
"def",
"test_cost_sensor_no_states",
"(",
"hass",
",",
"hass_storage",
")",
"->",
"None",
":",
"energy_data",
"=",
"data",
".",
"EnergyManager",
".",
"default_preferences",
"(",
")",
"energy_data",
"[",
"\"energy_sources\"",
"]",
".",
"append",
"(",
"{"... | [
40,
0
] | [
63,
33
] | python | en | ['en', 'et', 'en'] | True |
test_cost_sensor_price_entity_total_increasing | (
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
) | Test energy cost price from total_increasing type sensor entity. | Test energy cost price from total_increasing type sensor entity. | async def test_cost_sensor_price_entity_total_increasing(
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
) -> None:
"""Test energy cost price from total_increasing type sen... | [
"async",
"def",
"test_cost_sensor_price_entity_total_increasing",
"(",
"hass",
",",
"hass_storage",
",",
"hass_ws_client",
",",
"initial_energy",
",",
"initial_cost",
",",
"price_entity",
",",
"fixed_price",
",",
"usage_sensor_entity_id",
",",
"cost_sensor_entity_id",
",",
... | [
82,
0
] | [
266,
67
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_price_entity_total | (
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
energy_state_class,
) | Test energy cost price from total type sensor entity. | Test energy cost price from total type sensor entity. | async def test_cost_sensor_price_entity_total(
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
energy_state_class,
) -> None:
"""Test energy cost price from total type s... | [
"async",
"def",
"test_cost_sensor_price_entity_total",
"(",
"hass",
",",
"hass_storage",
",",
"hass_ws_client",
",",
"initial_energy",
",",
"initial_cost",
",",
"price_entity",
",",
"fixed_price",
",",
"usage_sensor_entity_id",
",",
"cost_sensor_entity_id",
",",
"flow_typ... | [
285,
0
] | [
472,
67
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_price_entity_total_no_reset | (
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
energy_state_class,
) | Test energy cost price from total type sensor entity with no last_reset. | Test energy cost price from total type sensor entity with no last_reset. | async def test_cost_sensor_price_entity_total_no_reset(
hass,
hass_storage,
hass_ws_client,
initial_energy,
initial_cost,
price_entity,
fixed_price,
usage_sensor_entity_id,
cost_sensor_entity_id,
flow_type,
energy_state_class,
) -> None:
"""Test energy cost price from tot... | [
"async",
"def",
"test_cost_sensor_price_entity_total_no_reset",
"(",
"hass",
",",
"hass_storage",
",",
"hass_ws_client",
",",
"initial_energy",
",",
"initial_cost",
",",
"price_entity",
",",
"fixed_price",
",",
"usage_sensor_entity_id",
",",
"cost_sensor_entity_id",
",",
... | [
491,
0
] | [
653,
67
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_handle_wh | (hass, hass_storage) | Test energy cost price from sensor entity. | Test energy cost price from sensor entity. | async def test_cost_sensor_handle_wh(hass, hass_storage) -> None:
"""Test energy cost price from sensor entity."""
energy_attributes = {
ATTR_UNIT_OF_MEASUREMENT: ENERGY_WATT_HOUR,
ATTR_STATE_CLASS: STATE_CLASS_TOTAL_INCREASING,
}
energy_data = data.EnergyManager.default_preferences()
... | [
"async",
"def",
"test_cost_sensor_handle_wh",
"(",
"hass",
",",
"hass_storage",
")",
"->",
"None",
":",
"energy_attributes",
"=",
"{",
"ATTR_UNIT_OF_MEASUREMENT",
":",
"ENERGY_WATT_HOUR",
",",
"ATTR_STATE_CLASS",
":",
"STATE_CLASS_TOTAL_INCREASING",
",",
"}",
"energy_da... | [
656,
0
] | [
709,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_handle_gas | (hass, hass_storage) | Test gas cost price from sensor entity. | Test gas cost price from sensor entity. | async def test_cost_sensor_handle_gas(hass, hass_storage) -> None:
"""Test gas cost price from sensor entity."""
energy_attributes = {
ATTR_UNIT_OF_MEASUREMENT: VOLUME_CUBIC_METERS,
ATTR_STATE_CLASS: STATE_CLASS_TOTAL_INCREASING,
}
energy_data = data.EnergyManager.default_preferences()
... | [
"async",
"def",
"test_cost_sensor_handle_gas",
"(",
"hass",
",",
"hass_storage",
")",
"->",
"None",
":",
"energy_attributes",
"=",
"{",
"ATTR_UNIT_OF_MEASUREMENT",
":",
"VOLUME_CUBIC_METERS",
",",
"ATTR_STATE_CLASS",
":",
"STATE_CLASS_TOTAL_INCREASING",
",",
"}",
"energ... | [
712,
0
] | [
758,
32
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_wrong_state_class | (
hass, hass_storage, caplog, state_class
) | Test energy sensor rejects sensor with wrong state_class. | Test energy sensor rejects sensor with wrong state_class. | async def test_cost_sensor_wrong_state_class(
hass, hass_storage, caplog, state_class
) -> None:
"""Test energy sensor rejects sensor with wrong state_class."""
energy_attributes = {
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
ATTR_STATE_CLASS: state_class,
}
energy_data = data.... | [
"async",
"def",
"test_cost_sensor_wrong_state_class",
"(",
"hass",
",",
"hass_storage",
",",
"caplog",
",",
"state_class",
")",
"->",
"None",
":",
"energy_attributes",
"=",
"{",
"ATTR_UNIT_OF_MEASUREMENT",
":",
"ENERGY_KILO_WATT_HOUR",
",",
"ATTR_STATE_CLASS",
":",
"s... | [
762,
0
] | [
820,
39
] | python | en | ['en', 'en', 'en'] | True |
test_cost_sensor_state_class_measurement_no_reset | (
hass, hass_storage, caplog, state_class
) | Test energy sensor rejects state_class measurement with no last_reset. | Test energy sensor rejects state_class measurement with no last_reset. | async def test_cost_sensor_state_class_measurement_no_reset(
hass, hass_storage, caplog, state_class
) -> None:
"""Test energy sensor rejects state_class measurement with no last_reset."""
energy_attributes = {
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
ATTR_STATE_CLASS: state_class,
... | [
"async",
"def",
"test_cost_sensor_state_class_measurement_no_reset",
"(",
"hass",
",",
"hass_storage",
",",
"caplog",
",",
"state_class",
")",
"->",
"None",
":",
"energy_attributes",
"=",
"{",
"ATTR_UNIT_OF_MEASUREMENT",
":",
"ENERGY_KILO_WATT_HOUR",
",",
"ATTR_STATE_CLAS... | [
824,
0
] | [
878,
39
] | python | en | ['en', 'en', 'en'] | True |
_discover | (hass, config, component_name, found_tellcore_devices) | Set up and send the discovery event. | Set up and send the discovery event. | def _discover(hass, config, component_name, found_tellcore_devices):
"""Set up and send the discovery event."""
if not found_tellcore_devices:
return
_LOGGER.info(
"Discovered %d new %s devices", len(found_tellcore_devices), component_name
)
signal_repetitions = config[DOMAIN].get(... | [
"def",
"_discover",
"(",
"hass",
",",
"config",
",",
"component_name",
",",
"found_tellcore_devices",
")",
":",
"if",
"not",
"found_tellcore_devices",
":",
"return",
"_LOGGER",
".",
"info",
"(",
"\"Discovered %d new %s devices\"",
",",
"len",
"(",
"found_tellcore_de... | [
59,
0
] | [
79,
5
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Tellstick component. | Set up the Tellstick component. | def setup(hass, config):
"""Set up the Tellstick component."""
conf = config.get(DOMAIN, {})
net_host = conf.get(CONF_HOST)
net_ports = conf.get(CONF_PORT)
# Initialize remote tellcore client
if net_host:
net_client = TellCoreClient(
host=net_host, port_client=net_ports[0],... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"net_host",
"=",
"conf",
".",
"get",
"(",
"CONF_HOST",
")",
"net_ports",
"=",
"conf",
".",
"get",
"(",
"CONF_PORT",
")",
"... | [
82,
0
] | [
161,
15
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.__init__ | (self, tellcore_device, signal_repetitions) | Init the Tellstick device. | Init the Tellstick device. | def __init__(self, tellcore_device, signal_repetitions):
"""Init the Tellstick device."""
self._signal_repetitions = signal_repetitions
self._state = None
self._requested_state = None
self._requested_data = None
self._repeats_left = 0
# Look up our corresponding ... | [
"def",
"__init__",
"(",
"self",
",",
"tellcore_device",
",",
"signal_repetitions",
")",
":",
"self",
".",
"_signal_repetitions",
"=",
"signal_repetitions",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_requested_state",
"=",
"None",
"self",
".",
"_requested... | [
170,
4
] | [
180,
41
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_TELLCORE_CALLBACK, self.update_from_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"SIGNAL_TELLCORE_CALLBACK",
",",
"self",
".",
"update_from_callback",
"... | [
182,
4
] | [
188,
9
] | python | en | ['en', 'no', 'en'] | False |
TellstickDevice.should_poll | (self) | Tell Home Assistant not to poll this device. | Tell Home Assistant not to poll this device. | def should_poll(self):
"""Tell Home Assistant not to poll this device."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
191,
4
] | [
193,
20
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.assumed_state | (self) | Tellstick devices are always assumed state. | Tellstick devices are always assumed state. | def assumed_state(self):
"""Tellstick devices are always assumed state."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
196,
4
] | [
198,
19
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.name | (self) | Return the name of the device as reported by tellcore. | Return the name of the device as reported by tellcore. | def name(self):
"""Return the name of the device as reported by tellcore."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
201,
4
] | [
203,
25
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.is_on | (self) | Return true if the device is on. | Return true if the device is on. | def is_on(self):
"""Return true if the device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
206,
4
] | [
208,
26
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._parse_ha_data | (self, kwargs) | Turn the value from HA into something useful. | Turn the value from HA into something useful. | def _parse_ha_data(self, kwargs):
"""Turn the value from HA into something useful."""
raise NotImplementedError | [
"def",
"_parse_ha_data",
"(",
"self",
",",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
210,
4
] | [
212,
33
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._parse_tellcore_data | (self, tellcore_data) | Turn the value received from tellcore into something useful. | Turn the value received from tellcore into something useful. | def _parse_tellcore_data(self, tellcore_data):
"""Turn the value received from tellcore into something useful."""
raise NotImplementedError | [
"def",
"_parse_tellcore_data",
"(",
"self",
",",
"tellcore_data",
")",
":",
"raise",
"NotImplementedError"
] | [
214,
4
] | [
216,
33
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._update_model | (self, new_state, data) | Update the device entity state to match the arguments. | Update the device entity state to match the arguments. | def _update_model(self, new_state, data):
"""Update the device entity state to match the arguments."""
raise NotImplementedError | [
"def",
"_update_model",
"(",
"self",
",",
"new_state",
",",
"data",
")",
":",
"raise",
"NotImplementedError"
] | [
218,
4
] | [
220,
33
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._send_device_command | (self, requested_state, requested_data) | Let tellcore update the actual device to the requested state. | Let tellcore update the actual device to the requested state. | def _send_device_command(self, requested_state, requested_data):
"""Let tellcore update the actual device to the requested state."""
raise NotImplementedError | [
"def",
"_send_device_command",
"(",
"self",
",",
"requested_state",
",",
"requested_data",
")",
":",
"raise",
"NotImplementedError"
] | [
222,
4
] | [
224,
33
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._send_repeated_command | (self) | Send a tellstick command once and decrease the repeat count. | Send a tellstick command once and decrease the repeat count. | def _send_repeated_command(self):
"""Send a tellstick command once and decrease the repeat count."""
with TELLSTICK_LOCK:
if self._repeats_left > 0:
self._repeats_left -= 1
try:
self._send_device_command(
self._requ... | [
"def",
"_send_repeated_command",
"(",
"self",
")",
":",
"with",
"TELLSTICK_LOCK",
":",
"if",
"self",
".",
"_repeats_left",
">",
"0",
":",
"self",
".",
"_repeats_left",
"-=",
"1",
"try",
":",
"self",
".",
"_send_device_command",
"(",
"self",
".",
"_requested_... | [
226,
4
] | [
237,
38
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._change_device_state | (self, new_state, data) | Turn on or off the device. | Turn on or off the device. | def _change_device_state(self, new_state, data):
"""Turn on or off the device."""
with TELLSTICK_LOCK:
# Set the requested state and number of repeats before calling
# _send_repeated_command the first time. Subsequent calls will be
# made from the callback. (We don't ... | [
"def",
"_change_device_state",
"(",
"self",
",",
"new_state",
",",
"data",
")",
":",
"with",
"TELLSTICK_LOCK",
":",
"# Set the requested state and number of repeats before calling",
"# _send_repeated_command the first time. Subsequent calls will be",
"# made from the callback. (We don'... | [
239,
4
] | [
255,
43
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
self._change_device_state(True, self._parse_ha_data(kwargs)) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_change_device_state",
"(",
"True",
",",
"self",
".",
"_parse_ha_data",
"(",
"kwargs",
")",
")"
] | [
257,
4
] | [
259,
68
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
self._change_device_state(False, None) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_change_device_state",
"(",
"False",
",",
"None",
")"
] | [
261,
4
] | [
263,
46
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._update_model_from_command | (self, tellcore_command, tellcore_data) | Update the model, from a sent tellcore command and data. | Update the model, from a sent tellcore command and data. | def _update_model_from_command(self, tellcore_command, tellcore_data):
"""Update the model, from a sent tellcore command and data."""
if tellcore_command not in [TELLSTICK_TURNON, TELLSTICK_TURNOFF, TELLSTICK_DIM]:
_LOGGER.debug("Unhandled tellstick command: %d", tellcore_command)
... | [
"def",
"_update_model_from_command",
"(",
"self",
",",
"tellcore_command",
",",
"tellcore_data",
")",
":",
"if",
"tellcore_command",
"not",
"in",
"[",
"TELLSTICK_TURNON",
",",
"TELLSTICK_TURNOFF",
",",
"TELLSTICK_DIM",
"]",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Un... | [
265,
4
] | [
275,
9
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice.update_from_callback | (self, tellcore_id, tellcore_command, tellcore_data) | Handle updates from the tellcore callback. | Handle updates from the tellcore callback. | def update_from_callback(self, tellcore_id, tellcore_command, tellcore_data):
"""Handle updates from the tellcore callback."""
if tellcore_id != self._tellcore_device.id:
return
self._update_model_from_command(tellcore_command, tellcore_data)
self.schedule_update_ha_state()
... | [
"def",
"update_from_callback",
"(",
"self",
",",
"tellcore_id",
",",
"tellcore_command",
",",
"tellcore_data",
")",
":",
"if",
"tellcore_id",
"!=",
"self",
".",
"_tellcore_device",
".",
"id",
":",
"return",
"self",
".",
"_update_model_from_command",
"(",
"tellcore... | [
277,
4
] | [
288,
41
] | python | en | ['en', 'en', 'en'] | True |
TellstickDevice._update_from_tellcore | (self) | Read the current state of the device from the tellcore library. | Read the current state of the device from the tellcore library. | def _update_from_tellcore(self):
"""Read the current state of the device from the tellcore library."""
with TELLSTICK_LOCK:
try:
last_command = self._tellcore_device.last_sent_command(
TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM
)... | [
"def",
"_update_from_tellcore",
"(",
"self",
")",
":",
"with",
"TELLSTICK_LOCK",
":",
"try",
":",
"last_command",
"=",
"self",
".",
"_tellcore_device",
".",
"last_sent_command",
"(",
"TELLSTICK_TURNON",
"|",
"TELLSTICK_TURNOFF",
"|",
"TELLSTICK_DIM",
")",
"last_data... | [
290,
4
] | [
301,
34
] | 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.