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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mock_google_config_store | (agent_user_ids=None) | Fake a storage for google assistant. | Fake a storage for google assistant. | def mock_google_config_store(agent_user_ids=None):
"""Fake a storage for google assistant."""
store = MagicMock(spec=helpers.GoogleConfigStore)
if agent_user_ids is not None:
store.agent_user_ids = agent_user_ids
else:
store.agent_user_ids = {}
return store | [
"def",
"mock_google_config_store",
"(",
"agent_user_ids",
"=",
"None",
")",
":",
"store",
"=",
"MagicMock",
"(",
"spec",
"=",
"helpers",
".",
"GoogleConfigStore",
")",
"if",
"agent_user_ids",
"is",
"not",
"None",
":",
"store",
".",
"agent_user_ids",
"=",
"agen... | [
6,
0
] | [
13,
16
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.__init__ | (
self,
*,
secure_devices_pin=None,
should_expose=None,
should_2fa=None,
entity_config=None,
hass=None,
local_sdk_webhook_id=None,
local_sdk_user_id=None,
enabled=True,
agent_user_ids=None,
) | Initialize config. | Initialize config. | def __init__(
self,
*,
secure_devices_pin=None,
should_expose=None,
should_2fa=None,
entity_config=None,
hass=None,
local_sdk_webhook_id=None,
local_sdk_user_id=None,
enabled=True,
agent_user_ids=None,
):
"""Initialize c... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"secure_devices_pin",
"=",
"None",
",",
"should_expose",
"=",
"None",
",",
"should_2fa",
"=",
"None",
",",
"entity_config",
"=",
"None",
",",
"hass",
"=",
"None",
",",
"local_sdk_webhook_id",
"=",
"None",
",",... | [
19,
4
] | [
41,
62
] | python | en | ['en', 'en', 'it'] | False |
MockConfig.enabled | (self) | Return if Google is enabled. | Return if Google is enabled. | def enabled(self):
"""Return if Google is enabled."""
return self._enabled | [
"def",
"enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"_enabled"
] | [
44,
4
] | [
46,
28
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.secure_devices_pin | (self) | Return secure devices pin. | Return secure devices pin. | def secure_devices_pin(self):
"""Return secure devices pin."""
return self._secure_devices_pin | [
"def",
"secure_devices_pin",
"(",
"self",
")",
":",
"return",
"self",
".",
"_secure_devices_pin"
] | [
49,
4
] | [
51,
39
] | python | en | ['fr', 'en', 'en'] | True |
MockConfig.entity_config | (self) | Return secure devices pin. | Return secure devices pin. | def entity_config(self):
"""Return secure devices pin."""
return self._entity_config | [
"def",
"entity_config",
"(",
"self",
")",
":",
"return",
"self",
".",
"_entity_config"
] | [
54,
4
] | [
56,
34
] | python | en | ['fr', 'en', 'en'] | True |
MockConfig.local_sdk_webhook_id | (self) | Return local SDK webhook id. | Return local SDK webhook id. | def local_sdk_webhook_id(self):
"""Return local SDK webhook id."""
return self._local_sdk_webhook_id | [
"def",
"local_sdk_webhook_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_local_sdk_webhook_id"
] | [
59,
4
] | [
61,
41
] | python | en | ['es', 'et', 'en'] | False |
MockConfig.local_sdk_user_id | (self) | Return local SDK webhook id. | Return local SDK webhook id. | def local_sdk_user_id(self):
"""Return local SDK webhook id."""
return self._local_sdk_user_id | [
"def",
"local_sdk_user_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_local_sdk_user_id"
] | [
64,
4
] | [
66,
38
] | python | en | ['es', 'et', 'en'] | False |
MockConfig.get_agent_user_id | (self, context) | Get agent user ID making request. | Get agent user ID making request. | def get_agent_user_id(self, context):
"""Get agent user ID making request."""
return context.user_id | [
"def",
"get_agent_user_id",
"(",
"self",
",",
"context",
")",
":",
"return",
"context",
".",
"user_id"
] | [
68,
4
] | [
70,
30
] | python | en | ['fr', 'en', 'en'] | True |
MockConfig.should_expose | (self, state) | Expose it all. | Expose it all. | def should_expose(self, state):
"""Expose it all."""
return self._should_expose is None or self._should_expose(state) | [
"def",
"should_expose",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_should_expose",
"is",
"None",
"or",
"self",
".",
"_should_expose",
"(",
"state",
")"
] | [
72,
4
] | [
74,
72
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.should_2fa | (self, state) | Expose it all. | Expose it all. | def should_2fa(self, state):
"""Expose it all."""
return self._should_2fa is None or self._should_2fa(state) | [
"def",
"should_2fa",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_should_2fa",
"is",
"None",
"or",
"self",
".",
"_should_2fa",
"(",
"state",
")"
] | [
76,
4
] | [
78,
66
] | python | en | ['en', 'en', 'en'] | True |
async_describe_events | (hass, async_describe_event) | Describe logbook events. | Describe logbook events. | def async_describe_events(hass, async_describe_event):
"""Describe logbook events."""
@callback
def async_describe_logbook_event(event):
"""Describe the logbook event."""
data = event.data
return {
"name": data.get(ATTR_NAME),
"message": "started",
... | [
"def",
"async_describe_events",
"(",
"hass",
",",
"async_describe_event",
")",
":",
"@",
"callback",
"def",
"async_describe_logbook_event",
"(",
"event",
")",
":",
"\"\"\"Describe the logbook event.\"\"\"",
"data",
"=",
"event",
".",
"data",
"return",
"{",
"\"name\"",... | [
8,
0
] | [
21,
84
] | python | en | ['en', 'es', 'en'] | True |
test_config_entry_not_ready | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the Elgato Key Light configuration entry not ready. | Test the Elgato Key Light configuration entry not ready. | async def test_config_entry_not_ready(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the Elgato Key Light configuration entry not ready."""
aioclient_mock.get(
"http://127.0.0.1:9123/elgato/accessory-info", exc=aiohttp.ClientError
)
entry = await init_integrati... | [
"async",
"def",
"test_config_entry_not_ready",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1:9123/elgato/accessory-info\"",
",",
"exc",
"=",
"aiohttp",... | [
11,
0
] | [
20,
54
] | python | en | ['en', 'en', 'en'] | True |
test_unload_config_entry | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the Elgato Key Light configuration entry unloading. | Test the Elgato Key Light configuration entry unloading. | async def test_unload_config_entry(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the Elgato Key Light configuration entry unloading."""
entry = await init_integration(hass, aioclient_mock)
assert hass.data[DOMAIN]
await hass.config_entries.async_unload(entry.entry_id)... | [
"async",
"def",
"test_unload_config_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"assert",
"hass",
".",
"... | [
23,
0
] | [
32,
36
] | python | en | ['en', 'zu', 'en'] | True |
install_multiple_zeroconf_catcher | (hass_zc: HaZeroconf) | Wrap the Zeroconf class to return the shared instance if multiple instances are detected. | Wrap the Zeroconf class to return the shared instance if multiple instances are detected. | def install_multiple_zeroconf_catcher(hass_zc: HaZeroconf) -> None:
"""Wrap the Zeroconf class to return the shared instance if multiple instances are detected."""
def new_zeroconf_new(self: zeroconf.Zeroconf, *k: Any, **kw: Any) -> HaZeroconf:
_report(
"attempted to create another Zeroconf... | [
"def",
"install_multiple_zeroconf_catcher",
"(",
"hass_zc",
":",
"HaZeroconf",
")",
"->",
"None",
":",
"def",
"new_zeroconf_new",
"(",
"self",
":",
"zeroconf",
".",
"Zeroconf",
",",
"*",
"k",
":",
"Any",
",",
"*",
"*",
"kw",
":",
"Any",
")",
"->",
"HaZer... | [
19,
0
] | [
32,
50
] | python | en | ['en', 'en', 'en'] | True |
_report | (what: str) | Report incorrect usage.
Async friendly.
| Report incorrect usage. | def _report(what: str) -> None:
"""Report incorrect usage.
Async friendly.
"""
integration_frame = None
with suppress(MissingIntegrationFrame):
integration_frame = get_integration_frame(exclude_integrations={"zeroconf"})
if not integration_frame:
_LOGGER.warning(
"... | [
"def",
"_report",
"(",
"what",
":",
"str",
")",
"->",
"None",
":",
"integration_frame",
"=",
"None",
"with",
"suppress",
"(",
"MissingIntegrationFrame",
")",
":",
"integration_frame",
"=",
"get_integration_frame",
"(",
"exclude_integrations",
"=",
"{",
"\"zeroconf... | [
35,
0
] | [
51,
47
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Lutron switches. | Set up the Lutron switches. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Lutron switches."""
devs = []
# Add Lutron Switches
for (area_name, device) in hass.data[LUTRON_DEVICES]["switch"]:
dev = LutronSwitch(area_name, device, hass.data[LUTRON_CONTROLLER])
devs.append(dev)
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"devs",
"=",
"[",
"]",
"# Add Lutron Switches",
"for",
"(",
"area_name",
",",
"device",
")",
"in",
"hass",
".",
"data",
"[",
"LUTRON_DEV... | [
6,
0
] | [
24,
28
] | python | en | ['en', 'en', 'en'] | True |
LutronSwitch.__init__ | (self, area_name, lutron_device, controller) | Initialize the switch. | Initialize the switch. | def __init__(self, area_name, lutron_device, controller):
"""Initialize the switch."""
self._prev_state = None
super().__init__(area_name, lutron_device, controller) | [
"def",
"__init__",
"(",
"self",
",",
"area_name",
",",
"lutron_device",
",",
"controller",
")",
":",
"self",
".",
"_prev_state",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"area_name",
",",
"lutron_device",
",",
"controller",
")"
] | [
30,
4
] | [
33,
62
] | python | en | ['en', 'en', 'en'] | True |
LutronSwitch.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
self._lutron_device.level = 100 | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_lutron_device",
".",
"level",
"=",
"100"
] | [
35,
4
] | [
37,
39
] | python | en | ['en', 'en', 'en'] | True |
LutronSwitch.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
self._lutron_device.level = 0 | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_lutron_device",
".",
"level",
"=",
"0"
] | [
39,
4
] | [
41,
37
] | python | en | ['en', 'en', 'en'] | True |
LutronSwitch.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
return {"lutron_integration_id": self._lutron_device.id} | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"lutron_integration_id\"",
":",
"self",
".",
"_lutron_device",
".",
"id",
"}"
] | [
44,
4
] | [
46,
64
] | python | en | ['en', 'en', 'en'] | True |
LutronSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._lutron_device.last_level() > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lutron_device",
".",
"last_level",
"(",
")",
">",
"0"
] | [
49,
4
] | [
51,
51
] | python | en | ['en', 'fy', 'en'] | True |
LutronSwitch.update | (self) | Call when forcing a refresh of the device. | Call when forcing a refresh of the device. | def update(self):
"""Call when forcing a refresh of the device."""
if self._prev_state is None:
self._prev_state = self._lutron_device.level > 0 | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_prev_state",
"is",
"None",
":",
"self",
".",
"_prev_state",
"=",
"self",
".",
"_lutron_device",
".",
"level",
">",
"0"
] | [
53,
4
] | [
56,
60
] | python | en | ['en', 'en', 'en'] | True |
LutronLed.__init__ | (self, area_name, keypad_name, scene_device, led_device, controller) | Initialize the switch. | Initialize the switch. | def __init__(self, area_name, keypad_name, scene_device, led_device, controller):
"""Initialize the switch."""
self._keypad_name = keypad_name
self._scene_name = scene_device.name
super().__init__(area_name, led_device, controller) | [
"def",
"__init__",
"(",
"self",
",",
"area_name",
",",
"keypad_name",
",",
"scene_device",
",",
"led_device",
",",
"controller",
")",
":",
"self",
".",
"_keypad_name",
"=",
"keypad_name",
"self",
".",
"_scene_name",
"=",
"scene_device",
".",
"name",
"super",
... | [
62,
4
] | [
66,
59
] | python | en | ['en', 'en', 'en'] | True |
LutronLed.turn_on | (self, **kwargs) | Turn the LED on. | Turn the LED on. | def turn_on(self, **kwargs):
"""Turn the LED on."""
self._lutron_device.state = 1 | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_lutron_device",
".",
"state",
"=",
"1"
] | [
68,
4
] | [
70,
37
] | python | en | ['en', 'zu', 'en'] | True |
LutronLed.turn_off | (self, **kwargs) | Turn the LED off. | Turn the LED off. | def turn_off(self, **kwargs):
"""Turn the LED off."""
self._lutron_device.state = 0 | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_lutron_device",
".",
"state",
"=",
"0"
] | [
72,
4
] | [
74,
37
] | python | en | ['en', 'sm', 'en'] | True |
LutronLed.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
return {
"keypad": self._keypad_name,
"scene": self._scene_name,
"led": self._lutron_device.name,
} | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"keypad\"",
":",
"self",
".",
"_keypad_name",
",",
"\"scene\"",
":",
"self",
".",
"_scene_name",
",",
"\"led\"",
":",
"self",
".",
"_lutron_device",
".",
"name",
",",
"}"
] | [
77,
4
] | [
83,
9
] | python | en | ['en', 'en', 'en'] | True |
LutronLed.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._lutron_device.last_state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lutron_device",
".",
"last_state"
] | [
86,
4
] | [
88,
45
] | python | en | ['en', 'fy', 'en'] | True |
LutronLed.name | (self) | Return the name of the LED. | Return the name of the LED. | def name(self):
"""Return the name of the LED."""
return f"{self._area_name} {self._keypad_name}: {self._scene_name} LED" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._area_name} {self._keypad_name}: {self._scene_name} LED\""
] | [
91,
4
] | [
93,
79
] | python | en | ['en', 'en', 'en'] | True |
LutronLed.update | (self) | Call when forcing a refresh of the device. | Call when forcing a refresh of the device. | def update(self):
"""Call when forcing a refresh of the device."""
if self._lutron_device.last_state is not None:
return
# The following property getter actually triggers an update in Lutron
self._lutron_device.state | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lutron_device",
".",
"last_state",
"is",
"not",
"None",
":",
"return",
"# The following property getter actually triggers an update in Lutron",
"self",
".",
"_lutron_device",
".",
"state"
] | [
95,
4
] | [
101,
33
] | python | en | ['en', 'en', 'en'] | True |
TestAnotherFakeApi.test_call_123_test_special_tags | (self) | Test case for call_123_test_special_tags
To test special tags # noqa: E501
| Test case for call_123_test_special_tags | def test_call_123_test_special_tags(self):
"""Test case for call_123_test_special_tags
To test special tags # noqa: E501
"""
pass | [
"def",
"test_call_123_test_special_tags",
"(",
"self",
")",
":",
"pass"
] | [
29,
4
] | [
34,
12
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities_callback, discovery_info=None) | Set up S20 switches. | Set up S20 switches. | def setup_platform(hass, config, add_entities_callback, discovery_info=None):
"""Set up S20 switches."""
switch_data = {}
switches = []
switch_conf = config.get(CONF_SWITCHES, [config])
if config.get(CONF_DISCOVERY):
_LOGGER.info("Discovering S20 switches")
switch_data.update(disco... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"switch_data",
"=",
"{",
"}",
"switches",
"=",
"[",
"]",
"switch_conf",
"=",
"config",
".",
"get",
"(",
"CONF_SWITCHES",
",",
"... | [
38,
0
] | [
61,
35
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.__init__ | (self, name, s20) | Initialize the S20 device. | Initialize the S20 device. | def __init__(self, name, s20):
"""Initialize the S20 device."""
self._name = name
self._s20 = s20
self._state = False
self._exc = S20Exception | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"s20",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_s20",
"=",
"s20",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_exc",
"=",
"S20Exception"
] | [
67,
4
] | [
73,
32
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
76,
4
] | [
78,
25
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
81,
4
] | [
83,
26
] | python | en | ['en', 'fy', 'en'] | True |
S20Switch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
try:
self._state = self._s20.on
except self._exc:
_LOGGER.exception("Error while fetching S20 state") | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_s20",
".",
"on",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while fetching S20 state\"",
")"
] | [
85,
4
] | [
90,
63
] | python | en | ['fr', 'en', 'en'] | True |
S20Switch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
try:
self._s20.on = True
except self._exc:
_LOGGER.exception("Error while turning on S20") | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_s20",
".",
"on",
"=",
"True",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while turning on S20\"",
")"
] | [
92,
4
] | [
97,
59
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
try:
self._s20.on = False
except self._exc:
_LOGGER.exception("Error while turning off S20") | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_s20",
".",
"on",
"=",
"False",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while turning off S20\"",
")"
] | [
99,
4
] | [
104,
60
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the APCUPSd sensors. | Set up the APCUPSd sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the APCUPSd sensors."""
apcups_data = hass.data[DOMAIN]
resources = config[CONF_RESOURCES]
for resource in resources:
if resource.upper() not in apcups_data.status:
_LOGGER.warning(
"Senso... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"apcups_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"resources",
"=",
"config",
"[",
"CONF_RESOURCES",
"]",
"for",
"resource",
... | [
411,
0
] | [
429,
32
] | python | en | ['en', 'ca', 'en'] | True |
infer_unit | (value) | If the value ends with any of the units from ALL_UNITS.
Split the unit off the end of the value and return the value, unit tuple
pair. Else return the original value and None as the unit.
| If the value ends with any of the units from ALL_UNITS. | def infer_unit(value):
"""If the value ends with any of the units from ALL_UNITS.
Split the unit off the end of the value and return the value, unit tuple
pair. Else return the original value and None as the unit.
"""
for unit in ALL_UNITS:
if value.endswith(unit):
return value... | [
"def",
"infer_unit",
"(",
"value",
")",
":",
"for",
"unit",
"in",
"ALL_UNITS",
":",
"if",
"value",
".",
"endswith",
"(",
"unit",
")",
":",
"return",
"value",
"[",
":",
"-",
"len",
"(",
"unit",
")",
"]",
",",
"INFERRED_UNITS",
".",
"get",
"(",
"unit... | [
432,
0
] | [
442,
22
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdSensor.__init__ | (self, data, description: SensorEntityDescription) | Initialize the sensor. | Initialize the sensor. | def __init__(self, data, description: SensorEntityDescription):
"""Initialize the sensor."""
self.entity_description = description
self._data = data
self._attr_name = f"{SENSOR_PREFIX}{description.name}" | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_attr_name",
"=",
"f\"{SENSOR_PREFIX}{description.nam... | [
448,
4
] | [
452,
62
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdSensor.update | (self) | Get the latest status and use it to update our sensor state. | Get the latest status and use it to update our sensor state. | def update(self):
"""Get the latest status and use it to update our sensor state."""
key = self.entity_description.key.upper()
if key not in self._data.status:
self._attr_native_value = None
else:
self._attr_native_value, inferred_unit = infer_unit(self._data.stat... | [
"def",
"update",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"entity_description",
".",
"key",
".",
"upper",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_data",
".",
"status",
":",
"self",
".",
"_attr_native_value",
"=",
"None",
"else",
":"... | [
454,
4
] | [
462,
69
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, _: ConfigType) | Set up the analytics integration. | Set up the analytics integration. | async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
"""Set up the analytics integration."""
analytics = Analytics(hass)
# Load stored data
await analytics.load()
async def start_schedule(_event):
"""Start the send schedule after the started event."""
# Wait 15 min af... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"_",
":",
"ConfigType",
")",
"->",
"bool",
":",
"analytics",
"=",
"Analytics",
"(",
"hass",
")",
"# Load stored data",
"await",
"analytics",
".",
"load",
"(",
")",
"async",
"def",
"star... | [
13,
0
] | [
34,
15
] | python | en | ['en', 'ky', 'en'] | True |
websocket_analytics | (
hass: HomeAssistant,
connection: websocket_api.connection.ActiveConnection,
msg: dict,
) | Return analytics preferences. | Return analytics preferences. | async def websocket_analytics(
hass: HomeAssistant,
connection: websocket_api.connection.ActiveConnection,
msg: dict,
) -> None:
"""Return analytics preferences."""
analytics: Analytics = hass.data[DOMAIN]
connection.send_result(
msg["id"],
{ATTR_PREFERENCES: analytics.preference... | [
"async",
"def",
"websocket_analytics",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection",
":",
"websocket_api",
".",
"connection",
".",
"ActiveConnection",
",",
"msg",
":",
"dict",
",",
")",
"->",
"None",
":",
"analytics",
":",
"Analytics",
"=",
"hass",
"... | [
40,
0
] | [
50,
5
] | python | en | ['en', 'ru-Latn', 'en'] | True |
websocket_analytics_preferences | (
hass: HomeAssistant,
connection: websocket_api.connection.ActiveConnection,
msg: dict,
) | Update analytics preferences. | Update analytics preferences. | async def websocket_analytics_preferences(
hass: HomeAssistant,
connection: websocket_api.connection.ActiveConnection,
msg: dict,
) -> None:
"""Update analytics preferences."""
preferences = msg[ATTR_PREFERENCES]
analytics: Analytics = hass.data[DOMAIN]
await analytics.save_preferences(pref... | [
"async",
"def",
"websocket_analytics_preferences",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection",
":",
"websocket_api",
".",
"connection",
".",
"ActiveConnection",
",",
"msg",
":",
"dict",
",",
")",
"->",
"None",
":",
"preferences",
"=",
"msg",
"[",
"AT... | [
61,
0
] | [
76,
5
] | python | en | ['en', 'de', 'en'] | True |
GrandparentAnimal.openapi_types | () |
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
|
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded | def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
lazy... | [
"def",
"openapi_types",
"(",
")",
":",
"lazy_import",
"(",
")",
"return",
"{",
"'pet_type'",
":",
"(",
"str",
",",
")",
",",
"# noqa: E501",
"}"
] | [
70,
4
] | [
82,
9
] | python | en | ['en', 'error', 'th'] | False |
GrandparentAnimal.__init__ | (self, pet_type, *args, **kwargs) | GrandparentAnimal - a model defined in OpenAPI
Args:
pet_type (str):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wron... | GrandparentAnimal - a model defined in OpenAPI | def __init__(self, pet_type, *args, **kwargs): # noqa: E501
"""GrandparentAnimal - a model defined in OpenAPI
Args:
pet_type (str):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked an... | [
"def",
"__init__",
"(",
"self",
",",
"pet_type",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"_check_type",
"=",
"kwargs",
".",
"pop",
"(",
"'_check_type'",
",",
"True",
")",
"_spec_property_naming",
"=",
"kwargs",
".",
"pop",
"(... | [
111,
4
] | [
181,
46
] | python | en | ['en', 'it', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Pushbullet Sensor platform. | Set up the Pushbullet Sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Pushbullet Sensor platform."""
try:
pushbullet = PushBullet(config.get(CONF_API_KEY))
except InvalidKeyError:
_LOGGER.error("Wrong API key for Pushbullet supplied")
return False
pbprovider = Push... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"try",
":",
"pushbullet",
"=",
"PushBullet",
"(",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
")",
"except",
"InvalidKeyError",
":",
... | [
74,
0
] | [
91,
26
] | python | en | ['en', 'da', 'en'] | True |
PushBulletNotificationSensor.__init__ | (self, pb, description: SensorEntityDescription) | Initialize the Pushbullet sensor. | Initialize the Pushbullet sensor. | def __init__(self, pb, description: SensorEntityDescription):
"""Initialize the Pushbullet sensor."""
self.entity_description = description
self.pushbullet = pb
self._attr_name = f"Pushbullet {description.key}" | [
"def",
"__init__",
"(",
"self",
",",
"pb",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"pushbullet",
"=",
"pb",
"self",
".",
"_attr_name",
"=",
"f\"Pushbullet {description.key}\"... | [
97,
4
] | [
102,
57
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationSensor.update | (self) | Fetch the latest data from the sensor.
This will fetch the 'sensor reading' into self._state but also all
attributes into self._state_attributes.
| Fetch the latest data from the sensor. | def update(self):
"""Fetch the latest data from the sensor.
This will fetch the 'sensor reading' into self._state but also all
attributes into self._state_attributes.
"""
try:
self._attr_native_value = self.pushbullet.data[self.entity_description.key]
sel... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_attr_native_value",
"=",
"self",
".",
"pushbullet",
".",
"data",
"[",
"self",
".",
"entity_description",
".",
"key",
"]",
"self",
".",
"_attr_extra_state_attributes",
"=",
"self",
".",
"pus... | [
104,
4
] | [
114,
16
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationProvider.__init__ | (self, pb) | Start to retrieve pushes from the given Pushbullet instance. | Start to retrieve pushes from the given Pushbullet instance. | def __init__(self, pb):
"""Start to retrieve pushes from the given Pushbullet instance."""
self.pushbullet = pb
self._data = None
self.listener = None
self.thread = threading.Thread(target=self.retrieve_pushes)
self.thread.daemon = True
self.thread.start() | [
"def",
"__init__",
"(",
"self",
",",
"pb",
")",
":",
"self",
".",
"pushbullet",
"=",
"pb",
"self",
".",
"_data",
"=",
"None",
"self",
".",
"listener",
"=",
"None",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
... | [
120,
4
] | [
128,
27
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationProvider.on_push | (self, data) | Update the current data.
Currently only monitors pushes but might be extended to monitor
different kinds of Pushbullet events.
| Update the current data. | def on_push(self, data):
"""Update the current data.
Currently only monitors pushes but might be extended to monitor
different kinds of Pushbullet events.
"""
if data["type"] == "push":
self._data = data["push"] | [
"def",
"on_push",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
"[",
"\"type\"",
"]",
"==",
"\"push\"",
":",
"self",
".",
"_data",
"=",
"data",
"[",
"\"push\"",
"]"
] | [
130,
4
] | [
137,
37
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationProvider.data | (self) | Return the current data stored in the provider. | Return the current data stored in the provider. | def data(self):
"""Return the current data stored in the provider."""
return self._data | [
"def",
"data",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data"
] | [
140,
4
] | [
142,
25
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationProvider.retrieve_pushes | (self) | Retrieve_pushes.
Spawn a new Listener and links it to self.on_push.
| Retrieve_pushes. | def retrieve_pushes(self):
"""Retrieve_pushes.
Spawn a new Listener and links it to self.on_push.
"""
self.listener = Listener(account=self.pushbullet, on_push=self.on_push)
_LOGGER.debug("Getting pushes")
try:
self.listener.run_forever()
finally:
... | [
"def",
"retrieve_pushes",
"(",
"self",
")",
":",
"self",
".",
"listener",
"=",
"Listener",
"(",
"account",
"=",
"self",
".",
"pushbullet",
",",
"on_push",
"=",
"self",
".",
"on_push",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Getting pushes\"",
")",
"try",
"... | [
144,
4
] | [
155,
33
] | python | en | ['en', 'hi-Latn', 'en'] | False |
escape_characteristic_name | (char_name) | Escape any dash or dots in a characteristics name. | Escape any dash or dots in a characteristics name. | def escape_characteristic_name(char_name):
"""Escape any dash or dots in a characteristics name."""
return char_name.replace("-", "_").replace(".", "_") | [
"def",
"escape_characteristic_name",
"(",
"char_name",
")",
":",
"return",
"char_name",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"_\"",
")"
] | [
26,
0
] | [
28,
56
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a HomeKit connection on a config entry. | Set up a HomeKit connection on a config entry. | async def async_setup_entry(hass, entry):
"""Set up a HomeKit connection on a config entry."""
conn = HKDevice(hass, entry, entry.data)
hass.data[KNOWN_DEVICES][conn.unique_id] = conn
# For backwards compat
if entry.unique_id is None:
hass.config_entries.async_update_entry(
entr... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"conn",
"=",
"HKDevice",
"(",
"hass",
",",
"entry",
",",
"entry",
".",
"data",
")",
"hass",
".",
"data",
"[",
"KNOWN_DEVICES",
"]",
"[",
"conn",
".",
"unique_id",
"]",
"=",
"co... | [
203,
0
] | [
218,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up for Homekit devices. | Set up for Homekit devices. | async def async_setup(hass, config):
"""Set up for Homekit devices."""
map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass)
await map_storage.async_initialize()
async_zeroconf_instance = await zeroconf.async_get_async_instance(hass)
hass.data[CONTROLLER] = aiohomekit.Controller(
asy... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"map_storage",
"=",
"hass",
".",
"data",
"[",
"ENTITY_MAP",
"]",
"=",
"EntityMapStorage",
"(",
"hass",
")",
"await",
"map_storage",
".",
"async_initialize",
"(",
")",
"async_zeroconf_instance... | [
221,
0
] | [
243,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Disconnect from HomeKit devices before unloading entry. | Disconnect from HomeKit devices before unloading entry. | async def async_unload_entry(hass, entry):
"""Disconnect from HomeKit devices before unloading entry."""
hkid = entry.data["AccessoryPairingID"]
if hkid in hass.data[KNOWN_DEVICES]:
connection = hass.data[KNOWN_DEVICES][hkid]
await connection.async_unload()
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hkid",
"=",
"entry",
".",
"data",
"[",
"\"AccessoryPairingID\"",
"]",
"if",
"hkid",
"in",
"hass",
".",
"data",
"[",
"KNOWN_DEVICES",
"]",
":",
"connection",
"=",
"hass",
".",
"da... | [
246,
0
] | [
254,
15
] | python | en | ['en', 'en', 'en'] | True |
async_remove_entry | (hass, entry) | Cleanup caches before removing config entry. | Cleanup caches before removing config entry. | async def async_remove_entry(hass, entry):
"""Cleanup caches before removing config entry."""
hkid = entry.data["AccessoryPairingID"]
hass.data[ENTITY_MAP].async_delete_map(hkid) | [
"async",
"def",
"async_remove_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hkid",
"=",
"entry",
".",
"data",
"[",
"\"AccessoryPairingID\"",
"]",
"hass",
".",
"data",
"[",
"ENTITY_MAP",
"]",
".",
"async_delete_map",
"(",
"hkid",
")"
] | [
257,
0
] | [
260,
48
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.__init__ | (self, accessory, devinfo) | Initialise a generic HomeKit device. | Initialise a generic HomeKit device. | def __init__(self, accessory, devinfo):
"""Initialise a generic HomeKit device."""
self._accessory = accessory
self._aid = devinfo["aid"]
self._iid = devinfo["iid"]
self._features = 0
self.setup()
self._signals = []
super().__init__() | [
"def",
"__init__",
"(",
"self",
",",
"accessory",
",",
"devinfo",
")",
":",
"self",
".",
"_accessory",
"=",
"accessory",
"self",
".",
"_aid",
"=",
"devinfo",
"[",
"\"aid\"",
"]",
"self",
".",
"_iid",
"=",
"devinfo",
"[",
"\"iid\"",
"]",
"self",
".",
... | [
36,
4
] | [
46,
26
] | python | en | ['fr', 'en', 'en'] | True |
HomeKitEntity.accessory | (self) | Return an Accessory model that this entity is attached to. | Return an Accessory model that this entity is attached to. | def accessory(self) -> Accessory:
"""Return an Accessory model that this entity is attached to."""
return self._accessory.entity_map.aid(self._aid) | [
"def",
"accessory",
"(",
"self",
")",
"->",
"Accessory",
":",
"return",
"self",
".",
"_accessory",
".",
"entity_map",
".",
"aid",
"(",
"self",
".",
"_aid",
")"
] | [
49,
4
] | [
51,
56
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.accessory_info | (self) | Information about the make and model of an accessory. | Information about the make and model of an accessory. | def accessory_info(self) -> Service:
"""Information about the make and model of an accessory."""
return self.accessory.services.first(
service_type=ServicesTypes.ACCESSORY_INFORMATION
) | [
"def",
"accessory_info",
"(",
"self",
")",
"->",
"Service",
":",
"return",
"self",
".",
"accessory",
".",
"services",
".",
"first",
"(",
"service_type",
"=",
"ServicesTypes",
".",
"ACCESSORY_INFORMATION",
")"
] | [
54,
4
] | [
58,
9
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.service | (self) | Return a Service model that this entity is attached to. | Return a Service model that this entity is attached to. | def service(self) -> Service:
"""Return a Service model that this entity is attached to."""
return self.accessory.services.iid(self._iid) | [
"def",
"service",
"(",
"self",
")",
"->",
"Service",
":",
"return",
"self",
".",
"accessory",
".",
"services",
".",
"iid",
"(",
"self",
".",
"_iid",
")"
] | [
61,
4
] | [
63,
53
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.async_added_to_hass | (self) | Entity added to hass. | Entity added to hass. | async def async_added_to_hass(self):
"""Entity added to hass."""
self._signals.append(
self.hass.helpers.dispatcher.async_dispatcher_connect(
self._accessory.signal_state_updated, self.async_write_ha_state
)
)
self._accessory.add_pollable_characte... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_signals",
".",
"append",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"self",
".",
"_accessory",
".",
"signal_state_updated",
","... | [
65,
4
] | [
74,
85
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.async_will_remove_from_hass | (self) | Prepare to be removed from hass. | Prepare to be removed from hass. | async def async_will_remove_from_hass(self):
"""Prepare to be removed from hass."""
self._accessory.remove_pollable_characteristics(self._aid)
self._accessory.remove_watchable_characteristics(self._aid)
for signal_remove in self._signals:
signal_remove()
self._signal... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_accessory",
".",
"remove_pollable_characteristics",
"(",
"self",
".",
"_aid",
")",
"self",
".",
"_accessory",
".",
"remove_watchable_characteristics",
"(",
"self",
".",
"_aid",
")... | [
76,
4
] | [
83,
29
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.async_put_characteristics | (self, characteristics: dict[str, Any]) |
Write characteristics to the device.
A characteristic type is unique within a service, but in order to write
to a named characteristic on a bridge we need to turn its type into
an aid and iid, and send it as a list of tuples, which is what this
helper does.
E.g. you ca... |
Write characteristics to the device. | async def async_put_characteristics(self, characteristics: dict[str, Any]):
"""
Write characteristics to the device.
A characteristic type is unique within a service, but in order to write
to a named characteristic on a bridge we need to turn its type into
an aid and iid, and se... | [
"async",
"def",
"async_put_characteristics",
"(",
"self",
",",
"characteristics",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"payload",
"=",
"self",
".",
"service",
".",
"build_update",
"(",
"characteristics",
")",
"return",
"await",
"self",
".",
... | [
85,
4
] | [
101,
65
] | python | en | ['en', 'error', 'th'] | False |
HomeKitEntity.setup | (self) | Configure an entity baed on its HomeKit characteristics metadata. | Configure an entity baed on its HomeKit characteristics metadata. | def setup(self):
"""Configure an entity baed on its HomeKit characteristics metadata."""
self.pollable_characteristics = []
self.watchable_characteristics = []
char_types = self.get_characteristic_types()
# Setup events and/or polling for characteristics directly attached to th... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"pollable_characteristics",
"=",
"[",
"]",
"self",
".",
"watchable_characteristics",
"=",
"[",
"]",
"char_types",
"=",
"self",
".",
"get_characteristic_types",
"(",
")",
"# Setup events and/or polling for character... | [
103,
4
] | [
118,
48
] | python | en | ['en', 'et', 'en'] | True |
HomeKitEntity._setup_characteristic | (self, char: Characteristic) | Configure an entity based on a HomeKit characteristics metadata. | Configure an entity based on a HomeKit characteristics metadata. | def _setup_characteristic(self, char: Characteristic):
"""Configure an entity based on a HomeKit characteristics metadata."""
# Build up a list of (aid, iid) tuples to poll on update()
if CharacteristicPermissions.paired_read in char.perms:
self.pollable_characteristics.append((self.... | [
"def",
"_setup_characteristic",
"(",
"self",
",",
"char",
":",
"Characteristic",
")",
":",
"# Build up a list of (aid, iid) tuples to poll on update()",
"if",
"CharacteristicPermissions",
".",
"paired_read",
"in",
"char",
".",
"perms",
":",
"self",
".",
"pollable_characte... | [
120,
4
] | [
128,
72
] | python | en | ['en', 'haw', 'en'] | True |
HomeKitEntity.unique_id | (self) | Return the ID of this device. | Return the ID of this device. | def unique_id(self) -> str:
"""Return the ID of this device."""
serial = self.accessory_info.value(CharacteristicsTypes.SERIAL_NUMBER)
return f"homekit-{serial}-{self._iid}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"serial",
"=",
"self",
".",
"accessory_info",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"SERIAL_NUMBER",
")",
"return",
"f\"homekit-{serial}-{self._iid}\""
] | [
131,
4
] | [
134,
46
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self) -> str:
"""Return the name of the device if any."""
return self.accessory_info.value(CharacteristicsTypes.NAME) | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"accessory_info",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"NAME",
")"
] | [
137,
4
] | [
139,
67
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._accessory.available and self.service.available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_accessory",
".",
"available",
"and",
"self",
".",
"service",
".",
"available"
] | [
142,
4
] | [
144,
67
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
info = self.accessory_info
accessory_serial = info.value(CharacteristicsTypes.SERIAL_NUMBER)
device_info = {
"identifiers": {(DOMAIN, "serial-number", accessory_serial)},
"name": info.value(CharacteristicsTypes... | [
"def",
"device_info",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"accessory_info",
"accessory_serial",
"=",
"info",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"SERIAL_NUMBER",
")",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",... | [
147,
4
] | [
166,
26
] | python | en | ['en', 'en', 'en'] | True |
HomeKitEntity.get_characteristic_types | (self) | Define the homekit characteristics the entity cares about. | Define the homekit characteristics the entity cares about. | def get_characteristic_types(self):
"""Define the homekit characteristics the entity cares about."""
raise NotImplementedError | [
"def",
"get_characteristic_types",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
168,
4
] | [
170,
33
] | python | en | ['en', 'en', 'en'] | True |
AccessoryEntity.unique_id | (self) | Return the ID of this device. | Return the ID of this device. | def unique_id(self) -> str:
"""Return the ID of this device."""
serial = self.accessory_info.value(CharacteristicsTypes.SERIAL_NUMBER)
return f"homekit-{serial}-aid:{self._aid}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"serial",
"=",
"self",
".",
"accessory_info",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"SERIAL_NUMBER",
")",
"return",
"f\"homekit-{serial}-aid:{self._aid}\""
] | [
177,
4
] | [
180,
50
] | python | en | ['en', 'en', 'en'] | True |
CharacteristicEntity.__init__ | (self, accessory, devinfo, char) | Initialise a generic single characteristic HomeKit entity. | Initialise a generic single characteristic HomeKit entity. | def __init__(self, accessory, devinfo, char):
"""Initialise a generic single characteristic HomeKit entity."""
self._char = char
super().__init__(accessory, devinfo) | [
"def",
"__init__",
"(",
"self",
",",
"accessory",
",",
"devinfo",
",",
"char",
")",
":",
"self",
".",
"_char",
"=",
"char",
"super",
"(",
")",
".",
"__init__",
"(",
"accessory",
",",
"devinfo",
")"
] | [
191,
4
] | [
194,
44
] | python | en | ['en', 'en', 'en'] | True |
CharacteristicEntity.unique_id | (self) | Return the ID of this device. | Return the ID of this device. | def unique_id(self) -> str:
"""Return the ID of this device."""
serial = self.accessory_info.value(CharacteristicsTypes.SERIAL_NUMBER)
return f"homekit-{serial}-aid:{self._aid}-sid:{self._char.service.iid}-cid:{self._char.iid}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"serial",
"=",
"self",
".",
"accessory_info",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"SERIAL_NUMBER",
")",
"return",
"f\"homekit-{serial}-aid:{self._aid}-sid:{self._char.service.iid}-cid:{self._char.iid}\""
] | [
197,
4
] | [
200,
100
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the BeagleBone Black GPIO component. | Set up the BeagleBone Black GPIO component. | def setup(hass, config):
"""Set up the BeagleBone Black GPIO component."""
def cleanup_gpio(event):
"""Stuff to do before stopping."""
GPIO.cleanup()
def prepare_gpio(event):
"""Stuff to do when Home Assistant starts."""
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanu... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"def",
"cleanup_gpio",
"(",
"event",
")",
":",
"\"\"\"Stuff to do before stopping.\"\"\"",
"GPIO",
".",
"cleanup",
"(",
")",
"def",
"prepare_gpio",
"(",
"event",
")",
":",
"\"\"\"Stuff to do when Home Assistant... | [
8,
0
] | [
20,
15
] | python | en | ['en', 'pt', 'en'] | True |
setup_output | (pin) | Set up a GPIO as output. | Set up a GPIO as output. | def setup_output(pin):
"""Set up a GPIO as output."""
GPIO.setup(pin, GPIO.OUT) | [
"def",
"setup_output",
"(",
"pin",
")",
":",
"GPIO",
".",
"setup",
"(",
"pin",
",",
"GPIO",
".",
"OUT",
")"
] | [
23,
0
] | [
26,
29
] | python | en | ['en', 'el-Latn', 'en'] | True |
setup_input | (pin, pull_mode) | Set up a GPIO as input. | Set up a GPIO as input. | def setup_input(pin, pull_mode):
"""Set up a GPIO as input."""
GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP) | [
"def",
"setup_input",
"(",
"pin",
",",
"pull_mode",
")",
":",
"GPIO",
".",
"setup",
"(",
"pin",
",",
"GPIO",
".",
"IN",
",",
"GPIO",
".",
"PUD_DOWN",
"if",
"pull_mode",
"==",
"\"DOWN\"",
"else",
"GPIO",
".",
"PUD_UP",
")"
] | [
29,
0
] | [
32,
83
] | python | en | ['en', 'haw', 'en'] | True |
write_output | (pin, value) | Write a value to a GPIO. | Write a value to a GPIO. | def write_output(pin, value):
"""Write a value to a GPIO."""
GPIO.output(pin, value) | [
"def",
"write_output",
"(",
"pin",
",",
"value",
")",
":",
"GPIO",
".",
"output",
"(",
"pin",
",",
"value",
")"
] | [
35,
0
] | [
38,
27
] | python | en | ['en', 'pt', 'en'] | True |
read_input | (pin) | Read a value from a GPIO. | Read a value from a GPIO. | def read_input(pin):
"""Read a value from a GPIO."""
return GPIO.input(pin) is GPIO.HIGH | [
"def",
"read_input",
"(",
"pin",
")",
":",
"return",
"GPIO",
".",
"input",
"(",
"pin",
")",
"is",
"GPIO",
".",
"HIGH"
] | [
41,
0
] | [
44,
39
] | python | en | ['en', 'en', 'en'] | True |
edge_detect | (pin, event_callback, bounce) | Add detection for RISING and FALLING events. | Add detection for RISING and FALLING events. | def edge_detect(pin, event_callback, bounce):
"""Add detection for RISING and FALLING events."""
GPIO.add_event_detect(pin, GPIO.BOTH, callback=event_callback, bouncetime=bounce) | [
"def",
"edge_detect",
"(",
"pin",
",",
"event_callback",
",",
"bounce",
")",
":",
"GPIO",
".",
"add_event_detect",
"(",
"pin",
",",
"GPIO",
".",
"BOTH",
",",
"callback",
"=",
"event_callback",
",",
"bouncetime",
"=",
"bounce",
")"
] | [
47,
0
] | [
50,
85
] | python | en | ['en', 'en', 'en'] | True |
scanner | (hass, enable_custom_integrations) | Initialize components. | Initialize components. | def scanner(hass, enable_custom_integrations):
"""Initialize components."""
scanner = getattr(hass.components, "test.device_tracker").get_scanner(None, None)
scanner.reset()
scanner.come_home("DEV1")
getattr(hass.components, "test.light").init()
with patch(
"homeassistant.components.d... | [
"def",
"scanner",
"(",
"hass",
",",
"enable_custom_integrations",
")",
":",
"scanner",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"\"test.device_tracker\"",
")",
".",
"get_scanner",
"(",
"None",
",",
"None",
")",
"scanner",
".",
"reset",
"(",
")",
... | [
31,
0
] | [
73,
18
] | python | en | ['de', 'en', 'en'] | False |
test_lights_on_when_sun_sets | (hass, scanner) | Test lights go on when there is someone home and the sun sets. | Test lights go on when there is someone home and the sun sets. | async def test_lights_on_when_sun_sets(hass, scanner):
"""Test lights go on when there is someone home and the sun sets."""
test_time = datetime(2017, 4, 5, 1, 2, 3, tzinfo=dt_util.UTC)
with patch("homeassistant.util.dt.utcnow", return_value=test_time):
assert await async_setup_component(
... | [
"async",
"def",
"test_lights_on_when_sun_sets",
"(",
"hass",
",",
"scanner",
")",
":",
"test_time",
"=",
"datetime",
"(",
"2017",
",",
"4",
",",
"5",
",",
"1",
",",
"2",
",",
"3",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"with",
"patch",
"(",
... | [
76,
0
] | [
99,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lights_turn_off_when_everyone_leaves | (hass, enable_custom_integrations) | Test lights turn off when everyone leaves the house. | Test lights turn off when everyone leaves the house. | async def test_lights_turn_off_when_everyone_leaves(hass, enable_custom_integrations):
"""Test lights turn off when everyone leaves the house."""
assert await async_setup_component(
hass, "light", {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
await hass.services.async_call(
light.DOMAIN,
... | [
"async",
"def",
"test_lights_turn_off_when_everyone_leaves",
"(",
"hass",
",",
"enable_custom_integrations",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"light\"",
",",
"{",
"light",
".",
"DOMAIN",
":",
"{",
"CONF_PLATFORM",
":",
"\"tes... | [
102,
0
] | [
126,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lights_turn_on_when_coming_home_after_sun_set | (hass, scanner) | Test lights turn on when coming home after sun set. | Test lights turn on when coming home after sun set. | async def test_lights_turn_on_when_coming_home_after_sun_set(hass, scanner):
"""Test lights turn on when coming home after sun set."""
test_time = datetime(2017, 4, 5, 3, 2, 3, tzinfo=dt_util.UTC)
with patch("homeassistant.util.dt.utcnow", return_value=test_time):
await hass.services.async_call(
... | [
"async",
"def",
"test_lights_turn_on_when_coming_home_after_sun_set",
"(",
"hass",
",",
"scanner",
")",
":",
"test_time",
"=",
"datetime",
"(",
"2017",
",",
"4",
",",
"5",
",",
"3",
",",
"2",
",",
"3",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"wit... | [
129,
0
] | [
148,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lights_turn_on_when_coming_home_after_sun_set_person | (hass, scanner) | Test lights turn on when coming home after sun set. | Test lights turn on when coming home after sun set. | async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanner):
"""Test lights turn on when coming home after sun set."""
device_1 = f"{DOMAIN}.device_1"
device_2 = f"{DOMAIN}.device_2"
test_time = datetime(2017, 4, 5, 3, 2, 3, tzinfo=dt_util.UTC)
with patch("homeassistant.util.... | [
"async",
"def",
"test_lights_turn_on_when_coming_home_after_sun_set_person",
"(",
"hass",
",",
"scanner",
")",
":",
"device_1",
"=",
"f\"{DOMAIN}.device_1\"",
"device_2",
"=",
"f\"{DOMAIN}.device_2\"",
"test_time",
"=",
"datetime",
"(",
"2017",
",",
"4",
",",
"5",
","... | [
151,
0
] | [
219,
59
] | python | en | ['en', 'en', 'en'] | True |
test_initialize_start | (hass) | Test we initialize when HA starts. | Test we initialize when HA starts. | async def test_initialize_start(hass):
"""Test we initialize when HA starts."""
hass.state = CoreState.not_running
assert await async_setup_component(
hass,
device_sun_light_trigger.DOMAIN,
{device_sun_light_trigger.DOMAIN: {}},
)
with patch(
"homeassistant.component... | [
"async",
"def",
"test_initialize_start",
"(",
"hass",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_sun_light_trigger",
".",
"DOMAIN",
",",
"{",
"device_sun_light_trigger",... | [
222,
0
] | [
237,
45
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_states | (
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) | Reproduce component states. | Reproduce component states. | async def _async_reproduce_states(
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) -> None:
"""Reproduce component states."""
async def call_service(service: str, keys: Iterable, data=None):
"""Call service wit... | [
"async",
"def",
"_async_reproduce_states",
"(",
"hass",
":",
"HomeAssistant",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Context",
"|",
"None",
"=",
"None",
",",
"reproduce_options",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",... | [
29,
0
] | [
73,
65
] | python | en | ['de', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) | Reproduce component states. | Reproduce component states. | async def async_reproduce_states(
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) -> None:
"""Reproduce component states."""
await asyncio.gather(
*(
_async_reproduce_states(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistant",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Context",
"|",
"None",
"=",
"None",
",",
"reproduce_options",
":",
"dict",
"[",
"str",
",",
"A... | [
76,
0
] | [
91,
5
] | python | en | ['de', 'en', 'en'] | True |
TestModel200Response.make_instance | (self, include_optional) | Test Model200Response
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test Model200Response
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | def make_instance(self, include_optional):
"""Test Model200Response
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.model200_response.Model200Response... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"# model = petstore_api.models.model200_response.Model200Response() # noqa: E501",
"if",
"include_optional",
":",
"return",
"Model200Response",
"(",
"name",
"=",
"56",
",",
"_class",
"=",
"''",
")",
... | [
30,
4
] | [
43,
9
] | python | en | ['en', 'no', 'en'] | False |
TestModel200Response.testModel200Response | (self) | Test Model200Response | Test Model200Response | def testModel200Response(self):
"""Test Model200Response"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True) | [
"def",
"testModel200Response",
"(",
"self",
")",
":",
"inst_req_only",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"False",
")",
"inst_req_and_optional",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"True",
")"
] | [
45,
4
] | [
48,
73
] | python | en | ['en', 'no', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the eQ-3 BLE thermostats. | Set up the eQ-3 BLE thermostats. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the eQ-3 BLE thermostats."""
devices = []
for name, device_cfg in config[CONF_DEVICES].items():
mac = device_cfg[CONF_MAC]
devices.append(EQ3BTSmartThermostat(mac, name))
add_entities(devices, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"name",
",",
"device_cfg",
"in",
"config",
"[",
"CONF_DEVICES",
"]",
".",
"items",
"(",
")",
":",
"... | [
66,
0
] | [
74,
31
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.__init__ | (self, _mac, _name) | Initialize the thermostat. | Initialize the thermostat. | def __init__(self, _mac, _name):
"""Initialize the thermostat."""
# We want to avoid name clash with this module.
self._name = _name
self._thermostat = eq3.Thermostat(_mac) | [
"def",
"__init__",
"(",
"self",
",",
"_mac",
",",
"_name",
")",
":",
"# We want to avoid name clash with this module.",
"self",
".",
"_name",
"=",
"_name",
"self",
".",
"_thermostat",
"=",
"eq3",
".",
"Thermostat",
"(",
"_mac",
")"
] | [
80,
4
] | [
84,
47
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.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 SUPPORT_FLAGS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_FLAGS"
] | [
87,
4
] | [
89,
28
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.available | (self) | Return if thermostat is available. | Return if thermostat is available. | def available(self) -> bool:
"""Return if thermostat is available."""
return self._thermostat.mode >= 0 | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_thermostat",
".",
"mode",
">=",
"0"
] | [
92,
4
] | [
94,
41
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.temperature_unit | (self) | Return the unit of measurement that is used. | Return the unit of measurement that is used. | def temperature_unit(self):
"""Return the unit of measurement that is used."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
102,
4
] | [
104,
27
] | python | en | ['en', 'en', 'en'] | True |
EQ3BTSmartThermostat.precision | (self) | Return eq3bt's precision 0.5. | Return eq3bt's precision 0.5. | def precision(self):
"""Return eq3bt's precision 0.5."""
return PRECISION_HALVES | [
"def",
"precision",
"(",
"self",
")",
":",
"return",
"PRECISION_HALVES"
] | [
107,
4
] | [
109,
31
] | python | en | ['en', 'cy', 'en'] | True |
EQ3BTSmartThermostat.current_temperature | (self) | Can not report temperature, so return target_temperature. | Can not report temperature, so return target_temperature. | def current_temperature(self):
"""Can not report temperature, so return target_temperature."""
return self.target_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"target_temperature"
] | [
112,
4
] | [
114,
38
] | python | en | ['en', 'la', 'en'] | True |
EQ3BTSmartThermostat.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."""
return self._thermostat.target_temperature | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_thermostat",
".",
"target_temperature"
] | [
117,
4
] | [
119,
50
] | 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.