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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SwitchBot.assumed_state | (self) | Return true if unable to access real state of entity. | Return true if unable to access real state of entity. | def assumed_state(self) -> bool:
"""Return true if unable to access real state of entity."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
68,
4
] | [
70,
19
] | python | en | ['en', 'en', 'en'] | True |
SwitchBot.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self) -> bool:
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
73,
4
] | [
75,
26
] | python | en | ['en', 'fy', 'en'] | True |
SwitchBot.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self) -> str:
"""Return a unique, Home Assistant friendly identifier for this entity."""
return self._mac.replace(":", "") | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac",
".",
"replace",
"(",
"\":\"",
",",
"\"\"",
")"
] | [
78,
4
] | [
80,
41
] | python | en | ['en', 'en', 'en'] | True |
SwitchBot.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self) -> str:
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
83,
4
] | [
85,
25
] | python | en | ['en', 'en', 'en'] | True |
SwitchBot.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self) -> Dict[str, Any]:
"""Return the state attributes."""
return {"last_run_success": self._last_run_success} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"last_run_success\"",
":",
"self",
".",
"_last_run_success",
"}"
] | [
88,
4
] | [
90,
59
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_state | (hass) | Test sensor state data. | Test sensor state data. | async def test_sensor_state(hass):
"""Test sensor state data."""
await init_integration(hass)
test_glucose_sensor = hass.states.get("sensor.blood_sugar")
assert test_glucose_sensor.state == str(
GLUCOSE_READINGS[0].sgv # pylint: disable=maybe-no-member
) | [
"async",
"def",
"test_sensor_state",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
")",
"test_glucose_sensor",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.blood_sugar\"",
")",
"assert",
"test_glucose_sensor",
".",
"state",
"==",
"st... | [
18,
0
] | [
25,
5
] | python | en | ['fr', 'no', 'en'] | False |
test_sensor_error | (hass) | Test sensor state data. | Test sensor state data. | async def test_sensor_error(hass):
"""Test sensor state data."""
await init_integration_unavailable(hass)
test_glucose_sensor = hass.states.get("sensor.blood_sugar")
assert test_glucose_sensor.state == STATE_UNAVAILABLE | [
"async",
"def",
"test_sensor_error",
"(",
"hass",
")",
":",
"await",
"init_integration_unavailable",
"(",
"hass",
")",
"test_glucose_sensor",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.blood_sugar\"",
")",
"assert",
"test_glucose_sensor",
".",
"state",
... | [
28,
0
] | [
33,
57
] | python | en | ['fr', 'no', 'en'] | False |
test_sensor_empty_response | (hass) | Test sensor state data. | Test sensor state data. | async def test_sensor_empty_response(hass):
"""Test sensor state data."""
await init_integration_empty_response(hass)
test_glucose_sensor = hass.states.get("sensor.blood_sugar")
assert test_glucose_sensor.state == STATE_UNAVAILABLE | [
"async",
"def",
"test_sensor_empty_response",
"(",
"hass",
")",
":",
"await",
"init_integration_empty_response",
"(",
"hass",
")",
"test_glucose_sensor",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.blood_sugar\"",
")",
"assert",
"test_glucose_sensor",
".",
... | [
36,
0
] | [
41,
57
] | python | en | ['fr', 'no', 'en'] | False |
test_sensor_attributes | (hass) | Test sensor attributes. | Test sensor attributes. | async def test_sensor_attributes(hass):
"""Test sensor attributes."""
await init_integration(hass)
test_glucose_sensor = hass.states.get("sensor.blood_sugar")
reading = GLUCOSE_READINGS[0]
assert reading is not None
attr = test_glucose_sensor.attributes
assert attr[ATTR_DATE] == reading.da... | [
"async",
"def",
"test_sensor_attributes",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
")",
"test_glucose_sensor",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.blood_sugar\"",
")",
"reading",
"=",
"GLUCOSE_READINGS",
"[",
"0",
"]",
... | [
44,
0
] | [
57,
54
] | python | en | ['sv', 'mt', 'en'] | False |
mock_responses | (mock) | Mock responses for Efergy. | Mock responses for Efergy. | def mock_responses(mock):
"""Mock responses for Efergy."""
base_url = "https://engage.efergy.com/mobile_proxy/"
mock.get(
f"{base_url}getInstant?token={token}",
text=load_fixture("efergy_instant.json"),
)
mock.get(
f"{base_url}getEnergy?token={token}&offset=300&period=day",
... | [
"def",
"mock_responses",
"(",
"mock",
")",
":",
"base_url",
"=",
"\"https://engage.efergy.com/mobile_proxy/\"",
"mock",
".",
"get",
"(",
"f\"{base_url}getInstant?token={token}\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"efergy_instant.json\"",
")",
",",
")",
"mock",
... | [
30,
0
] | [
56,
5
] | python | en | ['en', 'no', 'en'] | True |
test_single_sensor_readings | (hass, requests_mock) | Test for successfully setting up the Efergy platform. | Test for successfully setting up the Efergy platform. | async def test_single_sensor_readings(hass, requests_mock):
"""Test for successfully setting up the Efergy platform."""
mock_responses(requests_mock)
assert await async_setup_component(hass, "sensor", {"sensor": ONE_SENSOR_CONFIG})
await hass.async_block_till_done()
assert "38.21" == hass.states.ge... | [
"async",
"def",
"test_single_sensor_readings",
"(",
"hass",
",",
"requests_mock",
")",
":",
"mock_responses",
"(",
"requests_mock",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"ONE_SENSOR_CONFIG",
"}"... | [
59,
0
] | [
69,
66
] | python | en | ['en', 'en', 'en'] | True |
test_multi_sensor_readings | (hass, requests_mock) | Test for multiple sensors in one household. | Test for multiple sensors in one household. | async def test_multi_sensor_readings(hass, requests_mock):
"""Test for multiple sensors in one household."""
mock_responses(requests_mock)
assert await async_setup_component(hass, "sensor", {"sensor": MULTI_SENSOR_CONFIG})
await hass.async_block_till_done()
assert "218" == hass.states.get("sensor.e... | [
"async",
"def",
"test_multi_sensor_readings",
"(",
"hass",
",",
"requests_mock",
")",
":",
"mock_responses",
"(",
"requests_mock",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"MULTI_SENSOR_CONFIG",
"}... | [
72,
0
] | [
80,
65
] | python | en | ['en', 'no', 'en'] | True |
is_media_source_id | (media_content_id: str) | Test if identifier is a media source. | Test if identifier is a media source. | def is_media_source_id(media_content_id: str):
"""Test if identifier is a media source."""
return URI_SCHEME_REGEX.match(media_content_id) is not None | [
"def",
"is_media_source_id",
"(",
"media_content_id",
":",
"str",
")",
":",
"return",
"URI_SCHEME_REGEX",
".",
"match",
"(",
"media_content_id",
")",
"is",
"not",
"None"
] | [
21,
0
] | [
23,
63
] | python | en | ['en', 'fy', 'en'] | True |
generate_media_source_id | (domain: str, identifier: str) | Generate a media source ID. | Generate a media source ID. | def generate_media_source_id(domain: str, identifier: str) -> str:
"""Generate a media source ID."""
uri = f"{URI_SCHEME}{domain or ''}"
if identifier:
uri += f"/{identifier}"
return uri | [
"def",
"generate_media_source_id",
"(",
"domain",
":",
"str",
",",
"identifier",
":",
"str",
")",
"->",
"str",
":",
"uri",
"=",
"f\"{URI_SCHEME}{domain or ''}\"",
"if",
"identifier",
":",
"uri",
"+=",
"f\"/{identifier}\"",
"return",
"uri"
] | [
26,
0
] | [
31,
14
] | python | en | ['en', 'co', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the media_source component. | Set up the media_source component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the media_source component."""
hass.data[DOMAIN] = {}
hass.components.websocket_api.async_register_command(websocket_browse_media)
hass.components.websocket_api.async_register_command(websocket_resolve_media)
hass.components.fronten... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"hass",
".",
"components",
".",
"websocket_api",
".",
"async_register_command",
"(",
"websocket_... | [
34,
0
] | [
46,
15
] | python | en | ['en', 'en', 'en'] | True |
_process_media_source_platform | (hass, domain, platform) | Process a media source platform. | Process a media source platform. | async def _process_media_source_platform(hass, domain, platform):
"""Process a media source platform."""
hass.data[DOMAIN][domain] = await platform.async_get_media_source(hass) | [
"async",
"def",
"_process_media_source_platform",
"(",
"hass",
",",
"domain",
",",
"platform",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"domain",
"]",
"=",
"await",
"platform",
".",
"async_get_media_source",
"(",
"hass",
")"
] | [
49,
0
] | [
51,
75
] | python | en | ['en', 'lv', 'en'] | True |
_get_media_item | (
hass: HomeAssistant, media_content_id: Optional[str]
) | Return media item. | Return media item. | def _get_media_item(
hass: HomeAssistant, media_content_id: Optional[str]
) -> models.MediaSourceItem:
"""Return media item."""
if media_content_id:
return models.MediaSourceItem.from_uri(hass, media_content_id)
# We default to our own domain if its only one registered
domain = None if len(... | [
"def",
"_get_media_item",
"(",
"hass",
":",
"HomeAssistant",
",",
"media_content_id",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"models",
".",
"MediaSourceItem",
":",
"if",
"media_content_id",
":",
"return",
"models",
".",
"MediaSourceItem",
".",
"from_uri",
... | [
55,
0
] | [
64,
51
] | python | en | ['en', 'et', 'en'] | True |
async_browse_media | (
hass: HomeAssistant, media_content_id: str
) | Return media player browse media results. | Return media player browse media results. | async def async_browse_media(
hass: HomeAssistant, media_content_id: str
) -> models.BrowseMediaSource:
"""Return media player browse media results."""
return await _get_media_item(hass, media_content_id).async_browse() | [
"async",
"def",
"async_browse_media",
"(",
"hass",
":",
"HomeAssistant",
",",
"media_content_id",
":",
"str",
")",
"->",
"models",
".",
"BrowseMediaSource",
":",
"return",
"await",
"_get_media_item",
"(",
"hass",
",",
"media_content_id",
")",
".",
"async_browse",
... | [
68,
0
] | [
72,
71
] | python | en | ['en', 'en', 'en'] | True |
async_resolve_media | (
hass: HomeAssistant, media_content_id: str
) | Get info to play media. | Get info to play media. | async def async_resolve_media(
hass: HomeAssistant, media_content_id: str
) -> models.PlayMedia:
"""Get info to play media."""
return await _get_media_item(hass, media_content_id).async_resolve() | [
"async",
"def",
"async_resolve_media",
"(",
"hass",
":",
"HomeAssistant",
",",
"media_content_id",
":",
"str",
")",
"->",
"models",
".",
"PlayMedia",
":",
"return",
"await",
"_get_media_item",
"(",
"hass",
",",
"media_content_id",
")",
".",
"async_resolve",
"(",... | [
76,
0
] | [
80,
72
] | python | en | ['en', 'en', 'en'] | True |
websocket_browse_media | (hass, connection, msg) | Browse available media. | Browse available media. | async def websocket_browse_media(hass, connection, msg):
"""Browse available media."""
try:
media = await async_browse_media(hass, msg.get("media_content_id"))
connection.send_result(
msg["id"],
media.as_dict(),
)
except BrowseError as err:
connection.... | [
"async",
"def",
"websocket_browse_media",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"try",
":",
"media",
"=",
"await",
"async_browse_media",
"(",
"hass",
",",
"msg",
".",
"get",
"(",
"\"media_content_id\"",
")",
")",
"connection",
".",
"send_resu... | [
90,
0
] | [
99,
73
] | python | en | ['fr', 'en', 'en'] | True |
websocket_resolve_media | (hass, connection, msg) | Resolve media. | Resolve media. | async def websocket_resolve_media(hass, connection, msg):
"""Resolve media."""
try:
media = await async_resolve_media(hass, msg["media_content_id"])
url = media.url
except Unresolvable as err:
connection.send_error(msg["id"], "resolve_media_failed", str(err))
else:
if url... | [
"async",
"def",
"websocket_resolve_media",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"try",
":",
"media",
"=",
"await",
"async_resolve_media",
"(",
"hass",
",",
"msg",
"[",
"\"media_content_id\"",
"]",
")",
"url",
"=",
"media",
".",
"url",
"exc... | [
110,
0
] | [
126,
85
] | python | en | ['et', 'sv', 'en'] | False |
async_setup | (hass, config) | Initialize the DuckDNS component. | Initialize the DuckDNS component. | async def async_setup(hass, config):
"""Initialize the DuckDNS component."""
domain = config[DOMAIN][CONF_DOMAIN]
token = config[DOMAIN][CONF_ACCESS_TOKEN]
session = async_get_clientsession(hass)
async def update_domain_interval(_now):
"""Update the DuckDNS entry."""
return await _u... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"domain",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_DOMAIN",
"]",
"token",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_ACCESS_TOKEN",
"]",
"session",
"=",
"async_get_clientsession",
... | [
42,
0
] | [
69,
15
] | python | en | ['en', 'en', 'en'] | True |
_update_duckdns | (session, domain, token, *, txt=_SENTINEL, clear=False) | Update DuckDNS. | Update DuckDNS. | async def _update_duckdns(session, domain, token, *, txt=_SENTINEL, clear=False):
"""Update DuckDNS."""
params = {"domains": domain, "token": token}
if txt is not _SENTINEL:
if txt is None:
# Pass in empty txt value to indicate it's clearing txt record
params["txt"] = ""
... | [
"async",
"def",
"_update_duckdns",
"(",
"session",
",",
"domain",
",",
"token",
",",
"*",
",",
"txt",
"=",
"_SENTINEL",
",",
"clear",
"=",
"False",
")",
":",
"params",
"=",
"{",
"\"domains\"",
":",
"domain",
",",
"\"token\"",
":",
"token",
"}",
"if",
... | [
75,
0
] | [
97,
15
] | python | en | ['en', 'de', 'en'] | False |
async_track_time_interval_backoff | (hass, action, intervals) | Add a listener that fires repetitively at every timedelta interval. | Add a listener that fires repetitively at every timedelta interval. | def async_track_time_interval_backoff(hass, action, intervals) -> CALLBACK_TYPE:
"""Add a listener that fires repetitively at every timedelta interval."""
if not iscoroutinefunction:
_LOGGER.error("action needs to be a coroutine and return True/False")
return
if not isinstance(intervals, (l... | [
"def",
"async_track_time_interval_backoff",
"(",
"hass",
",",
"action",
",",
"intervals",
")",
"->",
"CALLBACK_TYPE",
":",
"if",
"not",
"iscoroutinefunction",
":",
"_LOGGER",
".",
"error",
"(",
"\"action needs to be a coroutine and return True/False\"",
")",
"return",
"... | [
102,
0
] | [
131,
26
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass, config_entry, async_add_entities, discovery_info=None
) | Set up the Agent DVR Alarm Control Panels. | Set up the Agent DVR Alarm Control Panels. | async def async_setup_entry(
hass, config_entry, async_add_entities, discovery_info=None
):
"""Set up the Agent DVR Alarm Control Panels."""
async_add_entities(
[AgentBaseStation(hass.data[AGENT_DOMAIN][config_entry.entry_id][CONNECTION])]
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"AgentBaseStation",
"(",
"hass",
".",
"data",
"[",
"AGENT_DOMAIN",
"]",
"[",
"config_e... | [
25,
0
] | [
31,
5
] | python | en | ['en', 'fr', 'en'] | True |
AgentBaseStation.__init__ | (self, client) | Initialize the alarm control panel. | Initialize the alarm control panel. | def __init__(self, client):
"""Initialize the alarm control panel."""
self._state = None
self._client = client
self._unique_id = f"{client.unique}_CP"
name = CONST_ALARM_CONTROL_PANEL_NAME
self._name = name = f"{client.name} {name}" | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_unique_id",
"=",
"f\"{client.unique}_CP\"",
"name",
"=",
"CONST_ALARM_CONTROL_PANEL_NAME",
"self",
".",
"_name",
... | [
37,
4
] | [
43,
51
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.icon | (self) | Return icon. | Return icon. | def icon(self):
"""Return icon."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
46,
4
] | [
48,
19
] | python | en | ['en', 'la', 'en'] | False |
AgentBaseStation.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
51,
4
] | [
53,
26
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_ARM_NIGHT"
] | [
56,
4
] | [
58,
88
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.device_info | (self) | Return the device info for adding the entity to the agent object. | Return the device info for adding the entity to the agent object. | def device_info(self):
"""Return the device info for adding the entity to the agent object."""
return {
"identifiers": {(AGENT_DOMAIN, self._client.unique)},
"manufacturer": "Agent",
"model": CONST_ALARM_CONTROL_PANEL_NAME,
"sw_version": self._client.versi... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"AGENT_DOMAIN",
",",
"self",
".",
"_client",
".",
"unique",
")",
"}",
",",
"\"manufacturer\"",
":",
"\"Agent\"",
",",
"\"model\"",
":",
"CONST_ALARM_CONTROL_PANEL_NAM... | [
61,
4
] | [
68,
9
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.async_update | (self) | Update the state of the device. | Update the state of the device. | async def async_update(self):
"""Update the state of the device."""
await self._client.update()
armed = self._client.is_armed
if armed is None:
self._state = None
return
if armed:
prof = (await self._client.get_active_profile()).lower()
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_client",
".",
"update",
"(",
")",
"armed",
"=",
"self",
".",
"_client",
".",
"is_armed",
"if",
"armed",
"is",
"None",
":",
"self",
".",
"_state",
"=",
"None",
"return",
"i... | [
70,
4
] | [
85,
46
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
await self._client.disarm()
self._state = STATE_ALARM_DISARMED | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"disarm",
"(",
")",
"self",
".",
"_state",
"=",
"STATE_ALARM_DISARMED"
] | [
87,
4
] | [
90,
42
] | python | en | ['en', 'pt', 'en'] | True |
AgentBaseStation.async_alarm_arm_away | (self, code=None) | Send arm away command. Uses custom mode. | Send arm away command. Uses custom mode. | async def async_alarm_arm_away(self, code=None):
"""Send arm away command. Uses custom mode."""
await self._client.arm()
await self._client.set_active_profile(CONF_AWAY_MODE_NAME)
self._state = STATE_ALARM_ARMED_AWAY | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"arm",
"(",
")",
"await",
"self",
".",
"_client",
".",
"set_active_profile",
"(",
"CONF_AWAY_MODE_NAME",
")",
"self",
".",
"_stat... | [
92,
4
] | [
96,
44
] | python | en | ['en', 'pt', 'en'] | True |
AgentBaseStation.async_alarm_arm_home | (self, code=None) | Send arm home command. Uses custom mode. | Send arm home command. Uses custom mode. | async def async_alarm_arm_home(self, code=None):
"""Send arm home command. Uses custom mode."""
await self._client.arm()
await self._client.set_active_profile(CONF_HOME_MODE_NAME)
self._state = STATE_ALARM_ARMED_HOME | [
"async",
"def",
"async_alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"arm",
"(",
")",
"await",
"self",
".",
"_client",
".",
"set_active_profile",
"(",
"CONF_HOME_MODE_NAME",
")",
"self",
".",
"_stat... | [
98,
4
] | [
102,
44
] | python | en | ['en', 'pt', 'en'] | True |
AgentBaseStation.async_alarm_arm_night | (self, code=None) | Send arm night command. Uses custom mode. | Send arm night command. Uses custom mode. | async def async_alarm_arm_night(self, code=None):
"""Send arm night command. Uses custom mode."""
await self._client.arm()
await self._client.set_active_profile(CONF_NIGHT_MODE_NAME)
self._state = STATE_ALARM_ARMED_NIGHT | [
"async",
"def",
"async_alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"arm",
"(",
")",
"await",
"self",
".",
"_client",
".",
"set_active_profile",
"(",
"CONF_NIGHT_MODE_NAME",
")",
"self",
".",
"_st... | [
104,
4
] | [
108,
45
] | python | en | ['en', 'pt', 'en'] | True |
AgentBaseStation.name | (self) | Return the name of the base station. | Return the name of the base station. | def name(self):
"""Return the name of the base station."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
111,
4
] | [
113,
25
] | python | en | ['en', 'en', 'en'] | True |
AgentBaseStation.available | (self) | Device available. | Device available. | def available(self) -> bool:
"""Device available."""
return self._client.is_available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_client",
".",
"is_available"
] | [
116,
4
] | [
118,
40
] | python | en | ['fr', 'en', 'en'] | False |
AgentBaseStation.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
121,
4
] | [
123,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) | Set up the Tado climate platform. | Set up the Tado climate platform. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
):
"""Set up the Tado climate platform."""
tado = hass.data[DOMAIN][entry.entry_id][DATA]
entities = await hass.async_add_executor_job(_generate_entities, tado)
platform = entity_platform.current_platform.get(... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"tado",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"DATA",
"]",
"en... | [
66,
0
] | [
83,
42
] | python | en | ['en', 'pt', 'en'] | True |
_generate_entities | (tado) | Create all climate entities. | Create all climate entities. | def _generate_entities(tado):
"""Create all climate entities."""
entities = []
for zone in tado.zones:
if zone["type"] in [TYPE_HEATING, TYPE_AIR_CONDITIONING]:
entity = create_climate_entity(
tado, zone["name"], zone["id"], zone["devices"][0]
)
if... | [
"def",
"_generate_entities",
"(",
"tado",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"zone",
"in",
"tado",
".",
"zones",
":",
"if",
"zone",
"[",
"\"type\"",
"]",
"in",
"[",
"TYPE_HEATING",
",",
"TYPE_AIR_CONDITIONING",
"]",
":",
"entity",
"=",
"create_c... | [
86,
0
] | [
96,
19
] | python | en | ['en', 'en', 'en'] | True |
create_climate_entity | (tado, name: str, zone_id: int, zone: dict) | Create a Tado climate entity. | Create a Tado climate entity. | def create_climate_entity(tado, name: str, zone_id: int, zone: dict):
"""Create a Tado climate entity."""
capabilities = tado.get_capabilities(zone_id)
_LOGGER.debug("Capabilities for zone %s: %s", zone_id, capabilities)
zone_type = capabilities["type"]
support_flags = SUPPORT_PRESET_MODE | SUPPORT... | [
"def",
"create_climate_entity",
"(",
"tado",
",",
"name",
":",
"str",
",",
"zone_id",
":",
"int",
",",
"zone",
":",
"dict",
")",
":",
"capabilities",
"=",
"tado",
".",
"get_capabilities",
"(",
"zone_id",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Capabilities f... | [
99,
0
] | [
184,
17
] | python | en | ['es', 'sm', 'en'] | False |
TadoClimate.__init__ | (
self,
tado,
zone_name,
zone_id,
zone_type,
heat_min_temp,
heat_max_temp,
heat_step,
cool_min_temp,
cool_max_temp,
cool_step,
supported_hvac_modes,
supported_fan_modes,
support_flags,
device_info,
... | Initialize of Tado climate entity. | Initialize of Tado climate entity. | def __init__(
self,
tado,
zone_name,
zone_id,
zone_type,
heat_min_temp,
heat_max_temp,
heat_step,
cool_min_temp,
cool_max_temp,
cool_step,
supported_hvac_modes,
supported_fan_modes,
support_flags,
dev... | [
"def",
"__init__",
"(",
"self",
",",
"tado",
",",
"zone_name",
",",
"zone_id",
",",
"zone_type",
",",
"heat_min_temp",
",",
"heat_max_temp",
",",
"heat_step",
",",
"cool_min_temp",
",",
"cool_max_temp",
",",
"cool_step",
",",
"supported_hvac_modes",
",",
"suppor... | [
190,
4
] | [
242,
38
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.async_added_to_hass | (self) | Register for sensor updates. | Register for sensor updates. | async def async_added_to_hass(self):
"""Register for sensor updates."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(
self._tado.device_id, "zone", self.zone_id
),
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_TADO_UPDATE_RECEIVED",
".",
"format",
"(",
"self",
".",
"_tado",
".",
"device_id",
",",
"\"zone\... | [
244,
4
] | [
255,
9
] | python | da | ['da', 'no', 'en'] | False |
TadoClimate.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return self._support_flags | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_support_flags"
] | [
258,
4
] | [
260,
34
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.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.zone_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"zone_name"
] | [
263,
4
] | [
265,
29
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.unique_id | (self) | Return the unique id. | Return the unique id. | def unique_id(self):
"""Return the unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
268,
4
] | [
270,
30
] | python | en | ['en', 'la', 'en'] | True |
TadoClimate.current_humidity | (self) | Return the current humidity. | Return the current humidity. | def current_humidity(self):
"""Return the current humidity."""
return self._tado_zone_data.current_humidity | [
"def",
"current_humidity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tado_zone_data",
".",
"current_humidity"
] | [
273,
4
] | [
275,
52
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.current_temperature | (self) | Return the sensor temperature. | Return the sensor temperature. | def current_temperature(self):
"""Return the sensor temperature."""
return self._tado_zone_data.current_temp | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tado_zone_data",
".",
"current_temp"
] | [
278,
4
] | [
280,
48
] | python | en | ['en', 'la', 'en'] | True |
TadoClimate.hvac_mode | (self) | Return hvac operation ie. heat, cool mode.
Need to be one of HVAC_MODE_*.
| Return hvac operation ie. heat, cool mode. | def hvac_mode(self):
"""Return hvac operation ie. heat, cool mode.
Need to be one of HVAC_MODE_*.
"""
return TADO_TO_HA_HVAC_MODE_MAP.get(self._current_tado_hvac_mode, HVAC_MODE_OFF) | [
"def",
"hvac_mode",
"(",
"self",
")",
":",
"return",
"TADO_TO_HA_HVAC_MODE_MAP",
".",
"get",
"(",
"self",
".",
"_current_tado_hvac_mode",
",",
"HVAC_MODE_OFF",
")"
] | [
283,
4
] | [
288,
88
] | python | bg | ['en', 'bg', 'bg'] | True |
TadoClimate.hvac_modes | (self) | Return the list of available hvac operation modes.
Need to be a subset of HVAC_MODES.
| Return the list of available hvac operation modes. | def hvac_modes(self):
"""Return the list of available hvac operation modes.
Need to be a subset of HVAC_MODES.
"""
return self._supported_hvac_modes | [
"def",
"hvac_modes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_hvac_modes"
] | [
291,
4
] | [
296,
41
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.hvac_action | (self) | Return the current running hvac operation if supported.
Need to be one of CURRENT_HVAC_*.
| Return the current running hvac operation if supported. | def hvac_action(self):
"""Return the current running hvac operation if supported.
Need to be one of CURRENT_HVAC_*.
"""
return TADO_HVAC_ACTION_TO_HA_HVAC_ACTION.get(
self._tado_zone_data.current_hvac_action, CURRENT_HVAC_OFF
) | [
"def",
"hvac_action",
"(",
"self",
")",
":",
"return",
"TADO_HVAC_ACTION_TO_HA_HVAC_ACTION",
".",
"get",
"(",
"self",
".",
"_tado_zone_data",
".",
"current_hvac_action",
",",
"CURRENT_HVAC_OFF",
")"
] | [
299,
4
] | [
306,
9
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.fan_mode | (self) | Return the fan setting. | Return the fan setting. | def fan_mode(self):
"""Return the fan setting."""
if self._ac_device:
return TADO_TO_HA_FAN_MODE_MAP.get(self._current_tado_fan_speed, FAN_AUTO)
return None | [
"def",
"fan_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ac_device",
":",
"return",
"TADO_TO_HA_FAN_MODE_MAP",
".",
"get",
"(",
"self",
".",
"_current_tado_fan_speed",
",",
"FAN_AUTO",
")",
"return",
"None"
] | [
309,
4
] | [
313,
19
] | python | en | ['en', 'fy', 'en'] | True |
TadoClimate.fan_modes | (self) | List of available fan modes. | List of available fan modes. | def fan_modes(self):
"""List of available fan modes."""
return self._supported_fan_modes | [
"def",
"fan_modes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_fan_modes"
] | [
316,
4
] | [
318,
40
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.set_fan_mode | (self, fan_mode: str) | Turn fan on/off. | Turn fan on/off. | def set_fan_mode(self, fan_mode: str):
"""Turn fan on/off."""
self._control_hvac(fan_mode=HA_TO_TADO_FAN_MODE_MAP[fan_mode]) | [
"def",
"set_fan_mode",
"(",
"self",
",",
"fan_mode",
":",
"str",
")",
":",
"self",
".",
"_control_hvac",
"(",
"fan_mode",
"=",
"HA_TO_TADO_FAN_MODE_MAP",
"[",
"fan_mode",
"]",
")"
] | [
320,
4
] | [
322,
70
] | python | en | ['en', 'fy', 'en'] | True |
TadoClimate.preset_mode | (self) | Return the current preset mode (home, away). | Return the current preset mode (home, away). | def preset_mode(self):
"""Return the current preset mode (home, away)."""
if self._tado_zone_data.is_away:
return PRESET_AWAY
return PRESET_HOME | [
"def",
"preset_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tado_zone_data",
".",
"is_away",
":",
"return",
"PRESET_AWAY",
"return",
"PRESET_HOME"
] | [
325,
4
] | [
329,
26
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.preset_modes | (self) | Return a list of available preset modes. | Return a list of available preset modes. | def preset_modes(self):
"""Return a list of available preset modes."""
return SUPPORT_PRESET | [
"def",
"preset_modes",
"(",
"self",
")",
":",
"return",
"SUPPORT_PRESET"
] | [
332,
4
] | [
334,
29
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.set_preset_mode | (self, preset_mode) | Set new preset mode. | Set new preset mode. | def set_preset_mode(self, preset_mode):
"""Set new preset mode."""
self._tado.set_presence(preset_mode) | [
"def",
"set_preset_mode",
"(",
"self",
",",
"preset_mode",
")",
":",
"self",
".",
"_tado",
".",
"set_presence",
"(",
"preset_mode",
")"
] | [
336,
4
] | [
338,
44
] | python | en | ['en', 'sr', 'en'] | True |
TadoClimate.temperature_unit | (self) | Return the unit of measurement used by the platform. | Return the unit of measurement used by the platform. | def temperature_unit(self):
"""Return the unit of measurement used by the platform."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
341,
4
] | [
343,
27
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.target_temperature_step | (self) | Return the supported step of target temperature. | Return the supported step of target temperature. | def target_temperature_step(self):
"""Return the supported step of target temperature."""
if self._tado_zone_data.current_hvac_mode == CONST_MODE_COOL:
return self._cool_step or self._heat_step
return self._heat_step or self._cool_step | [
"def",
"target_temperature_step",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tado_zone_data",
".",
"current_hvac_mode",
"==",
"CONST_MODE_COOL",
":",
"return",
"self",
".",
"_cool_step",
"or",
"self",
".",
"_heat_step",
"return",
"self",
".",
"_heat_step",
"or"... | [
346,
4
] | [
350,
49
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
# If the target temperature will be None
# if the device is performing an action
# that does not affect the temperature or
# the device is switching states
return self._tado_zone_data.target_temp ... | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"# If the target temperature will be None",
"# if the device is performing an action",
"# that does not affect the temperature or",
"# the device is switching states",
"return",
"self",
".",
"_tado_zone_data",
".",
"target_temp",
"o... | [
353,
4
] | [
359,
84
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.set_timer | (self, time_period, temperature=None) | Set the timer on the entity, and temperature if supported. | Set the timer on the entity, and temperature if supported. | def set_timer(self, time_period, temperature=None):
"""Set the timer on the entity, and temperature if supported."""
self._control_hvac(
hvac_mode=CONST_MODE_HEAT, target_temp=temperature, duration=time_period
) | [
"def",
"set_timer",
"(",
"self",
",",
"time_period",
",",
"temperature",
"=",
"None",
")",
":",
"self",
".",
"_control_hvac",
"(",
"hvac_mode",
"=",
"CONST_MODE_HEAT",
",",
"target_temp",
"=",
"temperature",
",",
"duration",
"=",
"time_period",
")"
] | [
361,
4
] | [
366,
9
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
if self._current_tado_hvac_mode not in (
CONST_MODE_OFF,
CONST_MODE_AUTO,
CONST_MODE_SMART_SCH... | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_current_tado_hvac_mode",
"not",
"in",
"... | [
368,
4
] | [
383,
76
] | python | en | ['en', 'ca', 'en'] | True |
TadoClimate.set_hvac_mode | (self, hvac_mode) | Set new target hvac mode. | Set new target hvac mode. | def set_hvac_mode(self, hvac_mode):
"""Set new target hvac mode."""
self._control_hvac(hvac_mode=HA_TO_TADO_HVAC_MODE_MAP[hvac_mode]) | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"self",
".",
"_control_hvac",
"(",
"hvac_mode",
"=",
"HA_TO_TADO_HVAC_MODE_MAP",
"[",
"hvac_mode",
"]",
")"
] | [
385,
4
] | [
388,
73
] | python | da | ['da', 'su', 'en'] | False |
TadoClimate.available | (self) | Return if the device is available. | Return if the device is available. | def available(self):
"""Return if the device is available."""
return self._tado_zone_data.available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tado_zone_data",
".",
"available"
] | [
391,
4
] | [
393,
45
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self):
"""Return the minimum temperature."""
if (
self._current_tado_hvac_mode == CONST_MODE_COOL
and self._cool_min_temp is not None
):
return self._cool_min_temp
if self._heat_min_temp is not None:
return self._heat_min_temp
... | [
"def",
"min_temp",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_current_tado_hvac_mode",
"==",
"CONST_MODE_COOL",
"and",
"self",
".",
"_cool_min_temp",
"is",
"not",
"None",
")",
":",
"return",
"self",
".",
"_cool_min_temp",
"if",
"self",
".",
"_heat_min_... | [
396,
4
] | [
406,
34
] | python | en | ['en', 'la', 'en'] | True |
TadoClimate.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self):
"""Return the maximum temperature."""
if (
self._current_tado_hvac_mode == CONST_MODE_HEAT
and self._heat_max_temp is not None
):
return self._heat_max_temp
if self._heat_max_temp is not None:
return self._heat_max_temp
... | [
"def",
"max_temp",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_current_tado_hvac_mode",
"==",
"CONST_MODE_HEAT",
"and",
"self",
".",
"_heat_max_temp",
"is",
"not",
"None",
")",
":",
"return",
"self",
".",
"_heat_max_temp",
"if",
"self",
".",
"_heat_max_... | [
409,
4
] | [
419,
34
] | python | en | ['en', 'la', 'en'] | True |
TadoClimate.swing_mode | (self) | Active swing mode for the device. | Active swing mode for the device. | def swing_mode(self):
"""Active swing mode for the device."""
return self._current_tado_swing_mode | [
"def",
"swing_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_tado_swing_mode"
] | [
422,
4
] | [
424,
44
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.swing_modes | (self) | Swing modes for the device. | Swing modes for the device. | def swing_modes(self):
"""Swing modes for the device."""
if self._support_flags & SUPPORT_SWING_MODE:
return [TADO_SWING_ON, TADO_SWING_OFF]
return None | [
"def",
"swing_modes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_support_flags",
"&",
"SUPPORT_SWING_MODE",
":",
"return",
"[",
"TADO_SWING_ON",
",",
"TADO_SWING_OFF",
"]",
"return",
"None"
] | [
427,
4
] | [
431,
19
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate.set_swing_mode | (self, swing_mode) | Set swing modes for the device. | Set swing modes for the device. | def set_swing_mode(self, swing_mode):
"""Set swing modes for the device."""
self._control_hvac(swing_mode=swing_mode) | [
"def",
"set_swing_mode",
"(",
"self",
",",
"swing_mode",
")",
":",
"self",
".",
"_control_hvac",
"(",
"swing_mode",
"=",
"swing_mode",
")"
] | [
433,
4
] | [
435,
49
] | python | en | ['en', 'en', 'en'] | True |
TadoClimate._async_update_zone_data | (self) | Load tado data into zone. | Load tado data into zone. | def _async_update_zone_data(self):
"""Load tado data into zone."""
self._tado_zone_data = self._tado.data["zone"][self.zone_id]
self._current_tado_fan_speed = self._tado_zone_data.current_fan_speed
self._current_tado_hvac_mode = self._tado_zone_data.current_hvac_mode
self._curren... | [
"def",
"_async_update_zone_data",
"(",
"self",
")",
":",
"self",
".",
"_tado_zone_data",
"=",
"self",
".",
"_tado",
".",
"data",
"[",
"\"zone\"",
"]",
"[",
"self",
".",
"zone_id",
"]",
"self",
".",
"_current_tado_fan_speed",
"=",
"self",
".",
"_tado_zone_dat... | [
438,
4
] | [
444,
79
] | python | pt | ['pt', 'it', 'pt'] | True |
TadoClimate._async_update_callback | (self) | Load tado data and update state. | Load tado data and update state. | def _async_update_callback(self):
"""Load tado data and update state."""
self._async_update_zone_data()
self.async_write_ha_state() | [
"def",
"_async_update_callback",
"(",
"self",
")",
":",
"self",
".",
"_async_update_zone_data",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
447,
4
] | [
450,
35
] | python | en | ['pt', 'en', 'en'] | True |
TadoClimate._control_hvac | (
self,
hvac_mode=None,
target_temp=None,
fan_mode=None,
swing_mode=None,
duration=None,
) | Send new target temperature to Tado. | Send new target temperature to Tado. | def _control_hvac(
self,
hvac_mode=None,
target_temp=None,
fan_mode=None,
swing_mode=None,
duration=None,
):
"""Send new target temperature to Tado."""
if hvac_mode:
self._current_tado_hvac_mode = hvac_mode
if target_temp:
... | [
"def",
"_control_hvac",
"(",
"self",
",",
"hvac_mode",
"=",
"None",
",",
"target_temp",
"=",
"None",
",",
"fan_mode",
"=",
"None",
",",
"swing_mode",
"=",
"None",
",",
"duration",
"=",
"None",
",",
")",
":",
"if",
"hvac_mode",
":",
"self",
".",
"_curre... | [
468,
4
] | [
553,
9
] | python | en | ['en', 'es', 'en'] | True |
test_show_user_form | (hass: HomeAssistant) | Test that the user set up form is served. | Test that the user set up form is served. | async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"
assert result["type"] == data_ent... | [
"async",
"def",
"test_show_user_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\""... | [
14,
0
] | [
22,
61
] | python | en | ['en', 'en', 'en'] | True |
test_user_device_exists_abort | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort flow if Agent device already configured. | Test we abort flow if Agent device already configured. | async def test_user_device_exists_abort(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort flow if Agent device already configured."""
await init_integration(hass, aioclient_mock)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
... | [
"async",
"def",
"test_user_device_exists_abort",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"result",
"=",
"await",
"hass",
"."... | [
25,
0
] | [
37,
62
] | python | en | ['fr', 'en', 'en'] | True |
test_connection_error | (hass: HomeAssistant, aioclient_mock) | Test we show user form on Agent connection error. | Test we show user form on Agent connection error. | async def test_connection_error(hass: HomeAssistant, aioclient_mock) -> None:
"""Test we show user form on Agent connection error."""
aioclient_mock.get("http://example.local:8090/command.cgi?cmd=getStatus", text="")
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
c... | [
"async",
"def",
"test_connection_error",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.local:8090/command.cgi?cmd=getStatus\"",
",",
"text",
"=",
"\"\"",
")",
"result",
"=",
"aw... | [
40,
0
] | [
53,
61
] | python | en | ['en', 'en', 'en'] | True |
test_full_user_flow_implementation | (
hass: HomeAssistant, aioclient_mock
) | Test the full manual user flow from start to finish. | Test the full manual user flow from start to finish. | async def test_full_user_flow_implementation(
hass: HomeAssistant, aioclient_mock
) -> None:
"""Test the full manual user flow from start to finish."""
aioclient_mock.get(
"http://example.local:8090/command.cgi?cmd=getStatus",
text=load_fixture("agent_dvr/status.json"),
headers={"Con... | [
"async",
"def",
"test_full_user_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.local:8090/command.cgi?cmd=getStatus\"",
",",
"text",
"=",
"load_fixture",
"(",
"... | [
56,
0
] | [
91,
73
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: Dict) | Set up the Sonarr component. | Set up the Sonarr component. | async def async_setup(hass: HomeAssistantType, config: Dict) -> bool:
"""Set up the Sonarr component."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"Dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
42,
0
] | [
45,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up Sonarr from a config entry. | Set up Sonarr from a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up Sonarr from a config entry."""
if not entry.options:
options = {
CONF_UPCOMING_DAYS: entry.data.get(
CONF_UPCOMING_DAYS, DEFAULT_UPCOMING_DAYS
),
CONF_WANTED_MA... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"if",
"not",
"entry",
".",
"options",
":",
"options",
"=",
"{",
"CONF_UPCOMING_DAYS",
":",
"entry",
".",
"data",
".",
"get... | [
48,
0
] | [
91,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"asyn... | [
94,
0
] | [
110,
20
] | python | en | ['en', 'es', 'en'] | True |
_async_update_listener | (hass: HomeAssistantType, entry: ConfigEntry) | Handle options update. | Handle options update. | async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry) -> None:
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"_async_update_listener",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
124,
0
] | [
126,
58
] | python | en | ['en', 'nl', 'en'] | True |
SonarrEntity.__init__ | (
self,
*,
sonarr: Sonarr,
entry_id: str,
device_id: str,
name: str,
icon: str,
enabled_default: bool = True,
) | Initialize the Sonar entity. | Initialize the Sonar entity. | def __init__(
self,
*,
sonarr: Sonarr,
entry_id: str,
device_id: str,
name: str,
icon: str,
enabled_default: bool = True,
) -> None:
"""Initialize the Sonar entity."""
self._entry_id = entry_id
self._device_id = device_id
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"sonarr",
":",
"Sonarr",
",",
"entry_id",
":",
"str",
",",
"device_id",
":",
"str",
",",
"name",
":",
"str",
",",
"icon",
":",
"str",
",",
"enabled_default",
":",
"bool",
"=",
"True",
",",
")",
"->",
... | [
132,
4
] | [
148,
28
] | python | en | ['en', 'en', 'en'] | True |
SonarrEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
151,
4
] | [
153,
25
] | python | en | ['en', 'en', 'en'] | True |
SonarrEntity.icon | (self) | Return the mdi icon of the entity. | Return the mdi icon of the entity. | def icon(self) -> str:
"""Return the mdi icon of the entity."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_icon"
] | [
156,
4
] | [
158,
25
] | python | en | ['en', 'en', 'en'] | True |
SonarrEntity.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self._enabled_default | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_enabled_default"
] | [
161,
4
] | [
163,
36
] | python | en | ['en', 'en', 'en'] | True |
SonarrEntity.device_info | (self) | Return device information about the application. | Return device information about the application. | def device_info(self) -> Dict[str, Any]:
"""Return device information about the application."""
if self._device_id is None:
return None
return {
ATTR_IDENTIFIERS: {(DOMAIN, self._device_id)},
ATTR_NAME: "Activity Sensor",
ATTR_MANUFACTURER: "Sonar... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"self",
".",
"_device_id",
"is",
"None",
":",
"return",
"None",
"return",
"{",
"ATTR_IDENTIFIERS",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
... | [
166,
4
] | [
177,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_daikin | () | Mock pydaikin. | Mock pydaikin. | def mock_daikin():
"""Mock pydaikin."""
async def mock_daikin_factory(*args, **kwargs):
"""Mock the init function in pydaikin."""
return Appliance
with patch("homeassistant.components.daikin.config_flow.Appliance") as Appliance:
type(Appliance).mac = PropertyMock(return_value="AABB... | [
"def",
"mock_daikin",
"(",
")",
":",
"async",
"def",
"mock_daikin_factory",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Mock the init function in pydaikin.\"\"\"",
"return",
"Appliance",
"with",
"patch",
"(",
"\"homeassistant.components.daikin.config_flo... | [
30,
0
] | [
40,
23
] | python | en | ['lt', 'tr', 'en'] | False |
mock_daikin_discovery | () | Mock pydaikin Discovery. | Mock pydaikin Discovery. | def mock_daikin_discovery():
"""Mock pydaikin Discovery."""
with patch("homeassistant.components.daikin.config_flow.Discovery") as Discovery:
Discovery().poll.return_value = {
"127.0.01": {"mac": "AABBCCDDEEFF", "id": "test"}
}.values()
yield Discovery | [
"def",
"mock_daikin_discovery",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.daikin.config_flow.Discovery\"",
")",
"as",
"Discovery",
":",
"Discovery",
"(",
")",
".",
"poll",
".",
"return_value",
"=",
"{",
"\"127.0.01\"",
":",
"{",
"\"mac\"",
"... | [
44,
0
] | [
50,
23
] | python | en | ['en', 'fy', 'en'] | True |
test_user | (hass, mock_daikin) | Test user config. | Test user config. | async def test_user(hass, mock_daikin):
"""Test user config."""
result = await hass.config_entries.flow.async_init(
"daikin",
context={"source": SOURCE_USER},
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"mock_daikin",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\"daikin\"",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
",",
")",
"... | [
53,
0
] | [
71,
41
] | python | en | ['en', 'da', 'en'] | True |
test_abort_if_already_setup | (hass, mock_daikin) | Test we abort if Daikin is already setup. | Test we abort if Daikin is already setup. | async def test_abort_if_already_setup(hass, mock_daikin):
"""Test we abort if Daikin is already setup."""
MockConfigEntry(domain="daikin", unique_id=MAC).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
"daikin",
context={"source": SOURCE_USER},
data={CONF_HOST: ... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
",",
"mock_daikin",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"daikin\"",
",",
"unique_id",
"=",
"MAC",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"conf... | [
74,
0
] | [
84,
51
] | python | en | ['en', 'de', 'en'] | True |
test_import | (hass, mock_daikin) | Test import step. | Test import step. | async def test_import(hass, mock_daikin):
"""Test import step."""
result = await hass.config_entries.flow.async_init(
"daikin",
context={"source": SOURCE_IMPORT},
data={},
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = await hass.... | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"mock_daikin",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\"daikin\"",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_IMPORT",
"}",
",",
"dat... | [
87,
0
] | [
105,
41
] | python | de | ['de', 'sd', 'en'] | False |
test_device_abort | (hass, mock_daikin, s_effect, reason) | Test device abort. | Test device abort. | async def test_device_abort(hass, mock_daikin, s_effect, reason):
"""Test device abort."""
mock_daikin.factory.side_effect = s_effect
result = await hass.config_entries.flow.async_init(
"daikin",
context={"source": SOURCE_USER},
data={CONF_HOST: HOST, KEY_MAC: MAC},
)
assert... | [
"async",
"def",
"test_device_abort",
"(",
"hass",
",",
"mock_daikin",
",",
"s_effect",
",",
"reason",
")",
":",
"mock_daikin",
".",
"factory",
".",
"side_effect",
"=",
"s_effect",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"asyn... | [
117,
0
] | [
128,
38
] | python | de | ['fr', 'de', 'en'] | False |
test_discovery_zeroconf | (
hass, mock_daikin, mock_daikin_discovery, source, data, unique_id
) | Test discovery/zeroconf step. | Test discovery/zeroconf step. | async def test_discovery_zeroconf(
hass, mock_daikin, mock_daikin_discovery, source, data, unique_id
):
"""Test discovery/zeroconf step."""
result = await hass.config_entries.flow.async_init(
"daikin",
context={"source": source},
data=data,
)
assert result["type"] == RESULT_T... | [
"async",
"def",
"test_discovery_zeroconf",
"(",
"hass",
",",
"mock_daikin",
",",
"mock_daikin_discovery",
",",
"source",
",",
"data",
",",
"unique_id",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\"dai... | [
138,
0
] | [
167,
52
] | python | de | ['de', 'pl', 'en'] | False |
get_service | (hass, config, discovery_info=None) | Get the RESTful notification service. | Get the RESTful notification service. | def get_service(hass, config, discovery_info=None):
"""Get the RESTful notification service."""
setup_reload_service(hass, DOMAIN, PLATFORMS)
resource = config.get(CONF_RESOURCE)
method = config.get(CONF_METHOD)
headers = config.get(CONF_HEADERS)
params = config.get(CONF_PARAMS)
message_par... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"resource",
"=",
"config",
".",
"get",
"(",
"CONF_RESOURCE",
")",
"method",
"=",
"con... | [
72,
0
] | [
110,
5
] | python | en | ['en', 'en', 'en'] | True |
RestNotificationService.__init__ | (
self,
hass,
resource,
method,
headers,
params,
message_param_name,
title_param_name,
target_param_name,
data,
data_template,
auth,
verify_ssl,
) | Initialize the service. | Initialize the service. | def __init__(
self,
hass,
resource,
method,
headers,
params,
message_param_name,
title_param_name,
target_param_name,
data,
data_template,
auth,
verify_ssl,
):
"""Initialize the service."""
self._... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"resource",
",",
"method",
",",
"headers",
",",
"params",
",",
"message_param_name",
",",
"title_param_name",
",",
"target_param_name",
",",
"data",
",",
"data_template",
",",
"auth",
",",
"verify_ssl",
",",
... | [
116,
4
] | [
143,
37
] | python | en | ['en', 'en', 'en'] | True |
RestNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
data = {self._message_param_name: message}
if self._title_param_name is not None:
data[self._title_param_name] = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
if self._target_param_name is not None a... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"self",
".",
"_message_param_name",
":",
"message",
"}",
"if",
"self",
".",
"_title_param_name",
"is",
"not",
"None",
":",
"data",
"["... | [
145,
4
] | [
224,
84
] | python | en | ['en', 'en', 'en'] | True |
block_digonal_matrix | (*blocks) |
Construct block diagonal matrix
:param blocks: blocks of block diagonal matrix
:param device
:param dtype
:return: block diagonal matrix
|
Construct block diagonal matrix
:param blocks: blocks of block diagonal matrix
:param device
:param dtype
:return: block diagonal matrix
| def block_digonal_matrix(*blocks):
"""
Construct block diagonal matrix
:param blocks: blocks of block diagonal matrix
:param device
:param dtype
:return: block diagonal matrix
"""
assert len(blocks) > 0
rows = [block.shape[0] for block in blocks]
cols = [block.shape[1] for block ... | [
"def",
"block_digonal_matrix",
"(",
"*",
"blocks",
")",
":",
"assert",
"len",
"(",
"blocks",
")",
">",
"0",
"rows",
"=",
"[",
"block",
".",
"shape",
"[",
"0",
"]",
"for",
"block",
"in",
"blocks",
"]",
"cols",
"=",
"[",
"block",
".",
"shape",
"[",
... | [
7,
0
] | [
28,
14
] | python | en | ['en', 'error', 'th'] | False |
summary_parameters | (model, logger=None) |
Summary Parameters of Model
:param model: torch.nn.module_name
:param logger: logger
:return: None
|
Summary Parameters of Model
:param model: torch.nn.module_name
:param logger: logger
:return: None
| def summary_parameters(model, logger=None):
"""
Summary Parameters of Model
:param model: torch.nn.module_name
:param logger: logger
:return: None
"""
print_and_log('>> Trainable Parameters:', logger)
trainable_paramters = [(str(n), str(v.dtype), str(tuple(v.shape)), str(v.numel()))
... | [
"def",
"summary_parameters",
"(",
"model",
",",
"logger",
"=",
"None",
")",
":",
"print_and_log",
"(",
"'>> Trainable Parameters:'",
",",
"logger",
")",
"trainable_paramters",
"=",
"[",
"(",
"str",
"(",
"n",
")",
",",
"str",
"(",
"v",
".",
"dtype",
")",
... | [
39,
0
] | [
66,
106
] | python | en | ['en', 'error', 'th'] | False |
clip_grad | (named_parameters, max_norm, logger=logging, std_verbose=False, log_verbose=False) | Clips gradient norm of an iterable of parameters.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
:param named_parameters: dict, named parameters of pytorch module
:param max_norm: float or int, max norm of the gradien... | Clips gradient norm of an iterable of parameters.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
:param named_parameters: dict, named parameters of pytorch module
:param max_norm: float or int, max norm of the gradien... | def clip_grad(named_parameters, max_norm, logger=logging, std_verbose=False, log_verbose=False):
"""Clips gradient norm of an iterable of parameters.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
:param named_paramet... | [
"def",
"clip_grad",
"(",
"named_parameters",
",",
"max_norm",
",",
"logger",
"=",
"logging",
",",
"std_verbose",
"=",
"False",
",",
"log_verbose",
"=",
"False",
")",
":",
"max_norm",
"=",
"float",
"(",
"max_norm",
")",
"parameters",
"=",
"[",
"(",
"n",
"... | [
71,
0
] | [
114,
70
] | python | en | ['en', 'en', 'en'] | True |
soft_cross_entropy | (input, target, reduction='mean') |
Cross entropy loss with input logits and soft target
:param input: Tensor, size: (N, C)
:param target: Tensor, size: (N, C)
:param reduction: 'none' or 'mean' or 'sum', default: 'mean'
:return: loss
|
Cross entropy loss with input logits and soft target
:param input: Tensor, size: (N, C)
:param target: Tensor, size: (N, C)
:param reduction: 'none' or 'mean' or 'sum', default: 'mean'
:return: loss
| def soft_cross_entropy(input, target, reduction='mean'):
"""
Cross entropy loss with input logits and soft target
:param input: Tensor, size: (N, C)
:param target: Tensor, size: (N, C)
:param reduction: 'none' or 'mean' or 'sum', default: 'mean'
:return: loss
"""
eps = 1.0e-1
# debug... | [
"def",
"soft_cross_entropy",
"(",
"input",
",",
"target",
",",
"reduction",
"=",
"'mean'",
")",
":",
"eps",
"=",
"1.0e-1",
"# debug = False",
"valid",
"=",
"(",
"target",
".",
"sum",
"(",
"1",
")",
"-",
"1",
")",
".",
"abs",
"(",
")",
"<",
"eps",
"... | [
123,
0
] | [
150,
77
] | python | en | ['en', 'error', 'th'] | False |
_make_causal_mask | (input_ids_shape: tf.TensorShape, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = tf.ones((tgt_len, tgt_len)) * LARGE_NEGATIVE
mask_cond = tf.range(shape_list(mask)[-1])
mask = tf.w... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"tf",
".",
"ones",
"(",
"(",
"tgt_len",
",",
"tgt_... | [
77,
0
] | [
90,
58
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.