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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ZHADevice.update_available | (self, available: bool) | Update device availability and signal entities. | Update device availability and signal entities. | def update_available(self, available: bool) -> None:
"""Update device availability and signal entities."""
availability_changed = self.available ^ available
self.available = available
if availability_changed and available:
# reinit channels then signal entities
se... | [
"def",
"update_available",
"(",
"self",
",",
"available",
":",
"bool",
")",
"->",
"None",
":",
"availability_changed",
"=",
"self",
".",
"available",
"^",
"available",
"self",
".",
"available",
"=",
"available",
"if",
"availability_changed",
"and",
"available",
... | [
347,
4
] | [
361,
76
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice._async_became_available | (self) | Update device availability and signal entities. | Update device availability and signal entities. | async def _async_became_available(self) -> None:
"""Update device availability and signal entities."""
await self.async_initialize(False)
async_dispatcher_send(self.hass, f"{self._available_signal}_entity") | [
"async",
"def",
"_async_became_available",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"async_initialize",
"(",
"False",
")",
"async_dispatcher_send",
"(",
"self",
".",
"hass",
",",
"f\"{self._available_signal}_entity\"",
")"
] | [
363,
4
] | [
366,
76
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.device_info | (self) | Return a device description for device. | Return a device description for device. | def device_info(self):
"""Return a device description for device."""
ieee = str(self.ieee)
time_struct = time.localtime(self.last_seen)
update_time = time.strftime("%Y-%m-%dT%H:%M:%S", time_struct)
return {
ATTR_IEEE: ieee,
ATTR_NWK: self.nwk,
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"ieee",
"=",
"str",
"(",
"self",
".",
"ieee",
")",
"time_struct",
"=",
"time",
".",
"localtime",
"(",
"self",
".",
"last_seen",
")",
"update_time",
"=",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%S\"",
"... | [
369,
4
] | [
390,
9
] | python | en | ['ro', 'fr', 'en'] | False |
ZHADevice.async_configure | (self) | Configure the device. | Configure the device. | async def async_configure(self):
"""Configure the device."""
self.debug("started configuration")
await self._channels.async_configure()
self.debug("completed configuration")
entry = self.gateway.zha_storage.async_create_or_update_device(self)
self.debug("stored in registr... | [
"async",
"def",
"async_configure",
"(",
"self",
")",
":",
"self",
".",
"debug",
"(",
"\"started configuration\"",
")",
"await",
"self",
".",
"_channels",
".",
"async_configure",
"(",
")",
"self",
".",
"debug",
"(",
"\"completed configuration\"",
")",
"entry",
... | [
392,
4
] | [
403,
13
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_initialize | (self, from_cache=False) | Initialize channels. | Initialize channels. | async def async_initialize(self, from_cache=False):
"""Initialize channels."""
self.debug("started initialization")
await self._channels.async_initialize(from_cache)
self.debug("power source: %s", self.power_source)
self.status = DeviceStatus.INITIALIZED
self.debug("compl... | [
"async",
"def",
"async_initialize",
"(",
"self",
",",
"from_cache",
"=",
"False",
")",
":",
"self",
".",
"debug",
"(",
"\"started initialization\"",
")",
"await",
"self",
".",
"_channels",
".",
"async_initialize",
"(",
"from_cache",
")",
"self",
".",
"debug",
... | [
405,
4
] | [
411,
46
] | python | en | ['en', 'en', 'en'] | False |
ZHADevice.async_cleanup_handles | (self) | Unsubscribe the dispatchers and timers. | Unsubscribe the dispatchers and timers. | def async_cleanup_handles(self) -> None:
"""Unsubscribe the dispatchers and timers."""
for unsubscribe in self.unsubs:
unsubscribe() | [
"def",
"async_cleanup_handles",
"(",
"self",
")",
"->",
"None",
":",
"for",
"unsubscribe",
"in",
"self",
".",
"unsubs",
":",
"unsubscribe",
"(",
")"
] | [
414,
4
] | [
417,
25
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_update_last_seen | (self, last_seen) | Set last seen on the zigpy device. | Set last seen on the zigpy device. | def async_update_last_seen(self, last_seen):
"""Set last seen on the zigpy device."""
if self._zigpy_device.last_seen is None and last_seen is not None:
self._zigpy_device.last_seen = last_seen | [
"def",
"async_update_last_seen",
"(",
"self",
",",
"last_seen",
")",
":",
"if",
"self",
".",
"_zigpy_device",
".",
"last_seen",
"is",
"None",
"and",
"last_seen",
"is",
"not",
"None",
":",
"self",
".",
"_zigpy_device",
".",
"last_seen",
"=",
"last_seen"
] | [
420,
4
] | [
423,
52
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.zha_device_info | (self) | Get ZHA device information. | Get ZHA device information. | def zha_device_info(self):
"""Get ZHA device information."""
device_info = {}
device_info.update(self.device_info)
device_info["entities"] = [
{
"entity_id": entity_ref.reference_id,
ATTR_NAME: entity_ref.device_info[ATTR_NAME],
}
... | [
"def",
"zha_device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"}",
"device_info",
".",
"update",
"(",
"self",
".",
"device_info",
")",
"device_info",
"[",
"\"entities\"",
"]",
"=",
"[",
"{",
"\"entity_id\"",
":",
"entity_ref",
".",
"reference_id"... | [
426,
4
] | [
475,
26
] | python | de | ['es', 'de', 'en'] | False |
ZHADevice.async_get_clusters | (self) | Get all clusters for this device. | Get all clusters for this device. | def async_get_clusters(self):
"""Get all clusters for this device."""
return {
ep_id: {
CLUSTER_TYPE_IN: endpoint.in_clusters,
CLUSTER_TYPE_OUT: endpoint.out_clusters,
}
for (ep_id, endpoint) in self._zigpy_device.endpoints.items()
... | [
"def",
"async_get_clusters",
"(",
"self",
")",
":",
"return",
"{",
"ep_id",
":",
"{",
"CLUSTER_TYPE_IN",
":",
"endpoint",
".",
"in_clusters",
",",
"CLUSTER_TYPE_OUT",
":",
"endpoint",
".",
"out_clusters",
",",
"}",
"for",
"(",
"ep_id",
",",
"endpoint",
")",
... | [
478,
4
] | [
487,
9
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_get_groupable_endpoints | (self) | Get device endpoints that have a group 'in' cluster. | Get device endpoints that have a group 'in' cluster. | def async_get_groupable_endpoints(self):
"""Get device endpoints that have a group 'in' cluster."""
return [
ep_id
for (ep_id, clusters) in self.async_get_clusters().items()
if Groups.cluster_id in clusters[CLUSTER_TYPE_IN]
] | [
"def",
"async_get_groupable_endpoints",
"(",
"self",
")",
":",
"return",
"[",
"ep_id",
"for",
"(",
"ep_id",
",",
"clusters",
")",
"in",
"self",
".",
"async_get_clusters",
"(",
")",
".",
"items",
"(",
")",
"if",
"Groups",
".",
"cluster_id",
"in",
"clusters"... | [
490,
4
] | [
496,
9
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_get_std_clusters | (self) | Get ZHA and ZLL clusters for this device. | Get ZHA and ZLL clusters for this device. | def async_get_std_clusters(self):
"""Get ZHA and ZLL clusters for this device."""
return {
ep_id: {
CLUSTER_TYPE_IN: endpoint.in_clusters,
CLUSTER_TYPE_OUT: endpoint.out_clusters,
}
for (ep_id, endpoint) in self._zigpy_device.endpoints... | [
"def",
"async_get_std_clusters",
"(",
"self",
")",
":",
"return",
"{",
"ep_id",
":",
"{",
"CLUSTER_TYPE_IN",
":",
"endpoint",
".",
"in_clusters",
",",
"CLUSTER_TYPE_OUT",
":",
"endpoint",
".",
"out_clusters",
",",
"}",
"for",
"(",
"ep_id",
",",
"endpoint",
"... | [
499,
4
] | [
509,
9
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_get_cluster | (self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN) | Get zigbee cluster from this entity. | Get zigbee cluster from this entity. | def async_get_cluster(self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN):
"""Get zigbee cluster from this entity."""
clusters = self.async_get_clusters()
return clusters[endpoint_id][cluster_type][cluster_id] | [
"def",
"async_get_cluster",
"(",
"self",
",",
"endpoint_id",
",",
"cluster_id",
",",
"cluster_type",
"=",
"CLUSTER_TYPE_IN",
")",
":",
"clusters",
"=",
"self",
".",
"async_get_clusters",
"(",
")",
"return",
"clusters",
"[",
"endpoint_id",
"]",
"[",
"cluster_type... | [
512,
4
] | [
515,
62
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_get_cluster_attributes | (
self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN
) | Get zigbee attributes for specified cluster. | Get zigbee attributes for specified cluster. | def async_get_cluster_attributes(
self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN
):
"""Get zigbee attributes for specified cluster."""
cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type)
if cluster is None:
return None
return clust... | [
"def",
"async_get_cluster_attributes",
"(",
"self",
",",
"endpoint_id",
",",
"cluster_id",
",",
"cluster_type",
"=",
"CLUSTER_TYPE_IN",
")",
":",
"cluster",
"=",
"self",
".",
"async_get_cluster",
"(",
"endpoint_id",
",",
"cluster_id",
",",
"cluster_type",
")",
"if... | [
518,
4
] | [
525,
33
] | python | en | ['nl', 'en', 'en'] | True |
ZHADevice.async_get_cluster_commands | (
self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN
) | Get zigbee commands for specified cluster. | Get zigbee commands for specified cluster. | def async_get_cluster_commands(
self, endpoint_id, cluster_id, cluster_type=CLUSTER_TYPE_IN
):
"""Get zigbee commands for specified cluster."""
cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type)
if cluster is None:
return None
return {
... | [
"def",
"async_get_cluster_commands",
"(",
"self",
",",
"endpoint_id",
",",
"cluster_id",
",",
"cluster_type",
"=",
"CLUSTER_TYPE_IN",
")",
":",
"cluster",
"=",
"self",
".",
"async_get_cluster",
"(",
"endpoint_id",
",",
"cluster_id",
",",
"cluster_type",
")",
"if",... | [
528,
4
] | [
538,
9
] | python | nl | ['nl', 'nl', 'en'] | True |
ZHADevice.write_zigbee_attribute | (
self,
endpoint_id,
cluster_id,
attribute,
value,
cluster_type=CLUSTER_TYPE_IN,
manufacturer=None,
) | Write a value to a zigbee attribute for a cluster in this entity. | Write a value to a zigbee attribute for a cluster in this entity. | async def write_zigbee_attribute(
self,
endpoint_id,
cluster_id,
attribute,
value,
cluster_type=CLUSTER_TYPE_IN,
manufacturer=None,
):
"""Write a value to a zigbee attribute for a cluster in this entity."""
cluster = self.async_get_cluster(endp... | [
"async",
"def",
"write_zigbee_attribute",
"(",
"self",
",",
"endpoint_id",
",",
"cluster_id",
",",
"attribute",
",",
"value",
",",
"cluster_type",
"=",
"CLUSTER_TYPE_IN",
",",
"manufacturer",
"=",
"None",
",",
")",
":",
"cluster",
"=",
"self",
".",
"async_get_... | [
540,
4
] | [
576,
23
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.issue_cluster_command | (
self,
endpoint_id,
cluster_id,
command,
command_type,
*args,
cluster_type=CLUSTER_TYPE_IN,
manufacturer=None,
) | Issue a command against specified zigbee cluster on this entity. | Issue a command against specified zigbee cluster on this entity. | async def issue_cluster_command(
self,
endpoint_id,
cluster_id,
command,
command_type,
*args,
cluster_type=CLUSTER_TYPE_IN,
manufacturer=None,
):
"""Issue a command against specified zigbee cluster on this entity."""
cluster = self.asyn... | [
"async",
"def",
"issue_cluster_command",
"(",
"self",
",",
"endpoint_id",
",",
"cluster_id",
",",
"command",
",",
"command_type",
",",
"*",
"args",
",",
"cluster_type",
"=",
"CLUSTER_TYPE_IN",
",",
"manufacturer",
"=",
"None",
",",
")",
":",
"cluster",
"=",
... | [
578,
4
] | [
609,
23
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_add_to_group | (self, group_id) | Add this device to the provided zigbee group. | Add this device to the provided zigbee group. | async def async_add_to_group(self, group_id):
"""Add this device to the provided zigbee group."""
try:
await self._zigpy_device.add_to_group(group_id)
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
self.debug(
"Failed to add device ... | [
"async",
"def",
"async_add_to_group",
"(",
"self",
",",
"group_id",
")",
":",
"try",
":",
"await",
"self",
".",
"_zigpy_device",
".",
"add_to_group",
"(",
"group_id",
")",
"except",
"(",
"zigpy",
".",
"exceptions",
".",
"ZigbeeException",
",",
"asyncio",
"."... | [
611,
4
] | [
621,
13
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_remove_from_group | (self, group_id) | Remove this device from the provided zigbee group. | Remove this device from the provided zigbee group. | async def async_remove_from_group(self, group_id):
"""Remove this device from the provided zigbee group."""
try:
await self._zigpy_device.remove_from_group(group_id)
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
self.debug(
"Failed... | [
"async",
"def",
"async_remove_from_group",
"(",
"self",
",",
"group_id",
")",
":",
"try",
":",
"await",
"self",
".",
"_zigpy_device",
".",
"remove_from_group",
"(",
"group_id",
")",
"except",
"(",
"zigpy",
".",
"exceptions",
".",
"ZigbeeException",
",",
"async... | [
623,
4
] | [
633,
13
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_add_endpoint_to_group | (self, endpoint_id, group_id) | Add the device endpoint to the provided zigbee group. | Add the device endpoint to the provided zigbee group. | async def async_add_endpoint_to_group(self, endpoint_id, group_id):
"""Add the device endpoint to the provided zigbee group."""
try:
await self._zigpy_device.endpoints[int(endpoint_id)].add_to_group(group_id)
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
... | [
"async",
"def",
"async_add_endpoint_to_group",
"(",
"self",
",",
"endpoint_id",
",",
"group_id",
")",
":",
"try",
":",
"await",
"self",
".",
"_zigpy_device",
".",
"endpoints",
"[",
"int",
"(",
"endpoint_id",
")",
"]",
".",
"add_to_group",
"(",
"group_id",
")... | [
635,
4
] | [
646,
13
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_remove_endpoint_from_group | (self, endpoint_id, group_id) | Remove the device endpoint from the provided zigbee group. | Remove the device endpoint from the provided zigbee group. | async def async_remove_endpoint_from_group(self, endpoint_id, group_id):
"""Remove the device endpoint from the provided zigbee group."""
try:
await self._zigpy_device.endpoints[int(endpoint_id)].remove_from_group(
group_id
)
except (zigpy.exceptions.Zigbe... | [
"async",
"def",
"async_remove_endpoint_from_group",
"(",
"self",
",",
"endpoint_id",
",",
"group_id",
")",
":",
"try",
":",
"await",
"self",
".",
"_zigpy_device",
".",
"endpoints",
"[",
"int",
"(",
"endpoint_id",
")",
"]",
".",
"remove_from_group",
"(",
"group... | [
648,
4
] | [
661,
13
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_bind_to_group | (self, group_id, cluster_bindings) | Directly bind this device to a group for the given clusters. | Directly bind this device to a group for the given clusters. | async def async_bind_to_group(self, group_id, cluster_bindings):
"""Directly bind this device to a group for the given clusters."""
await self._async_group_binding_operation(
group_id, zdo_types.ZDOCmd.Bind_req, cluster_bindings
) | [
"async",
"def",
"async_bind_to_group",
"(",
"self",
",",
"group_id",
",",
"cluster_bindings",
")",
":",
"await",
"self",
".",
"_async_group_binding_operation",
"(",
"group_id",
",",
"zdo_types",
".",
"ZDOCmd",
".",
"Bind_req",
",",
"cluster_bindings",
")"
] | [
663,
4
] | [
667,
9
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.async_unbind_from_group | (self, group_id, cluster_bindings) | Unbind this device from a group for the given clusters. | Unbind this device from a group for the given clusters. | async def async_unbind_from_group(self, group_id, cluster_bindings):
"""Unbind this device from a group for the given clusters."""
await self._async_group_binding_operation(
group_id, zdo_types.ZDOCmd.Unbind_req, cluster_bindings
) | [
"async",
"def",
"async_unbind_from_group",
"(",
"self",
",",
"group_id",
",",
"cluster_bindings",
")",
":",
"await",
"self",
".",
"_async_group_binding_operation",
"(",
"group_id",
",",
"zdo_types",
".",
"ZDOCmd",
".",
"Unbind_req",
",",
"cluster_bindings",
")"
] | [
669,
4
] | [
673,
9
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice._async_group_binding_operation | (
self, group_id, operation, cluster_bindings
) | Create or remove a direct zigbee binding between a device and a group. | Create or remove a direct zigbee binding between a device and a group. | async def _async_group_binding_operation(
self, group_id, operation, cluster_bindings
):
"""Create or remove a direct zigbee binding between a device and a group."""
zdo = self._zigpy_device.zdo
op_msg = "0x%04x: %s %s, ep: %s, cluster: %s to group: 0x%04x"
destination_addre... | [
"async",
"def",
"_async_group_binding_operation",
"(",
"self",
",",
"group_id",
",",
"operation",
",",
"cluster_bindings",
")",
":",
"zdo",
"=",
"self",
".",
"_zigpy_device",
".",
"zdo",
"op_msg",
"=",
"\"0x%04x: %s %s, ep: %s, cluster: %s to group: 0x%04x\"",
"destinat... | [
675,
4
] | [
725,
54
] | python | en | ['en', 'en', 'en'] | True |
ZHADevice.log | (self, level, msg, *args) | Log a message. | Log a message. | def log(self, level, msg, *args):
"""Log a message."""
msg = f"[%s](%s): {msg}"
args = (self.nwk, self.model) + args
_LOGGER.log(level, msg, *args) | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"msg",
",",
"*",
"args",
")",
":",
"msg",
"=",
"f\"[%s](%s): {msg}\"",
"args",
"=",
"(",
"self",
".",
"nwk",
",",
"self",
".",
"model",
")",
"+",
"args",
"_LOGGER",
".",
"log",
"(",
"level",
",",
"msg... | [
727,
4
] | [
731,
38
] | python | en | ['en', 'lb', 'en'] | True |
_handle_webhook | (job, hass, webhook_id, request) | Handle incoming webhook. | Handle incoming webhook. | async def _handle_webhook(job, hass, webhook_id, request):
"""Handle incoming webhook."""
result = {"platform": "webhook", "webhook_id": webhook_id}
if "json" in request.headers.get(hdrs.CONTENT_TYPE, ""):
result["json"] = await request.json()
else:
result["data"] = await request.post()... | [
"async",
"def",
"_handle_webhook",
"(",
"job",
",",
"hass",
",",
"webhook_id",
",",
"request",
")",
":",
"result",
"=",
"{",
"\"platform\"",
":",
"\"webhook\"",
",",
"\"webhook_id\"",
":",
"webhook_id",
"}",
"if",
"\"json\"",
"in",
"request",
".",
"headers",... | [
19,
0
] | [
30,
53
] | python | en | ['en', 'xh', 'en'] | True |
async_attach_trigger | (hass, config, action, automation_info) | Trigger based on incoming webhooks. | Trigger based on incoming webhooks. | async def async_attach_trigger(hass, config, action, automation_info):
"""Trigger based on incoming webhooks."""
webhook_id = config.get(CONF_WEBHOOK_ID)
job = HassJob(action)
hass.components.webhook.async_register(
automation_info["domain"],
automation_info["name"],
webhook_id,
... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
")",
":",
"webhook_id",
"=",
"config",
".",
"get",
"(",
"CONF_WEBHOOK_ID",
")",
"job",
"=",
"HassJob",
"(",
"action",
")",
"hass",
".",
"components",
... | [
33,
0
] | [
49,
21
] | python | en | ['en', 'zu', 'en'] | True |
problem4_1 | (wordlist) | Takes a word list prints it, sorts it, and prints the sorted list | Takes a word list prints it, sorts it, and prints the sorted list | def problem4_1(wordlist):
""" Takes a word list prints it, sorts it, and prints the sorted list """
print(wordlist)
wordlist.sort(key = lambda x:x.lower())
print(wordlist) | [
"def",
"problem4_1",
"(",
"wordlist",
")",
":",
"print",
"(",
"wordlist",
")",
"wordlist",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"lower",
"(",
")",
")",
"print",
"(",
"wordlist",
")"
] | [
21,
0
] | [
25,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass) | Enable the Area Registry views. | Enable the Area Registry views. | async def async_setup(hass):
"""Enable the Area Registry views."""
hass.components.websocket_api.async_register_command(
WS_TYPE_LIST, websocket_list_areas, SCHEMA_WS_LIST
)
hass.components.websocket_api.async_register_command(
WS_TYPE_CREATE, websocket_create_area, SCHEMA_WS_CREATE
... | [
"async",
"def",
"async_setup",
"(",
"hass",
")",
":",
"hass",
".",
"components",
".",
"websocket_api",
".",
"async_register_command",
"(",
"WS_TYPE_LIST",
",",
"websocket_list_areas",
",",
"SCHEMA_WS_LIST",
")",
"hass",
".",
"components",
".",
"websocket_api",
"."... | [
36,
0
] | [
50,
15
] | python | en | ['en', 'en', 'en'] | True |
websocket_list_areas | (hass, connection, msg) | Handle list areas command. | Handle list areas command. | async def websocket_list_areas(hass, connection, msg):
"""Handle list areas command."""
registry = await async_get_registry(hass)
connection.send_message(
websocket_api.result_message(
msg["id"],
[
{"name": entry.name, "area_id": entry.id}
for ... | [
"async",
"def",
"websocket_list_areas",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"connection",
".",
"send_message",
"(",
"websocket_api",
".",
"result_message",
"(",
"msg",
"[",
"\"... | [
54,
0
] | [
65,
5
] | python | en | ['en', 'en', 'en'] | True |
websocket_create_area | (hass, connection, msg) | Create area command. | Create area command. | async def websocket_create_area(hass, connection, msg):
"""Create area command."""
registry = await async_get_registry(hass)
try:
entry = registry.async_create(msg["name"])
except ValueError as err:
connection.send_message(
websocket_api.error_message(msg["id"], "invalid_info... | [
"async",
"def",
"websocket_create_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"entry",
"=",
"registry",
".",
"async_create",
"(",
"msg",
"[",
"\"name\"",
"]",
")... | [
70,
0
] | [
82,
9
] | python | en | ['en', 'sm', 'en'] | True |
websocket_delete_area | (hass, connection, msg) | Delete area command. | Delete area command. | async def websocket_delete_area(hass, connection, msg):
"""Delete area command."""
registry = await async_get_registry(hass)
try:
await registry.async_delete(msg["area_id"])
except KeyError:
connection.send_message(
websocket_api.error_message(
msg["id"], "in... | [
"async",
"def",
"websocket_delete_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"await",
"registry",
".",
"async_delete",
"(",
"msg",
"[",
"\"area_id\"",
"]",
")",
... | [
87,
0
] | [
100,
83
] | python | en | ['en', 'it', 'en'] | True |
websocket_update_area | (hass, connection, msg) | Handle update area websocket command. | Handle update area websocket command. | async def websocket_update_area(hass, connection, msg):
"""Handle update area websocket command."""
registry = await async_get_registry(hass)
try:
entry = registry.async_update(msg["area_id"], msg["name"])
except ValueError as err:
connection.send_message(
websocket_api.erro... | [
"async",
"def",
"websocket_update_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"entry",
"=",
"registry",
".",
"async_update",
"(",
"msg",
"[",
"\"area_id\"",
"]",
... | [
105,
0
] | [
118,
9
] | python | en | ['en', 'nl', 'en'] | True |
_entry_dict | (entry) | Convert entry to API format. | Convert entry to API format. | def _entry_dict(entry):
"""Convert entry to API format."""
return {"area_id": entry.id, "name": entry.name} | [
"def",
"_entry_dict",
"(",
"entry",
")",
":",
"return",
"{",
"\"area_id\"",
":",
"entry",
".",
"id",
",",
"\"name\"",
":",
"entry",
".",
"name",
"}"
] | [
122,
0
] | [
124,
52
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the swiches devices. | Set up the swiches devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the swiches devices."""
pins = config.get(CONF_PINS)
switches = []
pi4ioe5v9xxxx.setup(
i2c_bus=config[CONF_I2CBUS],
i2c_addr=config[CONF_I2CADDR],
bits=config[CONF_BITS],
read_mode=False,
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"pins",
"=",
"config",
".",
"get",
"(",
"CONF_PINS",
")",
"switches",
"=",
"[",
"]",
"pi4ioe5v9xxxx",
".",
"setup",
"(",
"i2c_bus",
"=... | [
32,
0
] | [
46,
26
] | python | en | ['en', 'en', 'en'] | True |
Pi4ioe5v9Switch.__init__ | (self, name, pin, invert_logic) | Initialize the pin. | Initialize the pin. | def __init__(self, name, pin, invert_logic):
"""Initialize the pin."""
self._name = name or DEVICE_DEFAULT_NAME
self._pin = pin
self._invert_logic = invert_logic
self._state = not invert_logic | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"pin",
",",
"invert_logic",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"DEVICE_DEFAULT_NAME",
"self",
".",
"_pin",
"=",
"pin",
"self",
".",
"_invert_logic",
"=",
"invert_logic",
"self",
".",
"_sta... | [
52,
4
] | [
57,
38
] | python | en | ['en', 'en', 'en'] | True |
Pi4ioe5v9Switch.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"
] | [
60,
4
] | [
62,
25
] | python | en | ['en', 'en', 'en'] | True |
Pi4ioe5v9Switch.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
65,
4
] | [
67,
20
] | python | en | ['en', 'en', 'en'] | True |
Pi4ioe5v9Switch.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"
] | [
70,
4
] | [
72,
26
] | python | en | ['en', 'fy', 'en'] | True |
Pi4ioe5v9Switch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
pi4ioe5v9xxxx.pin_to_memory(self._pin, not self._invert_logic)
pi4ioe5v9xxxx.memory_to_hw()
self._state = True
self.schedule_update_ha_state() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pi4ioe5v9xxxx",
".",
"pin_to_memory",
"(",
"self",
".",
"_pin",
",",
"not",
"self",
".",
"_invert_logic",
")",
"pi4ioe5v9xxxx",
".",
"memory_to_hw",
"(",
")",
"self",
".",
"_state",
"=",
... | [
74,
4
] | [
79,
39
] | python | en | ['en', 'en', 'en'] | True |
Pi4ioe5v9Switch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
pi4ioe5v9xxxx.pin_to_memory(self._pin, self._invert_logic)
pi4ioe5v9xxxx.memory_to_hw()
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pi4ioe5v9xxxx",
".",
"pin_to_memory",
"(",
"self",
".",
"_pin",
",",
"self",
".",
"_invert_logic",
")",
"pi4ioe5v9xxxx",
".",
"memory_to_hw",
"(",
")",
"self",
".",
"_state",
"=",
"False... | [
81,
4
] | [
86,
39
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Search component. | Set up the Search component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Search component."""
websocket_api.async_register_command(hass, websocket_search_related)
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_search_related",
")",
"return",
"True"
] | [
15,
0
] | [
18,
15
] | python | en | ['en', 'en', 'en'] | True |
websocket_search_related | (hass, connection, msg) | Handle search. | Handle search. | async def websocket_search_related(hass, connection, msg):
"""Handle search."""
searcher = Searcher(
hass,
await device_registry.async_get_registry(hass),
await entity_registry.async_get_registry(hass),
)
connection.send_result(
msg["id"], searcher.async_search(msg["item_... | [
"async",
"def",
"websocket_search_related",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"searcher",
"=",
"Searcher",
"(",
"hass",
",",
"await",
"device_registry",
".",
"async_get_registry",
"(",
"hass",
")",
",",
"await",
"entity_registry",
".",
"asy... | [
40,
0
] | [
49,
5
] | python | en | ['en', 'en', 'en'] | False |
Searcher.__init__ | (
self,
hass: HomeAssistant,
device_reg: device_registry.DeviceRegistry,
entity_reg: entity_registry.EntityRegistry,
) | Search results. | Search results. | def __init__(
self,
hass: HomeAssistant,
device_reg: device_registry.DeviceRegistry,
entity_reg: entity_registry.EntityRegistry,
):
"""Search results."""
self.hass = hass
self._device_reg = device_reg
self._entity_reg = entity_reg
self.results ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"device_reg",
":",
"device_registry",
".",
"DeviceRegistry",
",",
"entity_reg",
":",
"entity_registry",
".",
"EntityRegistry",
",",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".... | [
66,
4
] | [
77,
34
] | python | en | ['en', 'en', 'en'] | False |
Searcher.async_search | (self, item_type, item_id) | Find results. | Find results. | def async_search(self, item_type, item_id):
"""Find results."""
_LOGGER.debug("Searching for %s/%s", item_type, item_id)
self.results[item_type].add(item_id)
self._to_resolve.append((item_type, item_id))
while self._to_resolve:
search_type, search_id = self._to_resol... | [
"def",
"async_search",
"(",
"self",
",",
"item_type",
",",
"item_id",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Searching for %s/%s\"",
",",
"item_type",
",",
"item_id",
")",
"self",
".",
"results",
"[",
"item_type",
"]",
".",
"add",
"(",
"item_id",
")",
... | [
80,
4
] | [
106,
69
] | python | en | ['en', 'en', 'en'] | False |
Searcher._add_or_resolve | (self, item_type, item_id) | Add an item to explore. | Add an item to explore. | def _add_or_resolve(self, item_type, item_id):
"""Add an item to explore."""
if item_id in self.results[item_type]:
return
self.results[item_type].add(item_id)
if item_type not in self.DONT_RESOLVE:
self._to_resolve.append((item_type, item_id)) | [
"def",
"_add_or_resolve",
"(",
"self",
",",
"item_type",
",",
"item_id",
")",
":",
"if",
"item_id",
"in",
"self",
".",
"results",
"[",
"item_type",
"]",
":",
"return",
"self",
".",
"results",
"[",
"item_type",
"]",
".",
"add",
"(",
"item_id",
")",
"if"... | [
109,
4
] | [
117,
57
] | python | en | ['en', 'en', 'en'] | True |
Searcher._resolve_area | (self, area_id) | Resolve an area. | Resolve an area. | def _resolve_area(self, area_id) -> None:
"""Resolve an area."""
for device in device_registry.async_entries_for_area(self._device_reg, area_id):
self._add_or_resolve("device", device.id)
for entity_entry in entity_registry.async_entries_for_area(
self._entity_reg, area_i... | [
"def",
"_resolve_area",
"(",
"self",
",",
"area_id",
")",
"->",
"None",
":",
"for",
"device",
"in",
"device_registry",
".",
"async_entries_for_area",
"(",
"self",
".",
"_device_reg",
",",
"area_id",
")",
":",
"self",
".",
"_add_or_resolve",
"(",
"\"device\"",
... | [
120,
4
] | [
127,
66
] | python | en | ['en', 'en', 'en'] | True |
Searcher._resolve_device | (self, device_id) | Resolve a device. | Resolve a device. | def _resolve_device(self, device_id) -> None:
"""Resolve a device."""
device_entry = self._device_reg.async_get(device_id)
# Unlikely entry doesn't exist, but let's guard for bad data.
if device_entry is not None:
if device_entry.area_id:
self._add_or_resolve(... | [
"def",
"_resolve_device",
"(",
"self",
",",
"device_id",
")",
"->",
"None",
":",
"device_entry",
"=",
"self",
".",
"_device_reg",
".",
"async_get",
"(",
"device_id",
")",
"# Unlikely entry doesn't exist, but let's guard for bad data.",
"if",
"device_entry",
"is",
"not... | [
130,
4
] | [
153,
53
] | python | en | ['es', 'en', 'en'] | True |
Searcher._resolve_entity | (self, entity_id) | Resolve an entity. | Resolve an entity. | def _resolve_entity(self, entity_id) -> None:
"""Resolve an entity."""
# Extra: Find automations and scripts that reference this entity.
for entity in scene.scenes_with_entity(self.hass, entity_id):
self._add_or_resolve("entity", entity)
for entity in group.groups_with_enti... | [
"def",
"_resolve_entity",
"(",
"self",
",",
"entity_id",
")",
"->",
"None",
":",
"# Extra: Find automations and scripts that reference this entity.",
"for",
"entity",
"in",
"scene",
".",
"scenes_with_entity",
"(",
"self",
".",
"hass",
",",
"entity_id",
")",
":",
"se... | [
156,
4
] | [
184,
51
] | python | en | ['en', 'cy', 'en'] | True |
Searcher._resolve_automation | (self, automation_entity_id) | Resolve an automation.
Will only be called if automation is an entry point.
| Resolve an automation. | def _resolve_automation(self, automation_entity_id) -> None:
"""Resolve an automation.
Will only be called if automation is an entry point.
"""
for entity in automation.entities_in_automation(
self.hass, automation_entity_id
):
self._add_or_resolve("entit... | [
"def",
"_resolve_automation",
"(",
"self",
",",
"automation_entity_id",
")",
"->",
"None",
":",
"for",
"entity",
"in",
"automation",
".",
"entities_in_automation",
"(",
"self",
".",
"hass",
",",
"automation_entity_id",
")",
":",
"self",
".",
"_add_or_resolve",
"... | [
187,
4
] | [
198,
50
] | python | de | ['de', 'en', 'it'] | False |
Searcher._resolve_script | (self, script_entity_id) | Resolve a script.
Will only be called if script is an entry point.
| Resolve a script. | def _resolve_script(self, script_entity_id) -> None:
"""Resolve a script.
Will only be called if script is an entry point.
"""
for entity in script.entities_in_script(self.hass, script_entity_id):
self._add_or_resolve("entity", entity)
for device in script.devices_i... | [
"def",
"_resolve_script",
"(",
"self",
",",
"script_entity_id",
")",
"->",
"None",
":",
"for",
"entity",
"in",
"script",
".",
"entities_in_script",
"(",
"self",
".",
"hass",
",",
"script_entity_id",
")",
":",
"self",
".",
"_add_or_resolve",
"(",
"\"entity\"",
... | [
201,
4
] | [
210,
50
] | python | en | ['en', 'co', 'en'] | True |
Searcher._resolve_group | (self, group_entity_id) | Resolve a group.
Will only be called if group is an entry point.
| Resolve a group. | def _resolve_group(self, group_entity_id) -> None:
"""Resolve a group.
Will only be called if group is an entry point.
"""
for entity_id in group.get_entity_ids(self.hass, group_entity_id):
self._add_or_resolve("entity", entity_id) | [
"def",
"_resolve_group",
"(",
"self",
",",
"group_entity_id",
")",
"->",
"None",
":",
"for",
"entity_id",
"in",
"group",
".",
"get_entity_ids",
"(",
"self",
".",
"hass",
",",
"group_entity_id",
")",
":",
"self",
".",
"_add_or_resolve",
"(",
"\"entity\"",
","... | [
213,
4
] | [
219,
53
] | python | en | ['en', 'en', 'en'] | True |
Searcher._resolve_scene | (self, scene_entity_id) | Resolve a scene.
Will only be called if scene is an entry point.
| Resolve a scene. | def _resolve_scene(self, scene_entity_id) -> None:
"""Resolve a scene.
Will only be called if scene is an entry point.
"""
for entity in scene.entities_in_scene(self.hass, scene_entity_id):
self._add_or_resolve("entity", entity) | [
"def",
"_resolve_scene",
"(",
"self",
",",
"scene_entity_id",
")",
"->",
"None",
":",
"for",
"entity",
"in",
"scene",
".",
"entities_in_scene",
"(",
"self",
".",
"hass",
",",
"scene_entity_id",
")",
":",
"self",
".",
"_add_or_resolve",
"(",
"\"entity\"",
","... | [
222,
4
] | [
228,
50
] | python | en | ['en', 'co', 'en'] | True |
Searcher._resolve_config_entry | (self, config_entry_id) | Resolve a config entry.
Will only be called if config entry is an entry point.
| Resolve a config entry. | def _resolve_config_entry(self, config_entry_id) -> None:
"""Resolve a config entry.
Will only be called if config entry is an entry point.
"""
for device_entry in device_registry.async_entries_for_config_entry(
self._device_reg, config_entry_id
):
self._... | [
"def",
"_resolve_config_entry",
"(",
"self",
",",
"config_entry_id",
")",
"->",
"None",
":",
"for",
"device_entry",
"in",
"device_registry",
".",
"async_entries_for_config_entry",
"(",
"self",
".",
"_device_reg",
",",
"config_entry_id",
")",
":",
"self",
".",
"_ad... | [
231,
4
] | [
244,
66
] | python | en | ['en', 'gl', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up the HEOS component. | Set up the HEOS component. | async def async_setup(hass: HomeAssistantType, config: ConfigType):
"""Set up the HEOS component."""
if DOMAIN not in config:
return True
host = config[DOMAIN][CONF_HOST]
entries = hass.config_entries.async_entries(DOMAIN)
if not entries:
# Create new entry based on config
ha... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"host",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_HOST",
"]",
"entries",
"... | [
37,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Initialize config entry which represents the HEOS controller. | Initialize config entry which represents the HEOS controller. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Initialize config entry which represents the HEOS controller."""
# For backwards compat
if entry.unique_id is None:
hass.config_entries.async_update_entry(entry, unique_id=DOMAIN)
host = entry.data[CONF_HOST]
# Set... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"# For backwards compat",
"if",
"entry",
".",
"unique_id",
"is",
"None",
":",
"hass",
".",
"config_entries",
".",
"async_update_entry",
"(",
"... | [
61,
0
] | [
120,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Unload a config entry."""
controller_manager = hass.data[DOMAIN][DATA_CONTROLLER_MANAGER]
await controller_manager.disconnect()
hass.data.pop(DOMAIN)
services.remove(hass)
return await hass.config_entries.async_forwa... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"controller_manager",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CONTROLLER_MANAGER",
"]",
"await",
"controller_manager",
".",
... | [
123,
0
] | [
133,
5
] | python | en | ['en', 'es', 'en'] | True |
ControllerManager.__init__ | (self, hass, controller) | Init the controller manager. | Init the controller manager. | def __init__(self, hass, controller):
"""Init the controller manager."""
self._hass = hass
self._device_registry = None
self._entity_registry = None
self.controller = controller
self._signals = [] | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"controller",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_device_registry",
"=",
"None",
"self",
".",
"_entity_registry",
"=",
"None",
"self",
".",
"controller",
"=",
"controller",
"self",
... | [
139,
4
] | [
145,
26
] | python | en | ['en', 'en', 'en'] | True |
ControllerManager.connect_listeners | (self) | Subscribe to events of interest. | Subscribe to events of interest. | async def connect_listeners(self):
"""Subscribe to events of interest."""
self._device_registry, self._entity_registry = await asyncio.gather(
self._hass.helpers.device_registry.async_get_registry(),
self._hass.helpers.entity_registry.async_get_registry(),
)
# Han... | [
"async",
"def",
"connect_listeners",
"(",
"self",
")",
":",
"self",
".",
"_device_registry",
",",
"self",
".",
"_entity_registry",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"self",
".",
"_hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_regist... | [
147,
4
] | [
164,
9
] | python | en | ['en', 'en', 'en'] | True |
ControllerManager.disconnect | (self) | Disconnect subscriptions. | Disconnect subscriptions. | async def disconnect(self):
"""Disconnect subscriptions."""
for signal_remove in self._signals:
signal_remove()
self._signals.clear()
self.controller.dispatcher.disconnect_all()
await self.controller.disconnect() | [
"async",
"def",
"disconnect",
"(",
"self",
")",
":",
"for",
"signal_remove",
"in",
"self",
".",
"_signals",
":",
"signal_remove",
"(",
")",
"self",
".",
"_signals",
".",
"clear",
"(",
")",
"self",
".",
"controller",
".",
"dispatcher",
".",
"disconnect_all"... | [
166,
4
] | [
172,
42
] | python | en | ['en', 'en', 'en'] | False |
ControllerManager._controller_event | (self, event, data) | Handle controller event. | Handle controller event. | async def _controller_event(self, event, data):
"""Handle controller event."""
if event == heos_const.EVENT_PLAYERS_CHANGED:
self.update_ids(data[heos_const.DATA_MAPPED_IDS])
# Update players
self._hass.helpers.dispatcher.async_dispatcher_send(SIGNAL_HEOS_UPDATED) | [
"async",
"def",
"_controller_event",
"(",
"self",
",",
"event",
",",
"data",
")",
":",
"if",
"event",
"==",
"heos_const",
".",
"EVENT_PLAYERS_CHANGED",
":",
"self",
".",
"update_ids",
"(",
"data",
"[",
"heos_const",
".",
"DATA_MAPPED_IDS",
"]",
")",
"# Updat... | [
174,
4
] | [
179,
80
] | python | en | ['da', 'en', 'en'] | True |
ControllerManager._heos_event | (self, event) | Handle connection event. | Handle connection event. | async def _heos_event(self, event):
"""Handle connection event."""
if event == heos_const.EVENT_CONNECTED:
try:
# Retrieve latest players and refresh status
data = await self.controller.load_players()
self.update_ids(data[heos_const.DATA_MAPPED... | [
"async",
"def",
"_heos_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
"==",
"heos_const",
".",
"EVENT_CONNECTED",
":",
"try",
":",
"# Retrieve latest players and refresh status",
"data",
"=",
"await",
"self",
".",
"controller",
".",
"load_players",
... | [
181,
4
] | [
191,
80
] | python | en | ['es', 'en', 'en'] | True |
ControllerManager.update_ids | (self, mapped_ids: Dict[int, int]) | Update the IDs in the device and entity registry. | Update the IDs in the device and entity registry. | def update_ids(self, mapped_ids: Dict[int, int]):
"""Update the IDs in the device and entity registry."""
# mapped_ids contains the mapped IDs (new:old)
for new_id, old_id in mapped_ids.items():
# update device registry
entry = self._device_registry.async_get_device({(DOM... | [
"def",
"update_ids",
"(",
"self",
",",
"mapped_ids",
":",
"Dict",
"[",
"int",
",",
"int",
"]",
")",
":",
"# mapped_ids contains the mapped IDs (new:old)",
"for",
"new_id",
",",
"old_id",
"in",
"mapped_ids",
".",
"items",
"(",
")",
":",
"# update device registry"... | [
193,
4
] | [
215,
85
] | python | en | ['en', 'en', 'en'] | True |
SourceManager.__init__ | (
self,
favorites,
inputs,
*,
retry_delay: int = COMMAND_RETRY_DELAY,
max_retry_attempts: int = COMMAND_RETRY_ATTEMPTS,
) | Init input manager. | Init input manager. | def __init__(
self,
favorites,
inputs,
*,
retry_delay: int = COMMAND_RETRY_DELAY,
max_retry_attempts: int = COMMAND_RETRY_ATTEMPTS,
):
"""Init input manager."""
self.retry_delay = retry_delay
self.max_retry_attempts = max_retry_attempts
... | [
"def",
"__init__",
"(",
"self",
",",
"favorites",
",",
"inputs",
",",
"*",
",",
"retry_delay",
":",
"int",
"=",
"COMMAND_RETRY_DELAY",
",",
"max_retry_attempts",
":",
"int",
"=",
"COMMAND_RETRY_ATTEMPTS",
",",
")",
":",
"self",
".",
"retry_delay",
"=",
"retr... | [
221,
4
] | [
234,
52
] | python | en | ['en', 'en', 'en'] | True |
SourceManager._build_source_list | (self) | Build a single list of inputs from various types. | Build a single list of inputs from various types. | def _build_source_list(self):
"""Build a single list of inputs from various types."""
source_list = []
source_list.extend([favorite.name for favorite in self.favorites.values()])
source_list.extend([source.name for source in self.inputs])
return source_list | [
"def",
"_build_source_list",
"(",
"self",
")",
":",
"source_list",
"=",
"[",
"]",
"source_list",
".",
"extend",
"(",
"[",
"favorite",
".",
"name",
"for",
"favorite",
"in",
"self",
".",
"favorites",
".",
"values",
"(",
")",
"]",
")",
"source_list",
".",
... | [
236,
4
] | [
241,
26
] | python | en | ['en', 'en', 'en'] | True |
SourceManager.play_source | (self, source: str, player) | Determine type of source and play it. | Determine type of source and play it. | async def play_source(self, source: str, player):
"""Determine type of source and play it."""
index = next(
(
index
for index, favorite in self.favorites.items()
if favorite.name == source
),
None,
)
if i... | [
"async",
"def",
"play_source",
"(",
"self",
",",
"source",
":",
"str",
",",
"player",
")",
":",
"index",
"=",
"next",
"(",
"(",
"index",
"for",
"index",
",",
"favorite",
"in",
"self",
".",
"favorites",
".",
"items",
"(",
")",
"if",
"favorite",
".",
... | [
243,
4
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
SourceManager.get_current_source | (self, now_playing_media) | Determine current source from now playing media. | Determine current source from now playing media. | def get_current_source(self, now_playing_media):
"""Determine current source from now playing media."""
# Match input by input_name:media_id
if now_playing_media.source_id == heos_const.MUSIC_SOURCE_AUX_INPUT:
return next(
(
input_source.name
... | [
"def",
"get_current_source",
"(",
"self",
",",
"now_playing_media",
")",
":",
"# Match input by input_name:media_id",
"if",
"now_playing_media",
".",
"source_id",
"==",
"heos_const",
".",
"MUSIC_SOURCE_AUX_INPUT",
":",
"return",
"next",
"(",
"(",
"input_source",
".",
... | [
271,
4
] | [
292,
9
] | python | en | ['en', 'en', 'en'] | True |
SourceManager.connect_update | (self, hass, controller) |
Connect listener for when sources change and signal player update.
EVENT_SOURCES_CHANGED is often raised multiple times in response to a
physical event therefore throttle it. Retrieving sources immediately
after the event may fail so retry.
|
Connect listener for when sources change and signal player update. | def connect_update(self, hass, controller):
"""
Connect listener for when sources change and signal player update.
EVENT_SOURCES_CHANGED is often raised multiple times in response to a
physical event therefore throttle it. Retrieving sources immediately
after the event may fail ... | [
"def",
"connect_update",
"(",
"self",
",",
"hass",
",",
"controller",
")",
":",
"@",
"Throttle",
"(",
"MIN_UPDATE_SOURCES",
")",
"async",
"def",
"get_sources",
"(",
")",
":",
"retry_attempts",
"=",
"0",
"while",
"True",
":",
"try",
":",
"favorites",
"=",
... | [
294,
4
] | [
342,
83
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Old way of setting up Hue lights.
Can only be called when a user accidentally mentions hue platform in their
config. But even in that case it would have been ignored.
| Old way of setting up Hue lights. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up Hue lights.
Can only be called when a user accidentally mentions hue platform in their
config. But even in that case it would have been ignored.
""" | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":"
] | [
68,
0
] | [
73,
7
] | python | en | ['en', 'en', 'en'] | True |
create_light | (item_class, coordinator, bridge, is_group, api, item_id) | Create the light. | Create the light. | def create_light(item_class, coordinator, bridge, is_group, api, item_id):
"""Create the light."""
if is_group:
supported_features = 0
for light_id in api[item_id].lights:
if light_id not in bridge.api.lights:
continue
light = bridge.api.lights[light_id]
... | [
"def",
"create_light",
"(",
"item_class",
",",
"coordinator",
",",
"bridge",
",",
"is_group",
",",
"api",
",",
"item_id",
")",
":",
"if",
"is_group",
":",
"supported_features",
"=",
"0",
"for",
"light_id",
"in",
"api",
"[",
"item_id",
"]",
".",
"lights",
... | [
76,
0
] | [
88,
86
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Hue lights from a config entry. | Set up the Hue lights from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Hue lights from a config entry."""
bridge = hass.data[HUE_DOMAIN][config_entry.entry_id]
light_coordinator = DataUpdateCoordinator(
hass,
_LOGGER,
name="light",
update_method=partial(async_saf... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"bridge",
"=",
"hass",
".",
"data",
"[",
"HUE_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"light_coordinator",
"=",
"DataUpdateCoordinator",
... | [
91,
0
] | [
157,
43
] | python | en | ['en', 'en', 'en'] | True |
async_safe_fetch | (bridge, fetch_method) | Safely fetch data. | Safely fetch data. | async def async_safe_fetch(bridge, fetch_method):
"""Safely fetch data."""
try:
with async_timeout.timeout(4):
return await bridge.async_request_call(fetch_method)
except aiohue.Unauthorized as err:
await bridge.handle_unauthorized_error()
raise UpdateFailed("Unauthorized... | [
"async",
"def",
"async_safe_fetch",
"(",
"bridge",
",",
"fetch_method",
")",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"4",
")",
":",
"return",
"await",
"bridge",
".",
"async_request_call",
"(",
"fetch_method",
")",
"except",
"aiohue",
"... | [
160,
0
] | [
169,
56
] | python | cs | ['cy', 'cs', 'en'] | False |
async_update_items | (bridge, api, current, async_add_entities, create_item) | Update items. | Update items. | def async_update_items(bridge, api, current, async_add_entities, create_item):
"""Update items."""
new_items = []
for item_id in api:
if item_id in current:
continue
current[item_id] = create_item(api, item_id)
new_items.append(current[item_id])
bridge.hass.async_c... | [
"def",
"async_update_items",
"(",
"bridge",
",",
"api",
",",
"current",
",",
"async_add_entities",
",",
"create_item",
")",
":",
"new_items",
"=",
"[",
"]",
"for",
"item_id",
"in",
"api",
":",
"if",
"item_id",
"in",
"current",
":",
"continue",
"current",
"... | [
173,
0
] | [
187,
37
] | python | en | ['en', 'la', 'en'] | False |
hue_brightness_to_hass | (value) | Convert hue brightness 1..254 to hass format 0..255. | Convert hue brightness 1..254 to hass format 0..255. | def hue_brightness_to_hass(value):
"""Convert hue brightness 1..254 to hass format 0..255."""
return min(255, round((value / 254) * 255)) | [
"def",
"hue_brightness_to_hass",
"(",
"value",
")",
":",
"return",
"min",
"(",
"255",
",",
"round",
"(",
"(",
"value",
"/",
"254",
")",
"*",
"255",
")",
")"
] | [
190,
0
] | [
192,
47
] | python | en | ['en', 'en', 'en'] | True |
hass_to_hue_brightness | (value) | Convert hass brightness 0..255 to hue 1..254 scale. | Convert hass brightness 0..255 to hue 1..254 scale. | def hass_to_hue_brightness(value):
"""Convert hass brightness 0..255 to hue 1..254 scale."""
return max(1, round((value / 255) * 254)) | [
"def",
"hass_to_hue_brightness",
"(",
"value",
")",
":",
"return",
"max",
"(",
"1",
",",
"round",
"(",
"(",
"value",
"/",
"255",
")",
"*",
"254",
")",
")"
] | [
195,
0
] | [
197,
45
] | python | en | ['en', 'en', 'en'] | True |
HueLight.__init__ | (self, coordinator, bridge, is_group, light, supported_features) | Initialize the light. | Initialize the light. | def __init__(self, coordinator, bridge, is_group, light, supported_features):
"""Initialize the light."""
super().__init__(coordinator)
self.light = light
self.bridge = bridge
self.is_group = is_group
self._supported_features = supported_features
if is_group:
... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"bridge",
",",
"is_group",
",",
"light",
",",
"supported_features",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"light",
"=",
"light",
"self",
".",
"bridge",... | [
203,
4
] | [
235,
37
] | python | en | ['en', 'en', 'en'] | True |
HueLight.unique_id | (self) | Return the unique ID of this Hue light. | Return the unique ID of this Hue light. | def unique_id(self):
"""Return the unique ID of this Hue light."""
return self.light.uniqueid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"light",
".",
"uniqueid"
] | [
238,
4
] | [
240,
34
] | python | en | ['en', 'en', 'en'] | True |
HueLight.device_id | (self) | Return the ID of this Hue light. | Return the ID of this Hue light. | def device_id(self):
"""Return the ID of this Hue light."""
return self.unique_id | [
"def",
"device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"unique_id"
] | [
243,
4
] | [
245,
29
] | python | en | ['en', 'en', 'en'] | True |
HueLight.name | (self) | Return the name of the Hue light. | Return the name of the Hue light. | def name(self):
"""Return the name of the Hue light."""
return self.light.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"light",
".",
"name"
] | [
248,
4
] | [
250,
30
] | python | en | ['en', 'mi', 'en'] | True |
HueLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self):
"""Return the brightness of this light between 0..255."""
if self.is_group:
bri = self.light.action.get("bri")
else:
bri = self.light.state.get("bri")
if bri is None:
return bri
return hue_brightness_to_hass(bri) | [
"def",
"brightness",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_group",
":",
"bri",
"=",
"self",
".",
"light",
".",
"action",
".",
"get",
"(",
"\"bri\"",
")",
"else",
":",
"bri",
"=",
"self",
".",
"light",
".",
"state",
".",
"get",
"(",
"\"bri... | [
253,
4
] | [
263,
42
] | python | en | ['en', 'en', 'en'] | True |
HueLight._color_mode | (self) | Return the hue color mode. | Return the hue color mode. | def _color_mode(self):
"""Return the hue color mode."""
if self.is_group:
return self.light.action.get("colormode")
return self.light.state.get("colormode") | [
"def",
"_color_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_group",
":",
"return",
"self",
".",
"light",
".",
"action",
".",
"get",
"(",
"\"colormode\"",
")",
"return",
"self",
".",
"light",
".",
"state",
".",
"get",
"(",
"\"colormode\"",
")"
] | [
266,
4
] | [
270,
48
] | python | en | ['en', 'pt', 'en'] | True |
HueLight.hs_color | (self) | Return the hs color value. | Return the hs color value. | def hs_color(self):
"""Return the hs color value."""
mode = self._color_mode
source = self.light.action if self.is_group else self.light.state
if mode in ("xy", "hs") and "xy" in source:
return color.color_xy_to_hs(*source["xy"], self.gamut)
return None | [
"def",
"hs_color",
"(",
"self",
")",
":",
"mode",
"=",
"self",
".",
"_color_mode",
"source",
"=",
"self",
".",
"light",
".",
"action",
"if",
"self",
".",
"is_group",
"else",
"self",
".",
"light",
".",
"state",
"if",
"mode",
"in",
"(",
"\"xy\"",
",",
... | [
273,
4
] | [
281,
19
] | python | en | ['en', 'en', 'en'] | True |
HueLight.color_temp | (self) | Return the CT color value. | Return the CT color value. | def color_temp(self):
"""Return the CT color value."""
# Don't return color temperature unless in color temperature mode
if self._color_mode != "ct":
return None
if self.is_group:
return self.light.action.get("ct")
return self.light.state.get("ct") | [
"def",
"color_temp",
"(",
"self",
")",
":",
"# Don't return color temperature unless in color temperature mode",
"if",
"self",
".",
"_color_mode",
"!=",
"\"ct\"",
":",
"return",
"None",
"if",
"self",
".",
"is_group",
":",
"return",
"self",
".",
"light",
".",
"acti... | [
284,
4
] | [
292,
41
] | python | en | ['en', 'en', 'en'] | True |
HueLight.min_mireds | (self) | Return the coldest color_temp that this light supports. | Return the coldest color_temp that this light supports. | def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
if self.is_group:
return super().min_mireds
min_mireds = self.light.controlcapabilities.get("ct", {}).get("min")
# We filter out '0' too, which can be incorrectly reported by 3rd party buls
... | [
"def",
"min_mireds",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_group",
":",
"return",
"super",
"(",
")",
".",
"min_mireds",
"min_mireds",
"=",
"self",
".",
"light",
".",
"controlcapabilities",
".",
"get",
"(",
"\"ct\"",
",",
"{",
"}",
")",
".",
"... | [
295,
4
] | [
306,
25
] | python | en | ['en', 'en', 'en'] | True |
HueLight.max_mireds | (self) | Return the warmest color_temp that this light supports. | Return the warmest color_temp that this light supports. | def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
if self.is_group:
return super().max_mireds
max_mireds = self.light.controlcapabilities.get("ct", {}).get("max")
if not max_mireds:
return super().max_mireds
return max_... | [
"def",
"max_mireds",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_group",
":",
"return",
"super",
"(",
")",
".",
"max_mireds",
"max_mireds",
"=",
"self",
".",
"light",
".",
"controlcapabilities",
".",
"get",
"(",
"\"ct\"",
",",
"{",
"}",
")",
".",
"... | [
309,
4
] | [
319,
25
] | python | en | ['en', 'en', 'en'] | True |
HueLight.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."""
if self.is_group:
return self.light.state["any_on"]
return self.light.state["on"] | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_group",
":",
"return",
"self",
".",
"light",
".",
"state",
"[",
"\"any_on\"",
"]",
"return",
"self",
".",
"light",
".",
"state",
"[",
"\"on\"",
"]"
] | [
322,
4
] | [
326,
37
] | python | en | ['en', 'fy', 'en'] | True |
HueLight.available | (self) | Return if light is available. | Return if light is available. | def available(self):
"""Return if light is available."""
return self.coordinator.last_update_success and (
self.is_group
or self.bridge.allow_unreachable
or self.light.state["reachable"]
) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"(",
"self",
".",
"is_group",
"or",
"self",
".",
"bridge",
".",
"allow_unreachable",
"or",
"self",
".",
"light",
".",
"state",
"[",
"\"reach... | [
329,
4
] | [
335,
9
] | python | en | ['en', 'en', 'en'] | True |
HueLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_features"
] | [
338,
4
] | [
340,
39
] | python | en | ['da', 'en', 'en'] | True |
HueLight.effect | (self) | Return the current effect. | Return the current effect. | def effect(self):
"""Return the current effect."""
return self.light.state.get("effect", None) | [
"def",
"effect",
"(",
"self",
")",
":",
"return",
"self",
".",
"light",
".",
"state",
".",
"get",
"(",
"\"effect\"",
",",
"None",
")"
] | [
343,
4
] | [
345,
51
] | python | en | ['en', 'en', 'en'] | True |
HueLight.effect_list | (self) | Return the list of supported effects. | Return the list of supported effects. | def effect_list(self):
"""Return the list of supported effects."""
if self.is_osram:
return [EFFECT_RANDOM]
return [EFFECT_COLORLOOP, EFFECT_RANDOM] | [
"def",
"effect_list",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_osram",
":",
"return",
"[",
"EFFECT_RANDOM",
"]",
"return",
"[",
"EFFECT_COLORLOOP",
",",
"EFFECT_RANDOM",
"]"
] | [
348,
4
] | [
352,
48
] | python | en | ['en', 'en', 'en'] | True |
HueLight.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
if self.light.type in ("LightGroup", "Room", "Luminaire", "LightSource"):
return None
return {
"identifiers": {(HUE_DOMAIN, self.device_id)},
"name": self.name,
"manufacturer": self.light.manufa... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"light",
".",
"type",
"in",
"(",
"\"LightGroup\"",
",",
"\"Room\"",
",",
"\"Luminaire\"",
",",
"\"LightSource\"",
")",
":",
"return",
"None",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
... | [
355,
4
] | [
370,
9
] | python | en | ['en', 'en', 'en'] | True |
HueLight.async_turn_on | (self, **kwargs) | Turn the specified or all lights on. | Turn the specified or all lights on. | async def async_turn_on(self, **kwargs):
"""Turn the specified or all lights on."""
command = {"on": True}
if ATTR_TRANSITION in kwargs:
command["transitiontime"] = int(kwargs[ATTR_TRANSITION] * 10)
if ATTR_HS_COLOR in kwargs:
if self.is_osram:
c... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"command",
"=",
"{",
"\"on\"",
":",
"True",
"}",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"command",
"[",
"\"transitiontime\"",
"]",
"=",
"int",
"(",
"kwargs",
"[",
"... | [
372,
4
] | [
426,
54
] | python | en | ['en', 'en', 'en'] | True |
HueLight.async_turn_off | (self, **kwargs) | Turn the specified or all lights off. | Turn the specified or all lights off. | async def async_turn_off(self, **kwargs):
"""Turn the specified or all lights off."""
command = {"on": False}
if ATTR_TRANSITION in kwargs:
command["transitiontime"] = int(kwargs[ATTR_TRANSITION] * 10)
flash = kwargs.get(ATTR_FLASH)
if flash == FLASH_LONG:
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"command",
"=",
"{",
"\"on\"",
":",
"False",
"}",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"command",
"[",
"\"transitiontime\"",
"]",
"=",
"int",
"(",
"kwargs",
"[",
... | [
428,
4
] | [
455,
54
] | python | en | ['en', 'en', 'en'] | True |
HueLight.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
if not self.is_group:
return {}
return {ATTR_IS_HUE_GROUP: self.is_group} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_group",
":",
"return",
"{",
"}",
"return",
"{",
"ATTR_IS_HUE_GROUP",
":",
"self",
".",
"is_group",
"}"
] | [
458,
4
] | [
462,
49
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Smile switches from a config entry. | Set up the Smile switches from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Smile switches from a config entry."""
api = hass.data[DOMAIN][config_entry.entry_id]["api"]
coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
entities = []
switch_classes = ["plug", "switch_group"]... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"\"api\"",
"]",
"coordinator",
"=",
"hass",
"."... | [
15,
0
] | [
44,
38
] | python | en | ['en', 'en', 'en'] | True |
PwSwitch.__init__ | (self, api, coordinator, name, dev_id, members, model) | Set up the Plugwise API. | Set up the Plugwise API. | def __init__(self, api, coordinator, name, dev_id, members, model):
"""Set up the Plugwise API."""
super().__init__(api, coordinator, name, dev_id)
self._members = members
self._model = model
self._is_on = False
self._icon = SWITCH_ICON
self._unique_id = f"{dev... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"coordinator",
",",
"name",
",",
"dev_id",
",",
"members",
",",
"model",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"api",
",",
"coordinator",
",",
"name",
",",
"dev_id",
")",
"self",
".",
"_... | [
50,
4
] | [
60,
42
] | python | en | ['en', 'zu', 'en'] | True |
PwSwitch.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._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
63,
4
] | [
65,
26
] | python | en | ['en', 'fy', 'en'] | True |
PwSwitch.icon | (self) | Return the icon of this entity. | Return the icon of this entity. | def icon(self):
"""Return the icon of this entity."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
68,
4
] | [
70,
25
] | python | en | ['en', 'en', 'en'] | True |
PwSwitch.async_turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | async def async_turn_on(self, **kwargs):
"""Turn the device on."""
try:
state_on = await self._api.set_relay_state(
self._dev_id, self._members, "on"
)
if state_on:
self._is_on = True
self.async_write_ha_state()
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"state_on",
"=",
"await",
"self",
".",
"_api",
".",
"set_relay_state",
"(",
"self",
".",
"_dev_id",
",",
"self",
".",
"_members",
",",
"\"on\"",
")",
"if",
"... | [
72,
4
] | [
82,
64
] | python | en | ['en', 'en', 'en'] | True |
PwSwitch.async_turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off."""
try:
state_off = await self._api.set_relay_state(
self._dev_id, self._members, "off"
)
if state_off:
self._is_on = False
self.async_write_ha_state()
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"state_off",
"=",
"await",
"self",
".",
"_api",
".",
"set_relay_state",
"(",
"self",
".",
"_dev_id",
",",
"self",
".",
"_members",
",",
"\"off\"",
")",
"if",
... | [
84,
4
] | [
94,
64
] | python | en | ['en', 'en', 'en'] | True |
PwSwitch._async_process_data | (self) | Update the data from the Plugs. | Update the data from the Plugs. | def _async_process_data(self):
"""Update the data from the Plugs."""
data = self._api.get_device_data(self._dev_id)
if not data:
_LOGGER.error("Received no data for device %s", self._name)
self.async_write_ha_state()
return
if "relay" in data:
... | [
"def",
"_async_process_data",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_api",
".",
"get_device_data",
"(",
"self",
".",
"_dev_id",
")",
"if",
"not",
"data",
":",
"_LOGGER",
".",
"error",
"(",
"\"Received no data for device %s\"",
",",
"self",
".",
... | [
97,
4
] | [
109,
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.