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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SonosEntity.play_queue | (self, queue_position=0) | Start playing the queue. | Start playing the queue. | def play_queue(self, queue_position=0):
"""Start playing the queue."""
self.soco.play_from_queue(queue_position) | [
"def",
"play_queue",
"(",
"self",
",",
"queue_position",
"=",
"0",
")",
":",
"self",
".",
"soco",
".",
"play_from_queue",
"(",
"queue_position",
")"
] | [
1447,
4
] | [
1449,
49
] | python | en | ['en', 'en', 'en'] | True |
SonosEntity.remove_from_queue | (self, queue_position=0) | Remove item from the queue. | Remove item from the queue. | def remove_from_queue(self, queue_position=0):
"""Remove item from the queue."""
self.soco.remove_from_queue(queue_position) | [
"def",
"remove_from_queue",
"(",
"self",
",",
"queue_position",
"=",
"0",
")",
":",
"self",
".",
"soco",
".",
"remove_from_queue",
"(",
"queue_position",
")"
] | [
1453,
4
] | [
1455,
51
] | python | en | ['en', 'en', 'en'] | True |
SonosEntity.device_state_attributes | (self) | Return entity specific state attributes. | Return entity specific state attributes. | def device_state_attributes(self):
"""Return entity specific state attributes."""
attributes = {ATTR_SONOS_GROUP: [e.entity_id for e in self._sonos_group]}
if self._night_sound is not None:
attributes[ATTR_NIGHT_SOUND] = self._night_sound
if self._speech_enhance is not None... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"ATTR_SONOS_GROUP",
":",
"[",
"e",
".",
"entity_id",
"for",
"e",
"in",
"self",
".",
"_sonos_group",
"]",
"}",
"if",
"self",
".",
"_night_sound",
"is",
"not",
"None",
":",
"a... | [
1458,
4
] | [
1471,
25
] | python | en | ['en', 'en', 'en'] | True |
SonosEntity.async_browse_media | (self, media_content_type=None, media_content_id=None) | Implement the websocket media browsing helper. | Implement the websocket media browsing helper. | async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper."""
if media_content_type in [None, "library"]:
return await self.hass.async_add_executor_job(
library_payload, self._media_library
... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
"=",
"None",
",",
"media_content_id",
"=",
"None",
")",
":",
"if",
"media_content_type",
"in",
"[",
"None",
",",
"\"library\"",
"]",
":",
"return",
"await",
"self",
".",
"hass",
".... | [
1473,
4
] | [
1491,
23
] | python | en | ['en', 'af', 'en'] | True |
test_controlling_state_via_topic | (hass, mqtt_mock) | Test the controlling state via topic. | Test the controlling state via topic. | async def test_controlling_state_via_topic(hass, mqtt_mock):
"""Test the controlling state via topic."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": ... | [
"async",
"def",
"test_controlling_state_via_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"name\"",
":",
"\... | [
45,
0
] | [
77,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controlling_non_default_state_via_topic | (hass, mqtt_mock) | Test the controlling state via topic. | Test the controlling state via topic. | async def test_controlling_non_default_state_via_topic(hass, mqtt_mock):
"""Test the controlling state via topic."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
"name": "test",
"st... | [
"async",
"def",
"test_controlling_non_default_state_via_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"name\"",... | [
80,
0
] | [
112,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controlling_state_via_topic_and_json_message | (hass, mqtt_mock) | Test the controlling state via topic and JSON message. | Test the controlling state via topic and JSON message. | async def test_controlling_state_via_topic_and_json_message(hass, mqtt_mock):
"""Test the controlling state via topic and JSON message."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
"name": "test... | [
"async",
"def",
"test_controlling_state_via_topic_and_json_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"nam... | [
115,
0
] | [
147,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controlling_non_default_state_via_topic_and_json_message | (
hass, mqtt_mock
) | Test the controlling state via topic and JSON message. | Test the controlling state via topic and JSON message. | async def test_controlling_non_default_state_via_topic_and_json_message(
hass, mqtt_mock
):
"""Test the controlling state via topic and JSON message."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
... | [
"async",
"def",
"test_controlling_non_default_state_via_topic_and_json_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
"... | [
150,
0
] | [
184,
40
] | python | en | ['en', 'en', 'en'] | True |
test_sending_mqtt_commands_and_optimistic | (hass, mqtt_mock) | Test optimistic mode without state topic. | Test optimistic mode without state topic. | async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
"""Test optimistic mode without state topic."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
"name": "test",
"c... | [
"async",
"def",
"test_sending_mqtt_commands_and_optimistic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"name\"",
... | [
187,
0
] | [
228,
51
] | python | en | ['en', 'en', 'en'] | True |
test_sending_mqtt_commands_and_explicit_optimistic | (hass, mqtt_mock) | Test optimistic mode without state topic. | Test optimistic mode without state topic. | async def test_sending_mqtt_commands_and_explicit_optimistic(hass, mqtt_mock):
"""Test optimistic mode without state topic."""
assert await async_setup_component(
hass,
LOCK_DOMAIN,
{
LOCK_DOMAIN: {
"platform": "mqtt",
"name": "test",
... | [
"async",
"def",
"test_sending_mqtt_commands_and_explicit_optimistic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"na... | [
231,
0
] | [
274,
51
] | 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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_availability_when_connection_lost",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_availability_when_connection_lost",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
277,
0
] | [
281,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_availability_without_topic",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_availability_without_topic",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
284,
0
] | [
288,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_default_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_default_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
291,
0
] | [
295,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_custom_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_custom_availability_payload",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
298,
0
] | [
302,
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, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
305,
0
] | [
309,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_setting_attribute_with_template",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_setting_attribute_with_template",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
312,
0
] | [
316,
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, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
319,
0
] | [
323,
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, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
326,
0
] | [
330,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_discovery_update_attr",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"await",
"help_test_discovery_update_attr",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
333,
0
] | [
337,
5
] | python | en | ['en', 'en', 'en'] | True |
test_unique_id | (hass, mqtt_mock) | Test unique id option only creates one lock per unique_id. | Test unique id option only creates one lock per unique_id. | async def test_unique_id(hass, mqtt_mock):
"""Test unique id option only creates one lock per unique_id."""
config = {
LOCK_DOMAIN: [
{
"platform": "mqtt",
"name": "Test 1",
"state_topic": "test-topic",
"command_topic": "test_to... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"{",
"LOCK_DOMAIN",
":",
"[",
"{",
"\"platform\"",
":",
"\"mqtt\"",
",",
"\"name\"",
":",
"\"Test 1\"",
",",
"\"state_topic\"",
":",
"\"test-topic\"",
",",
"\"command_top... | [
340,
0
] | [
360,
67
] | python | en | ['en', 'la', 'en'] | True |
test_discovery_removal_lock | (hass, mqtt_mock, caplog) | Test removal of discovered lock. | Test removal of discovered lock. | async def test_discovery_removal_lock(hass, mqtt_mock, caplog):
"""Test removal of discovered lock."""
data = '{ "name": "test",' ' "command_topic": "test_topic" }'
await help_test_discovery_removal(hass, mqtt_mock, caplog, LOCK_DOMAIN, data) | [
"async",
"def",
"test_discovery_removal_lock",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data",
"=",
"'{ \"name\": \"test\",'",
"' \"command_topic\": \"test_topic\" }'",
"await",
"help_test_discovery_removal",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
... | [
363,
0
] | [
366,
81
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_update_lock | (hass, mqtt_mock, caplog) | Test update of discovered lock. | Test update of discovered lock. | async def test_discovery_update_lock(hass, mqtt_mock, caplog):
"""Test update of discovered lock."""
data1 = (
'{ "name": "Beer",'
' "state_topic": "test_topic",'
' "command_topic": "command_topic",'
' "availability_topic": "availability_topic1" }'
)
data2 = (
... | [
"async",
"def",
"test_discovery_update_lock",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"(",
"'{ \"name\": \"Beer\",'",
"' \"state_topic\": \"test_topic\",'",
"' \"command_topic\": \"command_topic\",'",
"' \"availability_topic\": \"availability_topic1... | [
369,
0
] | [
383,
88
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_update_unchanged_lock | (hass, mqtt_mock, caplog) | Test update of discovered lock. | Test update of discovered lock. | async def test_discovery_update_unchanged_lock(hass, mqtt_mock, caplog):
"""Test update of discovered lock."""
data1 = (
'{ "name": "Beer",'
' "state_topic": "test_topic",'
' "command_topic": "command_topic" }'
)
with patch(
"homeassistant.components.mqtt.lock.MqttLock.... | [
"async",
"def",
"test_discovery_update_unchanged_lock",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"(",
"'{ \"name\": \"Beer\",'",
"' \"state_topic\": \"test_topic\",'",
"' \"command_topic\": \"command_topic\" }'",
")",
"with",
"patch",
"(",
"\"... | [
386,
0
] | [
398,
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",' ' "command_topic": "test_topic" }'
await help_test_discovery_broken(hass, mqtt_mock, caplog, LOCK_DOMAIN, data1, data2) | [
"async",
"def",
"test_discovery_broken",
"(",
"hass",
",",
"mqtt_mock",
",",
"caplog",
")",
":",
"data1",
"=",
"'{ \"name\": \"Beer\" }'",
"data2",
"=",
"'{ \"name\": \"Milk\",'",
"' \"command_topic\": \"test_topic\" }'",
"await",
"help_test_discovery_broken",
"(",
"hass",... | [
402,
0
] | [
406,
88
] | python | en | ['en', 'en', 'en'] | True |
test_entity_device_info_with_connection | (hass, mqtt_mock) | Test MQTT lock device registry integration. | Test MQTT lock device registry integration. | async def test_entity_device_info_with_connection(hass, mqtt_mock):
"""Test MQTT lock device registry integration."""
await help_test_entity_device_info_with_connection(
hass, mqtt_mock, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
409,
0
] | [
413,
5
] | python | en | ['en', 'sv', 'en'] | True |
test_entity_device_info_with_identifier | (hass, mqtt_mock) | Test MQTT lock device registry integration. | Test MQTT lock device registry integration. | async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT lock device registry integration."""
await help_test_entity_device_info_with_identifier(
hass, mqtt_mock, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
416,
0
] | [
420,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_update",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_update",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
423,
0
] | [
427,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_device_info_remove",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_device_info_remove",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
430,
0
] | [
434,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_id_update_subscriptions",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_id_update_subscriptions",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
437,
0
] | [
441,
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, LOCK_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",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
444,
0
] | [
448,
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, LOCK_DOMAIN, DEFAULT_CONFIG
) | [
"async",
"def",
"test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"await",
"help_test_entity_debug_info_message",
"(",
"hass",
",",
"mqtt_mock",
",",
"LOCK_DOMAIN",
",",
"DEFAULT_CONFIG",
")"
] | [
451,
0
] | [
455,
5
] | python | es | ['es', 'mt', 'it'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Wink platform. | Set up the Wink platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Wink platform."""
for sensor in pywink.get_sensors():
_id = sensor.object_id() + sensor.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
if sensor.capability() in SENSOR_TYPES:
ad... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"for",
"sensor",
"in",
"pywink",
".",
"get_sensors",
"(",
")",
":",
"_id",
"=",
"sensor",
".",
"object_id",
"(",
")",
"+",
"sensor",
... | [
14,
0
] | [
40,
54
] | python | en | ['en', 'da', 'en'] | True |
WinkSensorDevice.__init__ | (self, wink, hass) | Initialize the Wink device. | Initialize the Wink device. | def __init__(self, wink, hass):
"""Initialize the Wink device."""
super().__init__(wink, hass)
self.capability = self.wink.capability()
if self.wink.unit() == DEGREE:
self._unit_of_measurement = TEMP_CELSIUS
else:
self._unit_of_measurement = self.wink.unit... | [
"def",
"__init__",
"(",
"self",
",",
"wink",
",",
"hass",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"wink",
",",
"hass",
")",
"self",
".",
"capability",
"=",
"self",
".",
"wink",
".",
"capability",
"(",
")",
"if",
"self",
".",
"wink",
".... | [
46,
4
] | [
53,
56
] | python | en | ['en', 'en', 'en'] | True |
WinkSensorDevice.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
self.hass.data[DOMAIN]["entities"]["sensor"].append(self) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"entities\"",
"]",
"[",
"\"sensor\"",
"]",
".",
"append",
"(",
"self",
")"
] | [
55,
4
] | [
57,
65
] | python | en | ['en', 'en', 'en'] | True |
WinkSensorDevice.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
state = None
if self.capability == "humidity":
if self.wink.state() is not None:
state = round(self.wink.state())
elif self.capability == "temperature":
if self.wink.state() is not None:
stat... | [
"def",
"state",
"(",
"self",
")",
":",
"state",
"=",
"None",
"if",
"self",
".",
"capability",
"==",
"\"humidity\"",
":",
"if",
"self",
".",
"wink",
".",
"state",
"(",
")",
"is",
"not",
"None",
":",
"state",
"=",
"round",
"(",
"self",
".",
"wink",
... | [
60,
4
] | [
77,
20
] | python | en | ['en', 'en', 'en'] | True |
WinkSensorDevice.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
80,
4
] | [
82,
40
] | python | en | ['en', 'en', 'en'] | True |
WinkSensorDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
super_attrs = super().device_state_attributes
try:
super_attrs["egg_times"] = self.wink.eggs()
except AttributeError:
# Ignore error, this sensor isn't an eggminder
pass
retu... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"super_attrs",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"try",
":",
"super_attrs",
"[",
"\"egg_times\"",
"]",
"=",
"self",
".",
"wink",
".",
"eggs",
"(",
")",
"except",
"AttributeError",
... | [
85,
4
] | [
93,
26
] | python | en | ['en', 'en', 'en'] | True |
test_lg_tv | (hass) | Test that a Koogeek LS1 can be correctly setup in HA. | Test that a Koogeek LS1 can be correctly setup in HA. | async def test_lg_tv(hass):
"""Test that a Koogeek LS1 can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, "lg_tv.json")
config_entry, pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
... | [
"async",
"def",
"test_lg_tv",
"(",
"hass",
")",
":",
"accessories",
"=",
"await",
"setup_accessories_from_file",
"(",
"hass",
",",
"\"lg_tv.json\"",
")",
"config_entry",
",",
"pairing",
"=",
"await",
"setup_test_accessories",
"(",
"hass",
",",
"accessories",
")",
... | [
16,
0
] | [
67,
25
] | python | en | ['en', 'ig', 'en'] | True |
NASBench201Cell.forward | (self, input) |
Parameters
---
input: torch.tensor
the output of the previous layer
|
Parameters
---
input: torch.tensor
the output of the previous layer
| def forward(self, input): # pylint: disable=W0622
"""
Parameters
---
input: torch.tensor
the output of the previous layer
"""
nodes = [input]
for i in range(1, self.NUM_NODES):
node_feature = sum(self.layers[i][k](nodes[k]) for k in range(i... | [
"def",
"forward",
"(",
"self",
",",
"input",
")",
":",
"# pylint: disable=W0622",
"nodes",
"=",
"[",
"input",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"NUM_NODES",
")",
":",
"node_feature",
"=",
"sum",
"(",
"self",
".",
"layers",
"... | [
60,
4
] | [
71,
24
] | python | en | ['en', 'error', 'th'] | False |
BertEncoderWrapper.init_bert_weights | (self, module) | Initialize the weights.
| Initialize the weights.
| def init_bert_weights(self, module):
""" Initialize the weights.
"""
if isinstance(module, (nn.Linear, nn.Embedding)):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
mod... | [
"def",
"init_bert_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"(",
"nn",
".",
"Linear",
",",
"nn",
".",
"Embedding",
")",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
... | [
21,
4
] | [
32,
36
] | python | en | ['en', 'en', 'en'] | True |
test_setup_component | (
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) | Test component setup. | Test component setup. | async def test_setup_component(
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test component setup."""
assert await async_setup_component(
hass, DOMAIN, {DOMAIN: MOCK_USER_VALID_TV_CONFIG}
)
await hass.async_block_till_done()
... | [
"async",
"def",
"test_setup_component",
"(",
"hass",
":",
"HomeAssistantType",
",",
"vizio_connect",
":",
"pytest",
".",
"fixture",
",",
"vizio_update",
":",
"pytest",
".",
"fixture",
",",
")",
"->",
"None",
":",
"assert",
"await",
"async_setup_component",
"(",
... | [
13,
0
] | [
23,
60
] | python | en | ['en', 'da', 'en'] | True |
test_tv_load_and_unload | (
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) | Test loading and unloading TV entry. | Test loading and unloading TV entry. | async def test_tv_load_and_unload(
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test loading and unloading TV entry."""
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_USER_VALID_TV_CONFIG, unique_id=UNIQUE_ID
)
config_e... | [
"async",
"def",
"test_tv_load_and_unload",
"(",
"hass",
":",
"HomeAssistantType",
",",
"vizio_connect",
":",
"pytest",
".",
"fixture",
",",
"vizio_update",
":",
"pytest",
".",
"fixture",
",",
")",
"->",
"None",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
... | [
26,
0
] | [
44,
34
] | python | en | ['en', 'en', 'en'] | True |
test_speaker_load_and_unload | (
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) | Test loading and unloading speaker entry. | Test loading and unloading speaker entry. | async def test_speaker_load_and_unload(
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test loading and unloading speaker entry."""
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, unique_id=UNIQUE_ID
)
conf... | [
"async",
"def",
"test_speaker_load_and_unload",
"(",
"hass",
":",
"HomeAssistantType",
",",
"vizio_connect",
":",
"pytest",
".",
"fixture",
",",
"vizio_update",
":",
"pytest",
".",
"fixture",
",",
")",
"->",
"None",
":",
"config_entry",
"=",
"MockConfigEntry",
"... | [
47,
0
] | [
65,
34
] | python | en | ['en', 'no', 'en'] | True |
calculate_rouge_path | (pred_path, tgt_path, save_path=None, **kwargs) | Kwargs will be passed to calculate_rouge | Kwargs will be passed to calculate_rouge | def calculate_rouge_path(pred_path, tgt_path, save_path=None, **kwargs):
"""Kwargs will be passed to calculate_rouge"""
pred_lns = [x.strip() for x in open(pred_path).readlines()]
tgt_lns = [x.strip() for x in open(tgt_path).readlines()][: len(pred_lns)]
metrics = calculate_rouge(pred_lns, tgt_lns, **kw... | [
"def",
"calculate_rouge_path",
"(",
"pred_path",
",",
"tgt_path",
",",
"save_path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"pred_lns",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"open",
"(",
"pred_path",
")",
".",
"readlines",
... | [
19,
0
] | [
26,
18
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the qBittorrent sensors. | Set up the qBittorrent sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the qBittorrent sensors."""
try:
client = Client(config[CONF_URL])
client.login(config[CONF_USERNAME], config[CONF_PASSWORD])
except LoginRequired:
_LOGGER.error("Invalid authentication")
return
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"try",
":",
"client",
"=",
"Client",
"(",
"config",
"[",
"CONF_URL",
"]",
")",
"client",
".",
"login",
"(",
"config",
"[",
"CONF_USERN... | [
44,
0
] | [
64,
27
] | python | en | ['en', 'ca', 'en'] | True |
format_speed | (speed) | Return a bytes/s measurement as a human readable string. | Return a bytes/s measurement as a human readable string. | def format_speed(speed):
"""Return a bytes/s measurement as a human readable string."""
kb_spd = float(speed) / 1024
return round(kb_spd, 2 if kb_spd < 0.1 else 1) | [
"def",
"format_speed",
"(",
"speed",
")",
":",
"kb_spd",
"=",
"float",
"(",
"speed",
")",
"/",
"1024",
"return",
"round",
"(",
"kb_spd",
",",
"2",
"if",
"kb_spd",
"<",
"0.1",
"else",
"1",
")"
] | [
67,
0
] | [
70,
50
] | python | en | ['en', 'en', 'en'] | True |
QBittorrentSensor.__init__ | (self, sensor_type, qbittorrent_client, client_name, exception) | Initialize the qBittorrent sensor. | Initialize the qBittorrent sensor. | def __init__(self, sensor_type, qbittorrent_client, client_name, exception):
"""Initialize the qBittorrent sensor."""
self._name = SENSOR_TYPES[sensor_type][0]
self.client = qbittorrent_client
self.type = sensor_type
self.client_name = client_name
self._state = None
... | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"qbittorrent_client",
",",
"client_name",
",",
"exception",
")",
":",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
"]",
"self",
".",
"client",
"=",
"qbittorrent_client"... | [
76,
4
] | [
85,
35
] | python | en | ['en', 'la', 'en'] | True |
QBittorrentSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
88,
4
] | [
90,
49
] | python | en | ['en', 'mi', 'en'] | True |
QBittorrentSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
93,
4
] | [
95,
26
] | python | en | ['en', 'en', 'en'] | True |
QBittorrentSensor.available | (self) | Return true if device is available. | Return true if device is available. | def available(self):
"""Return true if device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
98,
4
] | [
100,
30
] | python | en | ['en', 'en', 'en'] | True |
QBittorrentSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
103,
4
] | [
105,
40
] | python | en | ['en', 'en', 'en'] | True |
QBittorrentSensor.update | (self) | Get the latest data from qBittorrent and updates the state. | Get the latest data from qBittorrent and updates the state. | def update(self):
"""Get the latest data from qBittorrent and updates the state."""
try:
data = self.client.sync_main_data()
self._available = True
except RequestException:
_LOGGER.error("Connection lost")
self._available = False
return... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"client",
".",
"sync_main_data",
"(",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"RequestException",
":",
"_LOGGER",
".",
"error",
"(",
"\"Connection lost\"",
")",
... | [
107,
4
] | [
139,
46
] | python | en | ['en', 'en', 'en'] | True |
test_hassio_system_health | (hass, aioclient_mock) | Test hassio system health. | Test hassio system health. | async def test_hassio_system_health(hass, aioclient_mock):
"""Test hassio system health."""
aioclient_mock.get("http://127.0.0.1/info", json={"result": "ok", "data": {}})
aioclient_mock.get("http://127.0.0.1/host/info", json={"result": "ok", "data": {}})
aioclient_mock.get("http://127.0.0.1/os/info", js... | [
"async",
"def",
"test_hassio_system_health",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/info\"",
",",
"json",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
",",
"\"data\"",
":",
"{",
"}",
"}",
")",
"aioclient_... | [
14,
0
] | [
66,
5
] | python | en | ['es', 'en', 'en'] | True |
test_hassio_system_health_with_issues | (hass, aioclient_mock) | Test hassio system health. | Test hassio system health. | async def test_hassio_system_health_with_issues(hass, aioclient_mock):
"""Test hassio system health."""
aioclient_mock.get("http://127.0.0.1/info", json={"result": "ok", "data": {}})
aioclient_mock.get("http://127.0.0.1/host/info", json={"result": "ok", "data": {}})
aioclient_mock.get("http://127.0.0.1/... | [
"async",
"def",
"test_hassio_system_health_with_issues",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/info\"",
",",
"json",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
",",
"\"data\"",
":",
"{",
"}",
"}",
")",
... | [
69,
0
] | [
112,
5
] | python | en | ['es', 'en', 'en'] | True |
test_flow_no_discovered_stations | (hass, mock_get_stations) | Test config flow discovers no station. | Test config flow discovers no station. | async def test_flow_no_discovered_stations(hass, mock_get_stations):
"""Test config flow discovers no station."""
mock_get_stations.return_value = []
result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": "user"}
)
assert result["type"] == "abort"
assert res... | [
"async",
"def",
"test_flow_no_discovered_stations",
"(",
"hass",
",",
"mock_get_stations",
")",
":",
"mock_get_stations",
".",
"return_value",
"=",
"[",
"]",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
"."... | [
9,
0
] | [
16,
44
] | python | en | ['en', 'en', 'en'] | True |
test_flow_invalid_station | (hass, mock_get_stations) | Test config flow errors on invalid station. | Test config flow errors on invalid station. | async def test_flow_invalid_station(hass, mock_get_stations):
"""Test config flow errors on invalid station."""
mock_get_stations.return_value = [
{"label": "My station", "stationReference": "L12345"}
]
result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source":... | [
"async",
"def",
"test_flow_invalid_station",
"(",
"hass",
",",
"mock_get_stations",
")",
":",
"mock_get_stations",
".",
"return_value",
"=",
"[",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"stationReference\"",
":",
"\"L12345\"",
"}",
"]",
"result",
"=",
"awa... | [
19,
0
] | [
33,
9
] | python | en | ['en', 'en', 'en'] | True |
test_flow_works | (hass, mock_get_stations, mock_get_station) | Test config flow discovers no station. | Test config flow discovers no station. | async def test_flow_works(hass, mock_get_stations, mock_get_station):
"""Test config flow discovers no station."""
mock_get_stations.return_value = [
{"label": "My station", "stationReference": "L12345"}
]
mock_get_station.return_value = [
{"label": "My station", "stationReference": "L12... | [
"async",
"def",
"test_flow_works",
"(",
"hass",
",",
"mock_get_stations",
",",
"mock_get_station",
")",
":",
"mock_get_stations",
".",
"return_value",
"=",
"[",
"{",
"\"label\"",
":",
"\"My station\"",
",",
"\"stationReference\"",
":",
"\"L12345\"",
"}",
"]",
"moc... | [
36,
0
] | [
59,
5
] | python | en | ['en', 'en', 'en'] | True |
explore_module | (package) | Explore the modules. | Explore the modules. | def explore_module(package):
"""Explore the modules."""
module = importlib.import_module(package)
if not hasattr(module, "__path__"):
return []
for _, name, _ in pkgutil.iter_modules(module.__path__, f"{package}."):
yield name | [
"def",
"explore_module",
"(",
"package",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"package",
")",
"if",
"not",
"hasattr",
"(",
"module",
",",
"\"__path__\"",
")",
":",
"return",
"[",
"]",
"for",
"_",
",",
"name",
",",
"_",
"in",... | [
10,
0
] | [
16,
18
] | python | en | ['en', 'la', 'en'] | True |
main | () | Run the script. | Run the script. | def main():
"""Run the script."""
if not os.path.isfile("requirements_all.txt"):
print("Run this from HA root dir")
return
msg = {}
def add_msg(key, item):
"""Add a message."""
if key not in msg:
msg[key] = []
msg[key].append(item)
for package i... | [
"def",
"main",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"\"requirements_all.txt\"",
")",
":",
"print",
"(",
"\"Run this from HA root dir\"",
")",
"return",
"msg",
"=",
"{",
"}",
"def",
"add_msg",
"(",
"key",
",",
"item",
")",
... | [
19,
0
] | [
58,
64
] | python | en | ['en', 'co', 'en'] | True |
Getter.__init__ | (self) |
init db and crawlers
|
init db and crawlers
| def __init__(self):
"""
init db and crawlers
"""
self.redis = RedisClient()
self.crawlers_cls = crawlers_cls
self.crawlers = [crawler_cls() for crawler_cls in self.crawlers_cls] | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"redis",
"=",
"RedisClient",
"(",
")",
"self",
".",
"crawlers_cls",
"=",
"crawlers_cls",
"self",
".",
"crawlers",
"=",
"[",
"crawler_cls",
"(",
")",
"for",
"crawler_cls",
"in",
"self",
".",
"crawlers... | [
11,
4
] | [
17,
76
] | python | en | ['en', 'error', 'th'] | False |
Getter.is_full | (self) |
if proxypool if full
return: bool
|
if proxypool if full
return: bool
| def is_full(self):
"""
if proxypool if full
return: bool
"""
return self.redis.count() >= PROXY_NUMBER_MAX | [
"def",
"is_full",
"(",
"self",
")",
":",
"return",
"self",
".",
"redis",
".",
"count",
"(",
")",
">=",
"PROXY_NUMBER_MAX"
] | [
19,
4
] | [
24,
53
] | python | en | ['en', 'error', 'th'] | False |
Getter.run | (self) |
run crawlers to get proxy
:return:
|
run crawlers to get proxy
:return:
| def run(self):
"""
run crawlers to get proxy
:return:
"""
if self.is_full():
return
for crawler in self.crawlers:
for proxy in crawler.crawl():
self.redis.add(proxy) | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_full",
"(",
")",
":",
"return",
"for",
"crawler",
"in",
"self",
".",
"crawlers",
":",
"for",
"proxy",
"in",
"crawler",
".",
"crawl",
"(",
")",
":",
"self",
".",
"redis",
".",
"add",
"(",... | [
27,
4
] | [
36,
37
] | python | en | ['en', 'error', 'th'] | False |
test_report_state | (hass, caplog, legacy_patchable_time) | Test report state works. | Test report state works. | async def test_report_state(hass, caplog, legacy_patchable_time):
"""Test report state works."""
hass.states.async_set("light.ceiling", "off")
hass.states.async_set("switch.ac", "on")
with patch.object(
BASIC_CONFIG, "async_report_state_all", AsyncMock()
) as mock_report, patch.object(repor... | [
"async",
"def",
"test_report_state",
"(",
"hass",
",",
"caplog",
",",
"legacy_patchable_time",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.ceiling\"",
",",
"\"off\"",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"switch.ac\"",
",",... | [
10,
0
] | [
78,
43
] | python | en | ['nl', 'en', 'en'] | True |
setup | (hass, config) | Set up the BloomSky component. | Set up the BloomSky component. | def setup(hass, config):
"""Set up the BloomSky component."""
api_key = config[DOMAIN][CONF_API_KEY]
try:
bloomsky = BloomSky(api_key, hass.config.units.is_metric)
except RuntimeError:
return False
hass.data[DOMAIN] = bloomsky
for component in BLOOMSKY_TYPE:
discovery.... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"api_key",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_API_KEY",
"]",
"try",
":",
"bloomsky",
"=",
"BloomSky",
"(",
"api_key",
",",
"hass",
".",
"config",
".",
"units",
".",
"is_metric",
")",
"e... | [
33,
0
] | [
47,
15
] | python | en | ['en', 'en', 'en'] | True |
BloomSky.__init__ | (self, api_key, is_metric) | Initialize the BookSky. | Initialize the BookSky. | def __init__(self, api_key, is_metric):
"""Initialize the BookSky."""
self._api_key = api_key
self._endpoint_argument = "unit=intl" if is_metric else ""
self.devices = {}
self.is_metric = is_metric
_LOGGER.debug("Initial BloomSky device load...")
self.refresh_devi... | [
"def",
"__init__",
"(",
"self",
",",
"api_key",
",",
"is_metric",
")",
":",
"self",
".",
"_api_key",
"=",
"api_key",
"self",
".",
"_endpoint_argument",
"=",
"\"unit=intl\"",
"if",
"is_metric",
"else",
"\"\"",
"self",
".",
"devices",
"=",
"{",
"}",
"self",
... | [
56,
4
] | [
63,
30
] | python | en | ['en', 'en', 'en'] | True |
BloomSky.refresh_devices | (self) | Use the API to retrieve a list of devices. | Use the API to retrieve a list of devices. | def refresh_devices(self):
"""Use the API to retrieve a list of devices."""
_LOGGER.debug("Fetching BloomSky update")
response = requests.get(
f"{self.API_URL}?{self._endpoint_argument}",
headers={AUTHORIZATION: self._api_key},
timeout=10,
)
if... | [
"def",
"refresh_devices",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching BloomSky update\"",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"f\"{self.API_URL}?{self._endpoint_argument}\"",
",",
"headers",
"=",
"{",
"AUTHORIZATION",
":",
"self",... | [
66,
4
] | [
83,
87
] | python | en | ['en', 'haw', 'en'] | True |
MsgDispatcherBase.run | (self) | Run the tuner.
This function will never return unless raise.
| Run the tuner.
This function will never return unless raise.
| def run(self):
"""Run the tuner.
This function will never return unless raise.
"""
_logger.info('Dispatcher started')
if dispatcher_env_vars.NNI_MODE == 'resume':
self.load_checkpoint()
while not self.stopping:
command, data = receive()
... | [
"def",
"run",
"(",
"self",
")",
":",
"_logger",
".",
"info",
"(",
"'Dispatcher started'",
")",
"if",
"dispatcher_env_vars",
".",
"NNI_MODE",
"==",
"'resume'",
":",
"self",
".",
"load_checkpoint",
"(",
")",
"while",
"not",
"self",
".",
"stopping",
":",
"com... | [
41,
4
] | [
77,
46
] | python | en | ['en', 'fi', 'en'] | True |
MsgDispatcherBase.command_queue_worker | (self, command_queue) | Process commands in command queues.
| Process commands in command queues.
| def command_queue_worker(self, command_queue):
"""Process commands in command queues.
"""
while True:
try:
# set timeout to ensure self.stopping is checked periodically
command, data = command_queue.get(timeout=3)
try:
... | [
"def",
"command_queue_worker",
"(",
"self",
",",
"command_queue",
")",
":",
"while",
"True",
":",
"try",
":",
"# set timeout to ensure self.stopping is checked periodically",
"command",
",",
"data",
"=",
"command_queue",
".",
"get",
"(",
"timeout",
"=",
"3",
")",
... | [
79,
4
] | [
95,
21
] | python | en | ['en', 'ca', 'en'] | True |
MsgDispatcherBase.enqueue_command | (self, command, data) | Enqueue command into command queues
| Enqueue command into command queues
| def enqueue_command(self, command, data):
"""Enqueue command into command queues
"""
if command == CommandType.TrialEnd or (
command == CommandType.ReportMetricData and data['type'] == 'PERIODICAL'):
self.assessor_command_queue.put((command, data))
else:
... | [
"def",
"enqueue_command",
"(",
"self",
",",
"command",
",",
"data",
")",
":",
"if",
"command",
"==",
"CommandType",
".",
"TrialEnd",
"or",
"(",
"command",
"==",
"CommandType",
".",
"ReportMetricData",
"and",
"data",
"[",
"'type'",
"]",
"==",
"'PERIODICAL'",
... | [
97,
4
] | [
112,
63
] | python | en | ['en', 'ca', 'en'] | True |
MsgDispatcherBase.process_command_thread | (self, request) | Worker thread to process a command.
| Worker thread to process a command.
| def process_command_thread(self, request):
"""Worker thread to process a command.
"""
command, data = request
if multi_thread_enabled():
try:
self.process_command(command, data)
except Exception as e:
_logger.exception(str(e))
... | [
"def",
"process_command_thread",
"(",
"self",
",",
"request",
")",
":",
"command",
",",
"data",
"=",
"request",
"if",
"multi_thread_enabled",
"(",
")",
":",
"try",
":",
"self",
".",
"process_command",
"(",
"command",
",",
"data",
")",
"except",
"Exception",
... | [
114,
4
] | [
125,
16
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_initialize | (self, data) | Initialize search space and tuner, if any
This method is meant to be called only once for each experiment, after calling this method,
dispatcher should `send(CommandType.Initialized, '')`, to set the status of the experiment to be "INITIALIZED".
Parameters
----------
data: dict
... | Initialize search space and tuner, if any
This method is meant to be called only once for each experiment, after calling this method,
dispatcher should `send(CommandType.Initialized, '')`, to set the status of the experiment to be "INITIALIZED".
Parameters
----------
data: dict
... | def handle_initialize(self, data):
"""Initialize search space and tuner, if any
This method is meant to be called only once for each experiment, after calling this method,
dispatcher should `send(CommandType.Initialized, '')`, to set the status of the experiment to be "INITIALIZED".
Para... | [
"def",
"handle_initialize",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_initialize not implemented'",
")"
] | [
151,
4
] | [
160,
70
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_request_trial_jobs | (self, data) | The message dispatcher is demanded to generate ``data`` trial jobs.
These trial jobs should be sent via ``send(CommandType.NewTrialJob, json_tricks.dumps(parameter))``,
where ``parameter`` will be received by NNI Manager and eventually accessible to trial jobs as "next parameter".
Semantically, ... | The message dispatcher is demanded to generate ``data`` trial jobs.
These trial jobs should be sent via ``send(CommandType.NewTrialJob, json_tricks.dumps(parameter))``,
where ``parameter`` will be received by NNI Manager and eventually accessible to trial jobs as "next parameter".
Semantically, ... | def handle_request_trial_jobs(self, data):
"""The message dispatcher is demanded to generate ``data`` trial jobs.
These trial jobs should be sent via ``send(CommandType.NewTrialJob, json_tricks.dumps(parameter))``,
where ``parameter`` will be received by NNI Manager and eventually accessible to ... | [
"def",
"handle_request_trial_jobs",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_request_trial_jobs not implemented'",
")"
] | [
162,
4
] | [
185,
78
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_update_search_space | (self, data) | This method will be called when search space is updated.
It's recommended to call this method in `handle_initialize` to initialize search space.
*No need to* notify NNI Manager when this update is done.
Parameters
----------
data: dict
search space
| This method will be called when search space is updated.
It's recommended to call this method in `handle_initialize` to initialize search space.
*No need to* notify NNI Manager when this update is done.
Parameters
----------
data: dict
search space
| def handle_update_search_space(self, data):
"""This method will be called when search space is updated.
It's recommended to call this method in `handle_initialize` to initialize search space.
*No need to* notify NNI Manager when this update is done.
Parameters
----------
... | [
"def",
"handle_update_search_space",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_update_search_space not implemented'",
")"
] | [
187,
4
] | [
196,
79
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_import_data | (self, data) | Import previous data when experiment is resumed.
Parameters
----------
data: list
a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
| Import previous data when experiment is resumed.
Parameters
----------
data: list
a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
| def handle_import_data(self, data):
"""Import previous data when experiment is resumed.
Parameters
----------
data: list
a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
"""
raise NotImplementedError('handle_import_data not ... | [
"def",
"handle_import_data",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_import_data not implemented'",
")"
] | [
198,
4
] | [
205,
71
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_add_customized_trial | (self, data) | Experimental API. Not recommended for usage.
| Experimental API. Not recommended for usage.
| def handle_add_customized_trial(self, data):
"""Experimental API. Not recommended for usage.
"""
raise NotImplementedError('handle_add_customized_trial not implemented') | [
"def",
"handle_add_customized_trial",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_add_customized_trial not implemented'",
")"
] | [
207,
4
] | [
210,
80
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_report_metric_data | (self, data) | Called when metric data is reported or new parameters are requested (for multiphase).
When new parameters are requested, this method should send a new parameter.
Parameters
----------
data: dict
a dict which contains 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence... | Called when metric data is reported or new parameters are requested (for multiphase).
When new parameters are requested, this method should send a new parameter. | def handle_report_metric_data(self, data):
"""Called when metric data is reported or new parameters are requested (for multiphase).
When new parameters are requested, this method should send a new parameter.
Parameters
----------
data: dict
a dict which contains 'par... | [
"def",
"handle_report_metric_data",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_report_metric_data not implemented'",
")"
] | [
212,
4
] | [
230,
78
] | python | en | ['en', 'en', 'en'] | True |
MsgDispatcherBase.handle_trial_end | (self, data) | Called when the state of one of the trials is changed
Parameters
----------
data: dict
a dict with keys: trial_job_id, event, hyper_params.
trial_job_id: the id generated by training service.
event: the job’s state.
hyper_params: the string that i... | Called when the state of one of the trials is changed | def handle_trial_end(self, data):
"""Called when the state of one of the trials is changed
Parameters
----------
data: dict
a dict with keys: trial_job_id, event, hyper_params.
trial_job_id: the id generated by training service.
event: the job’s state... | [
"def",
"handle_trial_end",
"(",
"self",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'handle_trial_end not implemented'",
")"
] | [
232,
4
] | [
244,
69
] | python | en | ['en', 'en', 'en'] | True |
Subprocess.run | (command: str, timeout: int = None) | Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
| Run one-time command with subprocess.run(). | def run(command: str, timeout: int = None) -> str:
"""Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
"""
# TODO: Windows ... | [
"def",
"run",
"(",
"command",
":",
"str",
",",
"timeout",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"# TODO: Windows node",
"completed_process",
"=",
"subprocess",
".",
"run",
"(",
"command",
",",
"executable",
"=",
"\"/bin/bash\"",
",",
"shell",
"="... | [
14,
4
] | [
36,
51
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the XBee Zigbee switch platform. | Set up the XBee Zigbee switch platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the XBee Zigbee switch platform."""
zigbee_device = hass.data[DOMAIN]
add_entities([XBeeSwitch(XBeeDigitalOutConfig(config), zigbee_device)]) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"zigbee_device",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"add_entities",
"(",
"[",
"XBeeSwitch",
"(",
"XBeeDigitalOutConfig",
"(",
"... | [
16,
0
] | [
19,
75
] | python | en | ['en', 'xh', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry, async_add_entities) | Configure a dispatcher connection based on a config entry. | Configure a dispatcher connection based on a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry, async_add_entities):
"""Configure a dispatcher connection based on a config entry."""
@callback
def _receive_data(device, latitude, longitude, battery, accuracy, attrs):
"""Receive set location."""
if device in hass.data[DOMAIN]["d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
",",
"async_add_entities",
")",
":",
"@",
"callback",
"def",
"_receive_data",
"(",
"device",
",",
"latitude",
",",
"longitude",
",",
"battery",
",",
"accuracy",
",",
"att... | [
116,
0
] | [
152,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_scanner | (hass, config, async_see, discovery_info=None) | Validate the configuration and return a Traccar scanner. | Validate the configuration and return a Traccar scanner. | async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Validate the configuration and return a Traccar scanner."""
session = async_get_clientsession(hass, config[CONF_VERIFY_SSL])
api = API(
hass.loop,
session,
config[CONF_USERNAME],
config[CONF_PAS... | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
",",
"config",
",",
"async_see",
",",
"discovery_info",
"=",
"None",
")",
":",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
",",
"config",
"[",
"CONF_VERIFY_SSL",
"]",
")",
"api",
"=",
"API",
"("... | [
155,
0
] | [
181,
37
] | python | en | ['en', 'en', 'en'] | True |
TraccarScanner.__init__ | (
self,
api,
hass,
async_see,
scan_interval,
max_accuracy,
skip_accuracy_on,
custom_attributes,
event_types,
) | Initialize. | Initialize. | def __init__(
self,
api,
hass,
async_see,
scan_interval,
max_accuracy,
skip_accuracy_on,
custom_attributes,
event_types,
):
"""Initialize."""
self._event_types = {camelcase(evt): evt for evt in event_types}
self._custom... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"hass",
",",
"async_see",
",",
"scan_interval",
",",
"max_accuracy",
",",
"skip_accuracy_on",
",",
"custom_attributes",
",",
"event_types",
",",
")",
":",
"self",
".",
"_event_types",
"=",
"{",
"camelcase",
"(... | [
187,
4
] | [
208,
49
] | python | en | ['en', 'en', 'it'] | False |
TraccarScanner.async_init | (self) | Further initialize connection to Traccar. | Further initialize connection to Traccar. | async def async_init(self):
"""Further initialize connection to Traccar."""
await self._api.test_connection()
if self._api.connected and not self._api.authenticated:
_LOGGER.error("Authentication for Traccar failed")
return False
await self._async_update()
... | [
"async",
"def",
"async_init",
"(",
"self",
")",
":",
"await",
"self",
".",
"_api",
".",
"test_connection",
"(",
")",
"if",
"self",
".",
"_api",
".",
"connected",
"and",
"not",
"self",
".",
"_api",
".",
"authenticated",
":",
"_LOGGER",
".",
"error",
"("... | [
210,
4
] | [
219,
19
] | python | en | ['en', 'en', 'en'] | True |
TraccarScanner._async_update | (self, now=None) | Update info from Traccar. | Update info from Traccar. | async def _async_update(self, now=None):
"""Update info from Traccar."""
if not self.connected:
_LOGGER.debug("Testing connection to Traccar")
await self._api.test_connection()
self.connected = self._api.connected
if self.connected:
_LOGGER... | [
"async",
"def",
"_async_update",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"connected",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Testing connection to Traccar\"",
")",
"await",
"self",
".",
"_api",
".",
"test_connection",
"(",
... | [
221,
4
] | [
236,
44
] | python | en | ['en', 'en', 'en'] | True |
TraccarScanner.import_device_data | (self) | Import device data from Traccar. | Import device data from Traccar. | async def import_device_data(self):
"""Import device data from Traccar."""
for device_unique_id in self._api.device_info:
device_info = self._api.device_info[device_unique_id]
device = None
attr = {}
skip_accuracy_filter = False
attr[ATTR_TRAC... | [
"async",
"def",
"import_device_data",
"(",
"self",
")",
":",
"for",
"device_unique_id",
"in",
"self",
".",
"_api",
".",
"device_info",
":",
"device_info",
"=",
"self",
".",
"_api",
".",
"device_info",
"[",
"device_unique_id",
"]",
"device",
"=",
"None",
"att... | [
238,
4
] | [
292,
13
] | python | en | ['en', 'en', 'en'] | True |
TraccarScanner.import_events | (self) | Import events from Traccar. | Import events from Traccar. | async def import_events(self):
"""Import events from Traccar."""
device_ids = [device["id"] for device in self._api.devices]
end_interval = datetime.utcnow()
start_interval = end_interval - self._scan_interval
events = await self._api.get_events(
device_ids=device_ids... | [
"async",
"def",
"import_events",
"(",
"self",
")",
":",
"device_ids",
"=",
"[",
"device",
"[",
"\"id\"",
"]",
"for",
"device",
"in",
"self",
".",
"_api",
".",
"devices",
"]",
"end_interval",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start_interval",
"="... | [
294,
4
] | [
324,
17
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.__init__ | (self, device, latitude, longitude, battery, accuracy, attributes) | Set up Geofency entity. | Set up Geofency entity. | def __init__(self, device, latitude, longitude, battery, accuracy, attributes):
"""Set up Geofency entity."""
self._accuracy = accuracy
self._attributes = attributes
self._name = device
self._battery = battery
self._latitude = latitude
self._longitude = longitude
... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"latitude",
",",
"longitude",
",",
"battery",
",",
"accuracy",
",",
"attributes",
")",
":",
"self",
".",
"_accuracy",
"=",
"accuracy",
"self",
".",
"_attributes",
"=",
"attributes",
"self",
".",
"_name",
... | [
330,
4
] | [
339,
32
] | python | en | ['en', 'pl', 'en'] | True |
TraccarEntity.battery_level | (self) | Return battery value of the device. | Return battery value of the device. | def battery_level(self):
"""Return battery value of the device."""
return self._battery | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_battery"
] | [
342,
4
] | [
344,
28
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.device_state_attributes | (self) | Return device specific attributes. | Return device specific attributes. | def device_state_attributes(self):
"""Return device specific attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
347,
4
] | [
349,
31
] | python | en | ['fr', 'it', 'en'] | False |
TraccarEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
return self._latitude | [
"def",
"latitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_latitude"
] | [
352,
4
] | [
354,
29
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
return self._longitude | [
"def",
"longitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_longitude"
] | [
357,
4
] | [
359,
30
] | python | en | ['en', 'zu', 'en'] | True |
TraccarEntity.location_accuracy | (self) | Return the gps accuracy of the device. | Return the gps accuracy of the device. | def location_accuracy(self):
"""Return the gps accuracy of the device."""
return self._accuracy | [
"def",
"location_accuracy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_accuracy"
] | [
362,
4
] | [
364,
29
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
367,
4
] | [
369,
25
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.unique_id | (self) | Return the unique ID. | Return the unique ID. | def unique_id(self):
"""Return the unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
372,
4
] | [
374,
30
] | python | en | ['en', 'la', 'en'] | True |
TraccarEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {"name": self._name, "identifiers": {(DOMAIN, self._unique_id)}} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
"}"
] | [
377,
4
] | [
379,
79
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_GPS | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_GPS"
] | [
382,
4
] | [
384,
30
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
await super().async_added_to_hass()
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, TRACKER_UPDATE, self._async_receive_data
)
# don't restore if we got created with data
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_unsub_dispatcher",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"TRACKER_UPDATE",
",",
"self",
"."... | [
386,
4
] | [
419,
46
] | python | en | ['en', 'co', 'en'] | True |
TraccarEntity.async_will_remove_from_hass | (self) | Clean up after entity before removal. | Clean up after entity before removal. | async def async_will_remove_from_hass(self):
"""Clean up after entity before removal."""
await super().async_will_remove_from_hass()
self._unsub_dispatcher() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"self",
".",
"_unsub_dispatcher",
"(",
")"
] | [
421,
4
] | [
424,
32
] | python | en | ['en', 'en', 'en'] | True |
TraccarEntity._async_receive_data | (
self, device, latitude, longitude, battery, accuracy, attributes
) | Mark the device as seen. | Mark the device as seen. | def _async_receive_data(
self, device, latitude, longitude, battery, accuracy, attributes
):
"""Mark the device as seen."""
if device != self.name:
return
self._latitude = latitude
self._longitude = longitude
self._battery = battery
self._accuracy... | [
"def",
"_async_receive_data",
"(",
"self",
",",
"device",
",",
"latitude",
",",
"longitude",
",",
"battery",
",",
"accuracy",
",",
"attributes",
")",
":",
"if",
"device",
"!=",
"self",
".",
"name",
":",
"return",
"self",
".",
"_latitude",
"=",
"latitude",
... | [
427,
4
] | [
439,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the demo switches. | Set up the demo switches. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the demo switches."""
async_add_entities(
[
DemoSwitch("swith1", "Decorative Lights", True, None, True),
DemoSwitch(
"swith2",
"AC",
Fa... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"DemoSwitch",
"(",
"\"swith1\"",
",",
"\"Decorative Lights\"",
",",
"True",
",",
"None",
... | [
7,
0
] | [
21,
5
] | 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.