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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SignalNotificationService.__init__ | (self, recp_nrs, signal_cli_rest_api) | Initialize the service. | Initialize the service. | def __init__(self, recp_nrs, signal_cli_rest_api):
"""Initialize the service."""
self._recp_nrs = recp_nrs
self._signal_cli_rest_api = signal_cli_rest_api | [
"def",
"__init__",
"(",
"self",
",",
"recp_nrs",
",",
"signal_cli_rest_api",
")",
":",
"self",
".",
"_recp_nrs",
"=",
"recp_nrs",
"self",
".",
"_signal_cli_rest_api",
"=",
"signal_cli_rest_api"
] | [
45,
4
] | [
49,
55
] | python | en | ['en', 'en', 'en'] | True |
SignalNotificationService.send_message | (self, message="", **kwargs) | Send a message to a one or more recipients.
Additionally a file can be attached.
| Send a message to a one or more recipients. | def send_message(self, message="", **kwargs):
"""Send a message to a one or more recipients.
Additionally a file can be attached.
"""
_LOGGER.debug("Sending signal message")
data = kwargs.get(ATTR_DATA)
filenames = None
if data is not None:
if ATTR... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Sending signal message\"",
")",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"filenames",
"=",
"None",
"if",... | [
51,
4
] | [
78,
20
] | python | en | ['en', 'en', 'en'] | True |
time_changed | (hass, seconds) | Trigger time changed. | Trigger time changed. | async def time_changed(hass, seconds):
"""Trigger time changed."""
next_update = dt_util.utcnow() + timedelta(seconds)
async_fire_time_changed(hass, next_update)
await hass.async_block_till_done() | [
"async",
"def",
"time_changed",
"(",
"hass",
",",
"seconds",
")",
":",
"next_update",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
")",
"async_fire_time_changed",
"(",
"hass",
",",
"next_update",
")",
"await",
"hass",
".",
"as... | [
56,
0
] | [
60,
38
] | python | en | ['da', 'en', 'en'] | True |
setup_accessories_from_file | (hass, path) | Load an collection of accessory defs from JSON data. | Load an collection of accessory defs from JSON data. | async def setup_accessories_from_file(hass, path):
"""Load an collection of accessory defs from JSON data."""
accessories_fixture = await hass.async_add_executor_job(
load_fixture, os.path.join("homekit_controller", path)
)
accessories_json = json.loads(accessories_fixture)
accessories = Acc... | [
"async",
"def",
"setup_accessories_from_file",
"(",
"hass",
",",
"path",
")",
":",
"accessories_fixture",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"load_fixture",
",",
"os",
".",
"path",
".",
"join",
"(",
"\"homekit_controller\"",
",",
"path",
"... | [
63,
0
] | [
70,
22
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass) | Load the platform but with a fake Controller API. | Load the platform but with a fake Controller API. | async def setup_platform(hass):
"""Load the platform but with a fake Controller API."""
config = {"discovery": {}}
with mock.patch("aiohomekit.Controller") as controller:
fake_controller = controller.return_value = FakeController()
await async_setup_component(hass, DOMAIN, config)
retu... | [
"async",
"def",
"setup_platform",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"discovery\"",
":",
"{",
"}",
"}",
"with",
"mock",
".",
"patch",
"(",
"\"aiohomekit.Controller\"",
")",
"as",
"controller",
":",
"fake_controller",
"=",
"controller",
".",
"return... | [
73,
0
] | [
81,
26
] | python | en | ['en', 'en', 'en'] | True |
setup_test_accessories | (hass, accessories) | Load a fake homekit device based on captured JSON profile. | Load a fake homekit device based on captured JSON profile. | async def setup_test_accessories(hass, accessories):
"""Load a fake homekit device based on captured JSON profile."""
fake_controller = await setup_platform(hass)
pairing_id = "00:00:00:00:00:00"
accessories_obj = Accessories()
for accessory in accessories:
accessories_obj.add_accessory(ac... | [
"async",
"def",
"setup_test_accessories",
"(",
"hass",
",",
"accessories",
")",
":",
"fake_controller",
"=",
"await",
"setup_platform",
"(",
"hass",
")",
"pairing_id",
"=",
"\"00:00:00:00:00:00\"",
"accessories_obj",
"=",
"Accessories",
"(",
")",
"for",
"accessory",... | [
84,
0
] | [
108,
32
] | python | en | ['en', 'da', 'en'] | True |
device_config_changed | (hass, accessories) | Discover new devices added to Home Assistant at runtime. | Discover new devices added to Home Assistant at runtime. | async def device_config_changed(hass, accessories):
"""Discover new devices added to Home Assistant at runtime."""
# Update the accessories our FakePairing knows about
controller = hass.data[CONTROLLER]
pairing = controller.pairings["00:00:00:00:00:00"]
accessories_obj = Accessories()
for acces... | [
"async",
"def",
"device_config_changed",
"(",
"hass",
",",
"accessories",
")",
":",
"# Update the accessories our FakePairing knows about",
"controller",
"=",
"hass",
".",
"data",
"[",
"CONTROLLER",
"]",
"pairing",
"=",
"controller",
".",
"pairings",
"[",
"\"00:00:00:... | [
111,
0
] | [
145,
38
] | python | en | ['en', 'en', 'en'] | True |
setup_test_component | (hass, setup_accessory, capitalize=False, suffix=None) | Load a fake homekit accessory based on a homekit accessory model.
If capitalize is True, property names will be in upper case.
If suffix is set, entityId will include the suffix
| Load a fake homekit accessory based on a homekit accessory model. | async def setup_test_component(hass, setup_accessory, capitalize=False, suffix=None):
"""Load a fake homekit accessory based on a homekit accessory model.
If capitalize is True, property names will be in upper case.
If suffix is set, entityId will include the suffix
"""
accessory = Accessory.creat... | [
"async",
"def",
"setup_test_component",
"(",
"hass",
",",
"setup_accessory",
",",
"capitalize",
"=",
"False",
",",
"suffix",
"=",
"None",
")",
":",
"accessory",
"=",
"Accessory",
".",
"create_with_info",
"(",
"\"TestDevice\"",
",",
"\"example.com\"",
",",
"\"Tes... | [
148,
0
] | [
171,
85
] | python | en | ['en', 'haw', 'en'] | True |
Helper.__init__ | (self, hass, entity_id, pairing, accessory, config_entry) | Create a helper for a given accessory/entity. | Create a helper for a given accessory/entity. | def __init__(self, hass, entity_id, pairing, accessory, config_entry):
"""Create a helper for a given accessory/entity."""
self.hass = hass
self.entity_id = entity_id
self.pairing = pairing
self.accessory = accessory
self.config_entry = config_entry
self.characte... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"entity_id",
",",
"pairing",
",",
"accessory",
",",
"config_entry",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"entity_id",
"=",
"entity_id",
"self",
".",
"pairing",
"=",
"pairing",
"self",
... | [
27,
4
] | [
40,
70
] | python | en | ['en', 'en', 'en'] | True |
Helper.update_named_service | (self, service, characteristics) | Update a service. | Update a service. | async def update_named_service(self, service, characteristics):
"""Update a service."""
self.pairing.testing.update_named_service(service, characteristics)
await self.hass.async_block_till_done() | [
"async",
"def",
"update_named_service",
"(",
"self",
",",
"service",
",",
"characteristics",
")",
":",
"self",
".",
"pairing",
".",
"testing",
".",
"update_named_service",
"(",
"service",
",",
"characteristics",
")",
"await",
"self",
".",
"hass",
".",
"async_b... | [
42,
4
] | [
45,
47
] | python | en | ['en', 'co', 'en'] | True |
Helper.poll_and_get_state | (self) | Trigger a time based poll and return the current entity state. | Trigger a time based poll and return the current entity state. | async def poll_and_get_state(self):
"""Trigger a time based poll and return the current entity state."""
await time_changed(self.hass, 60)
state = self.hass.states.get(self.entity_id)
assert state is not None
return state | [
"async",
"def",
"poll_and_get_state",
"(",
"self",
")",
":",
"await",
"time_changed",
"(",
"self",
".",
"hass",
",",
"60",
")",
"state",
"=",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"self",
".",
"entity_id",
")",
"assert",
"state",
"is",
... | [
47,
4
] | [
53,
20
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Stookalert binary sensor platform. | Set up the Stookalert binary sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Stookalert binary sensor platform."""
province = config[CONF_PROVINCE]
name = config[CONF_NAME]
api_handler = stookalert.stookalert(province)
add_entities([StookalertBinarySensor(name, api_handler)], update_before_add... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"province",
"=",
"config",
"[",
"CONF_PROVINCE",
"]",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"api_handler",
"=",
"stookalert",
".",... | [
42,
0
] | [
47,
85
] | python | en | ['en', 'da', 'en'] | True |
StookalertBinarySensor.__init__ | (self, name, api_handler) | Initialize a Stookalert device. | Initialize a Stookalert device. | def __init__(self, name, api_handler):
"""Initialize a Stookalert device."""
self._name = name
self._api_handler = api_handler | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"api_handler",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_api_handler",
"=",
"api_handler"
] | [
53,
4
] | [
56,
39
] | python | en | ['fr', 'en', 'en'] | True |
StookalertBinarySensor.device_state_attributes | (self) | Return the attribute(s) of the sensor. | Return the attribute(s) of the sensor. | def device_state_attributes(self):
"""Return the attribute(s) of the sensor."""
state_attr = {ATTR_ATTRIBUTION: ATTRIBUTION}
if self._api_handler.last_updated is not None:
state_attr["last_updated"] = self._api_handler.last_updated.isoformat()
return state_attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"state_attr",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}",
"if",
"self",
".",
"_api_handler",
".",
"last_updated",
"is",
"not",
"None",
":",
"state_attr",
"[",
"\"last_updated\"",
"]",
"=",
"se... | [
59,
4
] | [
66,
25
] | python | en | ['en', 'no', 'en'] | True |
StookalertBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
69,
4
] | [
71,
25
] | python | en | ['en', 'mi', 'en'] | True |
StookalertBinarySensor.is_on | (self) | Return True if the Alert is active. | Return True if the Alert is active. | def is_on(self):
"""Return True if the Alert is active."""
return self._api_handler.state == 1 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api_handler",
".",
"state",
"==",
"1"
] | [
74,
4
] | [
76,
43
] | python | en | ['en', 'nl', 'en'] | True |
StookalertBinarySensor.device_class | (self) | Return the device class of this binary sensor. | Return the device class of this binary sensor. | def device_class(self):
"""Return the device class of this binary sensor."""
return DEFAULT_DEVICE_CLASS | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEFAULT_DEVICE_CLASS"
] | [
79,
4
] | [
81,
35
] | python | en | ['en', 'en', 'en'] | True |
StookalertBinarySensor.update | (self) | Update the data from the Stookalert handler. | Update the data from the Stookalert handler. | def update(self):
"""Update the data from the Stookalert handler."""
self._api_handler.get_alerts() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_api_handler",
".",
"get_alerts",
"(",
")"
] | [
83,
4
] | [
85,
38
] | python | en | ['en', 'no', 'en'] | True |
async_setup | (hass, config) | Set up the Dune HD component. | Set up the Dune HD component. | async def async_setup(hass, config):
"""Set up the Dune HD component."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"return",
"True"
] | [
12,
0
] | [
14,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up a config entry. | Set up a config entry. | async def async_setup_entry(hass, config_entry):
"""Set up a config entry."""
host = config_entry.data[CONF_HOST]
player = DuneHDPlayer(host)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = player
for component in PLATFORMS:
hass.async_create_task(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"host",
"=",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"player",
"=",
"DuneHDPlayer",
"(",
"host",
")",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
... | [
17,
0
] | [
31,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in PLATFORMS
]
)
)
if un... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"config_entry",
",",
"compo... | [
34,
0
] | [
48,
20
] | python | en | ['en', 'es', 'en'] | True |
async_setup_platform | (
hass, config, async_add_entities_callback, discovery_info=None
) | Set up the test image_processing platform. | Set up the test image_processing platform. | async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Set up the test image_processing platform."""
async_add_entities_callback([TestImageProcessing("camera.demo_camera", "Test")]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities_callback",
"(",
"[",
"TestImageProcessing",
"(",
"\"camera.demo_camera\"",
",",
"\"Test\"",
")",
"... | [
5,
0
] | [
9,
84
] | python | en | ['en', 'da', 'en'] | True |
TestImageProcessing.__init__ | (self, camera_entity, name) | Initialize test image processing. | Initialize test image processing. | def __init__(self, camera_entity, name):
"""Initialize test image processing."""
self._name = name
self._camera = camera_entity
self._count = 0
self._image = "" | [
"def",
"__init__",
"(",
"self",
",",
"camera_entity",
",",
"name",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_camera",
"=",
"camera_entity",
"self",
".",
"_count",
"=",
"0",
"self",
".",
"_image",
"=",
"\"\""
] | [
15,
4
] | [
20,
24
] | python | en | ['de', 'en', 'en'] | True |
TestImageProcessing.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
23,
4
] | [
25,
20
] | python | en | ['en', 'en', 'en'] | True |
TestImageProcessing.camera_entity | (self) | Return camera entity id from process pictures. | Return camera entity id from process pictures. | def camera_entity(self):
"""Return camera entity id from process pictures."""
return self._camera | [
"def",
"camera_entity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_camera"
] | [
28,
4
] | [
30,
27
] | python | en | ['en', 'en', 'en'] | True |
TestImageProcessing.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
33,
4
] | [
35,
25
] | python | en | ['en', 'en', 'en'] | True |
TestImageProcessing.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
return self._count | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_count"
] | [
38,
4
] | [
40,
26
] | python | en | ['en', 'en', 'en'] | True |
TestImageProcessing.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
return {"image": self._image} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"image\"",
":",
"self",
".",
"_image",
"}"
] | [
43,
4
] | [
45,
37
] | python | en | ['fr', 'en', 'en'] | True |
TestImageProcessing.process_image | (self, image) | Process image. | Process image. | def process_image(self, image):
"""Process image."""
self._image = image
self._count += 1 | [
"def",
"process_image",
"(",
"self",
",",
"image",
")",
":",
"self",
".",
"_image",
"=",
"image",
"self",
".",
"_count",
"+=",
"1"
] | [
47,
4
] | [
50,
24
] | python | en | ['en', 'ny', 'en'] | False |
trigger_plex_update | (mock_websocket) | Call the websocket callback method. | Call the websocket callback method. | def trigger_plex_update(mock_websocket):
"""Call the websocket callback method."""
callback = mock_websocket.call_args[0][1]
callback(SIGNAL_DATA, None, None) | [
"def",
"trigger_plex_update",
"(",
"mock_websocket",
")",
":",
"callback",
"=",
"mock_websocket",
".",
"call_args",
"[",
"0",
"]",
"[",
"1",
"]",
"callback",
"(",
"SIGNAL_DATA",
",",
"None",
",",
"None",
")"
] | [
4,
0
] | [
7,
37
] | python | en | ['en', 'st', 'en'] | True |
setup | (hass, config) | Set up the media extractor service. | Set up the media extractor service. | def setup(hass, config):
"""Set up the media extractor service."""
def play_media(call):
"""Get stream URL and send it to the play_media service."""
MediaExtractor(hass, config[DOMAIN], call.data).extract_and_send()
hass.services.register(
DOMAIN,
SERVICE_PLAY_MEDIA,
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"def",
"play_media",
"(",
"call",
")",
":",
"\"\"\"Get stream URL and send it to the play_media service.\"\"\"",
"MediaExtractor",
"(",
"hass",
",",
"config",
"[",
"DOMAIN",
"]",
",",
"call",
".",
"data",
")"... | [
40,
0
] | [
54,
15
] | python | en | ['en', 'en', 'en'] | True |
MediaExtractor.__init__ | (self, hass, component_config, call_data) | Initialize media extractor. | Initialize media extractor. | def __init__(self, hass, component_config, call_data):
"""Initialize media extractor."""
self.hass = hass
self.config = component_config
self.call_data = call_data | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"component_config",
",",
"call_data",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config",
"=",
"component_config",
"self",
".",
"call_data",
"=",
"call_data"
] | [
68,
4
] | [
72,
34
] | python | en | ['es', 'en', 'it'] | False |
MediaExtractor.get_media_url | (self) | Return media content url. | Return media content url. | def get_media_url(self):
"""Return media content url."""
return self.call_data.get(ATTR_MEDIA_CONTENT_ID) | [
"def",
"get_media_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"call_data",
".",
"get",
"(",
"ATTR_MEDIA_CONTENT_ID",
")"
] | [
74,
4
] | [
76,
56
] | python | en | ['ro', 'la', 'en'] | False |
MediaExtractor.get_entities | (self) | Return list of entities. | Return list of entities. | def get_entities(self):
"""Return list of entities."""
return self.call_data.get(ATTR_ENTITY_ID, []) | [
"def",
"get_entities",
"(",
"self",
")",
":",
"return",
"self",
".",
"call_data",
".",
"get",
"(",
"ATTR_ENTITY_ID",
",",
"[",
"]",
")"
] | [
78,
4
] | [
80,
53
] | python | en | ['en', 'et', 'en'] | True |
MediaExtractor.extract_and_send | (self) | Extract exact stream format for each entity_id and play it. | Extract exact stream format for each entity_id and play it. | def extract_and_send(self):
"""Extract exact stream format for each entity_id and play it."""
try:
stream_selector = self.get_stream_selector()
except MEDownloadException:
_LOGGER.error(
"Could not retrieve data for the URL: %s", self.get_media_url()
... | [
"def",
"extract_and_send",
"(",
"self",
")",
":",
"try",
":",
"stream_selector",
"=",
"self",
".",
"get_stream_selector",
"(",
")",
"except",
"MEDownloadException",
":",
"_LOGGER",
".",
"error",
"(",
"\"Could not retrieve data for the URL: %s\"",
",",
"self",
".",
... | [
82,
4
] | [
97,
74
] | python | en | ['en', 'en', 'en'] | True |
MediaExtractor.get_stream_selector | (self) | Return format selector for the media URL. | Return format selector for the media URL. | def get_stream_selector(self):
"""Return format selector for the media URL."""
ydl = YoutubeDL({"quiet": True, "logger": _LOGGER})
try:
all_media = ydl.extract_info(self.get_media_url(), process=False)
except DownloadError as err:
# This exception will be logged ... | [
"def",
"get_stream_selector",
"(",
"self",
")",
":",
"ydl",
"=",
"YoutubeDL",
"(",
"{",
"\"quiet\"",
":",
"True",
",",
"\"logger\"",
":",
"_LOGGER",
"}",
")",
"try",
":",
"all_media",
"=",
"ydl",
".",
"extract_info",
"(",
"self",
".",
"get_media_url",
"(... | [
99,
4
] | [
131,
30
] | python | en | ['en', 'no', 'en'] | True |
MediaExtractor.call_media_player_service | (self, stream_selector, entity_id) | Call Media player play_media service. | Call Media player play_media service. | def call_media_player_service(self, stream_selector, entity_id):
"""Call Media player play_media service."""
stream_query = self.get_stream_query_for_entity(entity_id)
try:
stream_url = stream_selector(stream_query)
except MEQueryException:
_LOGGER.error("Wrong q... | [
"def",
"call_media_player_service",
"(",
"self",
",",
"stream_selector",
",",
"entity_id",
")",
":",
"stream_query",
"=",
"self",
".",
"get_stream_query_for_entity",
"(",
"entity_id",
")",
"try",
":",
"stream_url",
"=",
"stream_selector",
"(",
"stream_query",
")",
... | [
133,
4
] | [
153,
13
] | python | en | ['en', 'en', 'en'] | True |
MediaExtractor.get_stream_query_for_entity | (self, entity_id) | Get stream format query for entity. | Get stream format query for entity. | def get_stream_query_for_entity(self, entity_id):
"""Get stream format query for entity."""
default_stream_query = self.config.get(
CONF_DEFAULT_STREAM_QUERY, DEFAULT_STREAM_QUERY
)
if entity_id:
media_content_type = self.call_data.get(ATTR_MEDIA_CONTENT_TYPE)
... | [
"def",
"get_stream_query_for_entity",
"(",
"self",
",",
"entity_id",
")",
":",
"default_stream_query",
"=",
"self",
".",
"config",
".",
"get",
"(",
"CONF_DEFAULT_STREAM_QUERY",
",",
"DEFAULT_STREAM_QUERY",
")",
"if",
"entity_id",
":",
"media_content_type",
"=",
"sel... | [
155,
4
] | [
170,
35
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Raspberry PI GPIO devices. | Set up the Raspberry PI GPIO devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Raspberry PI GPIO devices."""
setup_reload_service(hass, DOMAIN, PLATFORMS)
pull_mode = config.get(CONF_PULL_MODE)
bouncetime = config.get(CONF_BOUNCETIME)
invert_logic = config.get(CONF_INVERT_LOGIC)
binary_se... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"pull_mode",
"=",
"config",
".",
"get",
"(",
"CONF_PULL_MODE",
... | [
32,
0
] | [
49,
38
] | python | en | ['en', 'sr', 'en'] | True |
RPiGPIOBinarySensor.__init__ | (self, name, port, pull_mode, bouncetime, invert_logic) | Initialize the RPi binary sensor. | Initialize the RPi binary sensor. | def __init__(self, name, port, pull_mode, bouncetime, invert_logic):
"""Initialize the RPi binary sensor."""
self._name = name or DEVICE_DEFAULT_NAME
self._port = port
self._pull_mode = pull_mode
self._bouncetime = bouncetime
self._invert_logic = invert_logic
self... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"port",
",",
"pull_mode",
",",
"bouncetime",
",",
"invert_logic",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"DEVICE_DEFAULT_NAME",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"_pull_mode",
"=... | [
55,
4
] | [
71,
69
] | python | en | ['en', 'pt', 'en'] | True |
RPiGPIOBinarySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
74,
4
] | [
76,
20
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
79,
4
] | [
81,
25
] | python | en | ['en', 'mi', 'en'] | True |
RPiGPIOBinarySensor.is_on | (self) | Return the state of the entity. | Return the state of the entity. | def is_on(self):
"""Return the state of the entity."""
return self._state != self._invert_logic | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"!=",
"self",
".",
"_invert_logic"
] | [
84,
4
] | [
86,
48
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOBinarySensor.update | (self) | Update the GPIO state. | Update the GPIO state. | def update(self):
"""Update the GPIO state."""
self._state = rpi_gpio.read_input(self._port) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"rpi_gpio",
".",
"read_input",
"(",
"self",
".",
"_port",
")"
] | [
88,
4
] | [
90,
53
] | python | en | ['en', 'it', 'en'] | True |
extract | (data: BodyExtract, accept: Optional[List[str]] = Header(None)) |
Face extraction/embeddings endpoint accept json with
parameters in following format:
- **images**: dict containing either links or data lists. (*required*)
- **threshold**: Detection threshold. Default: 0.6 (*optional*)
- **embed_only**: Treat input images as face crops (112x112 crops req... |
Face extraction/embeddings endpoint accept json with
parameters in following format: | async def extract(data: BodyExtract, accept: Optional[List[str]] = Header(None)):
"""
Face extraction/embeddings endpoint accept json with
parameters in following format:
- **images**: dict containing either links or data lists. (*required*)
- **threshold**: Detection threshold. Default: 0.6 ... | [
"async",
"def",
"extract",
"(",
"data",
":",
"BodyExtract",
",",
"accept",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"Header",
"(",
"None",
")",
")",
":",
"images",
"=",
"jsonable_encoder",
"(",
"data",
".",
"images",
")",
"output",
"=... | [
53,
0
] | [
86,
36
] | python | en | ['en', 'error', 'th'] | False |
draw | (data: BodyDraw) |
Return image with drawn faces for testing purposes.
- **images**: dict containing either links or data lists. (*required*)
- **threshold**: Detection threshold. Default: 0.6 (*optional*)
- **draw_landmarks**: Draw faces landmarks Default: True (*optional*)
- **draw_scores**: Draw detec... |
Return image with drawn faces for testing purposes. | async def draw(data: BodyDraw):
"""
Return image with drawn faces for testing purposes.
- **images**: dict containing either links or data lists. (*required*)
- **threshold**: Detection threshold. Default: 0.6 (*optional*)
- **draw_landmarks**: Draw faces landmarks Default: True (*optional... | [
"async",
"def",
"draw",
"(",
"data",
":",
"BodyDraw",
")",
":",
"images",
"=",
"jsonable_encoder",
"(",
"data",
".",
"images",
")",
"output",
"=",
"await",
"processing",
".",
"draw",
"(",
"images",
",",
"threshold",
"=",
"data",
".",
"threshold",
",",
... | [
90,
0
] | [
108,
60
] | python | en | ['en', 'error', 'th'] | False |
draw_upl | (file: bytes = File(...), threshold: float = Form(0.6), draw_landmarks: bool = Form(True),
draw_scores: bool = Form(True), draw_sizes: bool = Form(True), limit_faces: int = Form(0)) |
Return image with drawn faces for testing purposes.
- **file**: Image file (*required*)
- **threshold**: Detection threshold. Default: 0.6 (*optional*)
- **draw_landmarks**: Draw faces landmarks Default: True (*optional*)
- **draw_scores**: Draw detection scores Default: True (*optiona... |
Return image with drawn faces for testing purposes. | async def draw_upl(file: bytes = File(...), threshold: float = Form(0.6), draw_landmarks: bool = Form(True),
draw_scores: bool = Form(True), draw_sizes: bool = Form(True), limit_faces: int = Form(0)):
"""
Return image with drawn faces for testing purposes.
- **file**: Image file (*req... | [
"async",
"def",
"draw_upl",
"(",
"file",
":",
"bytes",
"=",
"File",
"(",
"...",
")",
",",
"threshold",
":",
"float",
"=",
"Form",
"(",
"0.6",
")",
",",
"draw_landmarks",
":",
"bool",
"=",
"Form",
"(",
"True",
")",
",",
"draw_scores",
":",
"bool",
"... | [
112,
0
] | [
131,
60
] | python | en | ['en', 'error', 'th'] | False |
info | () |
Enslist container configuration.
|
Enslist container configuration. | def info():
"""
Enslist container configuration.
"""
about = dict(
version=__version__,
tensorrt_version=os.getenv('TRT_VERSION', os.getenv('TENSORRT_VERSION')),
log_level=configs.log_level,
models=vars(configs.models),
defaults=vars(configs.defaults),
)
... | [
"def",
"info",
"(",
")",
":",
"about",
"=",
"dict",
"(",
"version",
"=",
"__version__",
",",
"tensorrt_version",
"=",
"os",
".",
"getenv",
"(",
"'TRT_VERSION'",
",",
"os",
".",
"getenv",
"(",
"'TENSORRT_VERSION'",
")",
")",
",",
"log_level",
"=",
"config... | [
135,
0
] | [
151,
16
] | python | en | ['en', 'error', 'th'] | False |
async_get_conditions | (hass: HomeAssistant, device_id: str) | List device conditions for Lock devices. | List device conditions for Lock devices. | async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device conditions for Lock devices."""
registry = await entity_registry.async_get_registry(hass)
conditions = []
# Get all the integrations entities for this device
for entry in entity_registry.async_entries_... | [
"async",
"def",
"async_get_conditions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"conditions",
"=",
"[... | [
32,
0
] | [
62,
21
] | python | en | ['fr', 'en', 'en'] | True |
async_condition_from_config | (
config: ConfigType, config_validation: bool
) | Create a function to test a device condition. | Create a function to test a device condition. | def async_condition_from_config(
config: ConfigType, config_validation: bool
) -> condition.ConditionCheckerType:
"""Create a function to test a device condition."""
if config_validation:
config = CONDITION_SCHEMA(config)
if config[CONF_TYPE] == "is_locked":
state = STATE_LOCKED
else... | [
"def",
"async_condition_from_config",
"(",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
")",
"->",
"condition",
".",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"CONDITION_SCHEMA",
"(",
"config",
")",
"if",
"c... | [
66,
0
] | [
81,
24
] | python | en | ['en', 'en', 'en'] | True |
cls | () | Patch debounce decorator during import of type_fans. | Patch debounce decorator during import of type_fans. | def cls():
"""Patch debounce decorator during import of type_fans."""
patcher = patch_debounce()
patcher.start()
_import = __import__("homeassistant.components.homekit.type_fans", fromlist=["Fan"])
patcher_tuple = namedtuple("Cls", ["fan"])
yield patcher_tuple(fan=_import.Fan)
patcher.stop() | [
"def",
"cls",
"(",
")",
":",
"patcher",
"=",
"patch_debounce",
"(",
")",
"patcher",
".",
"start",
"(",
")",
"_import",
"=",
"__import__",
"(",
"\"homeassistant.components.homekit.type_fans\"",
",",
"fromlist",
"=",
"[",
"\"Fan\"",
"]",
")",
"patcher_tuple",
"=... | [
40,
0
] | [
47,
18
] | python | en | ['en', 'en', 'en'] | True |
test_fan_basic | (hass, hk_driver, cls, events) | Test fan with char state. | Test fan with char state. | async def test_fan_basic(hass, hk_driver, cls, events):
"""Test fan with char state."""
entity_id = "fan.demo"
hass.states.async_set(entity_id, STATE_ON, {ATTR_SUPPORTED_FEATURES: 0})
await hass.async_block_till_done()
acc = cls.fan(hass, hk_driver, "Fan", entity_id, 1, None)
hk_driver.add_acce... | [
"async",
"def",
"test_fan_basic",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"entity_id",
"=",
"\"fan.demo\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_ON",
",",
"{",
"ATTR_SUPPORTED_FEATURES",
":",
"0",... | [
50,
0
] | [
125,
46
] | python | en | ['en', 'en', 'en'] | True |
test_fan_direction | (hass, hk_driver, cls, events) | Test fan with direction. | Test fan with direction. | async def test_fan_direction(hass, hk_driver, cls, events):
"""Test fan with direction."""
entity_id = "fan.demo"
hass.states.async_set(
entity_id,
STATE_ON,
{ATTR_SUPPORTED_FEATURES: SUPPORT_DIRECTION, ATTR_DIRECTION: DIRECTION_FORWARD},
)
await hass.async_block_till_done()... | [
"async",
"def",
"test_fan_direction",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"entity_id",
"=",
"\"fan.demo\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_ON",
",",
"{",
"ATTR_SUPPORTED_FEATURES",
":",
... | [
128,
0
] | [
193,
59
] | python | en | ['en', 'en', 'en'] | True |
test_fan_oscillate | (hass, hk_driver, cls, events) | Test fan with oscillate. | Test fan with oscillate. | async def test_fan_oscillate(hass, hk_driver, cls, events):
"""Test fan with oscillate."""
entity_id = "fan.demo"
hass.states.async_set(
entity_id,
STATE_ON,
{ATTR_SUPPORTED_FEATURES: SUPPORT_OSCILLATE, ATTR_OSCILLATING: False},
)
await hass.async_block_till_done()
acc =... | [
"async",
"def",
"test_fan_oscillate",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"entity_id",
"=",
"\"fan.demo\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_ON",
",",
"{",
"ATTR_SUPPORTED_FEATURES",
":",
... | [
196,
0
] | [
262,
46
] | python | en | ['en', 'en', 'en'] | True |
test_fan_speed | (hass, hk_driver, cls, events) | Test fan with speed. | Test fan with speed. | async def test_fan_speed(hass, hk_driver, cls, events):
"""Test fan with speed."""
entity_id = "fan.demo"
speed_list = [SPEED_OFF, SPEED_LOW, SPEED_HIGH]
hass.states.async_set(
entity_id,
STATE_ON,
{
ATTR_SUPPORTED_FEATURES: SUPPORT_SET_SPEED,
ATTR_SPEED:... | [
"async",
"def",
"test_fan_speed",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"entity_id",
"=",
"\"fan.demo\"",
"speed_list",
"=",
"[",
"SPEED_OFF",
",",
"SPEED_LOW",
",",
"SPEED_HIGH",
"]",
"hass",
".",
"states",
".",
"async_set",
... | [
265,
0
] | [
352,
37
] | python | en | ['en', 'fy', 'en'] | True |
test_fan_set_all_one_shot | (hass, hk_driver, cls, events) | Test fan with speed. | Test fan with speed. | async def test_fan_set_all_one_shot(hass, hk_driver, cls, events):
"""Test fan with speed."""
entity_id = "fan.demo"
speed_list = [SPEED_OFF, SPEED_LOW, SPEED_HIGH]
hass.states.async_set(
entity_id,
STATE_ON,
{
ATTR_SUPPORTED_FEATURES: SUPPORT_SET_SPEED
|... | [
"async",
"def",
"test_fan_set_all_one_shot",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"entity_id",
"=",
"\"fan.demo\"",
"speed_list",
"=",
"[",
"SPEED_OFF",
",",
"SPEED_LOW",
",",
"SPEED_HIGH",
"]",
"hass",
".",
"states",
".",
"asy... | [
355,
0
] | [
558,
39
] | python | en | ['en', 'fy', 'en'] | True |
test_fan_restore | (hass, hk_driver, cls, events) | Test setting up an entity from state in the event registry. | Test setting up an entity from state in the event registry. | async def test_fan_restore(hass, hk_driver, cls, events):
"""Test setting up an entity from state in the event registry."""
hass.state = CoreState.not_running
registry = await entity_registry.async_get_registry(hass)
registry.async_get_or_create(
"fan",
"generic",
"1234",
... | [
"async",
"def",
"test_fan_restore",
"(",
"hass",
",",
"hk_driver",
",",
"cls",
",",
"events",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"reg... | [
561,
0
] | [
598,
37
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_devices, discovery_info=None) | Set up the StreamLabsWater mode sensor. | Set up the StreamLabsWater mode sensor. | def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the StreamLabsWater mode sensor."""
client = hass.data[STREAMLABSWATER_DOMAIN]["client"]
location_id = hass.data[STREAMLABSWATER_DOMAIN]["location_id"]
location_name = hass.data[STREAMLABSWATER_DOMAIN]["location_name"]
st... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_devices",
",",
"discovery_info",
"=",
"None",
")",
":",
"client",
"=",
"hass",
".",
"data",
"[",
"STREAMLABSWATER_DOMAIN",
"]",
"[",
"\"client\"",
"]",
"location_id",
"=",
"hass",
".",
"data",
... | [
16,
0
] | [
25,
78
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsLocationData.__init__ | (self, location_id, client) | Initialize the location data. | Initialize the location data. | def __init__(self, location_id, client):
"""Initialize the location data."""
self._location_id = location_id
self._client = client
self._is_away = None | [
"def",
"__init__",
"(",
"self",
",",
"location_id",
",",
"client",
")",
":",
"self",
".",
"_location_id",
"=",
"location_id",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_is_away",
"=",
"None"
] | [
31,
4
] | [
35,
28
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsLocationData.update | (self) | Query and store location data. | Query and store location data. | def update(self):
"""Query and store location data."""
location = self._client.get_location(self._location_id)
self._is_away = location["homeAway"] == "away" | [
"def",
"update",
"(",
"self",
")",
":",
"location",
"=",
"self",
".",
"_client",
".",
"get_location",
"(",
"self",
".",
"_location_id",
")",
"self",
".",
"_is_away",
"=",
"location",
"[",
"\"homeAway\"",
"]",
"==",
"\"away\""
] | [
38,
4
] | [
41,
54
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsLocationData.is_away | (self) | Return whether away more is enabled. | Return whether away more is enabled. | def is_away(self):
"""Return whether away more is enabled."""
return self._is_away | [
"def",
"is_away",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_away"
] | [
43,
4
] | [
45,
28
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsAwayMode.__init__ | (self, location_name, streamlabs_location_data) | Initialize the away mode device. | Initialize the away mode device. | def __init__(self, location_name, streamlabs_location_data):
"""Initialize the away mode device."""
self._location_name = location_name
self._streamlabs_location_data = streamlabs_location_data
self._is_away = None | [
"def",
"__init__",
"(",
"self",
",",
"location_name",
",",
"streamlabs_location_data",
")",
":",
"self",
".",
"_location_name",
"=",
"location_name",
"self",
".",
"_streamlabs_location_data",
"=",
"streamlabs_location_data",
"self",
".",
"_is_away",
"=",
"None"
] | [
51,
4
] | [
55,
28
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsAwayMode.name | (self) | Return the name for away mode. | Return the name for away mode. | def name(self):
"""Return the name for away mode."""
return f"{self._location_name} {NAME_AWAY_MODE}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._location_name} {NAME_AWAY_MODE}\""
] | [
58,
4
] | [
60,
56
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsAwayMode.is_on | (self) | Return if away mode is on. | Return if away mode is on. | def is_on(self):
"""Return if away mode is on."""
return self._streamlabs_location_data.is_away() | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_streamlabs_location_data",
".",
"is_away",
"(",
")"
] | [
63,
4
] | [
65,
55
] | python | en | ['en', 'en', 'en'] | True |
StreamlabsAwayMode.update | (self) | Retrieve the latest location data and away mode state. | Retrieve the latest location data and away mode state. | def update(self):
"""Retrieve the latest location data and away mode state."""
self._streamlabs_location_data.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_streamlabs_location_data",
".",
"update",
"(",
")"
] | [
67,
4
] | [
69,
47
] | python | en | ['en', 'en', 'en'] | True |
get_split | (split_name, dataset_dir, file_pattern=None, reader=None) | Gets a dataset tuple with instructions for reading cifar10.
Args:
split_name: A train/test split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset sources.
It is assumed that the pattern contains a '%s' string so that the s... | Gets a dataset tuple with instructions for reading cifar10. | def get_split(split_name, dataset_dir, file_pattern=None, reader=None):
"""Gets a dataset tuple with instructions for reading cifar10.
Args:
split_name: A train/test split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset sourc... | [
"def",
"get_split",
"(",
"split_name",
",",
"dataset_dir",
",",
"file_pattern",
"=",
"None",
",",
"reader",
"=",
"None",
")",
":",
"if",
"split_name",
"not",
"in",
"SPLITS_TO_SIZES",
":",
"raise",
"ValueError",
"(",
"'split name %s was not recognized.'",
"%",
"s... | [
44,
0
] | [
98,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the Goal Zero Yeti sensor. | Set up the Goal Zero Yeti sensor. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the Goal Zero Yeti sensor."""
name = entry.data[CONF_NAME]
goalzero_data = hass.data[DOMAIN][entry.entry_id]
sensors = [
YetiBinarySensor(
goalzero_data[DATA_KEY_API],
goalzero_data[DATA_KEY_COORDINAT... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"name",
"=",
"entry",
".",
"data",
"[",
"CONF_NAME",
"]",
"goalzero_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"... | [
10,
0
] | [
24,
37
] | python | en | ['en', 'zu', 'en'] | True |
YetiBinarySensor.__init__ | (self, api, coordinator, name, sensor_name, server_unique_id) | Initialize a Goal Zero Yeti sensor. | Initialize a Goal Zero Yeti sensor. | def __init__(self, api, coordinator, name, sensor_name, server_unique_id):
"""Initialize a Goal Zero Yeti sensor."""
super().__init__(api, coordinator, name, server_unique_id)
self._condition = sensor_name
variable_info = BINARY_SENSOR_DICT[sensor_name]
self._condition_name = v... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"coordinator",
",",
"name",
",",
"sensor_name",
",",
"server_unique_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"api",
",",
"coordinator",
",",
"name",
",",
"server_unique_id",
")",
"self",
"."... | [
30,
4
] | [
39,
45
] | python | en | ['es', 'eu', 'en'] | False |
YetiBinarySensor.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._name} {self._condition_name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._name} {self._condition_name}\""
] | [
42,
4
] | [
44,
53
] | python | en | ['en', 'mi', 'en'] | True |
YetiBinarySensor.unique_id | (self) | Return the unique id of the sensor. | Return the unique id of the sensor. | def unique_id(self):
"""Return the unique id of the sensor."""
return f"{self._server_unique_id}/{self._condition_name}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._server_unique_id}/{self._condition_name}\""
] | [
47,
4
] | [
49,
65
] | python | en | ['en', 'la', 'en'] | True |
YetiBinarySensor.is_on | (self) | Return if the service is on. | Return if the service is on. | def is_on(self):
"""Return if the service is on."""
if self.api.data:
return self.api.data[self._condition] == 1
return False | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"api",
".",
"data",
":",
"return",
"self",
".",
"api",
".",
"data",
"[",
"self",
".",
"_condition",
"]",
"==",
"1",
"return",
"False"
] | [
52,
4
] | [
56,
20
] | python | en | ['en', 'en', 'en'] | True |
YetiBinarySensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
59,
4
] | [
61,
25
] | python | en | ['en', 'en', 'en'] | True |
mock_http_client | (hass, hass_client) | Start the Home Assistant HTTP component. | Start the Home Assistant HTTP component. | def mock_http_client(hass, hass_client):
"""Start the Home Assistant HTTP component."""
config = {mailbox.DOMAIN: {"platform": "demo"}}
hass.loop.run_until_complete(async_setup_component(hass, mailbox.DOMAIN, config))
return hass.loop.run_until_complete(hass_client()) | [
"def",
"mock_http_client",
"(",
"hass",
",",
"hass_client",
")",
":",
"config",
"=",
"{",
"mailbox",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"async_setup_component",
"(",
"hass"... | [
11,
0
] | [
15,
54
] | python | en | ['en', 'en', 'en'] | True |
test_get_platforms_from_mailbox | (mock_http_client) | Get platforms from mailbox. | Get platforms from mailbox. | async def test_get_platforms_from_mailbox(mock_http_client):
"""Get platforms from mailbox."""
url = "/api/mailbox/platforms"
req = await mock_http_client.get(url)
assert req.status == 200
result = await req.json()
assert len(result) == 1 and "DemoMailbox" == result[0].get("name", None) | [
"async",
"def",
"test_get_platforms_from_mailbox",
"(",
"mock_http_client",
")",
":",
"url",
"=",
"\"/api/mailbox/platforms\"",
"req",
"=",
"await",
"mock_http_client",
".",
"get",
"(",
"url",
")",
"assert",
"req",
".",
"status",
"==",
"200",
"result",
"=",
"awa... | [
18,
0
] | [
25,
76
] | python | en | ['en', 'en', 'en'] | True |
test_get_messages_from_mailbox | (mock_http_client) | Get messages from mailbox. | Get messages from mailbox. | async def test_get_messages_from_mailbox(mock_http_client):
"""Get messages from mailbox."""
url = "/api/mailbox/messages/DemoMailbox"
req = await mock_http_client.get(url)
assert req.status == 200
result = await req.json()
assert len(result) == 10 | [
"async",
"def",
"test_get_messages_from_mailbox",
"(",
"mock_http_client",
")",
":",
"url",
"=",
"\"/api/mailbox/messages/DemoMailbox\"",
"req",
"=",
"await",
"mock_http_client",
".",
"get",
"(",
"url",
")",
"assert",
"req",
".",
"status",
"==",
"200",
"result",
"... | [
28,
0
] | [
35,
28
] | python | en | ['en', 'en', 'en'] | True |
test_get_media_from_mailbox | (mock_http_client) | Get audio from mailbox. | Get audio from mailbox. | async def test_get_media_from_mailbox(mock_http_client):
"""Get audio from mailbox."""
mp3sha = "3f67c4ea33b37d1710f772a26dd3fb43bb159d50"
msgtxt = "Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
msgsha = sha1(msgtxt.encode("utf-8")).hexdigest()
url = "/api/mailbox/media/Demo... | [
"async",
"def",
"test_get_media_from_mailbox",
"(",
"mock_http_client",
")",
":",
"mp3sha",
"=",
"\"3f67c4ea33b37d1710f772a26dd3fb43bb159d50\"",
"msgtxt",
"=",
"\"Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \"",
"msgsha",
"=",
"sha1",
"(",
"msgtxt",
".",
... | [
38,
0
] | [
48,
43
] | python | en | ['en', 'en', 'en'] | True |
test_delete_from_mailbox | (mock_http_client) | Get audio from mailbox. | Get audio from mailbox. | async def test_delete_from_mailbox(mock_http_client):
"""Get audio from mailbox."""
msgtxt1 = "Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
msgtxt2 = "Message 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
msgsha1 = sha1(msgtxt1.encode("utf-8")).hexdigest()
ms... | [
"async",
"def",
"test_delete_from_mailbox",
"(",
"mock_http_client",
")",
":",
"msgtxt1",
"=",
"\"Message 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \"",
"msgtxt2",
"=",
"\"Message 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \"",
"msgsha1",
"=",
"sha1",... | [
51,
0
] | [
67,
27
] | python | en | ['en', 'en', 'en'] | True |
test_get_messages_from_invalid_mailbox | (mock_http_client) | Get messages from mailbox. | Get messages from mailbox. | async def test_get_messages_from_invalid_mailbox(mock_http_client):
"""Get messages from mailbox."""
url = "/api/mailbox/messages/mailbox.invalid_mailbox"
req = await mock_http_client.get(url)
assert req.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_get_messages_from_invalid_mailbox",
"(",
"mock_http_client",
")",
":",
"url",
"=",
"\"/api/mailbox/messages/mailbox.invalid_mailbox\"",
"req",
"=",
"await",
"mock_http_client",
".",
"get",
"(",
"url",
")",
"assert",
"req",
".",
"status",
"==",
"H... | [
70,
0
] | [
75,
39
] | python | en | ['en', 'en', 'en'] | True |
test_get_media_from_invalid_mailbox | (mock_http_client) | Get messages from mailbox. | Get messages from mailbox. | async def test_get_media_from_invalid_mailbox(mock_http_client):
"""Get messages from mailbox."""
msgsha = "0000000000000000000000000000000000000000"
url = "/api/mailbox/media/mailbox.invalid_mailbox/%s" % (msgsha)
req = await mock_http_client.get(url)
assert req.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_get_media_from_invalid_mailbox",
"(",
"mock_http_client",
")",
":",
"msgsha",
"=",
"\"0000000000000000000000000000000000000000\"",
"url",
"=",
"\"/api/mailbox/media/mailbox.invalid_mailbox/%s\"",
"%",
"(",
"msgsha",
")",
"req",
"=",
"await",
"mock_http_c... | [
78,
0
] | [
84,
39
] | python | en | ['en', 'en', 'en'] | True |
test_get_media_from_invalid_msgid | (mock_http_client) | Get messages from mailbox. | Get messages from mailbox. | async def test_get_media_from_invalid_msgid(mock_http_client):
"""Get messages from mailbox."""
msgsha = "0000000000000000000000000000000000000000"
url = "/api/mailbox/media/DemoMailbox/%s" % (msgsha)
req = await mock_http_client.get(url)
assert req.status == HTTP_INTERNAL_SERVER_ERROR | [
"async",
"def",
"test_get_media_from_invalid_msgid",
"(",
"mock_http_client",
")",
":",
"msgsha",
"=",
"\"0000000000000000000000000000000000000000\"",
"url",
"=",
"\"/api/mailbox/media/DemoMailbox/%s\"",
"%",
"(",
"msgsha",
")",
"req",
"=",
"await",
"mock_http_client",
".",... | [
87,
0
] | [
93,
51
] | python | en | ['en', 'en', 'en'] | True |
test_delete_from_invalid_mailbox | (mock_http_client) | Get audio from mailbox. | Get audio from mailbox. | async def test_delete_from_invalid_mailbox(mock_http_client):
"""Get audio from mailbox."""
msgsha = "0000000000000000000000000000000000000000"
url = "/api/mailbox/delete/mailbox.invalid_mailbox/%s" % (msgsha)
req = await mock_http_client.delete(url)
assert req.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_delete_from_invalid_mailbox",
"(",
"mock_http_client",
")",
":",
"msgsha",
"=",
"\"0000000000000000000000000000000000000000\"",
"url",
"=",
"\"/api/mailbox/delete/mailbox.invalid_mailbox/%s\"",
"%",
"(",
"msgsha",
")",
"req",
"=",
"await",
"mock_http_cli... | [
96,
0
] | [
102,
39
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Enphase Envoy sensor. | Set up the Enphase Envoy sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Enphase Envoy sensor."""
ip_address = config[CONF_IP_ADDRESS]
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
name = config[CONF_NAME]
username = config[CONF_USERNAME]
password = config[... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"ip_address",
"=",
"config",
"[",
"CONF_IP_ADDRESS",
"]",
"monitored_conditions",
"=",
"config",
"[",
"CONF_MONITORED_CONDITI... | [
57,
0
] | [
100,
32
] | python | en | ['en', 'da', 'en'] | True |
Envoy.__init__ | (self, envoy_reader, sensor_type, name, unit) | Initialize the sensor. | Initialize the sensor. | def __init__(self, envoy_reader, sensor_type, name, unit):
"""Initialize the sensor."""
self._envoy_reader = envoy_reader
self._type = sensor_type
self._name = name
self._unit_of_measurement = unit
self._state = None
self._last_reported = None | [
"def",
"__init__",
"(",
"self",
",",
"envoy_reader",
",",
"sensor_type",
",",
"name",
",",
"unit",
")",
":",
"self",
".",
"_envoy_reader",
"=",
"envoy_reader",
"self",
".",
"_type",
"=",
"sensor_type",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_un... | [
106,
4
] | [
113,
34
] | python | en | ['en', 'en', 'en'] | True |
Envoy.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
116,
4
] | [
118,
25
] | python | en | ['en', 'mi', 'en'] | True |
Envoy.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"
] | [
121,
4
] | [
123,
26
] | python | en | ['en', 'en', 'en'] | True |
Envoy.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"
] | [
126,
4
] | [
128,
40
] | python | en | ['en', 'en', 'en'] | True |
Envoy.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
131,
4
] | [
133,
19
] | python | en | ['en', 'en', 'en'] | True |
Envoy.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if self._type == "inverters":
return {"last_reported": self._last_reported}
return None | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_type",
"==",
"\"inverters\"",
":",
"return",
"{",
"\"last_reported\"",
":",
"self",
".",
"_last_reported",
"}",
"return",
"None"
] | [
136,
4
] | [
141,
19
] | python | en | ['en', 'en', 'en'] | True |
Envoy.async_update | (self) | Get the energy production data from the Enphase Envoy. | Get the energy production data from the Enphase Envoy. | async def async_update(self):
"""Get the energy production data from the Enphase Envoy."""
if self._type != "inverters":
_state = await getattr(self._envoy_reader, self._type)()
if isinstance(_state, int):
self._state = _state
else:
_LO... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_type",
"!=",
"\"inverters\"",
":",
"_state",
"=",
"await",
"getattr",
"(",
"self",
".",
"_envoy_reader",
",",
"self",
".",
"_type",
")",
"(",
")",
"if",
"isinstance",
"(",
"_st... | [
143,
4
] | [
167,
34
] | python | en | ['en', 'en', 'en'] | True |
train_command_factory | (args: Namespace) |
Factory function used to instantiate training command from provided command line arguments.
Returns: TrainCommand
|
Factory function used to instantiate training command from provided command line arguments. | def train_command_factory(args: Namespace):
"""
Factory function used to instantiate training command from provided command line arguments.
Returns: TrainCommand
"""
return TrainCommand(args) | [
"def",
"train_command_factory",
"(",
"args",
":",
"Namespace",
")",
":",
"return",
"TrainCommand",
"(",
"args",
")"
] | [
32,
0
] | [
38,
29
] | python | en | ['en', 'error', 'th'] | False |
TrainCommand.register_subcommand | (parser: ArgumentParser) |
Register this command to argparse so it's available for the transformer-cli
Args:
parser: Root parser to register command-specific arguments
|
Register this command to argparse so it's available for the transformer-cli | def register_subcommand(parser: ArgumentParser):
"""
Register this command to argparse so it's available for the transformer-cli
Args:
parser: Root parser to register command-specific arguments
"""
train_parser = parser.add_parser("train", help="CLI tool to train a m... | [
"def",
"register_subcommand",
"(",
"parser",
":",
"ArgumentParser",
")",
":",
"train_parser",
"=",
"parser",
".",
"add_parser",
"(",
"\"train\"",
",",
"help",
"=",
"\"CLI tool to train a model on a task.\"",
")",
"train_parser",
".",
"add_argument",
"(",
"\"--train_da... | [
43,
4
] | [
92,
61
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Create the Rova data service and sensors. | Create the Rova data service and sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Create the Rova data service and sensors."""
zip_code = config[CONF_ZIP_CODE]
house_number = config[CONF_HOUSE_NUMBER]
house_number_suffix = config[CONF_HOUSE_NUMBER_SUFFIX]
platform_name = config[CONF_NAME]
# Create new R... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"zip_code",
"=",
"config",
"[",
"CONF_ZIP_CODE",
"]",
"house_number",
"=",
"config",
"[",
"CONF_HOUSE_NUMBER",
"]",
"house_number_suffix",
"="... | [
51,
0
] | [
79,
32
] | python | en | ['en', 'sm', 'en'] | True |
RovaSensor.__init__ | (self, platform_name, sensor_key, data_service) | Initialize the sensor. | Initialize the sensor. | def __init__(self, platform_name, sensor_key, data_service):
"""Initialize the sensor."""
self.sensor_key = sensor_key
self.platform_name = platform_name
self.data_service = data_service
self._state = None
self._json_key = SENSOR_TYPES[self.sensor_key][0] | [
"def",
"__init__",
"(",
"self",
",",
"platform_name",
",",
"sensor_key",
",",
"data_service",
")",
":",
"self",
".",
"sensor_key",
"=",
"sensor_key",
"self",
".",
"platform_name",
"=",
"platform_name",
"self",
".",
"data_service",
"=",
"data_service",
"self",
... | [
85,
4
] | [
93,
57
] | python | en | ['en', 'en', 'en'] | True |
RovaSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return f"{self.platform_name}_{self.sensor_key}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.platform_name}_{self.sensor_key}\""
] | [
96,
4
] | [
98,
56
] | python | en | ['en', 'ig', 'en'] | True |
RovaSensor.icon | (self) | Return the sensor icon. | Return the sensor icon. | def icon(self):
"""Return the sensor icon."""
return SENSOR_TYPES[self.sensor_key][2] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"sensor_key",
"]",
"[",
"2",
"]"
] | [
101,
4
] | [
103,
47
] | python | en | ['en', 'fa', 'en'] | True |
RovaSensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
106,
4
] | [
108,
37
] | python | en | ['en', 'en', 'en'] | True |
RovaSensor.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"
] | [
111,
4
] | [
113,
26
] | python | en | ['en', 'en', 'en'] | True |
RovaSensor.update | (self) | Get the latest data from the sensor and update the state. | Get the latest data from the sensor and update the state. | def update(self):
"""Get the latest data from the sensor and update the state."""
self.data_service.update()
pickup_date = self.data_service.data.get(self._json_key)
if pickup_date is not None:
self._state = pickup_date.isoformat() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"data_service",
".",
"update",
"(",
")",
"pickup_date",
"=",
"self",
".",
"data_service",
".",
"data",
".",
"get",
"(",
"self",
".",
"_json_key",
")",
"if",
"pickup_date",
"is",
"not",
"None",
":",
... | [
115,
4
] | [
120,
49
] | python | en | ['en', 'en', 'en'] | True |
RovaData.__init__ | (self, api) | Initialize the data object. | Initialize the data object. | def __init__(self, api):
"""Initialize the data object."""
self.api = api
self.data = {} | [
"def",
"__init__",
"(",
"self",
",",
"api",
")",
":",
"self",
".",
"api",
"=",
"api",
"self",
".",
"data",
"=",
"{",
"}"
] | [
126,
4
] | [
129,
22
] | python | en | ['en', 'en', 'en'] | True |
RovaData.update | (self) | Update the data from the Rova API. | Update the data from the Rova API. | def update(self):
"""Update the data from the Rova API."""
try:
items = self.api.get_calendar_items()
except (ConnectTimeout, HTTPError):
_LOGGER.error("Could not retrieve data, retry again later")
return
self.data = {}
for item in items:
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"items",
"=",
"self",
".",
"api",
".",
"get_calendar_items",
"(",
")",
"except",
"(",
"ConnectTimeout",
",",
"HTTPError",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Could not retrieve data, retry again later\... | [
132,
4
] | [
150,
61
] | 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.