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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_setup_entry_multiple_gateways | (hass) | Test setup entry is successful with multiple gateways. | Test setup entry is successful with multiple gateways. | async def test_setup_entry_multiple_gateways(hass):
"""Test setup entry is successful with multiple gateways."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
data = deepcopy(DECONZ_WEB_REQUEST)
data["config"]["bridgeid"] = "01234E56... | [
"async",
"def",
"test_setup_entry_multiple_gateways",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"data",
"=",
"deepcopy",
... | [
62,
0
] | [
76,
65
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test being able to unload an entry. | Test being able to unload an entry. | async def test_unload_entry(hass):
"""Test being able to unload an entry."""
config_entry = await setup_deconz_integration(hass)
assert hass.data[DECONZ_DOMAIN]
assert await async_unload_entry(hass, config_entry)
assert not hass.data[DECONZ_DOMAIN] | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"hass",
".",
"data",
"[",
"DECONZ_DOMAIN",
"]",
"assert",
"await",
"async_unload_entry",
"(",
"hass",
",",
"config_e... | [
79,
0
] | [
85,
39
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry_multiple_gateways | (hass) | Test being able to unload an entry and master gateway gets moved. | Test being able to unload an entry and master gateway gets moved. | async def test_unload_entry_multiple_gateways(hass):
"""Test being able to unload an entry and master gateway gets moved."""
config_entry = await setup_deconz_integration(hass)
data = deepcopy(DECONZ_WEB_REQUEST)
data["config"]["bridgeid"] = "01234E56789B"
config_entry2 = await setup_deconz_integra... | [
"async",
"def",
"test_unload_entry_multiple_gateways",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"config\"",
"]",
"[",
"\"bridgeid\"",
... | [
88,
0
] | [
104,
61
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up mobile app binary sensor from a config entry. | Set up mobile app binary sensor from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mobile app binary sensor from a config entry."""
entities = []
webhook_id = config_entry.data[CONF_WEBHOOK_ID]
for config in hass.data[DOMAIN][ENTITY_TYPE].values():
if config[CONF_WEBHOOK_ID] != webhook_id:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"webhook_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
"for",
"config",
"in",
"hass",
".",
"data",
"[... | [
18,
0
] | [
56,
5
] | python | en | ['en', 'en', 'en'] | True |
MobileAppBinarySensor.is_on | (self) | Return the state of the binary sensor. | Return the state of the binary sensor. | def is_on(self):
"""Return the state of the binary sensor."""
return self._config[ATTR_SENSOR_STATE] | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"ATTR_SENSOR_STATE",
"]"
] | [
63,
4
] | [
65,
46
] | python | en | ['en', 'ig', 'en'] | True |
async_setup_entry | (hass, entry) | Create a tellduslive session. | Create a tellduslive session. | async def async_setup_entry(hass, entry):
"""Create a tellduslive session."""
conf = entry.data[KEY_SESSION]
if CONF_HOST in conf:
# Session(**conf) does blocking IO when
# communicating with local devices.
session = await hass.async_add_executor_job(partial(Session, **conf))
e... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"conf",
"=",
"entry",
".",
"data",
"[",
"KEY_SESSION",
"]",
"if",
"CONF_HOST",
"in",
"conf",
":",
"# Session(**conf) does blocking IO when",
"# communicating with local devices.",
"session",
"... | [
53,
0
] | [
77,
15
] | python | en | ['et', 'sm', 'en'] | False |
async_new_client | (hass, session, entry) | Add the hubs associated with the current client to device_registry. | Add the hubs associated with the current client to device_registry. | async def async_new_client(hass, session, entry):
"""Add the hubs associated with the current client to device_registry."""
interval = entry.data[KEY_SCAN_INTERVAL]
_LOGGER.debug("Update interval %s seconds", interval)
client = TelldusLiveClient(hass, entry, session, interval)
hass.data[DOMAIN] = cl... | [
"async",
"def",
"async_new_client",
"(",
"hass",
",",
"session",
",",
"entry",
")",
":",
"interval",
"=",
"entry",
".",
"data",
"[",
"KEY_SCAN_INTERVAL",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"Update interval %s seconds\"",
",",
"interval",
")",
"client",
"=",
... | [
80,
0
] | [
97,
25
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Telldus Live component. | Set up the Telldus Live component. | async def async_setup(hass, config):
"""Set up the Telldus Live component."""
if DOMAIN not in config:
return True
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"... | [
100,
0
] | [
115,
15
] | python | en | ['en', 'fr', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
if not hass.data[NEW_CLIENT_TASK].done():
hass.data[NEW_CLIENT_TASK].cancel()
interval_tracker = hass.data.pop(INTERVAL_TRACKER)
interval_tracker()
await asyncio.wait(
[
hass.config_entries.asy... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"if",
"not",
"hass",
".",
"data",
"[",
"NEW_CLIENT_TASK",
"]",
".",
"done",
"(",
")",
":",
"hass",
".",
"data",
"[",
"NEW_CLIENT_TASK",
"]",
".",
"cancel",
"(",
")",
"int... | [
118,
0
] | [
132,
15
] | python | en | ['en', 'es', 'en'] | True |
TelldusLiveClient.__init__ | (self, hass, config_entry, session, interval) | Initialize the Tellus data object. | Initialize the Tellus data object. | def __init__(self, hass, config_entry, session, interval):
"""Initialize the Tellus data object."""
self._known_devices = set()
self._device_infos = {}
self._hass = hass
self._config_entry = config_entry
self._client = session
self._interval = interval | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
",",
"session",
",",
"interval",
")",
":",
"self",
".",
"_known_devices",
"=",
"set",
"(",
")",
"self",
".",
"_device_infos",
"=",
"{",
"}",
"self",
".",
"_hass",
"=",
"hass",
"self",
... | [
138,
4
] | [
146,
33
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveClient.async_get_hubs | (self) | Return hubs registered for the user. | Return hubs registered for the user. | async def async_get_hubs(self):
"""Return hubs registered for the user."""
clients = await self._hass.async_add_executor_job(self._client.get_clients)
return clients or [] | [
"async",
"def",
"async_get_hubs",
"(",
"self",
")",
":",
"clients",
"=",
"await",
"self",
".",
"_hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_client",
".",
"get_clients",
")",
"return",
"clients",
"or",
"[",
"]"
] | [
148,
4
] | [
151,
28
] | python | en | ['en', 'no', 'en'] | True |
TelldusLiveClient.device_info | (self, device_id) | Return device info. | Return device info. | def device_info(self, device_id):
"""Return device info."""
return self._device_infos.get(device_id) | [
"def",
"device_info",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"self",
".",
"_device_infos",
".",
"get",
"(",
"device_id",
")"
] | [
153,
4
] | [
155,
48
] | python | en | ['es', 'hr', 'en'] | False |
TelldusLiveClient.identify_device | (device) | Find out what type of HA component to create. | Find out what type of HA component to create. | def identify_device(device):
"""Find out what type of HA component to create."""
if device.is_sensor:
return "sensor"
if device.methods & DIM:
return "light"
if device.methods & UP:
return "cover"
if device.methods & TURNON:
return... | [
"def",
"identify_device",
"(",
"device",
")",
":",
"if",
"device",
".",
"is_sensor",
":",
"return",
"\"sensor\"",
"if",
"device",
".",
"methods",
"&",
"DIM",
":",
"return",
"\"light\"",
"if",
"device",
".",
"methods",
"&",
"UP",
":",
"return",
"\"cover\"",... | [
158,
4
] | [
172,
23
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveClient._discover | (self, device_id) | Discover the component. | Discover the component. | async def _discover(self, device_id):
"""Discover the component."""
device = self._client.device(device_id)
component = self.identify_device(device)
self._device_infos.update(
{device_id: await self._hass.async_add_executor_job(device.info)}
)
async with self.... | [
"async",
"def",
"_discover",
"(",
"self",
",",
"device_id",
")",
":",
"device",
"=",
"self",
".",
"_client",
".",
"device",
"(",
"device_id",
")",
"component",
"=",
"self",
".",
"identify_device",
"(",
"device",
")",
"self",
".",
"_device_infos",
".",
"u... | [
174,
4
] | [
196,
13
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveClient.update | (self, *args) | Periodically poll the servers for current state. | Periodically poll the servers for current state. | async def update(self, *args):
"""Periodically poll the servers for current state."""
try:
if not await self._hass.async_add_executor_job(self._client.update):
_LOGGER.warning("Failed request")
return
dev_ids = {dev.device_id for dev in self._clien... | [
"async",
"def",
"update",
"(",
"self",
",",
"*",
"args",
")",
":",
"try",
":",
"if",
"not",
"await",
"self",
".",
"_hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_client",
".",
"update",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Failed re... | [
198,
4
] | [
214,
13
] | python | en | ['en', 'en', 'en'] | True |
TelldusLiveClient.device | (self, device_id) | Return device representation. | Return device representation. | def device(self, device_id):
"""Return device representation."""
return self._client.device(device_id) | [
"def",
"device",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"self",
".",
"_client",
".",
"device",
"(",
"device_id",
")"
] | [
216,
4
] | [
218,
45
] | python | en | ['es', 'it', 'en'] | False |
TelldusLiveClient.is_available | (self, device_id) | Return device availability. | Return device availability. | def is_available(self, device_id):
"""Return device availability."""
return device_id in self._client.device_ids | [
"def",
"is_available",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"device_id",
"in",
"self",
".",
"_client",
".",
"device_ids"
] | [
220,
4
] | [
222,
51
] | python | en | ['fr', 'ga', 'en'] | False |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Yeelight bulbs. | Set up the Yeelight bulbs. | async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the Yeelight bulbs."""
conf = config.get(DOMAIN, {})
hass.data[DOMAIN] = {
DATA_CUSTOM_EFFECTS: conf.get(CONF_CUSTOM_EFFECTS, {}),
DATA_CONFIG_ENTRIES: {},
DATA_SCAN_INTERVAL: conf.get(CONF_SCAN_INTERVAL, SCA... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
"->",
"bool",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_CUS... | [
152,
0
] | [
176,
15
] | python | en | ['en', 'xh', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Yeelight from a config entry. | Set up Yeelight from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Yeelight from a config entry."""
async def _initialize(host: str, capabilities: Optional[dict] = None) -> None:
device = await _async_setup_device(hass, host, entry, capabilities)
hass.data[DOMAIN][DATA_CONF... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"async",
"def",
"_initialize",
"(",
"host",
":",
"str",
",",
"capabilities",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
... | [
179,
0
] | [
225,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""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",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
228,
0
] | [
248,
20
] | python | en | ['en', 'es', 'en'] | True |
_async_unique_name | (capabilities: dict) | Generate name from capabilities. | Generate name from capabilities. | def _async_unique_name(capabilities: dict) -> str:
"""Generate name from capabilities."""
model = capabilities["model"]
unique_id = capabilities["id"]
return f"yeelight_{model}_{unique_id}" | [
"def",
"_async_unique_name",
"(",
"capabilities",
":",
"dict",
")",
"->",
"str",
":",
"model",
"=",
"capabilities",
"[",
"\"model\"",
"]",
"unique_id",
"=",
"capabilities",
"[",
"\"id\"",
"]",
"return",
"f\"yeelight_{model}_{unique_id}\""
] | [
274,
0
] | [
278,
42
] | python | en | ['en', 'en', 'en'] | True |
_async_update_listener | (hass: HomeAssistant, entry: ConfigEntry) | Handle options update. | Handle options update. | async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry):
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"_async_update_listener",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
281,
0
] | [
283,
58
] | python | en | ['en', 'nl', 'en'] | True |
YeelightScanner.async_get | (cls, hass: HomeAssistant) | Get scanner instance. | Get scanner instance. | def async_get(cls, hass: HomeAssistant):
"""Get scanner instance."""
if cls._scanner is None:
cls._scanner = cls(hass)
return cls._scanner | [
"def",
"async_get",
"(",
"cls",
",",
"hass",
":",
"HomeAssistant",
")",
":",
"if",
"cls",
".",
"_scanner",
"is",
"None",
":",
"cls",
".",
"_scanner",
"=",
"cls",
"(",
"hass",
")",
"return",
"cls",
".",
"_scanner"
] | [
293,
4
] | [
297,
27
] | python | da | ['it', 'da', 'en'] | False |
YeelightScanner.__init__ | (self, hass: HomeAssistant) | Initialize class. | Initialize class. | def __init__(self, hass: HomeAssistant):
"""Initialize class."""
self._hass = hass
self._seen = {}
self._callbacks = {}
self._scan_task = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_seen",
"=",
"{",
"}",
"self",
".",
"_callbacks",
"=",
"{",
"}",
"self",
".",
"_scan_task",
"=",
"None"
] | [
299,
4
] | [
304,
30
] | python | en | ['en', 'co', 'en'] | False |
YeelightScanner._async_start_scan | (self) | Start scanning for Yeelight devices. | Start scanning for Yeelight devices. | def _async_start_scan(self):
"""Start scanning for Yeelight devices."""
_LOGGER.debug("Start scanning")
# Use loop directly to avoid home assistant track this task
self._scan_task = self._hass.loop.create_task(self._async_scan()) | [
"def",
"_async_start_scan",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Start scanning\"",
")",
"# Use loop directly to avoid home assistant track this task",
"self",
".",
"_scan_task",
"=",
"self",
".",
"_hass",
".",
"loop",
".",
"create_task",
"(",
"se... | [
328,
4
] | [
332,
73
] | python | da | ['da', 'no', 'en'] | False |
YeelightScanner._async_stop_scan | (self) | Stop scanning. | Stop scanning. | def _async_stop_scan(self):
"""Stop scanning."""
_LOGGER.debug("Stop scanning")
if self._scan_task is not None:
self._scan_task.cancel()
self._scan_task = None | [
"def",
"_async_stop_scan",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Stop scanning\"",
")",
"if",
"self",
".",
"_scan_task",
"is",
"not",
"None",
":",
"self",
".",
"_scan_task",
".",
"cancel",
"(",
")",
"self",
".",
"_scan_task",
"=",
"None... | [
335,
4
] | [
340,
34
] | python | en | ['en', 'jv', 'en'] | False |
YeelightScanner.async_register_callback | (self, unique_id, callback_func) | Register callback function. | Register callback function. | def async_register_callback(self, unique_id, callback_func):
"""Register callback function."""
host = self._seen.get(unique_id)
if host is not None:
self._hass.async_create_task(callback_func(host))
else:
self._callbacks[unique_id] = callback_func
if l... | [
"def",
"async_register_callback",
"(",
"self",
",",
"unique_id",
",",
"callback_func",
")",
":",
"host",
"=",
"self",
".",
"_seen",
".",
"get",
"(",
"unique_id",
")",
"if",
"host",
"is",
"not",
"None",
":",
"self",
".",
"_hass",
".",
"async_create_task",
... | [
343,
4
] | [
351,
40
] | python | en | ['en', 'no', 'en'] | True |
YeelightScanner.async_unregister_callback | (self, unique_id) | Unregister callback function. | Unregister callback function. | def async_unregister_callback(self, unique_id):
"""Unregister callback function."""
if unique_id not in self._callbacks:
return
self._callbacks.pop(unique_id)
if len(self._callbacks) == 0:
self._async_stop_scan() | [
"def",
"async_unregister_callback",
"(",
"self",
",",
"unique_id",
")",
":",
"if",
"unique_id",
"not",
"in",
"self",
".",
"_callbacks",
":",
"return",
"self",
".",
"_callbacks",
".",
"pop",
"(",
"unique_id",
")",
"if",
"len",
"(",
"self",
".",
"_callbacks"... | [
354,
4
] | [
360,
35
] | python | en | ['en', 'la', 'en'] | True |
YeelightDevice.__init__ | (self, hass, host, config, bulb, capabilities) | Initialize device. | Initialize device. | def __init__(self, hass, host, config, bulb, capabilities):
"""Initialize device."""
self._hass = hass
self._config = config
self._host = host
self._bulb_device = bulb
self._capabilities = capabilities or {}
self._device_type = None
self._available = False... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"host",
",",
"config",
",",
"bulb",
",",
"capabilities",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_bulb_devi... | [
366,
4
] | [
383,
42
] | python | en | ['fr', 'en', 'en'] | False |
YeelightDevice.bulb | (self) | Return bulb device. | Return bulb device. | def bulb(self):
"""Return bulb device."""
return self._bulb_device | [
"def",
"bulb",
"(",
"self",
")",
":",
"return",
"self",
".",
"_bulb_device"
] | [
386,
4
] | [
388,
32
] | python | bg | ['es', 'bg', 'en'] | False |
YeelightDevice.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self):
"""Return the name of the device if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
391,
4
] | [
393,
25
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.config | (self) | Return device config. | Return device config. | def config(self):
"""Return device config."""
return self._config | [
"def",
"config",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config"
] | [
396,
4
] | [
398,
27
] | python | en | ['es', 'en', 'en'] | True |
YeelightDevice.host | (self) | Return hostname. | Return hostname. | def host(self):
"""Return hostname."""
return self._host | [
"def",
"host",
"(",
"self",
")",
":",
"return",
"self",
".",
"_host"
] | [
401,
4
] | [
403,
25
] | python | en | ['en', 'no', 'en'] | False |
YeelightDevice.available | (self) | Return true is device is available. | Return true is device is available. | def available(self):
"""Return true is device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
406,
4
] | [
408,
30
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.model | (self) | Return configured/autodetected device model. | Return configured/autodetected device model. | def model(self):
"""Return configured/autodetected device model."""
return self._bulb_device.model | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"_bulb_device",
".",
"model"
] | [
411,
4
] | [
413,
38
] | python | en | ['es', 'en', 'en'] | True |
YeelightDevice.fw_version | (self) | Return the firmware version. | Return the firmware version. | def fw_version(self):
"""Return the firmware version."""
return self._capabilities.get("fw_ver") | [
"def",
"fw_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_capabilities",
".",
"get",
"(",
"\"fw_ver\"",
")"
] | [
416,
4
] | [
418,
47
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.is_nightlight_supported | (self) |
Return true / false if nightlight is supported.
Uses brightness as it appears to be supported in both ceiling and other lights.
|
Return true / false if nightlight is supported. | def is_nightlight_supported(self) -> bool:
"""
Return true / false if nightlight is supported.
Uses brightness as it appears to be supported in both ceiling and other lights.
"""
return self._nightlight_brightness is not None | [
"def",
"is_nightlight_supported",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_nightlight_brightness",
"is",
"not",
"None"
] | [
421,
4
] | [
428,
54
] | python | en | ['en', 'error', 'th'] | False |
YeelightDevice.is_nightlight_enabled | (self) | Return true / false if nightlight is currently enabled. | Return true / false if nightlight is currently enabled. | def is_nightlight_enabled(self) -> bool:
"""Return true / false if nightlight is currently enabled."""
if self.bulb is None:
return False
# Only ceiling lights have active_mode, from SDK docs:
# active_mode 0: daylight mode / 1: moonlight mode (ceiling light only)
if... | [
"def",
"is_nightlight_enabled",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"bulb",
"is",
"None",
":",
"return",
"False",
"# Only ceiling lights have active_mode, from SDK docs:",
"# active_mode 0: daylight mode / 1: moonlight mode (ceiling light only)",
"if",
"se... | [
431,
4
] | [
444,
20
] | python | en | ['en', 'cy', 'en'] | True |
YeelightDevice.is_color_flow_enabled | (self) | Return true / false if color flow is currently running. | Return true / false if color flow is currently running. | def is_color_flow_enabled(self) -> bool:
"""Return true / false if color flow is currently running."""
return self._color_flow == ACTIVE_COLOR_FLOWING | [
"def",
"is_color_flow_enabled",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_color_flow",
"==",
"ACTIVE_COLOR_FLOWING"
] | [
447,
4
] | [
449,
55
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.type | (self) | Return bulb type. | Return bulb type. | def type(self):
"""Return bulb type."""
if not self._device_type:
self._device_type = self.bulb.bulb_type
return self._device_type | [
"def",
"type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device_type",
":",
"self",
".",
"_device_type",
"=",
"self",
".",
"bulb",
".",
"bulb_type",
"return",
"self",
".",
"_device_type"
] | [
464,
4
] | [
469,
32
] | python | en | ['en', 'no', 'en'] | True |
YeelightDevice.turn_on | (self, duration=DEFAULT_TRANSITION, light_type=None, power_mode=None) | Turn on device. | Turn on device. | def turn_on(self, duration=DEFAULT_TRANSITION, light_type=None, power_mode=None):
"""Turn on device."""
try:
self.bulb.turn_on(
duration=duration, light_type=light_type, power_mode=power_mode
)
except BulbException as ex:
_LOGGER.error("Unable ... | [
"def",
"turn_on",
"(",
"self",
",",
"duration",
"=",
"DEFAULT_TRANSITION",
",",
"light_type",
"=",
"None",
",",
"power_mode",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"bulb",
".",
"turn_on",
"(",
"duration",
"=",
"duration",
",",
"light_type",
"="... | [
471,
4
] | [
478,
63
] | python | en | ['fr', 'en', 'en'] | True |
YeelightDevice.turn_off | (self, duration=DEFAULT_TRANSITION, light_type=None) | Turn off device. | Turn off device. | def turn_off(self, duration=DEFAULT_TRANSITION, light_type=None):
"""Turn off device."""
try:
self.bulb.turn_off(duration=duration, light_type=light_type)
except BulbException as ex:
_LOGGER.error(
"Unable to turn the bulb off: %s, %s: %s", self._host, sel... | [
"def",
"turn_off",
"(",
"self",
",",
"duration",
"=",
"DEFAULT_TRANSITION",
",",
"light_type",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"bulb",
".",
"turn_off",
"(",
"duration",
"=",
"duration",
",",
"light_type",
"=",
"light_type",
")",
"except",
... | [
480,
4
] | [
487,
13
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice._update_properties | (self) | Read new properties from the device. | Read new properties from the device. | def _update_properties(self):
"""Read new properties from the device."""
if not self.bulb:
return
try:
self.bulb.get_properties(UPDATE_REQUEST_PROPERTIES)
self._available = True
except BulbException as ex:
if self._available: # just infor... | [
"def",
"_update_properties",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"bulb",
":",
"return",
"try",
":",
"self",
".",
"bulb",
".",
"get_properties",
"(",
"UPDATE_REQUEST_PROPERTIES",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"BulbExcepti... | [
489,
4
] | [
504,
30
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice._get_capabilities | (self) | Request device capabilities. | Request device capabilities. | def _get_capabilities(self):
"""Request device capabilities."""
try:
self.bulb.get_capabilities()
_LOGGER.debug(
"Device %s, %s capabilities: %s",
self._host,
self.name,
self.bulb.capabilities,
)
... | [
"def",
"_get_capabilities",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"bulb",
".",
"get_capabilities",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Device %s, %s capabilities: %s\"",
",",
"self",
".",
"_host",
",",
"self",
".",
"name",
",",
"self",
"."... | [
506,
4
] | [
522,
13
] | python | en | ['fr', 'en', 'en'] | True |
YeelightDevice.update | (self) | Update device properties and send data updated signal. | Update device properties and send data updated signal. | def update(self):
"""Update device properties and send data updated signal."""
self._update_properties()
dispatcher_send(self._hass, DATA_UPDATED.format(self._host)) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_update_properties",
"(",
")",
"dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"DATA_UPDATED",
".",
"format",
"(",
"self",
".",
"_host",
")",
")"
] | [
524,
4
] | [
527,
68
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.async_setup | (self) | Set up the device. | Set up the device. | async def async_setup(self):
"""Set up the device."""
async def _async_update(_):
await self._hass.async_add_executor_job(self.update)
await _async_update(None)
self._remove_time_tracker = async_track_time_interval(
self._hass, _async_update, self._hass.data[DOM... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"async",
"def",
"_async_update",
"(",
"_",
")",
":",
"await",
"self",
".",
"_hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"update",
")",
"await",
"_async_update",
"(",
"None",
")",
"self",
... | [
529,
4
] | [
538,
9
] | python | en | ['en', 'en', 'en'] | True |
YeelightDevice.async_unload | (self) | Unload the device. | Unload the device. | def async_unload(self):
"""Unload the device."""
self._remove_time_tracker() | [
"def",
"async_unload",
"(",
"self",
")",
":",
"self",
".",
"_remove_time_tracker",
"(",
")"
] | [
541,
4
] | [
543,
35
] | python | en | ['en', 'en', 'en'] | True |
YeelightEntity.__init__ | (self, device: YeelightDevice, entry: ConfigEntry) | Initialize the entity. | Initialize the entity. | def __init__(self, device: YeelightDevice, entry: ConfigEntry):
"""Initialize the entity."""
self._device = device
self._unique_id = entry.entry_id
if entry.unique_id is not None:
# Use entry unique id (device id) whenever possible
self._unique_id = entry.unique_i... | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"YeelightDevice",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_unique_id",
"=",
"entry",
".",
"entry_id",
"if",
"entry",
".",
"unique_id",
"is",
"not... | [
549,
4
] | [
555,
45
] | python | en | ['en', 'en', 'en'] | True |
YeelightEntity.unique_id | (self) | Return the unique ID. | Return the unique ID. | def unique_id(self) -> str:
"""Return the unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
558,
4
] | [
560,
30
] | python | en | ['en', 'la', 'en'] | True |
YeelightEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self) -> dict:
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self._unique_id)},
"name": self._device.name,
"manufacturer": "Yeelight",
"model": self._device.model,
"sw_version": self._device.fw_version,
... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"... | [
563,
4
] | [
571,
9
] | python | en | ['en', 'en', 'en'] | True |
YeelightEntity.available | (self) | Return if bulb is available. | Return if bulb is available. | def available(self) -> bool:
"""Return if bulb is available."""
return self._device.available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"available"
] | [
574,
4
] | [
576,
37
] | python | en | ['en', 'en', 'en'] | True |
YeelightEntity.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
579,
4
] | [
581,
20
] | python | en | ['en', 'en', 'en'] | True |
YeelightEntity.update | (self) | Update the entity. | Update the entity. | def update(self) -> None:
"""Update the entity."""
self._device.update() | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_device",
".",
"update",
"(",
")"
] | [
583,
4
] | [
585,
29
] | python | en | ['en', 'en', 'en'] | True |
pairwise_comparisons | (G) |
Produces a generator of pairs of nodes.
|
Produces a generator of pairs of nodes.
| def pairwise_comparisons(G):
"""
Produces a generator of pairs of nodes.
"""
return combinations(G.nodes(), 2) | [
"def",
"pairwise_comparisons",
"(",
"G",
")",
":",
"return",
"combinations",
"(",
"G",
".",
"nodes",
"(",
")",
",",
"2",
")"
] | [
17,
0
] | [
21,
37
] | python | en | ['en', 'error', 'th'] | False |
edge_blocked_comparisons | (G) |
A generator of pairwise comparisons, that highlights comparisons
between nodes that have an edge to the same entity.
|
A generator of pairwise comparisons, that highlights comparisons
between nodes that have an edge to the same entity.
| def edge_blocked_comparisons(G):
"""
A generator of pairwise comparisons, that highlights comparisons
between nodes that have an edge to the same entity.
"""
for n1, n2 in pairwise_comparisons(G):
hood1 = frozenset(G.neighbors(n1))
hood2 = frozenset(G.neighbors(n2))
if hood1 ... | [
"def",
"edge_blocked_comparisons",
"(",
"G",
")",
":",
"for",
"n1",
",",
"n2",
"in",
"pairwise_comparisons",
"(",
"G",
")",
":",
"hood1",
"=",
"frozenset",
"(",
"G",
".",
"neighbors",
"(",
"n1",
")",
")",
"hood2",
"=",
"frozenset",
"(",
"G",
".",
"ne... | [
24,
0
] | [
33,
23
] | python | en | ['en', 'error', 'th'] | False |
similarity | (n1, n2) |
Returns the mean of the partial_ratio score for each field in the two
entities. Note that if they don't have fields that match, the score will
be zero.
|
Returns the mean of the partial_ratio score for each field in the two
entities. Note that if they don't have fields that match, the score will
be zero.
| def similarity(n1, n2):
"""
Returns the mean of the partial_ratio score for each field in the two
entities. Note that if they don't have fields that match, the score will
be zero.
"""
scores = [
fuzz.partial_ratio(n1, n2),
fuzz.partial_ratio(G.node[n1]['type'], G.node[n2]['type']... | [
"def",
"similarity",
"(",
"n1",
",",
"n2",
")",
":",
"scores",
"=",
"[",
"fuzz",
".",
"partial_ratio",
"(",
"n1",
",",
"n2",
")",
",",
"fuzz",
".",
"partial_ratio",
"(",
"G",
".",
"node",
"[",
"n1",
"]",
"[",
"'type'",
"]",
",",
"G",
".",
"node... | [
36,
0
] | [
47,
61
] | python | en | ['en', 'error', 'th'] | False |
fuzzy_blocked_comparisons | (G, threshold=65) |
A generator of pairwise comparisons, that highlights comparisons between
nodes that have an edge to the same entity, but filters out comparisons
if the similarity of n1 and n2 is below the threshold.
|
A generator of pairwise comparisons, that highlights comparisons between
nodes that have an edge to the same entity, but filters out comparisons
if the similarity of n1 and n2 is below the threshold.
| def fuzzy_blocked_comparisons(G, threshold=65):
"""
A generator of pairwise comparisons, that highlights comparisons between
nodes that have an edge to the same entity, but filters out comparisons
if the similarity of n1 and n2 is below the threshold.
"""
for n1, n2 in pairwise_comparisons(G):
... | [
"def",
"fuzzy_blocked_comparisons",
"(",
"G",
",",
"threshold",
"=",
"65",
")",
":",
"for",
"n1",
",",
"n2",
"in",
"pairwise_comparisons",
"(",
"G",
")",
":",
"hood1",
"=",
"frozenset",
"(",
"G",
".",
"neighbors",
"(",
"n1",
")",
")",
"hood2",
"=",
"... | [
50,
0
] | [
61,
27
] | python | en | ['en', 'error', 'th'] | False |
info | (G) |
Wrapper for nx.info with some other helpers.
|
Wrapper for nx.info with some other helpers.
| def info(G):
"""
Wrapper for nx.info with some other helpers.
"""
pairwise = len(list(pairwise_comparisons(G)))
edge_blocked = len(list(edge_blocked_comparisons(G)))
fuzz_blocked = len(list(fuzzy_blocked_comparisons(G)))
output = [""]
output.append("Number of Pairwise Comparisons: {}".f... | [
"def",
"info",
"(",
"G",
")",
":",
"pairwise",
"=",
"len",
"(",
"list",
"(",
"pairwise_comparisons",
"(",
"G",
")",
")",
")",
"edge_blocked",
"=",
"len",
"(",
"list",
"(",
"edge_blocked_comparisons",
"(",
"G",
")",
")",
")",
"fuzz_blocked",
"=",
"len",... | [
63,
0
] | [
76,
41
] | python | en | ['en', 'error', 'th'] | False |
_async_create_entities | (hass, config) | Create the template sensors. | Create the template sensors. | async def _async_create_entities(hass, config):
"""Create the template sensors."""
sensors = []
for device, device_config in config[CONF_SENSORS].items():
state_template = device_config[CONF_VALUE_TEMPLATE]
icon_template = device_config.get(CONF_ICON_TEMPLATE)
entity_picture_templa... | [
"async",
"def",
"_async_create_entities",
"(",
"hass",
",",
"config",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"device",
",",
"device_config",
"in",
"config",
"[",
"CONF_SENSORS",
"]",
".",
"items",
"(",
")",
":",
"state_template",
"=",
"device_config",
... | [
59,
0
] | [
93,
18
] | python | en | ['en', 'mi', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the template sensors. | Set up the template sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the template sensors."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
async_add_entities(await _async_create_entities(hass, config)) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"async_add_entities",
"(",
"await... | [
96,
0
] | [
100,
66
] | python | en | ['en', 'en', 'en'] | True |
SensorTemplate.__init__ | (
self,
hass,
device_id,
friendly_name,
friendly_name_template,
unit_of_measurement,
state_template,
icon_template,
entity_picture_template,
availability_template,
device_class,
attribute_templates,
unique_id,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
hass,
device_id,
friendly_name,
friendly_name_template,
unit_of_measurement,
state_template,
icon_template,
entity_picture_template,
availability_template,
device_class,
attribute_templates,
uniqu... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"device_id",
",",
"friendly_name",
",",
"friendly_name_template",
",",
"unit_of_measurement",
",",
"state_template",
",",
"icon_template",
",",
"entity_picture_template",
",",
"availability_template",
",",
"device_class"... | [
106,
4
] | [
138,
35
] | python | en | ['en', 'en', 'en'] | True |
SensorTemplate.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.add_template_attribute("_state", self._template, None, self._update_state)
if self._friendly_name_template is not None:
self.add_template_attribute("_name", self._friendly_name_template)
await super().async... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"add_template_attribute",
"(",
"\"_state\"",
",",
"self",
".",
"_template",
",",
"None",
",",
"self",
".",
"_update_state",
")",
"if",
"self",
".",
"_friendly_name_template",
"is",
"not... | [
140,
4
] | [
147,
43
] | python | en | ['en', 'no', 'en'] | False |
SensorTemplate.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
155,
4
] | [
157,
25
] | python | en | ['en', 'mi', 'en'] | True |
SensorTemplate.unique_id | (self) | Return the unique id of this sensor. | Return the unique id of this sensor. | def unique_id(self):
"""Return the unique id of this sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
160,
4
] | [
162,
30
] | python | en | ['en', 'la', 'en'] | True |
SensorTemplate.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
165,
4
] | [
167,
26
] | python | en | ['en', 'en', 'en'] | True |
SensorTemplate.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> Optional[str]:
"""Return the device class of the sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_device_class"
] | [
170,
4
] | [
172,
33
] | python | en | ['en', 'en', 'en'] | True |
SensorTemplate.unit_of_measurement | (self) | Return the unit_of_measurement of the device. | Return the unit_of_measurement of the device. | def unit_of_measurement(self):
"""Return the unit_of_measurement of the device."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
175,
4
] | [
177,
40
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up MQTT lock panel through configuration.yaml. | Set up MQTT lock panel through configuration.yaml. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up MQTT lock panel through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
await _async_setup_entity(hass, config, async_add_entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATF... | [
74,
0
] | [
79,
63
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT lock dynamically through MQTT discovery. | Set up MQTT lock dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT lock dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add an MQTT lock."""
discovery_data = discovery_payload.discovery_data
try:
config = P... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add an MQTT lock.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
".",... | [
82,
0
] | [
99,
5
] | python | en | ['en', 'vi', 'en'] | True |
_async_setup_entity | (
hass, config, async_add_entities, config_entry=None, discovery_data=None
) | Set up the MQTT Lock platform. | Set up the MQTT Lock platform. | async def _async_setup_entity(
hass, config, async_add_entities, config_entry=None, discovery_data=None
):
"""Set up the MQTT Lock platform."""
async_add_entities([MqttLock(hass, config, config_entry, discovery_data)]) | [
"async",
"def",
"_async_setup_entity",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"config_entry",
"=",
"None",
",",
"discovery_data",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"MqttLock",
"(",
"hass",
",",
"config",
",",
"config_e... | [
102,
0
] | [
106,
78
] | python | en | ['en', 'sv', 'en'] | True |
MqttLock.__init__ | (self, hass, config, config_entry, discovery_data) | Initialize the lock. | Initialize the lock. | def __init__(self, hass, config, config_entry, discovery_data):
"""Initialize the lock."""
self.hass = hass
self._unique_id = config.get(CONF_UNIQUE_ID)
self._state = False
self._sub_state = None
self._optimistic = False
# Load config
self._setup_from_con... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_unique_id",
"=",
"config",
".",
"get",
"(",
"CONF_UNIQUE_ID",
")",
"self",
".",
"_state",
... | [
118,
4
] | [
134,
72
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self):
"""Subscribe to MQTT events."""
await super().async_added_to_hass()
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
136,
4
] | [
139,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.discovery_update | (self, discovery_payload) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, discovery_payload):
"""Handle updated discovery message."""
config = PLATFORM_SCHEMA(discovery_payload)
self._setup_from_config(config)
await self.attributes_discovery_update(config)
await self.availability_discovery_update(config)
await s... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"discovery_payload",
")",
":",
"config",
"=",
"PLATFORM_SCHEMA",
"(",
"discovery_payload",
")",
"self",
".",
"_setup_from_config",
"(",
"config",
")",
"await",
"self",
".",
"attributes_discovery_update",
"(",
"... | [
141,
4
] | [
149,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttLock._setup_from_config | (self, config) | (Re)Setup the entity. | (Re)Setup the entity. | def _setup_from_config(self, config):
"""(Re)Setup the entity."""
self._config = config
self._optimistic = config[CONF_OPTIMISTIC]
value_template = self._config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = self.hass | [
"def",
"_setup_from_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_optimistic",
"=",
"config",
"[",
"CONF_OPTIMISTIC",
"]",
"value_template",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_VALUE_TEMP... | [
151,
4
] | [
159,
43
] | python | en | ['en', 'haw', 'en'] | True |
MqttLock._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
@callback
@log_messages(self.hass, self.entity_id)
def message_received(msg):
"""Handle new MQTT messages."""
payload = msg.payload
value_template = self._config.get(CONF_VALUE_TEMPLATE... | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"@",
"callback",
"@",
"log_messages",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity_id",
")",
"def",
"message_received",
"(",
"msg",
")",
":",
"\"\"\"Handle new MQTT messages.\"\"\"",
"payload",
... | [
161,
4
] | [
193,
13
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state
)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_fro... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_sub_state",
"=",
"await",
"subscription",
".",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sub_state",
")",
"await",
"MqttAttributes",
".",
"async_... | [
195,
4
] | [
202,
67
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
205,
4
] | [
207,
20
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.name | (self) | Return the name of the lock. | Return the name of the lock. | def name(self):
"""Return the name of the lock."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
210,
4
] | [
212,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
215,
4
] | [
217,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
MqttLock.is_locked | (self) | Return true if lock is locked. | Return true if lock is locked. | def is_locked(self):
"""Return true if lock is locked."""
return self._state | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
220,
4
] | [
222,
26
] | python | en | ['en', 'mt', 'en'] | True |
MqttLock.assumed_state | (self) | Return true if we do optimistic updates. | Return true if we do optimistic updates. | def assumed_state(self):
"""Return true if we do optimistic updates."""
return self._optimistic | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_optimistic"
] | [
225,
4
] | [
227,
31
] | python | en | ['pt', 'la', 'en'] | False |
MqttLock.async_lock | (self, **kwargs) | Lock the device.
This method is a coroutine.
| Lock the device. | async def async_lock(self, **kwargs):
"""Lock the device.
This method is a coroutine.
"""
mqtt.async_publish(
self.hass,
self._config[CONF_COMMAND_TOPIC],
self._config[CONF_PAYLOAD_LOCK],
self._config[CONF_QOS],
self._config[CO... | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"mqtt",
".",
"async_publish",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_config",
"[",
"CONF_COMMAND_TOPIC",
"]",
",",
"self",
".",
"_config",
"[",
"CONF_PAYLOAD_LOCK",
"]",... | [
229,
4
] | [
244,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttLock.async_unlock | (self, **kwargs) | Unlock the device.
This method is a coroutine.
| Unlock the device. | async def async_unlock(self, **kwargs):
"""Unlock the device.
This method is a coroutine.
"""
mqtt.async_publish(
self.hass,
self._config[CONF_COMMAND_TOPIC],
self._config[CONF_PAYLOAD_UNLOCK],
self._config[CONF_QOS],
self._con... | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"mqtt",
".",
"async_publish",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_config",
"[",
"CONF_COMMAND_TOPIC",
"]",
",",
"self",
".",
"_config",
"[",
"CONF_PAYLOAD_UNLOCK",
... | [
246,
4
] | [
261,
39
] | python | en | ['en', 'zh', 'en'] | True |
DistanceFilter.filter | (self, station_idx: int, deision_type: DecisionType, source: Dict[int, int]) | Filter neighbors by distance from neareat to farest.
Args:
station_idx (int): Station index to sort its neighbors.
deision_type (DecisionType): Current decision type.
source (dict): Input neighbors for sorting.
Returns:
dict: N nearest neighbors.
... | Filter neighbors by distance from neareat to farest. | def filter(self, station_idx: int, deision_type: DecisionType, source: Dict[int, int]) -> Dict[int, int]:
"""Filter neighbors by distance from neareat to farest.
Args:
station_idx (int): Station index to sort its neighbors.
deision_type (DecisionType): Current decision type.
... | [
"def",
"filter",
"(",
"self",
",",
"station_idx",
":",
"int",
",",
"deision_type",
":",
"DecisionType",
",",
"source",
":",
"Dict",
"[",
"int",
",",
"int",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"int",
"]",
":",
"output_num",
"=",
"min",
"(",
"se... | [
26,
4
] | [
48,
21
] | python | en | ['en', 'en', 'en'] | True |
DistanceFilter.reset | (self) | Reset internal states. | Reset internal states. | def reset(self):
"""Reset internal states."""
pass | [
"def",
"reset",
"(",
"self",
")",
":",
"pass"
] | [
50,
4
] | [
52,
12
] | python | en | ['en', 'jv', 'en'] | True |
RequirementsFilter.filter | (self, station_idx: int, deision_type: DecisionType, source: Dict[int, int]) | Filter neighbors by requirements number.
Args:
station_idx (int): Station index to sort its neighbors.
decision_type (DecisionType): Current decision type.
source (Dict[int, int]): Neighbors to sort.
Returns:
dict: N neighors sorted by requirement.
... | Filter neighbors by requirements number. | def filter(self, station_idx: int, deision_type: DecisionType, source: Dict[int, int]) -> Dict[int, int]:
"""Filter neighbors by requirements number.
Args:
station_idx (int): Station index to sort its neighbors.
decision_type (DecisionType): Current decision type.
so... | [
"def",
"filter",
"(",
"self",
",",
"station_idx",
":",
"int",
",",
"deision_type",
":",
"DecisionType",
",",
"source",
":",
"Dict",
"[",
"int",
",",
"int",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"int",
"]",
":",
"output_num",
"=",
"min",
"(",
"se... | [
65,
4
] | [
81,
86
] | python | en | ['en', 'en', 'en'] | True |
RequirementsFilter.reset | (self) | Reset internal states. | Reset internal states. | def reset(self):
"""Reset internal states."""
pass | [
"def",
"reset",
"(",
"self",
")",
":",
"pass"
] | [
83,
4
] | [
85,
12
] | python | en | ['en', 'jv', 'en'] | True |
TripsWindowFilter.filter | (self, station_idx: int, decision_type: DecisionType, source: Dict[int, int]) | Filter neighbors by trip requirements in latest N windows.
Args:
station_idx (int): Station index to sort its neighbors.
decision_type (DecisionType): Current decision type.
source (Dict[int, int]): Neighbors to sort.
Returns:
dict: N neighors sorted by ... | Filter neighbors by trip requirements in latest N windows. | def filter(self, station_idx: int, decision_type: DecisionType, source: Dict[int, int]) -> Dict[int, int]:
"""Filter neighbors by trip requirements in latest N windows.
Args:
station_idx (int): Station index to sort its neighbors.
decision_type (DecisionType): Current decision t... | [
"def",
"filter",
"(",
"self",
",",
"station_idx",
":",
"int",
",",
"decision_type",
":",
"DecisionType",
",",
"source",
":",
"Dict",
"[",
"int",
",",
"int",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"int",
"]",
":",
"output_num",
"=",
"min",
"(",
"s... | [
106,
4
] | [
158,
21
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.transfer_time | (self) | int: Transfer time from one station to another. | int: Transfer time from one station to another. | def transfer_time(self) -> int:
"""int: Transfer time from one station to another."""
return round(np.random.normal(self.time_mean, scale=self.time_std)) | [
"def",
"transfer_time",
"(",
"self",
")",
"->",
"int",
":",
"return",
"round",
"(",
"np",
".",
"random",
".",
"normal",
"(",
"self",
".",
"time_mean",
",",
"scale",
"=",
"self",
".",
"time_std",
")",
")"
] | [
212,
4
] | [
214,
75
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.is_decision_tick | (self, tick: int) | If it is time to generate a decision event.
Args:
tick (int): Tick to check.
Returns:
bool: True if current tick should check deicion, or False.
| If it is time to generate a decision event. | def is_decision_tick(self, tick: int) -> bool:
"""If it is time to generate a decision event.
Args:
tick (int): Tick to check.
Returns:
bool: True if current tick should check deicion, or False.
"""
return (tick + 1) % self.resolution == 0 | [
"def",
"is_decision_tick",
"(",
"self",
",",
"tick",
":",
"int",
")",
"->",
"bool",
":",
"return",
"(",
"tick",
"+",
"1",
")",
"%",
"self",
".",
"resolution",
"==",
"0"
] | [
216,
4
] | [
225,
48
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.get_stations_need_decision | (self, tick: int) | Get stations that need to take an action from agent at current tick.
Args:
tick (int): Tick to check.
Returns:
list: List of station indices who need action at this tick.
| Get stations that need to take an action from agent at current tick. | def get_stations_need_decision(self, tick: int) -> list:
"""Get stations that need to take an action from agent at current tick.
Args:
tick (int): Tick to check.
Returns:
list: List of station indices who need action at this tick.
"""
stations = []
... | [
"def",
"get_stations_need_decision",
"(",
"self",
",",
"tick",
":",
"int",
")",
"->",
"list",
":",
"stations",
"=",
"[",
"]",
"if",
"(",
"tick",
"+",
"1",
")",
"%",
"self",
".",
"resolution",
"==",
"0",
":",
"for",
"station",
"in",
"self",
".",
"_s... | [
227,
4
] | [
249,
23
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.action_scope | (self, station_idx: int, decision_type: DecisionType) | Calculate action scopes for self and N neighbors.
Args:
station_idx (int): Target station index.
decision_type (DecisionType): Current decision type.
Returns:
dict : Dictionary that key is station index, value is the max supply/demand value.
| Calculate action scopes for self and N neighbors. | def action_scope(self, station_idx: int, decision_type: DecisionType):
"""Calculate action scopes for self and N neighbors.
Args:
station_idx (int): Target station index.
decision_type (DecisionType): Current decision type.
Returns:
dict : Dictionary that ke... | [
"def",
"action_scope",
"(",
"self",
",",
"station_idx",
":",
"int",
",",
"decision_type",
":",
"DecisionType",
")",
":",
"station",
":",
"Station",
"=",
"self",
".",
"_stations",
"[",
"station_idx",
"]",
"neighbors",
"=",
"self",
".",
"_get_neighbors",
"(",
... | [
251,
4
] | [
291,
29
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.move_to_neighbor | (self, src_station: Station, cur_station: Station, bike_number: int) | Move extra bikes to neighbor when transferred bikes more than available docks.
Args:
src_station (Station): Which station current bike come from.
cur_station (Station): Which station current bike arrive.
bike_number (int): How many bikes need to move.
NOTE:
... | Move extra bikes to neighbor when transferred bikes more than available docks. | def move_to_neighbor(self, src_station: Station, cur_station: Station, bike_number: int):
"""Move extra bikes to neighbor when transferred bikes more than available docks.
Args:
src_station (Station): Which station current bike come from.
cur_station (Station): Which station cur... | [
"def",
"move_to_neighbor",
"(",
"self",
",",
"src_station",
":",
"Station",
",",
"cur_station",
":",
"Station",
",",
"bike_number",
":",
"int",
")",
":",
"total_cost",
"=",
"0",
"cost",
"=",
"0",
"neighbors",
"=",
"self",
".",
"_get_neighbors",
"(",
"cur_s... | [
293,
4
] | [
338,
25
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy.reset | (self) | Reset internal states. | Reset internal states. | def reset(self):
"""Reset internal states."""
for filter_instance in self._filters:
filter_instance.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"filter_instance",
"in",
"self",
".",
"_filters",
":",
"filter_instance",
".",
"reset",
"(",
")"
] | [
340,
4
] | [
343,
35
] | python | en | ['en', 'jv', 'en'] | True |
BikeDecisionStrategy._set_extra_cost | (self, src_station: Station, target_station: Station, neighbor: Station, cost: int) | set extra cost to station according to the mode | set extra cost to station according to the mode | def _set_extra_cost(self, src_station: Station, target_station: Station, neighbor: Station, cost: int):
"""set extra cost to station according to the mode"""
if self._extra_cost_mode == ExtraCostMode.Source:
# extra cost from source cell
src_station.extra_cost += cost
eli... | [
"def",
"_set_extra_cost",
"(",
"self",
",",
"src_station",
":",
"Station",
",",
"target_station",
":",
"Station",
",",
"neighbor",
":",
"Station",
",",
"cost",
":",
"int",
")",
":",
"if",
"self",
".",
"_extra_cost_mode",
"==",
"ExtraCostMode",
".",
"Source",... | [
366,
4
] | [
374,
39
] | python | en | ['en', 'en', 'en'] | True |
BikeDecisionStrategy._get_neighbors | (self, station_idx: int) | get neighbors for station, from cache if exists | get neighbors for station, from cache if exists | def _get_neighbors(self, station_idx: int):
"""get neighbors for station, from cache if exists"""
# check cache first
neighbors = self._neighbors_cache.get(station_idx, None)
if neighbors is None:
distances = self._distance_adj[station_idx]
# index is the statio... | [
"def",
"_get_neighbors",
"(",
"self",
",",
"station_idx",
":",
"int",
")",
":",
"# check cache first",
"neighbors",
"=",
"self",
".",
"_neighbors_cache",
".",
"get",
"(",
"station_idx",
",",
"None",
")",
"if",
"neighbors",
"is",
"None",
":",
"distances",
"="... | [
376,
4
] | [
392,
24
] | python | en | ['en', 'en', 'en'] | True |
test_reproducing_states | (hass, caplog) | Test reproducing Cover states. | Test reproducing Cover states. | async def test_reproducing_states(hass, caplog):
"""Test reproducing Cover states."""
hass.states.async_set("cover.entity_close", STATE_CLOSED, {})
hass.states.async_set(
"cover.entity_close_attr",
STATE_CLOSED,
{ATTR_CURRENT_POSITION: 0, ATTR_CURRENT_TILT_POSITION: 0},
)
has... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"cover.entity_close\"",
",",
"STATE_CLOSED",
",",
"{",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"cover.entity_clos... | [
22,
0
] | [
196,
5
] | python | en | ['en', 'en', 'en'] | True |
WeightMasker.calc_mask | (self, sparsity, wrapper, wrapper_idx=None) |
Calculate the mask of given layer.
Parameters
----------
sparsity: float
pruning ratio, preserved weight ratio is `1 - sparsity`
wrapper: PrunerModuleWrapper
layer wrapper of this layer
wrapper_idx: int
index of this wrapper in pruner... |
Calculate the mask of given layer.
Parameters
----------
sparsity: float
pruning ratio, preserved weight ratio is `1 - sparsity`
wrapper: PrunerModuleWrapper
layer wrapper of this layer
wrapper_idx: int
index of this wrapper in pruner... | def calc_mask(self, sparsity, wrapper, wrapper_idx=None):
"""
Calculate the mask of given layer.
Parameters
----------
sparsity: float
pruning ratio, preserved weight ratio is `1 - sparsity`
wrapper: PrunerModuleWrapper
layer wrapper of this layer... | [
"def",
"calc_mask",
"(",
"self",
",",
"sparsity",
",",
"wrapper",
",",
"wrapper_idx",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'{} calc_mask is not implemented'",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
")"
] | [
8,
4
] | [
27,
100
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the platform for a Skybell device. | Set up the platform for a Skybell device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the platform for a Skybell device."""
skybell = hass.data.get(SKYBELL_DOMAIN)
sensors = []
for device in skybell.get_devices():
sensors.append(SkybellLight(device))
add_entities(sensors, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"skybell",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"SKYBELL_DOMAIN",
")",
"sensors",
"=",
"[",
"]",
"for",
"device",
"in",
"skybell... | [
13,
0
] | [
21,
31
] | python | en | ['en', 'en', 'en'] | True |
_to_skybell_level | (level) | Convert the given Home Assistant light level (0-255) to Skybell (0-100). | Convert the given Home Assistant light level (0-255) to Skybell (0-100). | def _to_skybell_level(level):
"""Convert the given Home Assistant light level (0-255) to Skybell (0-100)."""
return int((level * 100) / 255) | [
"def",
"_to_skybell_level",
"(",
"level",
")",
":",
"return",
"int",
"(",
"(",
"level",
"*",
"100",
")",
"/",
"255",
")"
] | [
24,
0
] | [
26,
35
] | 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.