Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_setup_entry | (hass, entry) | Set up a config entry. | Set up a config entry. | async def async_setup_entry(hass, entry):
"""Set up a config entry."""
return await hass.data[DOMAIN].async_setup_entry(entry) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_setup_entry",
"(",
"entry",
")"
] | [
156,
0
] | [
158,
59
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
return await hass.data[DOMAIN].async_unload_entry(entry) | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_unload_entry",
"(",
"entry",
")"
] | [
161,
0
] | [
163,
60
] | python | en | ['en', 'es', 'en'] | True |
CoverEntity.current_cover_position | (self) | Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
| Return current position of cover. | def current_cover_position(self):
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
""" | [
"def",
"current_cover_position",
"(",
"self",
")",
":"
] | [
170,
4
] | [
174,
11
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.current_cover_tilt_position | (self) | Return current position of cover tilt.
None is unknown, 0 is closed, 100 is fully open.
| Return current position of cover tilt. | def current_cover_tilt_position(self):
"""Return current position of cover tilt.
None is unknown, 0 is closed, 100 is fully open.
""" | [
"def",
"current_cover_tilt_position",
"(",
"self",
")",
":"
] | [
177,
4
] | [
181,
11
] | python | en | ['en', 'da', 'en'] | True |
CoverEntity.state | (self) | Return the state of the cover. | Return the state of the cover. | def state(self):
"""Return the state of the cover."""
if self.is_opening:
return STATE_OPENING
if self.is_closing:
return STATE_CLOSING
closed = self.is_closed
if closed is None:
return None
return STATE_CLOSED if closed else STATE_O... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_opening",
":",
"return",
"STATE_OPENING",
"if",
"self",
".",
"is_closing",
":",
"return",
"STATE_CLOSING",
"closed",
"=",
"self",
".",
"is_closed",
"if",
"closed",
"is",
"None",
":",
"return",
... | [
184,
4
] | [
196,
53
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.state_attributes | (self) | Return the state attributes. | Return the state attributes. | def state_attributes(self):
"""Return the state attributes."""
data = {}
current = self.current_cover_position
if current is not None:
data[ATTR_CURRENT_POSITION] = self.current_cover_position
current_tilt = self.current_cover_tilt_position
if current_tilt i... | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"current",
"=",
"self",
".",
"current_cover_position",
"if",
"current",
"is",
"not",
"None",
":",
"data",
"[",
"ATTR_CURRENT_POSITION",
"]",
"=",
"self",
".",
"current_cover_position",
... | [
199,
4
] | [
211,
19
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP
if self.current_cover_position is not None:
supported_features |= SUPPORT_SET_POSITION
if self.current_cover_tilt_position is not None:
... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE",
"|",
"SUPPORT_STOP",
"if",
"self",
".",
"current_cover_position",
"is",
"not",
"None",
":",
"supported_features",
"|=",
"SUPPORT_SET_POSITION",
"if",
... | [
214,
4
] | [
229,
33
] | python | en | ['da', 'en', 'en'] | True |
CoverEntity.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not.""" | [
"def",
"is_opening",
"(",
"self",
")",
":"
] | [
232,
4
] | [
233,
52
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not.""" | [
"def",
"is_closing",
"(",
"self",
")",
":"
] | [
236,
4
] | [
237,
52
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.is_closed | (self) | Return if the cover is closed or not. | Return if the cover is closed or not. | def is_closed(self):
"""Return if the cover is closed or not."""
raise NotImplementedError() | [
"def",
"is_closed",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
240,
4
] | [
242,
35
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.open_cover | (self, **kwargs: Any) | Open the cover. | Open the cover. | def open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
raise NotImplementedError() | [
"def",
"open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
244,
4
] | [
246,
35
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
await self.hass.async_add_executor_job(ft.partial(self.open_cover, **kwargs)) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"open_cover",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
248,
4
] | [
250,
85
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.close_cover | (self, **kwargs: Any) | Close cover. | Close cover. | def close_cover(self, **kwargs: Any) -> None:
"""Close cover."""
raise NotImplementedError() | [
"def",
"close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
252,
4
] | [
254,
35
] | python | en | ['en', 'la', 'en'] | False |
CoverEntity.async_close_cover | (self, **kwargs) | Close cover. | Close cover. | async def async_close_cover(self, **kwargs):
"""Close cover."""
await self.hass.async_add_executor_job(ft.partial(self.close_cover, **kwargs)) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"close_cover",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
256,
4
] | [
258,
86
] | python | en | ['en', 'la', 'en'] | False |
CoverEntity.toggle | (self, **kwargs: Any) | Toggle the entity. | Toggle the entity. | def toggle(self, **kwargs: Any) -> None:
"""Toggle the entity."""
if self.is_closed:
self.open_cover(**kwargs)
else:
self.close_cover(**kwargs) | [
"def",
"toggle",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"is_closed",
":",
"self",
".",
"open_cover",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"self",
".",
"close_cover",
"(",
"*",
"*",
"kwar... | [
260,
4
] | [
265,
38
] | python | en | ['en', 'sm', 'en'] | True |
CoverEntity.async_toggle | (self, **kwargs) | Toggle the entity. | Toggle the entity. | async def async_toggle(self, **kwargs):
"""Toggle the entity."""
if self.is_closed:
await self.async_open_cover(**kwargs)
else:
await self.async_close_cover(**kwargs) | [
"async",
"def",
"async_toggle",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_closed",
":",
"await",
"self",
".",
"async_open_cover",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"await",
"self",
".",
"async_close_cover",
"(",
"*... | [
267,
4
] | [
272,
50
] | python | en | ['en', 'sm', 'en'] | True |
CoverEntity.set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | def set_cover_position(self, **kwargs):
"""Move the cover to a specific position.""" | [
"def",
"set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
274,
4
] | [
275,
52
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
await self.hass.async_add_executor_job(
ft.partial(self.set_cover_position, **kwargs)
) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"set_cover_position",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
277,
4
] | [
281,
9
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | def stop_cover(self, **kwargs):
"""Stop the cover.""" | [
"def",
"stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
283,
4
] | [
284,
29
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
await self.hass.async_add_executor_job(ft.partial(self.stop_cover, **kwargs)) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"stop_cover",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
286,
4
] | [
288,
85
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.open_cover_tilt | (self, **kwargs: Any) | Open the cover tilt. | Open the cover tilt. | def open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" | [
"def",
"open_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":"
] | [
290,
4
] | [
291,
34
] | python | en | ['en', 'no', 'en'] | True |
CoverEntity.async_open_cover_tilt | (self, **kwargs) | Open the cover tilt. | Open the cover tilt. | async def async_open_cover_tilt(self, **kwargs):
"""Open the cover tilt."""
await self.hass.async_add_executor_job(
ft.partial(self.open_cover_tilt, **kwargs)
) | [
"async",
"def",
"async_open_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"open_cover_tilt",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
293,
4
] | [
297,
9
] | python | en | ['en', 'no', 'en'] | True |
CoverEntity.close_cover_tilt | (self, **kwargs: Any) | Close the cover tilt. | Close the cover tilt. | def close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt.""" | [
"def",
"close_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":"
] | [
299,
4
] | [
300,
35
] | python | en | ['en', 'fr', 'en'] | True |
CoverEntity.async_close_cover_tilt | (self, **kwargs) | Close the cover tilt. | Close the cover tilt. | async def async_close_cover_tilt(self, **kwargs):
"""Close the cover tilt."""
await self.hass.async_add_executor_job(
ft.partial(self.close_cover_tilt, **kwargs)
) | [
"async",
"def",
"async_close_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"close_cover_tilt",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
302,
4
] | [
306,
9
] | python | en | ['en', 'fr', 'en'] | True |
CoverEntity.set_cover_tilt_position | (self, **kwargs) | Move the cover tilt to a specific position. | Move the cover tilt to a specific position. | def set_cover_tilt_position(self, **kwargs):
"""Move the cover tilt to a specific position.""" | [
"def",
"set_cover_tilt_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
308,
4
] | [
309,
57
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.async_set_cover_tilt_position | (self, **kwargs) | Move the cover tilt to a specific position. | Move the cover tilt to a specific position. | async def async_set_cover_tilt_position(self, **kwargs):
"""Move the cover tilt to a specific position."""
await self.hass.async_add_executor_job(
ft.partial(self.set_cover_tilt_position, **kwargs)
) | [
"async",
"def",
"async_set_cover_tilt_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"set_cover_tilt_position",
",",
"*",
"*",
"kwargs",
")"... | [
311,
4
] | [
315,
9
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.stop_cover_tilt | (self, **kwargs) | Stop the cover. | Stop the cover. | def stop_cover_tilt(self, **kwargs):
"""Stop the cover.""" | [
"def",
"stop_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
317,
4
] | [
318,
29
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.async_stop_cover_tilt | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover_tilt(self, **kwargs):
"""Stop the cover."""
await self.hass.async_add_executor_job(
ft.partial(self.stop_cover_tilt, **kwargs)
) | [
"async",
"def",
"async_stop_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"stop_cover_tilt",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
320,
4
] | [
324,
9
] | python | en | ['en', 'en', 'en'] | True |
CoverEntity.toggle_tilt | (self, **kwargs: Any) | Toggle the entity. | Toggle the entity. | def toggle_tilt(self, **kwargs: Any) -> None:
"""Toggle the entity."""
if self.current_cover_tilt_position == 0:
self.open_cover_tilt(**kwargs)
else:
self.close_cover_tilt(**kwargs) | [
"def",
"toggle_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"current_cover_tilt_position",
"==",
"0",
":",
"self",
".",
"open_cover_tilt",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"self",
".",
... | [
326,
4
] | [
331,
43
] | python | en | ['en', 'sm', 'en'] | True |
CoverEntity.async_toggle_tilt | (self, **kwargs) | Toggle the entity. | Toggle the entity. | async def async_toggle_tilt(self, **kwargs):
"""Toggle the entity."""
if self.current_cover_tilt_position == 0:
await self.async_open_cover_tilt(**kwargs)
else:
await self.async_close_cover_tilt(**kwargs) | [
"async",
"def",
"async_toggle_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"current_cover_tilt_position",
"==",
"0",
":",
"await",
"self",
".",
"async_open_cover_tilt",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"await",
"self"... | [
333,
4
] | [
338,
55
] | python | en | ['en', 'sm', 'en'] | True |
CoverDevice.__init_subclass__ | (cls, **kwargs) | Print deprecation warning. | Print deprecation warning. | def __init_subclass__(cls, **kwargs):
"""Print deprecation warning."""
super().__init_subclass__(**kwargs)
_LOGGER.warning(
"CoverDevice is deprecated, modify %s to extend CoverEntity",
cls.__name__,
) | [
"def",
"__init_subclass__",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init_subclass__",
"(",
"*",
"*",
"kwargs",
")",
"_LOGGER",
".",
"warning",
"(",
"\"CoverDevice is deprecated, modify %s to extend CoverEntity\"",
",",
"cls",
".... | [
344,
4
] | [
350,
9
] | python | de | ['de', 'sv', 'en'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Create the Elk-M1 sensor platform. | Create the Elk-M1 sensor platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Create the Elk-M1 sensor platform."""
elk_data = hass.data[DOMAIN][config_entry.entry_id]
entities = []
elk = elk_data["elk"]
create_elk_entities(elk_data, elk.counters, "counter", ElkCounter, entities)
create_elk_entities(e... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"elk_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"]",
"elk",
"=",
"elk_dat... | [
28,
0
] | [
61,
5
] | python | en | ['en', 'da', 'en'] | True |
temperature_to_state | (temperature, undefined_temperature) | Convert temperature to a state. | Convert temperature to a state. | def temperature_to_state(temperature, undefined_temperature):
"""Convert temperature to a state."""
return temperature if temperature > undefined_temperature else None | [
"def",
"temperature_to_state",
"(",
"temperature",
",",
"undefined_temperature",
")",
":",
"return",
"temperature",
"if",
"temperature",
">",
"undefined_temperature",
"else",
"None"
] | [
64,
0
] | [
66,
71
] | python | en | ['en', 'en', 'en'] | True |
ElkSensor.__init__ | (self, element, elk, elk_data) | Initialize the base of all Elk sensors. | Initialize the base of all Elk sensors. | def __init__(self, element, elk, elk_data):
"""Initialize the base of all Elk sensors."""
super().__init__(element, elk, elk_data)
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"element",
",",
"elk",
",",
"elk_data",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"element",
",",
"elk",
",",
"elk_data",
")",
"self",
".",
"_state",
"=",
"None"
] | [
72,
4
] | [
75,
26
] | python | en | ['en', 'en', 'en'] | True |
ElkSensor.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"
] | [
78,
4
] | [
80,
26
] | python | en | ['en', 'en', 'en'] | True |
ElkSensor.async_counter_refresh | (self) | Refresh the value of a counter from the panel. | Refresh the value of a counter from the panel. | async def async_counter_refresh(self):
"""Refresh the value of a counter from the panel."""
if not isinstance(self, ElkCounter):
raise HomeAssistantError("supported only on ElkM1 Counter sensors")
self._element.get() | [
"async",
"def",
"async_counter_refresh",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"ElkCounter",
")",
":",
"raise",
"HomeAssistantError",
"(",
"\"supported only on ElkM1 Counter sensors\"",
")",
"self",
".",
"_element",
".",
"get",
"(",
... | [
82,
4
] | [
86,
27
] | python | en | ['en', 'en', 'en'] | True |
ElkSensor.async_counter_set | (self, value=None) | Set the value of a counter on the panel. | Set the value of a counter on the panel. | async def async_counter_set(self, value=None):
"""Set the value of a counter on the panel."""
if not isinstance(self, ElkCounter):
raise HomeAssistantError("supported only on ElkM1 Counter sensors")
self._element.set(value) | [
"async",
"def",
"async_counter_set",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"ElkCounter",
")",
":",
"raise",
"HomeAssistantError",
"(",
"\"supported only on ElkM1 Counter sensors\"",
")",
"self",
".",
"_ele... | [
88,
4
] | [
92,
32
] | python | en | ['en', 'en', 'en'] | True |
ElkSensor.async_zone_bypass | (self, code=None) | Bypass zone. | Bypass zone. | async def async_zone_bypass(self, code=None):
"""Bypass zone."""
if not isinstance(self, ElkZone):
raise HomeAssistantError("supported only on ElkM1 Zone sensors")
self._element.bypass(code) | [
"async",
"def",
"async_zone_bypass",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"ElkZone",
")",
":",
"raise",
"HomeAssistantError",
"(",
"\"supported only on ElkM1 Zone sensors\"",
")",
"self",
".",
"_element",
... | [
94,
4
] | [
98,
34
] | python | en | ['pl', 'en', 'en'] | False |
ElkSensor.async_zone_trigger | (self) | Trigger zone. | Trigger zone. | async def async_zone_trigger(self):
"""Trigger zone."""
if not isinstance(self, ElkZone):
raise HomeAssistantError("supported only on ElkM1 Zone sensors")
self._element.trigger() | [
"async",
"def",
"async_zone_trigger",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"ElkZone",
")",
":",
"raise",
"HomeAssistantError",
"(",
"\"supported only on ElkM1 Zone sensors\"",
")",
"self",
".",
"_element",
".",
"trigger",
"(",
")"
... | [
100,
4
] | [
104,
31
] | python | en | ['nl', 'it', 'en'] | False |
ElkCounter.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return "mdi:numeric" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:numeric\""
] | [
111,
4
] | [
113,
28
] | python | en | ['en', 'en', 'en'] | True |
ElkKeypad.temperature_unit | (self) | Return the temperature unit. | Return the temperature unit. | def temperature_unit(self):
"""Return the temperature unit."""
return self._temperature_unit | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"self",
".",
"_temperature_unit"
] | [
123,
4
] | [
125,
37
] | python | en | ['en', 'la', 'en'] | True |
ElkKeypad.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._temperature_unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_temperature_unit"
] | [
128,
4
] | [
130,
37
] | python | en | ['en', 'la', 'en'] | True |
ElkKeypad.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return "mdi:thermometer-lines" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:thermometer-lines\""
] | [
133,
4
] | [
135,
38
] | python | en | ['en', 'en', 'en'] | True |
ElkKeypad.device_state_attributes | (self) | Attributes of the sensor. | Attributes of the sensor. | def device_state_attributes(self):
"""Attributes of the sensor."""
attrs = self.initial_attrs()
attrs["area"] = self._element.area + 1
attrs["temperature"] = self._state
attrs["last_user_time"] = self._element.last_user_time.isoformat()
attrs["last_user"] = self._element.... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"initial_attrs",
"(",
")",
"attrs",
"[",
"\"area\"",
"]",
"=",
"self",
".",
"_element",
".",
"area",
"+",
"1",
"attrs",
"[",
"\"temperature\"",
"]",
"=",
"self",
".",
"... | [
138,
4
] | [
148,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkPanel.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return "mdi:home" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:home\""
] | [
160,
4
] | [
162,
25
] | python | en | ['en', 'en', 'en'] | True |
ElkPanel.device_state_attributes | (self) | Attributes of the sensor. | Attributes of the sensor. | def device_state_attributes(self):
"""Attributes of the sensor."""
attrs = self.initial_attrs()
attrs["system_trouble_status"] = self._element.system_trouble_status
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"initial_attrs",
"(",
")",
"attrs",
"[",
"\"system_trouble_status\"",
"]",
"=",
"self",
".",
"_element",
".",
"system_trouble_status",
"return",
"attrs"
] | [
165,
4
] | [
169,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkSetting.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return "mdi:numeric" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:numeric\""
] | [
184,
4
] | [
186,
28
] | python | en | ['en', 'en', 'en'] | True |
ElkSetting.device_state_attributes | (self) | Attributes of the sensor. | Attributes of the sensor. | def device_state_attributes(self):
"""Attributes of the sensor."""
attrs = self.initial_attrs()
attrs["value_format"] = SettingFormat(self._element.value_format).name.lower()
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"initial_attrs",
"(",
")",
"attrs",
"[",
"\"value_format\"",
"]",
"=",
"SettingFormat",
"(",
"self",
".",
"_element",
".",
"value_format",
")",
".",
"name",
".",
"lower",
"... | [
192,
4
] | [
196,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkZone.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
zone_icons = {
ZoneType.FIRE_ALARM.value: "fire",
ZoneType.FIRE_VERIFIED.value: "fire",
ZoneType.FIRE_SUPERVISORY.value: "fire",
ZoneType.KEYFOB.value: "key",
ZoneType.NON_ALARM.value: "alarm-o... | [
"def",
"icon",
"(",
"self",
")",
":",
"zone_icons",
"=",
"{",
"ZoneType",
".",
"FIRE_ALARM",
".",
"value",
":",
"\"fire\"",
",",
"ZoneType",
".",
"FIRE_VERIFIED",
".",
"value",
":",
"\"fire\"",
",",
"ZoneType",
".",
"FIRE_SUPERVISORY",
".",
"value",
":",
... | [
203,
4
] | [
226,
78
] | python | en | ['en', 'en', 'en'] | True |
ElkZone.device_state_attributes | (self) | Attributes of the sensor. | Attributes of the sensor. | def device_state_attributes(self):
"""Attributes of the sensor."""
attrs = self.initial_attrs()
attrs["physical_status"] = ZonePhysicalStatus(
self._element.physical_status
).name.lower()
attrs["logical_status"] = ZoneLogicalStatus(
self._element.logical_s... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"self",
".",
"initial_attrs",
"(",
")",
"attrs",
"[",
"\"physical_status\"",
"]",
"=",
"ZonePhysicalStatus",
"(",
"self",
".",
"_element",
".",
"physical_status",
")",
".",
"name",
".",
"... | [
229,
4
] | [
241,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkZone.temperature_unit | (self) | Return the temperature unit. | Return the temperature unit. | def temperature_unit(self):
"""Return the temperature unit."""
if self._element.definition == ZoneType.TEMPERATURE.value:
return self._temperature_unit
return None | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_element",
".",
"definition",
"==",
"ZoneType",
".",
"TEMPERATURE",
".",
"value",
":",
"return",
"self",
".",
"_temperature_unit",
"return",
"None"
] | [
244,
4
] | [
248,
19
] | python | en | ['en', 'la', 'en'] | True |
ElkZone.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
if self._element.definition == ZoneType.TEMPERATURE.value:
return self._temperature_unit
if self._element.definition == ZoneType.ANALOG_ZONE.value:
return VOLT
return None | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_element",
".",
"definition",
"==",
"ZoneType",
".",
"TEMPERATURE",
".",
"value",
":",
"return",
"self",
".",
"_temperature_unit",
"if",
"self",
".",
"_element",
".",
"definition",
"=="... | [
251,
4
] | [
257,
19
] | python | en | ['en', 'la', 'en'] | True |
brute_force | (step) |
A function that searches all possible combinations (Brute Force) and finds
a collection of values for DVFS coefficients that minimizes the energy function
due to the constraints (optimization depends on the step).
Returns optimum coefficients and corresponding energy
|
A function that searches all possible combinations (Brute Force) and finds
a collection of values for DVFS coefficients that minimizes the energy function
due to the constraints (optimization depends on the step).
Returns optimum coefficients and corresponding energy
| def brute_force(step):
"""
A function that searches all possible combinations (Brute Force) and finds
a collection of values for DVFS coefficients that minimizes the energy function
due to the constraints (optimization depends on the step).
Returns optimum coefficients and corresponding energ... | [
"def",
"brute_force",
"(",
"step",
")",
":",
"#for the length of for loop\r",
"length",
"=",
"(",
"int",
")",
"(",
"1",
"/",
"step",
")",
"task_numbers",
"=",
"10",
"x",
"=",
"[",
"step",
"]",
"*",
"task_numbers",
"#list contining different set of coefficients\r... | [
110,
0
] | [
205,
26
] | python | en | ['en', 'ja', 'th'] | False |
conditions | (x) |
This function will check whether the constraints that apply to
our optimization are met or not.
|
This function will check whether the constraints that apply to
our optimization are met or not.
| def conditions(x):
"""
This function will check whether the constraints that apply to
our optimization are met or not.
"""
if ( (10/x[0]) > 66.0 ):
return False
elif ( (10/x[0] + 12/x[1]) > 88.0 ):
return False
elif ( (10/x[0] + 12/x[1] + 7/x[2]) > 107.0 ):
... | [
"def",
"conditions",
"(",
"x",
")",
":",
"if",
"(",
"(",
"10",
"/",
"x",
"[",
"0",
"]",
")",
">",
"66.0",
")",
":",
"return",
"False",
"elif",
"(",
"(",
"10",
"/",
"x",
"[",
"0",
"]",
"+",
"12",
"/",
"x",
"[",
"1",
"]",
")",
">",
"88.0"... | [
207,
0
] | [
233,
15
] | python | en | ['en', 'ja', 'th'] | False |
calculate_energy | (x) |
This function takes the DVFS coefficients (as a list named x),
and will calculate the energy consumption for this sequence of
DVFS coefficients that are applied to the task sequence.
|
This function takes the DVFS coefficients (as a list named x),
and will calculate the energy consumption for this sequence of
DVFS coefficients that are applied to the task sequence.
| def calculate_energy(x):
"""
This function takes the DVFS coefficients (as a list named x),
and will calculate the energy consumption for this sequence of
DVFS coefficients that are applied to the task sequence.
"""
# Defining a positive infinite integer
positive_infinity = float... | [
"def",
"calculate_energy",
"(",
"x",
")",
":",
"# Defining a positive infinite integer\r",
"positive_infinity",
"=",
"float",
"(",
"'inf'",
")",
"energy",
"=",
"positive_infinity",
"value",
"=",
"0.0",
"#backslash at the end of the line means the instruction continues to the ne... | [
237,
0
] | [
254,
17
] | python | en | ['en', 'ja', 'th'] | False |
floating_point_chrome_generator | (n) |
Produces chromosomes with floating-point values for each gene. (floating-point alleles)
n: The length of the chromosome to be produced
|
Produces chromosomes with floating-point values for each gene. (floating-point alleles)
n: The length of the chromosome to be produced
| def floating_point_chrome_generator(n):
"""
Produces chromosomes with floating-point values for each gene. (floating-point alleles)
n: The length of the chromosome to be produced
"""
return np.random.uniform(low=0, high=1, size=n).tolist() | [
"def",
"floating_point_chrome_generator",
"(",
"n",
")",
":",
"return",
"np",
".",
"random",
".",
"uniform",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"1",
",",
"size",
"=",
"n",
")",
".",
"tolist",
"(",
")"
] | [
283,
0
] | [
288,
61
] | python | en | ['en', 'ja', 'th'] | False |
fitness_function | (chrom) |
This function, takes a chromosome and returns a value as its fitness.
chrom: The chromosome which its fitness is calculated and returned.
|
This function, takes a chromosome and returns a value as its fitness.
chrom: The chromosome which its fitness is calculated and returned.
| def fitness_function(chrom): #TODO needs to be more generalize and useful
"""
This function, takes a chromosome and returns a value as its fitness.
chrom: The chromosome which its fitness is calculated and returned.
"""
return (1/calculate_energy(chrom)) | [
"def",
"fitness_function",
"(",
"chrom",
")",
":",
"#TODO needs to be more generalize and useful\r",
"return",
"(",
"1",
"/",
"calculate_energy",
"(",
"chrom",
")",
")"
] | [
290,
0
] | [
295,
38
] | python | en | ['en', 'ja', 'th'] | False |
pop_sort | (pop) |
This function sorts the population based on their fitnesses, using selection sort.
pop: The population that are sorted based on their fitnesses.
|
This function sorts the population based on their fitnesses, using selection sort.
pop: The population that are sorted based on their fitnesses.
| def pop_sort(pop):
"""
This function sorts the population based on their fitnesses, using selection sort.
pop: The population that are sorted based on their fitnesses.
"""
for i in range(len(pop)):
min_index = i
for j in range(i+1, len(pop)):
if pop[min_index... | [
"def",
"pop_sort",
"(",
"pop",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"pop",
")",
")",
":",
"min_index",
"=",
"i",
"for",
"j",
"in",
"range",
"(",
"i",
"+",
"1",
",",
"len",
"(",
"pop",
")",
")",
":",
"if",
"pop",
"[",
"min_i... | [
297,
0
] | [
308,
14
] | python | en | ['en', 'ja', 'th'] | False |
find_best_chromosome | (pop) |
This function searches a list of chromosomes and returns the chromosome with the best fitness.
pop: The given list of chromosomes
|
This function searches a list of chromosomes and returns the chromosome with the best fitness.
pop: The given list of chromosomes
| def find_best_chromosome(pop):
"""
This function searches a list of chromosomes and returns the chromosome with the best fitness.
pop: The given list of chromosomes
"""
best_chrom = Chromosome(genes= np.array([0.0]*10), id_=200, fitness = 0.0)
for i in range(len(pop)):
if(pop[... | [
"def",
"find_best_chromosome",
"(",
"pop",
")",
":",
"best_chrom",
"=",
"Chromosome",
"(",
"genes",
"=",
"np",
".",
"array",
"(",
"[",
"0.0",
"]",
"*",
"10",
")",
",",
"id_",
"=",
"200",
",",
"fitness",
"=",
"0.0",
")",
"for",
"i",
"in",
"range",
... | [
311,
0
] | [
321,
21
] | python | en | ['en', 'ja', 'th'] | False |
pop_initialization | (pop_size, chrom_size) |
This function creates a population with the size pop_size, with chrom_size for the size of the chromosomes.
pop_size: Size of the population
chrom_size: Size of each chromosome in the population
|
This function creates a population with the size pop_size, with chrom_size for the size of the chromosomes.
pop_size: Size of the population
chrom_size: Size of each chromosome in the population
| def pop_initialization(pop_size, chrom_size):
"""
This function creates a population with the size pop_size, with chrom_size for the size of the chromosomes.
pop_size: Size of the population
chrom_size: Size of each chromosome in the population
"""
pop = []
for i in range(pop_size)... | [
"def",
"pop_initialization",
"(",
"pop_size",
",",
"chrom_size",
")",
":",
"pop",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"pop_size",
")",
":",
"chrom",
"=",
"floating_point_chrome_generator",
"(",
"chrom_size",
")",
"chrom_fitness",
"=",
"fitness_funct... | [
324,
0
] | [
336,
14
] | python | en | ['en', 'ja', 'th'] | False |
truncation_selection | (selection_size, pop) |
In Truncation Selection, Only the fittest members of the population will be selected
and these individuals will be duplicated to maintain the population.
This function takes a population, and returns the fittest ones inside.
selection_size: Number of individuals to be selected within the population... |
In Truncation Selection, Only the fittest members of the population will be selected
and these individuals will be duplicated to maintain the population.
This function takes a population, and returns the fittest ones inside.
selection_size: Number of individuals to be selected within the population... | def truncation_selection(selection_size, pop):
"""
In Truncation Selection, Only the fittest members of the population will be selected
and these individuals will be duplicated to maintain the population.
This function takes a population, and returns the fittest ones inside.
selection_size: Num... | [
"def",
"truncation_selection",
"(",
"selection_size",
",",
"pop",
")",
":",
"pop_size",
"=",
"len",
"(",
"pop",
")",
"#Size of the population\r",
"sorted_pop",
"=",
"pop_sort",
"(",
"pop",
")",
"select",
"=",
"[",
"]",
"if",
"selection_size",
">",
"pop_size",
... | [
338,
0
] | [
359,
17
] | python | en | ['en', 'ja', 'th'] | False |
heuristic_crossover | (parent_one, parent_two, pc) |
This function takes two parents, and performs Heuristic crossover on them.
parent_one: First parent
parent_two: Second parent
pc: The probability of crossover
|
This function takes two parents, and performs Heuristic crossover on them.
parent_one: First parent
parent_two: Second parent
pc: The probability of crossover
| def heuristic_crossover(parent_one, parent_two, pc):
"""
This function takes two parents, and performs Heuristic crossover on them.
parent_one: First parent
parent_two: Second parent
pc: The probability of crossover
"""
# print("\nParents")
# print("=====================... | [
"def",
"heuristic_crossover",
"(",
"parent_one",
",",
"parent_two",
",",
"pc",
")",
":",
"# print(\"\\nParents\")\r",
"# print(\"=================================================\")\r",
"# Chromosome.describe(parent_one)\r",
"# Chromosome.describe(parent_two)\r",
"chrom_length",
"=",
... | [
363,
0
] | [
391,
20
] | python | en | ['en', 'ja', 'th'] | False |
creep_mutation | (parent_one, pm) |
This function takes one chromosome, and performs Creep mutation on it.
parent_one: The parent
pm: The probability of mutation
|
This function takes one chromosome, and performs Creep mutation on it.
parent_one: The parent
pm: The probability of mutation
| def creep_mutation(parent_one, pm):
"""
This function takes one chromosome, and performs Creep mutation on it.
parent_one: The parent
pm: The probability of mutation
"""
# print("\nParent")
# print("=================================================")
# Chromosome.describe(p... | [
"def",
"creep_mutation",
"(",
"parent_one",
",",
"pm",
")",
":",
"# print(\"\\nParent\")\r",
"# print(\"=================================================\")\r",
"# Chromosome.describe(parent_one)\r",
"chrom_length",
"=",
"Chromosome",
".",
"get_chrom_length",
"(",
"parent_one",
"... | [
394,
0
] | [
419,
20
] | python | en | ['en', 'ja', 'th'] | False |
generation_production | (pop_size, iterations) |
This function produces generation after generation,
to get the DVFS coefficients that sufficiently minimize the energy.
pop_size: The size of initial population given for further optimization.
iterations: The number of iterations that a generation is updated with new offsprings.
|
This function produces generation after generation,
to get the DVFS coefficients that sufficiently minimize the energy.
pop_size: The size of initial population given for further optimization.
iterations: The number of iterations that a generation is updated with new offsprings.
| def generation_production(pop_size, iterations):
"""
This function produces generation after generation,
to get the DVFS coefficients that sufficiently minimize the energy.
pop_size: The size of initial population given for further optimization.
iterations: The number of iterations that a gen... | [
"def",
"generation_production",
"(",
"pop_size",
",",
"iterations",
")",
":",
"pop",
"=",
"pop_initialization",
"(",
"pop_size",
",",
"10",
")",
"#initializing the population\r",
"offsprings",
"=",
"[",
"]",
"# a list containing offsprings produced in crossover and mutation... | [
421,
0
] | [
466,
21
] | python | en | ['en', 'ja', 'th'] | False |
Chromosome.describe | (self) |
Prints the ID, fitness, and genes
|
Prints the ID, fitness, and genes
| def describe(self):
"""
Prints the ID, fitness, and genes
"""
print(f"ID=#{self.id_}, Fitness={self.fitness}, \nGenes=\n{self.genes}") | [
"def",
"describe",
"(",
"self",
")",
":",
"print",
"(",
"f\"ID=#{self.id_}, Fitness={self.fitness}, \\nGenes=\\n{self.genes}\"",
")"
] | [
271,
4
] | [
275,
80
] | python | en | ['en', 'ja', 'th'] | False |
Chromosome.get_chrom_length | (self) |
Returns the length of `self.genes`
|
Returns the length of `self.genes`
| def get_chrom_length(self):
"""
Returns the length of `self.genes`
"""
return len(self.genes) | [
"def",
"get_chrom_length",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"genes",
")"
] | [
277,
4
] | [
281,
30
] | python | en | ['en', 'ja', 'th'] | False |
coerce_host_port | (value) | Validate that provided value is either just host or host:port.
Returns (host, None) or (host, port) respectively.
| Validate that provided value is either just host or host:port. | def coerce_host_port(value):
"""Validate that provided value is either just host or host:port.
Returns (host, None) or (host, port) respectively.
"""
host, _, port = value.partition(":")
if not host:
raise vol.Invalid("host cannot be empty")
if port:
port = cv.port(port)
e... | [
"def",
"coerce_host_port",
"(",
"value",
")",
":",
"host",
",",
"_",
",",
"port",
"=",
"value",
".",
"partition",
"(",
"\":\"",
")",
"if",
"not",
"host",
":",
"raise",
"vol",
".",
"Invalid",
"(",
"\"host cannot be empty\"",
")",
"if",
"port",
":",
"por... | [
32,
0
] | [
47,
21
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up for WeMo devices. | Set up for WeMo devices. | async def async_setup(hass, config):
"""Set up for WeMo devices."""
hass.data[DOMAIN] = {
"config": config.get(DOMAIN, {}),
"registry": None,
"pending": {},
}
if DOMAIN in config:
hass.async_create_task(
hass.config_entries.flow.async_init(
DO... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"\"config\"",
":",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
",",
"\"registry\"",
":",
"None",
",",
"\"pending\"",
... | [
70,
0
] | [
85,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a wemo config entry. | Set up a wemo config entry. | async def async_setup_entry(hass, entry):
"""Set up a wemo config entry."""
config = hass.data[DOMAIN].pop("config")
# Keep track of WeMo device subscriptions for push updates
registry = hass.data[DOMAIN]["registry"] = pywemo.SubscriptionRegistry()
await hass.async_add_executor_job(registry.start)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"config",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"\"config\"",
")",
"# Keep track of WeMo device subscriptions for push updates",
"registry",
"=",
"hass",
".",
"dat... | [
88,
0
] | [
161,
15
] | python | en | ['en', 'pt', 'en'] | True |
validate_static_config | (host, port) | Handle a static config. | Handle a static config. | def validate_static_config(host, port):
"""Handle a static config."""
url = pywemo.setup_url_for_address(host, port)
if not url:
_LOGGER.error(
"Unable to get description url for WeMo at: %s",
f"{host}:{port}" if port else host,
)
return None
try:
... | [
"def",
"validate_static_config",
"(",
"host",
",",
"port",
")",
":",
"url",
"=",
"pywemo",
".",
"setup_url_for_address",
"(",
"host",
",",
"port",
")",
"if",
"not",
"url",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to get description url for WeMo at: %s\"",
",... | [
164,
0
] | [
184,
17
] | python | en | ['en', 'en', 'en'] | True |
gen_salt | (salt) | Generate a random salt. | Generate a random salt. | def gen_salt(salt):
'''Generate a random salt.'''
ret = ''
if not salt:
with open('/dev/urandom', 'rb') as urandom:
while True:
byte = urandom.read(1)
if byte in ('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
'./0123456... | [
"def",
"gen_salt",
"(",
"salt",
")",
":",
"ret",
"=",
"''",
"if",
"not",
"salt",
":",
"with",
"open",
"(",
"'/dev/urandom'",
",",
"'rb'",
")",
"as",
"urandom",
":",
"while",
"True",
":",
"byte",
"=",
"urandom",
".",
"read",
"(",
"1",
")",
"if",
"... | [
7,
0
] | [
21,
29
] | python | en | ['en', 'mt', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up cover(s) for KNX platform. | Set up cover(s) for KNX platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up cover(s) for KNX platform."""
entities = []
for device in hass.data[DOMAIN].xknx.devices:
if isinstance(device, XknxCover):
entities.append(KNXCover(device))
async_add_entities(entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"xknx",
".",
"dev... | [
21,
0
] | [
27,
32
] | python | en | ['en', 'da', 'en'] | True |
KNXCover.__init__ | (self, device: XknxCover) | Initialize the cover. | Initialize the cover. | def __init__(self, device: XknxCover):
"""Initialize the cover."""
super().__init__(device)
self._unsubscribe_auto_updater = None | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"XknxCover",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"_unsubscribe_auto_updater",
"=",
"None"
] | [
33,
4
] | [
37,
45
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.after_update_callback | (self, device) | Call after device was updated. | Call after device was updated. | async def after_update_callback(self, device):
"""Call after device was updated."""
self.async_write_ha_state()
if self._device.is_traveling():
self.start_auto_updater() | [
"async",
"def",
"after_update_callback",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")",
"if",
"self",
".",
"_device",
".",
"is_traveling",
"(",
")",
":",
"self",
".",
"start_auto_updater",
"(",
")"
] | [
40,
4
] | [
44,
37
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
if self._device.supports_angle:
return DEVICE_CLASS_BLIND
return None | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"supports_angle",
":",
"return",
"DEVICE_CLASS_BLIND",
"return",
"None"
] | [
47,
4
] | [
51,
19
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
if self._device.supports_stop:
supported_features |= SUPPORT_STOP
if self._device.supports_angle:
supported_features |= SUPPORT_SE... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE",
"|",
"SUPPORT_SET_POSITION",
"if",
"self",
".",
"_device",
".",
"supports_stop",
":",
"supported_features",
"|=",
"SUPPORT_STOP",
"if",
"self",
".",
... | [
54,
4
] | [
61,
33
] | python | en | ['da', 'en', 'en'] | True |
KNXCover.current_cover_position | (self) | Return the current position of the cover.
None is unknown, 0 is closed, 100 is fully open.
| Return the current position of the cover. | def current_cover_position(self):
"""Return the current position of the cover.
None is unknown, 0 is closed, 100 is fully open.
"""
# In KNX 0 is open, 100 is closed.
try:
return 100 - self._device.current_position()
except TypeError:
return None | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"# In KNX 0 is open, 100 is closed.",
"try",
":",
"return",
"100",
"-",
"self",
".",
"_device",
".",
"current_position",
"(",
")",
"except",
"TypeError",
":",
"return",
"None"
] | [
64,
4
] | [
73,
23
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
return self._device.is_closed() | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"is_closed",
"(",
")"
] | [
76,
4
] | [
78,
39
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return self._device.is_opening() | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"is_opening",
"(",
")"
] | [
81,
4
] | [
83,
40
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return self._device.is_closing() | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"is_closing",
"(",
")"
] | [
86,
4
] | [
88,
40
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs):
"""Close the cover."""
await self._device.set_down() | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set_down",
"(",
")"
] | [
90,
4
] | [
92,
37
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
await self._device.set_up() | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set_up",
"(",
")"
] | [
94,
4
] | [
96,
35
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
knx_position = 100 - kwargs[ATTR_POSITION]
await self._device.set_position(knx_position) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"knx_position",
"=",
"100",
"-",
"kwargs",
"[",
"ATTR_POSITION",
"]",
"await",
"self",
".",
"_device",
".",
"set_position",
"(",
"knx_position",
")"
] | [
98,
4
] | [
101,
53
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
await self._device.stop()
self.stop_auto_updater() | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"stop",
"(",
")",
"self",
".",
"stop_auto_updater",
"(",
")"
] | [
103,
4
] | [
106,
32
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.current_cover_tilt_position | (self) | Return current tilt position of cover. | Return current tilt position of cover. | def current_cover_tilt_position(self):
"""Return current tilt position of cover."""
if not self._device.supports_angle:
return None
try:
return 100 - self._device.current_angle()
except TypeError:
return None | [
"def",
"current_cover_tilt_position",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"supports_angle",
":",
"return",
"None",
"try",
":",
"return",
"100",
"-",
"self",
".",
"_device",
".",
"current_angle",
"(",
")",
"except",
"TypeError",
... | [
109,
4
] | [
116,
23
] | python | en | ['en', 'da', 'en'] | True |
KNXCover.async_set_cover_tilt_position | (self, **kwargs) | Move the cover tilt to a specific position. | Move the cover tilt to a specific position. | async def async_set_cover_tilt_position(self, **kwargs):
"""Move the cover tilt to a specific position."""
knx_tilt_position = 100 - kwargs[ATTR_TILT_POSITION]
await self._device.set_angle(knx_tilt_position) | [
"async",
"def",
"async_set_cover_tilt_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"knx_tilt_position",
"=",
"100",
"-",
"kwargs",
"[",
"ATTR_TILT_POSITION",
"]",
"await",
"self",
".",
"_device",
".",
"set_angle",
"(",
"knx_tilt_position",
")"
] | [
118,
4
] | [
121,
55
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.start_auto_updater | (self) | Start the autoupdater to update Home Assistant while cover is moving. | Start the autoupdater to update Home Assistant while cover is moving. | def start_auto_updater(self):
"""Start the autoupdater to update Home Assistant while cover is moving."""
if self._unsubscribe_auto_updater is None:
self._unsubscribe_auto_updater = async_track_utc_time_change(
self.hass, self.auto_updater_hook
) | [
"def",
"start_auto_updater",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unsubscribe_auto_updater",
"is",
"None",
":",
"self",
".",
"_unsubscribe_auto_updater",
"=",
"async_track_utc_time_change",
"(",
"self",
".",
"hass",
",",
"self",
".",
"auto_updater_hook",
")... | [
123,
4
] | [
128,
13
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.stop_auto_updater | (self) | Stop the autoupdater. | Stop the autoupdater. | def stop_auto_updater(self):
"""Stop the autoupdater."""
if self._unsubscribe_auto_updater is not None:
self._unsubscribe_auto_updater()
self._unsubscribe_auto_updater = None | [
"def",
"stop_auto_updater",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unsubscribe_auto_updater",
"is",
"not",
"None",
":",
"self",
".",
"_unsubscribe_auto_updater",
"(",
")",
"self",
".",
"_unsubscribe_auto_updater",
"=",
"None"
] | [
130,
4
] | [
134,
49
] | python | en | ['en', 'en', 'en'] | True |
KNXCover.auto_updater_hook | (self, now) | Call for the autoupdater. | Call for the autoupdater. | def auto_updater_hook(self, now):
"""Call for the autoupdater."""
self.async_write_ha_state()
if self._device.position_reached():
self.stop_auto_updater()
self.hass.add_job(self._device.auto_stop_if_necessary()) | [
"def",
"auto_updater_hook",
"(",
"self",
",",
"now",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")",
"if",
"self",
".",
"_device",
".",
"position_reached",
"(",
")",
":",
"self",
".",
"stop_auto_updater",
"(",
")",
"self",
".",
"hass",
".",
"add... | [
137,
4
] | [
143,
64
] | python | en | ['en', 'en', 'en'] | True |
test_validate_entity_config | () | Test validate entities. | Test validate entities. | def test_validate_entity_config():
"""Test validate entities."""
configs = [
None,
[],
"string",
12345,
{"invalid_entity_id": {}},
{"demo.test": 1},
{"binary_sensor.demo": {CONF_LINKED_BATTERY_SENSOR: None}},
{"binary_sensor.demo": {CONF_LINKED_BAT... | [
"def",
"test_validate_entity_config",
"(",
")",
":",
"configs",
"=",
"[",
"None",
",",
"[",
"]",
",",
"\"string\"",
",",
"12345",
",",
"{",
"\"invalid_entity_id\"",
":",
"{",
"}",
"}",
",",
"{",
"\"demo.test\"",
":",
"1",
"}",
",",
"{",
"\"binary_sensor.... | [
59,
0
] | [
156,
5
] | python | et | ['nl', 'et', 'it'] | False |
test_validate_media_player_features | () | Test validate modes for media players. | Test validate modes for media players. | def test_validate_media_player_features():
"""Test validate modes for media players."""
config = {}
attrs = {ATTR_SUPPORTED_FEATURES: 20873}
entity_state = State("media_player.demo", "on", attrs)
assert validate_media_player_features(entity_state, config) is True
config = {FEATURE_ON_OFF: None}... | [
"def",
"test_validate_media_player_features",
"(",
")",
":",
"config",
"=",
"{",
"}",
"attrs",
"=",
"{",
"ATTR_SUPPORTED_FEATURES",
":",
"20873",
"}",
"entity_state",
"=",
"State",
"(",
"\"media_player.demo\"",
",",
"\"on\"",
",",
"attrs",
")",
"assert",
"valida... | [
159,
0
] | [
170,
72
] | python | en | ['en', 'en', 'en'] | True |
test_convert_to_float | () | Test convert_to_float method. | Test convert_to_float method. | def test_convert_to_float():
"""Test convert_to_float method."""
assert convert_to_float(12) == 12
assert convert_to_float(12.4) == 12.4
assert convert_to_float(STATE_UNKNOWN) is None
assert convert_to_float(None) is None | [
"def",
"test_convert_to_float",
"(",
")",
":",
"assert",
"convert_to_float",
"(",
"12",
")",
"==",
"12",
"assert",
"convert_to_float",
"(",
"12.4",
")",
"==",
"12.4",
"assert",
"convert_to_float",
"(",
"STATE_UNKNOWN",
")",
"is",
"None",
"assert",
"convert_to_fl... | [
173,
0
] | [
178,
41
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_name_for_homekit | () | Ensure name sanitize works as expected. | Ensure name sanitize works as expected. | def test_cleanup_name_for_homekit():
"""Ensure name sanitize works as expected."""
assert cleanup_name_for_homekit("abc") == "abc"
assert cleanup_name_for_homekit("a b c") == "a b c"
assert cleanup_name_for_homekit("ab_c") == "ab c"
assert (
cleanup_name_for_homekit('ab!@#$%^&*()-=":.,><?//... | [
"def",
"test_cleanup_name_for_homekit",
"(",
")",
":",
"assert",
"cleanup_name_for_homekit",
"(",
"\"abc\"",
")",
"==",
"\"abc\"",
"assert",
"cleanup_name_for_homekit",
"(",
"\"a b c\"",
")",
"==",
"\"a b c\"",
"assert",
"cleanup_name_for_homekit",
"(",
"\"ab_c\"",
")",... | [
181,
0
] | [
191,
101
] | python | en | ['en', 'en', 'en'] | True |
test_temperature_to_homekit | () | Test temperature conversion from HA to HomeKit. | Test temperature conversion from HA to HomeKit. | def test_temperature_to_homekit():
"""Test temperature conversion from HA to HomeKit."""
assert temperature_to_homekit(20.46, TEMP_CELSIUS) == 20.5
assert temperature_to_homekit(92.1, TEMP_FAHRENHEIT) == 33.4 | [
"def",
"test_temperature_to_homekit",
"(",
")",
":",
"assert",
"temperature_to_homekit",
"(",
"20.46",
",",
"TEMP_CELSIUS",
")",
"==",
"20.5",
"assert",
"temperature_to_homekit",
"(",
"92.1",
",",
"TEMP_FAHRENHEIT",
")",
"==",
"33.4"
] | [
194,
0
] | [
197,
64
] | python | en | ['en', 'en', 'en'] | True |
test_temperature_to_states | () | Test temperature conversion from HomeKit to HA. | Test temperature conversion from HomeKit to HA. | def test_temperature_to_states():
"""Test temperature conversion from HomeKit to HA."""
assert temperature_to_states(20, TEMP_CELSIUS) == 20.0
assert temperature_to_states(20.2, TEMP_FAHRENHEIT) == 68.5 | [
"def",
"test_temperature_to_states",
"(",
")",
":",
"assert",
"temperature_to_states",
"(",
"20",
",",
"TEMP_CELSIUS",
")",
"==",
"20.0",
"assert",
"temperature_to_states",
"(",
"20.2",
",",
"TEMP_FAHRENHEIT",
")",
"==",
"68.5"
] | [
200,
0
] | [
203,
63
] | python | en | ['en', 'en', 'en'] | True |
test_density_to_air_quality | () | Test map PM2.5 density to HomeKit AirQuality level. | Test map PM2.5 density to HomeKit AirQuality level. | def test_density_to_air_quality():
"""Test map PM2.5 density to HomeKit AirQuality level."""
assert density_to_air_quality(0) == 1
assert density_to_air_quality(35) == 1
assert density_to_air_quality(35.1) == 2
assert density_to_air_quality(75) == 2
assert density_to_air_quality(115) == 3
as... | [
"def",
"test_density_to_air_quality",
"(",
")",
":",
"assert",
"density_to_air_quality",
"(",
"0",
")",
"==",
"1",
"assert",
"density_to_air_quality",
"(",
"35",
")",
"==",
"1",
"assert",
"density_to_air_quality",
"(",
"35.1",
")",
"==",
"2",
"assert",
"density_... | [
206,
0
] | [
214,
43
] | python | en | ['en', 'en', 'en'] | True |
test_show_setup_msg | (hass, hk_driver) | Test show setup message as persistence notification. | Test show setup message as persistence notification. | async def test_show_setup_msg(hass, hk_driver):
"""Test show setup message as persistence notification."""
pincode = b"123-45-678"
entry = await async_init_integration(hass)
assert entry
call_create_notification = async_mock_service(
hass, PERSISTENT_NOTIFICATION_DOMAIN, "create"
)
... | [
"async",
"def",
"test_show_setup_msg",
"(",
"hass",
",",
"hk_driver",
")",
":",
"pincode",
"=",
"b\"123-45-678\"",
"entry",
"=",
"await",
"async_init_integration",
"(",
"hass",
")",
"assert",
"entry",
"call_create_notification",
"=",
"async_mock_service",
"(",
"hass... | [
217,
0
] | [
237,
77
] | python | en | ['en', 'en', 'en'] | True |
test_dismiss_setup_msg | (hass) | Test dismiss setup message. | Test dismiss setup message. | async def test_dismiss_setup_msg(hass):
"""Test dismiss setup message."""
call_dismiss_notification = async_mock_service(
hass, PERSISTENT_NOTIFICATION_DOMAIN, "dismiss"
)
await hass.async_add_executor_job(dismiss_setup_message, hass, "entry_id")
await hass.async_block_till_done()
asse... | [
"async",
"def",
"test_dismiss_setup_msg",
"(",
"hass",
")",
":",
"call_dismiss_notification",
"=",
"async_mock_service",
"(",
"hass",
",",
"PERSISTENT_NOTIFICATION_DOMAIN",
",",
"\"dismiss\"",
")",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"dismiss_setup_messag... | [
240,
0
] | [
250,
80
] | python | en | ['en', 'da', 'en'] | True |
test_homekit_speed_mapping | () | Test if the SpeedRanges from a speed_list are as expected. | Test if the SpeedRanges from a speed_list are as expected. | def test_homekit_speed_mapping():
"""Test if the SpeedRanges from a speed_list are as expected."""
# A standard 2-speed fan
speed_mapping = HomeKitSpeedMapping(["off", "low", "high"])
assert speed_mapping.speed_ranges == {
"off": SpeedRange(0, 0),
"low": SpeedRange(100 / 3, 50),
... | [
"def",
"test_homekit_speed_mapping",
"(",
")",
":",
"# A standard 2-speed fan",
"speed_mapping",
"=",
"HomeKitSpeedMapping",
"(",
"[",
"\"off\"",
",",
"\"low\"",
",",
"\"high\"",
"]",
")",
"assert",
"speed_mapping",
".",
"speed_ranges",
"==",
"{",
"\"off\"",
":",
... | [
253,
0
] | [
285,
5
] | python | en | ['en', 'en', 'en'] | True |
test_speed_to_homekit | () | Test speed conversion from HA to Homekit. | Test speed conversion from HA to Homekit. | def test_speed_to_homekit():
"""Test speed conversion from HA to Homekit."""
speed_mapping = HomeKitSpeedMapping(["off", "low", "high"])
assert speed_mapping.speed_to_homekit(None) is None
assert speed_mapping.speed_to_homekit("off") == 0
assert speed_mapping.speed_to_homekit("low") == 50
assert... | [
"def",
"test_speed_to_homekit",
"(",
")",
":",
"speed_mapping",
"=",
"HomeKitSpeedMapping",
"(",
"[",
"\"off\"",
",",
"\"low\"",
",",
"\"high\"",
"]",
")",
"assert",
"speed_mapping",
".",
"speed_to_homekit",
"(",
"None",
")",
"is",
"None",
"assert",
"speed_mappi... | [
288,
0
] | [
294,
56
] | 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.