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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
CommandSwitch.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._command_state is None | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_command_state",
"is",
"None"
] | [
140,
4
] | [
142,
42
] | python | en | ['pt', 'la', 'en'] | False |
CommandSwitch._query_state | (self) | Query for state. | Query for state. | def _query_state(self):
"""Query for state."""
if not self._command_state:
_LOGGER.error("No state command specified")
return
if self._value_template:
return self._query_state_value(self._command_state)
return self._query_state_code(self._command_state... | [
"def",
"_query_state",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_command_state",
":",
"_LOGGER",
".",
"error",
"(",
"\"No state command specified\"",
")",
"return",
"if",
"self",
".",
"_value_template",
":",
"return",
"self",
".",
"_query_state_value",
... | [
144,
4
] | [
151,
58
] | python | en | ['en', 'en', 'en'] | True |
CommandSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
if self._command_state:
payload = str(self._query_state())
if self._value_template:
payload = self._value_template.render_with_possible_json_value(payload)
self._state = payload.lower() == "true" | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_command_state",
":",
"payload",
"=",
"str",
"(",
"self",
".",
"_query_state",
"(",
")",
")",
"if",
"self",
".",
"_value_template",
":",
"payload",
"=",
"self",
".",
"_value_template",
".",
"r... | [
153,
4
] | [
159,
51
] | python | en | ['fr', 'en', 'en'] | True |
CommandSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
if self._switch(self._command_on) and not self._command_state:
self._state = True
self.schedule_update_ha_state() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_switch",
"(",
"self",
".",
"_command_on",
")",
"and",
"not",
"self",
".",
"_command_state",
":",
"self",
".",
"_state",
"=",
"True",
"self",
".",
"schedule_update_ha... | [
161,
4
] | [
165,
43
] | python | en | ['en', 'en', 'en'] | True |
CommandSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
if self._switch(self._command_off) and not self._command_state:
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_switch",
"(",
"self",
".",
"_command_off",
")",
"and",
"not",
"self",
".",
"_command_state",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"schedule_update... | [
167,
4
] | [
171,
43
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we can setup though the user path. | Test we can setup though the user path. | async def test_form(hass):
"""Test we can setup though the user path."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
ass... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
20,
0
] | [
53,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass) | Test we can import. | Test we can import. | async def test_import(hass):
"""Test we can import."""
await setup.async_setup_component(hass, "persistent_notification", {})
mock_tado_api = _get_mock_tado_api(getMe={"homes": [{"id": 1, "name": "myhome"}]})
with patch(
"homeassistant.components.tado.config_flow.Tado",
return_value=mo... | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mock_tado_api",
"=",
"_get_mock_tado_api",
"(",
"getMe",
"=",
"{",
"\"homes\"",
":",
"["... | [
56,
0
] | [
85,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
response_mock = MagicMock()
type(response_mock).status_code = 401
mock_tado_api = _get_mock_tado_api(ge... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
88,
0
] | [
108,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
response_mock = MagicMock()
type(response_mock).status_code = 500
mock_tado_api = _get_mock_t... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
111,
0
] | [
131,
58
] | python | en | ['en', 'en', 'en'] | True |
test_no_homes | (hass) | Test we handle no homes error. | Test we handle no homes error. | async def test_no_homes(hass):
"""Test we handle no homes error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
mock_tado_api = _get_mock_tado_api(getMe={"homes": []})
with patch(
"homeassistant.components.tado.config... | [
"async",
"def",
"test_no_homes",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
"mock... | [
134,
0
] | [
152,
52
] | python | es | ['es', 'es', 'en'] | True |
test_form_homekit | (hass) | Test that we abort from homekit if tado is already setup. | Test that we abort from homekit if tado is already setup. | async def test_form_homekit(hass):
"""Test that we abort from homekit if tado is already setup."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": "homekit"},
data={"properties": {"... | [
"async",
"def",
"test_form_homekit",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_ini... | [
155,
0
] | [
183,
36
] | python | en | ['en', 'en', 'en'] | True |
DropPath.__init__ | (self, p=0.) |
Drop path with probability.
Parameters
----------
p : float
Probability of an path to be zeroed.
|
Drop path with probability. | def __init__(self, p=0.):
"""
Drop path with probability.
Parameters
----------
p : float
Probability of an path to be zeroed.
"""
super().__init__()
self.p = p | [
"def",
"__init__",
"(",
"self",
",",
"p",
"=",
"0.",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"p",
"=",
"p"
] | [
8,
4
] | [
18,
18
] | python | en | ['en', 'error', 'th'] | False |
sanity_checks | (args) |
A bunch of args sanity checks to perform even starting...
|
A bunch of args sanity checks to perform even starting...
| def sanity_checks(args):
"""
A bunch of args sanity checks to perform even starting...
"""
assert (args.mlm and args.alpha_mlm > 0.0) or (not args.mlm and args.alpha_mlm == 0.0)
assert (args.alpha_mlm > 0.0 and args.alpha_clm == 0.0) or (args.alpha_mlm == 0.0 and args.alpha_clm > 0.0)
if args.ml... | [
"def",
"sanity_checks",
"(",
"args",
")",
":",
"assert",
"(",
"args",
".",
"mlm",
"and",
"args",
".",
"alpha_mlm",
">",
"0.0",
")",
"or",
"(",
"not",
"args",
".",
"mlm",
"and",
"args",
".",
"alpha_mlm",
"==",
"0.0",
")",
"assert",
"(",
"args",
".",... | [
54,
0
] | [
81,
98
] | python | en | ['en', 'error', 'th'] | False |
get_scanner | (hass, config) | Validate the configuration and returns a Tomato scanner. | Validate the configuration and returns a Tomato scanner. | def get_scanner(hass, config):
"""Validate the configuration and returns a Tomato scanner."""
return TomatoDeviceScanner(config[DOMAIN]) | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"return",
"TomatoDeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")"
] | [
42,
0
] | [
44,
46
] | python | en | ['en', 'en', 'en'] | True |
TomatoDeviceScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
host, http_id = config[CONF_HOST], config[CONF_HTTP_ID]
port = config.get(CONF_PORT)
username, password = config[CONF_USERNAME], config[CONF_PASSWORD]
self.ssl, self.verify_ssl = config[CONF_SSL], config[CONF_VERIFY_SSL]
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"host",
",",
"http_id",
"=",
"config",
"[",
"CONF_HOST",
"]",
",",
"config",
"[",
"CONF_HTTP_ID",
"]",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"username",
",",
"password",
"=",
... | [
50,
4
] | [
70,
54
] | python | en | ['en', 'en', 'en'] | True |
TomatoDeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_tomato_info()
return [item[1] for item in self.last_results["wldev"]] | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_tomato_info",
"(",
")",
"return",
"[",
"item",
"[",
"1",
"]",
"for",
"item",
"in",
"self",
".",
"last_results",
"[",
"\"wldev\"",
"]",
"]"
] | [
72,
4
] | [
76,
63
] | python | en | ['en', 'en', 'en'] | True |
TomatoDeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [
item[0] for item in self.last_results["dhcpd_lease"] if item[2] == device
]
if not filter_named or not filter_named[0]:
return None
re... | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"filter_named",
"=",
"[",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"self",
".",
"last_results",
"[",
"\"dhcpd_lease\"",
"]",
"if",
"item",
"[",
"2",
"]",
"==",
"device",
"]",
"if",
"n... | [
78,
4
] | [
87,
30
] | python | en | ['en', 'en', 'en'] | True |
TomatoDeviceScanner._update_tomato_info | (self) | Ensure the information from the Tomato router is up to date.
Return boolean if scanning successful.
| Ensure the information from the Tomato router is up to date. | def _update_tomato_info(self):
"""Ensure the information from the Tomato router is up to date.
Return boolean if scanning successful.
"""
_LOGGER.info("Scanning")
try:
if self.ssl:
response = requests.Session().send(
self.req, tim... | [
"def",
"_update_tomato_info",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Scanning\"",
")",
"try",
":",
"if",
"self",
".",
"ssl",
":",
"response",
"=",
"requests",
".",
"Session",
"(",
")",
".",
"send",
"(",
"self",
".",
"req",
",",
"timeo... | [
89,
4
] | [
138,
24
] | python | en | ['en', 'en', 'en'] | True |
setup_base_test | (
sensor_name,
hass,
use_mock_hub,
data_array,
entity_domain,
scan_interval,
) | Run setup device for given config. | Run setup device for given config. | async def setup_base_test(
sensor_name,
hass,
use_mock_hub,
data_array,
entity_domain,
scan_interval,
):
"""Run setup device for given config."""
# Full sensor configuration
config = {
entity_domain: {
CONF_PLATFORM: "modbus",
CONF_SCAN_INTERVAL: scan... | [
"async",
"def",
"setup_base_test",
"(",
"sensor_name",
",",
"hass",
",",
"use_mock_hub",
",",
"data_array",
",",
"entity_domain",
",",
"scan_interval",
",",
")",
":",
"# Full sensor configuration",
"config",
"=",
"{",
"entity_domain",
":",
"{",
"CONF_PLATFORM",
":... | [
39,
0
] | [
68,
33
] | python | en | ['en', 'en', 'en'] | True |
run_base_read_test | (
entity_id,
hass,
use_mock_hub,
register_type,
register_words,
expected,
now,
) | Run test for given config. | Run test for given config. | async def run_base_read_test(
entity_id,
hass,
use_mock_hub,
register_type,
register_words,
expected,
now,
):
"""Run test for given config."""
# Setup inputs for the sensor
read_result = ReadResult(register_words)
if register_type == CALL_TYPE_COIL:
use_mock_hub.read... | [
"async",
"def",
"run_base_read_test",
"(",
"entity_id",
",",
"hass",
",",
"use_mock_hub",
",",
"register_type",
",",
"register_words",
",",
"expected",
",",
"now",
",",
")",
":",
"# Setup inputs for the sensor",
"read_result",
"=",
"ReadResult",
"(",
"register_words... | [
71,
0
] | [
100,
28
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.__init__ | (
self,
hap: HomematicipHAP,
device,
post: Optional[str] = None,
channel: Optional[int] = None,
) | Initialize the generic entity. | Initialize the generic entity. | def __init__(
self,
hap: HomematicipHAP,
device,
post: Optional[str] = None,
channel: Optional[int] = None,
) -> None:
"""Initialize the generic entity."""
self._hap = hap
self._home = hap.home
self._device = device
self._post = post
... | [
"def",
"__init__",
"(",
"self",
",",
"hap",
":",
"HomematicipHAP",
",",
"device",
",",
"post",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"channel",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
... | [
72,
4
] | [
87,
77
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self) -> Dict[str, Any]:
"""Return device specific attributes."""
# Only physical devices should be HA devices.
if isinstance(self._device, AsyncDevice):
return {
"identifiers": {
# Serial numbers of Homematic IP device
... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Only physical devices should be HA devices.",
"if",
"isinstance",
"(",
"self",
".",
"_device",
",",
"AsyncDevice",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
... | [
90,
4
] | [
106,
19
] | python | en | ['fr', 'it', 'en'] | False |
HomematicipGenericEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self) -> None:
"""Register callbacks."""
self._hap.hmip_device_by_entity_id[self.entity_id] = self._device
self._device.on_update(self._async_device_changed)
self._device.on_remove(self._async_device_removed) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_hap",
".",
"hmip_device_by_entity_id",
"[",
"self",
".",
"entity_id",
"]",
"=",
"self",
".",
"_device",
"self",
".",
"_device",
".",
"on_update",
"(",
"self",
".",
... | [
108,
4
] | [
112,
58
] | python | en | ['en', 'no', 'en'] | False |
HomematicipGenericEntity._async_device_changed | (self, *args, **kwargs) | Handle device state changes. | Handle device state changes. | def _async_device_changed(self, *args, **kwargs) -> None:
"""Handle device state changes."""
# Don't update disabled entities
if self.enabled:
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType)
self.async_write_ha_state()
else:
_LOGGER.d... | [
"def",
"_async_device_changed",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"# Don't update disabled entities",
"if",
"self",
".",
"enabled",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Event %s (%s)\"",
",",
"self",
".",
"name"... | [
115,
4
] | [
126,
13
] | python | en | ['ro', 'en', 'en'] | True |
HomematicipGenericEntity.async_will_remove_from_hass | (self) | Run when hmip device will be removed from hass. | Run when hmip device will be removed from hass. | async def async_will_remove_from_hass(self) -> None:
"""Run when hmip device will be removed from hass."""
# Only go further if the device/entity should be removed from registries
# due to a removal of the HmIP device.
if self.hmip_device_removed:
try:
del s... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"# Only go further if the device/entity should be removed from registries",
"# due to a removal of the HmIP device.",
"if",
"self",
".",
"hmip_device_removed",
":",
"try",
":",
"del",
"self",
... | [
128,
4
] | [
139,
82
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.async_remove_from_registries | (self) | Remove entity/device from registry. | Remove entity/device from registry. | async def async_remove_from_registries(self) -> None:
"""Remove entity/device from registry."""
# Remove callback from device.
self._device.remove_callback(self._async_device_changed)
self._device.remove_callback(self._async_device_removed)
if not self.registry_entry:
... | [
"async",
"def",
"async_remove_from_registries",
"(",
"self",
")",
"->",
"None",
":",
"# Remove callback from device.",
"self",
".",
"_device",
".",
"remove_callback",
"(",
"self",
".",
"_async_device_changed",
")",
"self",
".",
"_device",
".",
"remove_callback",
"("... | [
141,
4
] | [
165,
59
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity._async_device_removed | (self, *args, **kwargs) | Handle hmip device removal. | Handle hmip device removal. | def _async_device_removed(self, *args, **kwargs) -> None:
"""Handle hmip device removal."""
# Set marker showing that the HmIP device hase been removed.
self.hmip_device_removed = True
self.hass.async_create_task(self.async_remove()) | [
"def",
"_async_device_removed",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"# Set marker showing that the HmIP device hase been removed.",
"self",
".",
"hmip_device_removed",
"=",
"True",
"self",
".",
"hass",
".",
"async_create_t... | [
168,
4
] | [
172,
56
] | python | en | ['nl', 'en', 'en'] | True |
HomematicipGenericEntity.name | (self) | Return the name of the generic entity. | Return the name of the generic entity. | def name(self) -> str:
"""Return the name of the generic entity."""
name = None
# Try to get a label from a channel.
if hasattr(self._device, "functionalChannels"):
if self._channel:
name = self._device.functionalChannels[self._channel].label
else... | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"name",
"=",
"None",
"# Try to get a label from a channel.",
"if",
"hasattr",
"(",
"self",
".",
"_device",
",",
"\"functionalChannels\"",
")",
":",
"if",
"self",
".",
"_channel",
":",
"name",
"=",
"self",
... | [
175,
4
] | [
199,
19
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.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"
] | [
202,
4
] | [
204,
20
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.available | (self) | Return if entity is available. | Return if entity is available. | def available(self) -> bool:
"""Return if entity is available."""
return not self._device.unreach | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"not",
"self",
".",
"_device",
".",
"unreach"
] | [
207,
4
] | [
209,
39
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGenericEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
unique_id = f"{self.__class__.__name__}_{self._device.id}"
if self._channel:
unique_id = (
f"{self.__class__.__name__}_Channel{self._channel}_{self._device.id}"
)
return unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"unique_id",
"=",
"f\"{self.__class__.__name__}_{self._device.id}\"",
"if",
"self",
".",
"_channel",
":",
"unique_id",
"=",
"(",
"f\"{self.__class__.__name__}_Channel{self._channel}_{self._device.id}\"",
")",
"return",... | [
212,
4
] | [
220,
24
] | python | ca | ['fr', 'ca', 'en'] | False |
HomematicipGenericEntity.icon | (self) | Return the icon. | Return the icon. | def icon(self) -> Optional[str]:
"""Return the icon."""
for attr, icon in DEVICE_ATTRIBUTE_ICONS.items():
if getattr(self._device, attr, None):
return icon
return None | [
"def",
"icon",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"for",
"attr",
",",
"icon",
"in",
"DEVICE_ATTRIBUTE_ICONS",
".",
"items",
"(",
")",
":",
"if",
"getattr",
"(",
"self",
".",
"_device",
",",
"attr",
",",
"None",
")",
":",
"ret... | [
223,
4
] | [
229,
19
] | python | en | ['en', 'sr', 'en'] | True |
HomematicipGenericEntity.device_state_attributes | (self) | Return the state attributes of the generic entity. | Return the state attributes of the generic entity. | def device_state_attributes(self) -> Dict[str, Any]:
"""Return the state attributes of the generic entity."""
state_attr = {}
if isinstance(self._device, AsyncDevice):
for attr, attr_key in DEVICE_ATTRIBUTES.items():
attr_value = getattr(self._device, attr, None)
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"state_attr",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"self",
".",
"_device",
",",
"AsyncDevice",
")",
":",
"for",
"attr",
",",
"attr_key",
"in",
"DEVIC... | [
232,
4
] | [
252,
25
] | python | en | ['en', 'en', 'en'] | True |
async_get_service | (hass, config, discovery_info=None) | Return the notify service. | Return the notify service. | async def async_get_service(hass, config, discovery_info=None):
"""Return the notify service."""
return TTSNotificationService(config) | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"TTSNotificationService",
"(",
"config",
")"
] | [
29,
0
] | [
32,
41
] | python | en | ['en', 'en', 'en'] | True |
TTSNotificationService.__init__ | (self, config) | Initialize the service. | Initialize the service. | def __init__(self, config):
"""Initialize the service."""
_, self._tts_service = split_entity_id(config[CONF_TTS_SERVICE])
self._media_player = config[CONF_MEDIA_PLAYER]
self._language = config.get(ATTR_LANGUAGE) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"_",
",",
"self",
".",
"_tts_service",
"=",
"split_entity_id",
"(",
"config",
"[",
"CONF_TTS_SERVICE",
"]",
")",
"self",
".",
"_media_player",
"=",
"config",
"[",
"CONF_MEDIA_PLAYER",
"]",
"self",
".... | [
38,
4
] | [
42,
50
] | python | en | ['en', 'en', 'en'] | True |
TTSNotificationService.async_send_message | (self, message="", **kwargs) | Call TTS service to speak the notification. | Call TTS service to speak the notification. | async def async_send_message(self, message="", **kwargs):
"""Call TTS service to speak the notification."""
_LOGGER.debug("%s '%s' on %s", self._tts_service, message, self._media_player)
data = {
ATTR_MESSAGE: message,
ATTR_ENTITY_ID: self._media_player,
}
... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"%s '%s' on %s\"",
",",
"self",
".",
"_tts_service",
",",
"message",
",",
"self",
".",
"_media_player",
")",
... | [
44,
4
] | [
59,
9
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
25,
0
] | [
27,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
31,
0
] | [
33,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
37,
0
] | [
39,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a binary_sensor. | Test we get the expected triggers from a binary_sensor. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a binary_sensor."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = dev... | [
"async",
"def",
"test_get_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"config_entry",
"=",
"MockConfigEnt... | [
42,
0
] | [
76,
40
] | python | en | ['en', 'en', 'en'] | True |
test_get_trigger_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a binary_sensor trigger. | Test we get the expected capabilities from a binary_sensor trigger. | async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a binary_sensor trigger."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=co... | [
"async",
"def",
"test_get_trigger_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"has... | [
79,
0
] | [
98,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls) | Test for on and off triggers firing. | Test for on and off triggers firing. | async def test_if_fires_on_state_change(hass, calls):
"""Test for on and off triggers firing."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
sensor1 =... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
... | [
101,
0
] | [
182,
5
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change_with_for | (hass, calls) | Test for triggers firing with delay. | Test for triggers firing with delay. | async def test_if_fires_on_state_change_with_for(hass, calls):
"""Test for triggers firing with delay."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_state_change_with_for",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component"... | [
185,
0
] | [
241,
5
] | python | en | ['en', 'en', 'en'] | True |
add_statestream | (
hass,
base_topic=None,
publish_attributes=None,
publish_timestamps=None,
publish_include=None,
publish_exclude=None,
) | Add a mqtt_statestream component. | Add a mqtt_statestream component. | async def add_statestream(
hass,
base_topic=None,
publish_attributes=None,
publish_timestamps=None,
publish_include=None,
publish_exclude=None,
):
"""Add a mqtt_statestream component."""
config = {}
if base_topic:
config["base_topic"] = base_topic
if publish_attributes:
... | [
"async",
"def",
"add_statestream",
"(",
"hass",
",",
"base_topic",
"=",
"None",
",",
"publish_attributes",
"=",
"None",
",",
"publish_timestamps",
"=",
"None",
",",
"publish_include",
"=",
"None",
",",
"publish_exclude",
"=",
"None",
",",
")",
":",
"config",
... | [
9,
0
] | [
31,
5
] | python | co | ['en', 'co', 'it'] | False |
test_fails_with_no_base | (hass, mqtt_mock) | Setup should fail if no base_topic is set. | Setup should fail if no base_topic is set. | async def test_fails_with_no_base(hass, mqtt_mock):
"""Setup should fail if no base_topic is set."""
assert await add_statestream(hass) is False | [
"async",
"def",
"test_fails_with_no_base",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"add_statestream",
"(",
"hass",
")",
"is",
"False"
] | [
34,
0
] | [
36,
47
] | python | en | ['en', 'st', 'en'] | True |
test_setup_succeeds_without_attributes | (hass, mqtt_mock) | Test the success of the setup with a valid base_topic. | Test the success of the setup with a valid base_topic. | async def test_setup_succeeds_without_attributes(hass, mqtt_mock):
"""Test the success of the setup with a valid base_topic."""
assert await add_statestream(hass, base_topic="pub") | [
"async",
"def",
"test_setup_succeeds_without_attributes",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"add_statestream",
"(",
"hass",
",",
"base_topic",
"=",
"\"pub\"",
")"
] | [
39,
0
] | [
41,
56
] | python | en | ['en', 'en', 'en'] | True |
test_setup_succeeds_with_attributes | (hass, mqtt_mock) | Test setup with a valid base_topic and publish_attributes. | Test setup with a valid base_topic and publish_attributes. | async def test_setup_succeeds_with_attributes(hass, mqtt_mock):
"""Test setup with a valid base_topic and publish_attributes."""
assert await add_statestream(hass, base_topic="pub", publish_attributes=True) | [
"async",
"def",
"test_setup_succeeds_with_attributes",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"assert",
"await",
"add_statestream",
"(",
"hass",
",",
"base_topic",
"=",
"\"pub\"",
",",
"publish_attributes",
"=",
"True",
")"
] | [
44,
0
] | [
46,
81
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_sends_message | (hass, mqtt_mock) | Test the sending of a new message if event changed. | Test the sending of a new message if event changed. | async def test_state_changed_event_sends_message(hass, mqtt_mock):
"""Test the sending of a new message if event changed."""
e_id = "fake.entity"
base_topic = "pub"
# Add the statestream component for publishing state updates
assert await add_statestream(hass, base_topic=base_topic)
await hass.... | [
"async",
"def",
"test_state_changed_event_sends_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"e_id",
"=",
"\"fake.entity\"",
"base_topic",
"=",
"\"pub\"",
"# Add the statestream component for publishing state updates",
"assert",
"await",
"add_statestream",
"(",
"hass",
... | [
49,
0
] | [
69,
41
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_sends_message_and_timestamp | (hass, mqtt_mock) | Test the sending of a message and timestamps if event changed. | Test the sending of a message and timestamps if event changed. | async def test_state_changed_event_sends_message_and_timestamp(hass, mqtt_mock):
"""Test the sending of a message and timestamps if event changed."""
e_id = "another.entity"
base_topic = "pub"
# Add the statestream component for publishing state updates
assert await add_statestream(
hass, b... | [
"async",
"def",
"test_state_changed_event_sends_message_and_timestamp",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"e_id",
"=",
"\"another.entity\"",
"base_topic",
"=",
"\"pub\"",
"# Add the statestream component for publishing state updates",
"assert",
"await",
"add_statestream",
... | [
72,
0
] | [
100,
41
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_attr_sends_message | (hass, mqtt_mock) | Test the sending of a new message if attribute changed. | Test the sending of a new message if attribute changed. | async def test_state_changed_attr_sends_message(hass, mqtt_mock):
"""Test the sending of a new message if attribute changed."""
e_id = "fake.entity"
base_topic = "pub"
# Add the statestream component for publishing state updates
assert await add_statestream(hass, base_topic=base_topic, publish_attr... | [
"async",
"def",
"test_state_changed_attr_sends_message",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"e_id",
"=",
"\"fake.entity\"",
"base_topic",
"=",
"\"pub\"",
"# Add the statestream component for publishing state updates",
"assert",
"await",
"add_statestream",
"(",
"hass",
... | [
103,
0
] | [
132,
41
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_include_domain | (hass, mqtt_mock) | Test that filtering on included domain works as expected. | Test that filtering on included domain works as expected. | async def test_state_changed_event_include_domain(hass, mqtt_mock):
"""Test that filtering on included domain works as expected."""
base_topic = "pub"
incl = {"domains": ["fake"]}
excl = {}
# Add the statestream component for publishing state updates
# Set the filter to allow fake.* items
... | [
"async",
"def",
"test_state_changed_event_include_domain",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
"}",
"excl",
"=",
"{",
"}",
"# Add the statestream component for publishing ... | [
135,
0
] | [
168,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_include_entity | (hass, mqtt_mock) | Test that filtering on included entity works as expected. | Test that filtering on included entity works as expected. | async def test_state_changed_event_include_entity(hass, mqtt_mock):
"""Test that filtering on included entity works as expected."""
base_topic = "pub"
incl = {"entities": ["fake.entity"]}
excl = {}
# Add the statestream component for publishing state updates
# Set the filter to allow fake.* it... | [
"async",
"def",
"test_state_changed_event_include_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"entities\"",
":",
"[",
"\"fake.entity\"",
"]",
"}",
"excl",
"=",
"{",
"}",
"# Add the statestream component for pub... | [
171,
0
] | [
204,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_exclude_domain | (hass, mqtt_mock) | Test that filtering on excluded domain works as expected. | Test that filtering on excluded domain works as expected. | async def test_state_changed_event_exclude_domain(hass, mqtt_mock):
"""Test that filtering on excluded domain works as expected."""
base_topic = "pub"
incl = {}
excl = {"domains": ["fake2"]}
# Add the statestream component for publishing state updates
# Set the filter to allow fake.* items
... | [
"async",
"def",
"test_state_changed_event_exclude_domain",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"}",
"excl",
"=",
"{",
"\"domains\"",
":",
"[",
"\"fake2\"",
"]",
"}",
"# Add the statestream component for publishing... | [
207,
0
] | [
240,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_exclude_entity | (hass, mqtt_mock) | Test that filtering on excluded entity works as expected. | Test that filtering on excluded entity works as expected. | async def test_state_changed_event_exclude_entity(hass, mqtt_mock):
"""Test that filtering on excluded entity works as expected."""
base_topic = "pub"
incl = {}
excl = {"entities": ["fake.entity2"]}
# Add the statestream component for publishing state updates
# Set the filter to allow fake.* i... | [
"async",
"def",
"test_state_changed_event_exclude_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"}",
"excl",
"=",
"{",
"\"entities\"",
":",
"[",
"\"fake.entity2\"",
"]",
"}",
"# Add the statestream component for pu... | [
243,
0
] | [
276,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_exclude_domain_include_entity | (hass, mqtt_mock) | Test filtering with excluded domain and included entity. | Test filtering with excluded domain and included entity. | async def test_state_changed_event_exclude_domain_include_entity(hass, mqtt_mock):
"""Test filtering with excluded domain and included entity."""
base_topic = "pub"
incl = {"entities": ["fake.entity"]}
excl = {"domains": ["fake"]}
# Add the statestream component for publishing state updates
# ... | [
"async",
"def",
"test_state_changed_event_exclude_domain_include_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"entities\"",
":",
"[",
"\"fake.entity\"",
"]",
"}",
"excl",
"=",
"{",
"\"domains\"",
":",
"[",
"... | [
279,
0
] | [
312,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_include_domain_exclude_entity | (hass, mqtt_mock) | Test filtering with included domain and excluded entity. | Test filtering with included domain and excluded entity. | async def test_state_changed_event_include_domain_exclude_entity(hass, mqtt_mock):
"""Test filtering with included domain and excluded entity."""
base_topic = "pub"
incl = {"domains": ["fake"]}
excl = {"entities": ["fake.entity2"]}
# Add the statestream component for publishing state updates
#... | [
"async",
"def",
"test_state_changed_event_include_domain_exclude_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
"}",
"excl",
"=",
"{",
"\"entities\"",
":",
"[",
"\"fake.... | [
315,
0
] | [
348,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_include_globs | (hass, mqtt_mock) | Test that filtering on included glob works as expected. | Test that filtering on included glob works as expected. | async def test_state_changed_event_include_globs(hass, mqtt_mock):
"""Test that filtering on included glob works as expected."""
base_topic = "pub"
incl = {"entity_globs": ["*.included_*"]}
excl = {}
# Add the statestream component for publishing state updates
# Set the filter to allow *.inclu... | [
"async",
"def",
"test_state_changed_event_include_globs",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.included_*\"",
"]",
"}",
"excl",
"=",
"{",
"}",
"# Add the statestream component for... | [
351,
0
] | [
386,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_exclude_globs | (hass, mqtt_mock) | Test that filtering on excluded globs works as expected. | Test that filtering on excluded globs works as expected. | async def test_state_changed_event_exclude_globs(hass, mqtt_mock):
"""Test that filtering on excluded globs works as expected."""
base_topic = "pub"
incl = {}
excl = {"entity_globs": ["*.excluded_*"]}
# Add the statestream component for publishing state updates
# Set the filter to allow *.excl... | [
"async",
"def",
"test_state_changed_event_exclude_globs",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"}",
"excl",
"=",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.excluded_*\"",
"]",
"}",
"# Add the statestream component for... | [
389,
0
] | [
422,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_exclude_domain_globs_include_entity | (hass, mqtt_mock) | Test filtering with excluded domain and glob and included entity. | Test filtering with excluded domain and glob and included entity. | async def test_state_changed_event_exclude_domain_globs_include_entity(hass, mqtt_mock):
"""Test filtering with excluded domain and glob and included entity."""
base_topic = "pub"
incl = {"entities": ["fake.entity"]}
excl = {"domains": ["fake"], "entity_globs": ["*.excluded_*"]}
# Add the statestr... | [
"async",
"def",
"test_state_changed_event_exclude_domain_globs_include_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"entities\"",
":",
"[",
"\"fake.entity\"",
"]",
"}",
"excl",
"=",
"{",
"\"domains\"",
":",
"[... | [
425,
0
] | [
478,
45
] | python | en | ['en', 'en', 'en'] | True |
test_state_changed_event_include_domain_globs_exclude_entity | (hass, mqtt_mock) | Test filtering with included domain and glob and excluded entity. | Test filtering with included domain and glob and excluded entity. | async def test_state_changed_event_include_domain_globs_exclude_entity(hass, mqtt_mock):
"""Test filtering with included domain and glob and excluded entity."""
base_topic = "pub"
incl = {"domains": ["fake"], "entity_globs": ["*.included_*"]}
excl = {"entities": ["fake.entity2"]}
# Add the statest... | [
"async",
"def",
"test_state_changed_event_include_domain_globs_exclude_entity",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"base_topic",
"=",
"\"pub\"",
"incl",
"=",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
",",
"\"entity_globs\"",
":",
"[",
"\"*.included_*\"",
... | [
481,
0
] | [
534,
45
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, config_entry, async_add_entities) | Set up lights. | Set up lights. | async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities):
"""Set up lights."""
entities = await hass.async_add_executor_job(
add_available_devices, hass, CONF_LIGHT, TPLinkSmartBulb
)
if entities:
async_add_entities(entities, update_before_add=True)
if... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"add_available_devices",
",",
"hass",
",",
"CONF_LIGHT",
",",
... | [
61,
0
] | [
71,
30
] | python | en | ['en', 'da', 'en'] | True |
brightness_to_percentage | (byt) | Convert brightness from absolute 0..255 to percentage. | Convert brightness from absolute 0..255 to percentage. | def brightness_to_percentage(byt):
"""Convert brightness from absolute 0..255 to percentage."""
return round((byt * 100.0) / 255.0) | [
"def",
"brightness_to_percentage",
"(",
"byt",
")",
":",
"return",
"round",
"(",
"(",
"byt",
"*",
"100.0",
")",
"/",
"255.0",
")"
] | [
74,
0
] | [
76,
39
] | python | en | ['en', 'en', 'en'] | True |
brightness_from_percentage | (percent) | Convert percentage to absolute value 0..255. | Convert percentage to absolute value 0..255. | def brightness_from_percentage(percent):
"""Convert percentage to absolute value 0..255."""
return round((percent * 255.0) / 100.0) | [
"def",
"brightness_from_percentage",
"(",
"percent",
")",
":",
"return",
"round",
"(",
"(",
"percent",
"*",
"255.0",
")",
"/",
"100.0",
")"
] | [
79,
0
] | [
81,
43
] | python | en | ['en', 'en', 'en'] | True |
LightState.to_param | (self) | Return a version that we can send to the bulb. | Return a version that we can send to the bulb. | def to_param(self):
"""Return a version that we can send to the bulb."""
if self.color_temp:
color_temp = mired_to_kelvin(self.color_temp)
else:
color_temp = None
return {
LIGHT_STATE_ON_OFF: 1 if self.state else 0,
LIGHT_STATE_BRIGHTNESS:... | [
"def",
"to_param",
"(",
"self",
")",
":",
"if",
"self",
".",
"color_temp",
":",
"color_temp",
"=",
"mired_to_kelvin",
"(",
"self",
".",
"color_temp",
")",
"else",
":",
"color_temp",
"=",
"None",
"return",
"{",
"LIGHT_STATE_ON_OFF",
":",
"1",
"if",
"self",
... | [
92,
4
] | [
105,
9
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.__init__ | (self, smartbulb: SmartBulb) | Initialize the bulb. | Initialize the bulb. | def __init__(self, smartbulb: SmartBulb) -> None:
"""Initialize the bulb."""
self.smartbulb = smartbulb
self._light_features = cast(LightFeatures, None)
self._light_state = cast(LightState, None)
self._is_available = True
self._is_setting_light_state = False
self.... | [
"def",
"__init__",
"(",
"self",
",",
"smartbulb",
":",
"SmartBulb",
")",
"->",
"None",
":",
"self",
".",
"smartbulb",
"=",
"smartbulb",
"self",
".",
"_light_features",
"=",
"cast",
"(",
"LightFeatures",
",",
"None",
")",
"self",
".",
"_light_state",
"=",
... | [
124,
4
] | [
136,
26
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._light_features.mac | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_features",
".",
"mac"
] | [
139,
4
] | [
141,
39
] | python | ca | ['fr', 'ca', 'en'] | False |
TPLinkSmartBulb.name | (self) | Return the name of the Smart Bulb. | Return the name of the Smart Bulb. | def name(self):
"""Return the name of the Smart Bulb."""
return self._light_features.alias | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_features",
".",
"alias"
] | [
144,
4
] | [
146,
41
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.device_info | (self) | Return information about the device. | Return information about the device. | def device_info(self):
"""Return information about the device."""
return {
"name": self._light_features.alias,
"model": self._light_features.model,
"manufacturer": "TP-Link",
"connections": {(dr.CONNECTION_NETWORK_MAC, self._light_features.mac)},
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_light_features",
".",
"alias",
",",
"\"model\"",
":",
"self",
".",
"_light_features",
".",
"model",
",",
"\"manufacturer\"",
":",
"\"TP-Link\"",
",",
"\"connections\"",... | [
149,
4
] | [
157,
9
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.available | (self) | Return if bulb is available. | Return if bulb is available. | def available(self) -> bool:
"""Return if bulb is available."""
return self._is_available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_is_available"
] | [
160,
4
] | [
162,
33
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return self._emeter_params | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_emeter_params"
] | [
165,
4
] | [
167,
34
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs:
brightness = int(kwargs[ATTR_BRIGHTNESS])
elif self._light_state.brightness is not None:
brightness = self._light_state.brightness
else:
brightness = 255
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"brightness",
"=",
"int",
"(",
"kwargs",
"[",
"ATTR_BRIGHTNESS",
"]",
")",
"elif",
"self",
".",
"_light_state",
".",
"brightness"... | [
169,
4
] | [
200,
9
] | python | en | ['en', 'et', 'en'] | True |
TPLinkSmartBulb.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._async_set_light_state_retry(
self._light_state,
self._light_state._replace(state=False),
) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_async_set_light_state_retry",
"(",
"self",
".",
"_light_state",
",",
"self",
".",
"_light_state",
".",
"_replace",
"(",
"state",
"=",
"False",
")",
",... | [
202,
4
] | [
207,
9
] | python | en | ['en', 'zh', 'en'] | True |
TPLinkSmartBulb.min_mireds | (self) | Return minimum supported color temperature. | Return minimum supported color temperature. | def min_mireds(self):
"""Return minimum supported color temperature."""
return self._light_features.min_mireds | [
"def",
"min_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_features",
".",
"min_mireds"
] | [
210,
4
] | [
212,
46
] | python | en | ['ro', 'la', 'en'] | False |
TPLinkSmartBulb.max_mireds | (self) | Return maximum supported color temperature. | Return maximum supported color temperature. | def max_mireds(self):
"""Return maximum supported color temperature."""
return self._light_features.max_mireds | [
"def",
"max_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_features",
".",
"max_mireds"
] | [
215,
4
] | [
217,
46
] | python | en | ['ro', 'la', 'en'] | False |
TPLinkSmartBulb.color_temp | (self) | Return the color temperature of this light in mireds for HA. | Return the color temperature of this light in mireds for HA. | def color_temp(self):
"""Return the color temperature of this light in mireds for HA."""
return self._light_state.color_temp | [
"def",
"color_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_state",
".",
"color_temp"
] | [
220,
4
] | [
222,
43
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.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."""
return self._light_state.brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_state",
".",
"brightness"
] | [
225,
4
] | [
227,
43
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.hs_color | (self) | Return the color. | Return the color. | def hs_color(self):
"""Return the color."""
return self._light_state.hs | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_state",
".",
"hs"
] | [
230,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.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._light_state.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_state",
".",
"state"
] | [
235,
4
] | [
237,
38
] | python | en | ['en', 'fy', 'en'] | True |
TPLinkSmartBulb.attempt_update | (self, update_attempt) | Attempt to get details the TP-Link bulb. | Attempt to get details the TP-Link bulb. | def attempt_update(self, update_attempt):
"""Attempt to get details the TP-Link bulb."""
# State is currently being set, ignore.
if self._is_setting_light_state:
return False
try:
if not self._light_features:
self._light_features = self._get_light... | [
"def",
"attempt_update",
"(",
"self",
",",
"update_attempt",
")",
":",
"# State is currently being set, ignore.",
"if",
"self",
".",
"_is_setting_light_state",
":",
"return",
"False",
"try",
":",
"if",
"not",
"self",
".",
"_light_features",
":",
"self",
".",
"_lig... | [
239,
4
] | [
262,
24
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._light_features.supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light_features",
".",
"supported_features"
] | [
265,
4
] | [
267,
54
] | python | en | ['da', 'en', 'en'] | True |
TPLinkSmartBulb._get_light_features | (self) | Determine all supported features in one go. | Determine all supported features in one go. | def _get_light_features(self):
"""Determine all supported features in one go."""
sysinfo = self.smartbulb.sys_info
supported_features = 0
# Calling api here as it reformats
mac = self.smartbulb.mac
alias = sysinfo[LIGHT_SYSINFO_ALIAS]
model = sysinfo[LIGHT_SYSINFO... | [
"def",
"_get_light_features",
"(",
"self",
")",
":",
"sysinfo",
"=",
"self",
".",
"smartbulb",
".",
"sys_info",
"supported_features",
"=",
"0",
"# Calling api here as it reformats",
"mac",
"=",
"self",
".",
"smartbulb",
".",
"mac",
"alias",
"=",
"sysinfo",
"[",
... | [
269,
4
] | [
302,
9
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb._get_light_state | (self) | Get the light state. | Get the light state. | def _get_light_state(self) -> LightState:
"""Get the light state."""
self._update_emeter()
return self._light_state_from_params(self._get_device_state()) | [
"def",
"_get_light_state",
"(",
"self",
")",
"->",
"LightState",
":",
"self",
".",
"_update_emeter",
"(",
")",
"return",
"self",
".",
"_light_state_from_params",
"(",
"self",
".",
"_get_device_state",
"(",
")",
")"
] | [
340,
4
] | [
343,
70
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb._async_set_light_state_retry | (
self, old_light_state: LightState, new_light_state: LightState
) | Set the light state with retry. | Set the light state with retry. | async def _async_set_light_state_retry(
self, old_light_state: LightState, new_light_state: LightState
) -> None:
"""Set the light state with retry."""
# Tell the device to set the states.
if not _light_state_diff(old_light_state, new_light_state):
# Nothing to do, avoid ... | [
"async",
"def",
"_async_set_light_state_retry",
"(",
"self",
",",
"old_light_state",
":",
"LightState",
",",
"new_light_state",
":",
"LightState",
")",
"->",
"None",
":",
"# Tell the device to set the states.",
"if",
"not",
"_light_state_diff",
"(",
"old_light_state",
"... | [
378,
4
] | [
414,
44
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb._set_light_state | (
self, old_light_state: LightState, new_light_state: LightState
) | Set the light state. | Set the light state. | def _set_light_state(
self, old_light_state: LightState, new_light_state: LightState
) -> None:
"""Set the light state."""
diff = _light_state_diff(old_light_state, new_light_state)
if not diff:
return
return self._set_device_state(diff) | [
"def",
"_set_light_state",
"(",
"self",
",",
"old_light_state",
":",
"LightState",
",",
"new_light_state",
":",
"LightState",
")",
"->",
"None",
":",
"diff",
"=",
"_light_state_diff",
"(",
"old_light_state",
",",
"new_light_state",
")",
"if",
"not",
"diff",
":",... | [
416,
4
] | [
425,
43
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb._get_device_state | (self) | State of the bulb or smart dimmer switch. | State of the bulb or smart dimmer switch. | def _get_device_state(self):
"""State of the bulb or smart dimmer switch."""
if isinstance(self.smartbulb, SmartBulb):
return self.smartbulb.get_light_state()
sysinfo = self.smartbulb.sys_info
# Its not really a bulb, its a dimmable SmartPlug (aka Wall Switch)
return... | [
"def",
"_get_device_state",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"smartbulb",
",",
"SmartBulb",
")",
":",
"return",
"self",
".",
"smartbulb",
".",
"get_light_state",
"(",
")",
"sysinfo",
"=",
"self",
".",
"smartbulb",
".",
"sys_info... | [
427,
4
] | [
440,
9
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb._set_device_state | (self, state) | Set state of the bulb or smart dimmer switch. | Set state of the bulb or smart dimmer switch. | def _set_device_state(self, state):
"""Set state of the bulb or smart dimmer switch."""
if isinstance(self.smartbulb, SmartBulb):
return self.smartbulb.set_light_state(state)
# Its not really a bulb, its a dimmable SmartPlug (aka Wall Switch)
if LIGHT_STATE_BRIGHTNESS in sta... | [
"def",
"_set_device_state",
"(",
"self",
",",
"state",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"smartbulb",
",",
"SmartBulb",
")",
":",
"return",
"self",
".",
"smartbulb",
".",
"set_light_state",
"(",
"state",
")",
"# Its not really a bulb, its a dimmabl... | [
442,
4
] | [
462,
39
] | python | en | ['en', 'en', 'en'] | True |
TPLinkSmartBulb.async_update | (self) | Update the TP-Link bulb's state. | Update the TP-Link bulb's state. | async def async_update(self):
"""Update the TP-Link bulb's state."""
for update_attempt in range(MAX_ATTEMPTS):
is_ready = await self.hass.async_add_executor_job(
self.attempt_update, update_attempt
)
if is_ready:
self._is_available = ... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"for",
"update_attempt",
"in",
"range",
"(",
"MAX_ATTEMPTS",
")",
":",
"is_ready",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"attempt_update",
",",
"update_attempt... | [
464,
4
] | [
489,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[list], None],
) | Set up the ISY994 lock platform. | Set up the ISY994 lock platform. | async def async_setup_entry(
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[list], None],
) -> bool:
"""Set up the ISY994 lock platform."""
hass_isy_data = hass.data[ISY994_DOMAIN][entry.entry_id]
devices = []
for node in hass_isy_data[ISY994_NODES][LOCK]:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"list",
"]",
",",
"None",
"]",
",",
")",
"->",
"bool",
":",
"hass_isy_data",
"=",
"hass",
".... | [
16,
0
] | [
31,
31
] | python | en | ['en', 'ky', 'en'] | True |
ISYLockEntity.is_locked | (self) | Get whether the lock is in locked state. | Get whether the lock is in locked state. | def is_locked(self) -> bool:
"""Get whether the lock is in locked state."""
if self._node.status == ISY_VALUE_UNKNOWN:
return None
return VALUE_TO_STATE.get(self._node.status) | [
"def",
"is_locked",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_node",
".",
"status",
"==",
"ISY_VALUE_UNKNOWN",
":",
"return",
"None",
"return",
"VALUE_TO_STATE",
".",
"get",
"(",
"self",
".",
"_node",
".",
"status",
")"
] | [
38,
4
] | [
42,
52
] | python | en | ['en', 'en', 'en'] | True |
ISYLockEntity.lock | (self, **kwargs) | Send the lock command to the ISY994 device. | Send the lock command to the ISY994 device. | def lock(self, **kwargs) -> None:
"""Send the lock command to the ISY994 device."""
if not self._node.secure_lock():
_LOGGER.error("Unable to lock device") | [
"def",
"lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_node",
".",
"secure_lock",
"(",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to lock device\"",
")"
] | [
44,
4
] | [
47,
50
] | python | en | ['en', 'en', 'en'] | True |
ISYLockEntity.unlock | (self, **kwargs) | Send the unlock command to the ISY994 device. | Send the unlock command to the ISY994 device. | def unlock(self, **kwargs) -> None:
"""Send the unlock command to the ISY994 device."""
if not self._node.secure_unlock():
_LOGGER.error("Unable to lock device") | [
"def",
"unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_node",
".",
"secure_unlock",
"(",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to lock device\"",
")"
] | [
49,
4
] | [
52,
50
] | python | en | ['en', 'en', 'en'] | True |
ISYLockProgramEntity.is_locked | (self) | Return true if the device is locked. | Return true if the device is locked. | def is_locked(self) -> bool:
"""Return true if the device is locked."""
return bool(self._node.status) | [
"def",
"is_locked",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"self",
".",
"_node",
".",
"status",
")"
] | [
59,
4
] | [
61,
38
] | python | en | ['en', 'en', 'en'] | True |
ISYLockProgramEntity.lock | (self, **kwargs) | Lock the device. | Lock the device. | def lock(self, **kwargs) -> None:
"""Lock the device."""
if not self._actions.run_then():
_LOGGER.error("Unable to lock device") | [
"def",
"lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_actions",
".",
"run_then",
"(",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to lock device\"",
")"
] | [
63,
4
] | [
66,
50
] | python | en | ['en', 'en', 'en'] | True |
ISYLockProgramEntity.unlock | (self, **kwargs) | Unlock the device. | Unlock the device. | def unlock(self, **kwargs) -> None:
"""Unlock the device."""
if not self._actions.run_else():
_LOGGER.error("Unable to unlock device") | [
"def",
"unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_actions",
".",
"run_else",
"(",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to unlock device\"",
")"
] | [
68,
4
] | [
71,
52
] | python | en | ['en', 'zh', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the brunt platform. | Set up the brunt platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the brunt platform."""
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
bapi = BruntAPI(username=username, password=password)
try:
things = bapi.getThings()["things"]
if not things:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD",
"]",
"bapi",
"=",
"BruntAPI",
"(",
... | [
36,
0
] | [
61,
9
] | python | en | ['en', 'da', 'en'] | True |
BruntDevice.__init__ | (self, bapi, name, thing_uri) | Init the Brunt device. | Init the Brunt device. | def __init__(self, bapi, name, thing_uri):
"""Init the Brunt device."""
self._bapi = bapi
self._name = name
self._thing_uri = thing_uri
self._state = {}
self._available = None | [
"def",
"__init__",
"(",
"self",
",",
"bapi",
",",
"name",
",",
"thing_uri",
")",
":",
"self",
".",
"_bapi",
"=",
"bapi",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_thing_uri",
"=",
"thing_uri",
"self",
".",
"_state",
"=",
"{",
"}",
"self",
"... | [
71,
4
] | [
78,
30
] | python | en | ['en', 'en', 'en'] | True |
BruntDevice.name | (self) | Return the name of the device as reported by tellcore. | Return the name of the device as reported by tellcore. | def name(self):
"""Return the name of the device as reported by tellcore."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
81,
4
] | [
83,
25
] | python | en | ['en', 'en', 'en'] | True |
BruntDevice.available | (self) | Could the device be accessed during the last update call. | Could the device be accessed during the last update call. | def available(self):
"""Could the device be accessed during the last update call."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
86,
4
] | [
88,
30
] | python | en | ['en', 'en', 'en'] | True |
BruntDevice.current_cover_position | (self) |
Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
|
Return current position of cover. | def current_cover_position(self):
"""
Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""
pos = self._state.get("currentPosition")
return int(pos) if pos else None | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"_state",
".",
"get",
"(",
"\"currentPosition\"",
")",
"return",
"int",
"(",
"pos",
")",
"if",
"pos",
"else",
"None"
] | [
91,
4
] | [
98,
40
] | python | en | ['en', 'error', 'th'] | False |
BruntDevice.request_cover_position | (self) |
Return request position of cover.
The request position is the position of the last request
to Brunt, at times there is a diff of 1 to current
None is unknown, 0 is closed, 100 is fully open.
|
Return request position of cover. | def request_cover_position(self):
"""
Return request position of cover.
The request position is the position of the last request
to Brunt, at times there is a diff of 1 to current
None is unknown, 0 is closed, 100 is fully open.
"""
pos = self._state.get("request... | [
"def",
"request_cover_position",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"_state",
".",
"get",
"(",
"\"requestPosition\"",
")",
"return",
"int",
"(",
"pos",
")",
"if",
"pos",
"else",
"None"
] | [
101,
4
] | [
110,
40
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.