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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
XiaomiAirFresh.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
# On state change the device doesn't provide the new state immediately.
if self._skip_update:
self._skip_update = False
return
try:
state = await self.hass.async_add_executor_job(self._d... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# On state change the device doesn't provide the new state immediately.",
"if",
"self",
".",
"_skip_update",
":",
"self",
".",
"_skip_update",
"=",
"False",
"return",
"try",
":",
"state",
"=",
"await",
"self",
... | [
1247,
4
] | [
1270,
79
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirFresh.speed_list | (self) | Get the list of available speeds. | Get the list of available speeds. | def speed_list(self) -> list:
"""Get the list of available speeds."""
return self._speed_list | [
"def",
"speed_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"self",
".",
"_speed_list"
] | [
1273,
4
] | [
1275,
31
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirFresh.speed | (self) | Return the current speed. | Return the current speed. | def speed(self):
"""Return the current speed."""
if self._state:
return AirfreshOperationMode(self._state_attrs[ATTR_MODE]).name
return None | [
"def",
"speed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
":",
"return",
"AirfreshOperationMode",
"(",
"self",
".",
"_state_attrs",
"[",
"ATTR_MODE",
"]",
")",
".",
"name",
"return",
"None"
] | [
1278,
4
] | [
1283,
19
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirFresh.async_set_speed | (self, speed: str) | Set the speed of the fan. | Set the speed of the fan. | async def async_set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
if self.supported_features & SUPPORT_SET_SPEED == 0:
return
_LOGGER.debug("Setting the operation mode to: %s", speed)
await self._try_command(
"Setting operation mode of the mii... | [
"async",
"def",
"async_set_speed",
"(",
"self",
",",
"speed",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"supported_features",
"&",
"SUPPORT_SET_SPEED",
"==",
"0",
":",
"return",
"_LOGGER",
".",
"debug",
"(",
"\"Setting the operation mode to: %s\"",
... | [
1285,
4
] | [
1296,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirFresh.async_set_led_on | (self) | Turn the led on. | Turn the led on. | async def async_set_led_on(self):
"""Turn the led on."""
if self._device_features & FEATURE_SET_LED == 0:
return
await self._try_command(
"Turning the led of the miio device off failed.", self._device.set_led, True
) | [
"async",
"def",
"async_set_led_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_LED",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the led of the miio device off failed.\"",
",",
"self",
".",
"... | [
1298,
4
] | [
1305,
9
] | python | en | ['en', 'zu', 'en'] | True |
XiaomiAirFresh.async_set_led_off | (self) | Turn the led off. | Turn the led off. | async def async_set_led_off(self):
"""Turn the led off."""
if self._device_features & FEATURE_SET_LED == 0:
return
await self._try_command(
"Turning the led of the miio device off failed.",
self._device.set_led,
False,
) | [
"async",
"def",
"async_set_led_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_LED",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the led of the miio device off failed.\"",
",",
"self",
".",
... | [
1307,
4
] | [
1316,
9
] | python | en | ['en', 'sm', 'en'] | True |
XiaomiAirFresh.async_set_led_brightness | (self, brightness: int = 2) | Set the led brightness. | Set the led brightness. | async def async_set_led_brightness(self, brightness: int = 2):
"""Set the led brightness."""
if self._device_features & FEATURE_SET_LED_BRIGHTNESS == 0:
return
await self._try_command(
"Setting the led brightness of the miio device failed.",
self._device.set_... | [
"async",
"def",
"async_set_led_brightness",
"(",
"self",
",",
"brightness",
":",
"int",
"=",
"2",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_LED_BRIGHTNESS",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Settin... | [
1318,
4
] | [
1327,
9
] | python | en | ['en', 'zu', 'en'] | True |
XiaomiAirFresh.async_set_extra_features | (self, features: int = 1) | Set the extra features. | Set the extra features. | async def async_set_extra_features(self, features: int = 1):
"""Set the extra features."""
if self._device_features & FEATURE_SET_EXTRA_FEATURES == 0:
return
await self._try_command(
"Setting the extra features of the miio device failed.",
self._device.set_ex... | [
"async",
"def",
"async_set_extra_features",
"(",
"self",
",",
"features",
":",
"int",
"=",
"1",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_EXTRA_FEATURES",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Setting ... | [
1329,
4
] | [
1338,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirFresh.async_reset_filter | (self) | Reset the filter lifetime and usage. | Reset the filter lifetime and usage. | async def async_reset_filter(self):
"""Reset the filter lifetime and usage."""
if self._device_features & FEATURE_RESET_FILTER == 0:
return
await self._try_command(
"Resetting the filter lifetime of the miio device failed.",
self._device.reset_filter,
... | [
"async",
"def",
"async_reset_filter",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_RESET_FILTER",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Resetting the filter lifetime of the miio device failed.\"",
",",
"... | [
1340,
4
] | [
1348,
9
] | python | en | ['en', 'en', 'en'] | True |
test_form_user | (hass) | Test we get the user form. | Test we get the user form. | async def test_form_user(hass):
"""Test we get the user form."""
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"
assert resu... | [
"async",
"def",
"test_form_user",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
11,
0
] | [
42,
48
] | python | en | ['en', 'da', '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", {})
with patch(
"homeassistant.components.myq.config_flow.pymyq.login",
return_value=True,
), patch(
"homeassistant.components.myq.async_setup", return_value... | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.myq.config_flow.pymyq.login\"",
",",
"return_va... | [
45,
0
] | [
72,
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}
)
with patch(
"homeassistant.components.myq.config_flow.pymyq.login",
side_effect=InvalidCredenti... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
75,
0
] | [
91,
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}
)
with patch(
"homeassistant.components.myq.config_flow.pymyq.login",
side_effect=MyQEr... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
94,
0
] | [
110,
58
] | python | en | ['en', 'en', 'en'] | True |
test_form_homekit | (hass) | Test that we abort from homekit if myq is already setup. | Test that we abort from homekit if myq is already setup. | async def test_form_homekit(hass):
"""Test that we abort from homekit if myq 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": {"i... | [
"async",
"def",
"test_form_homekit",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_ini... | [
113,
0
] | [
141,
36
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the GeoNet NZ Volcano component. | Set up the GeoNet NZ Volcano component. | async def async_setup(hass, config):
"""Set up the GeoNet NZ Volcano component."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
latitude = conf.get(CONF_LATITUDE, hass.config.latitude)
longitude = conf.get(CONF_LONGITUDE, hass.config.longitude)
scan_interval = conf[CONF_S... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"latitude",
"=",
"conf",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
... | [
47,
0
] | [
75,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up the GeoNet NZ Volcano component as config entry. | Set up the GeoNet NZ Volcano component as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up the GeoNet NZ Volcano component as config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN].setdefault(FEED, {})
radius = config_entry.data[CONF_RADIUS]
unit_system = config_entry.data[CONF_UNIT_SYSTEM]
if unit_system == CONF... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"setdefault",
"(",
"FEED",
",",
"{",
"}",
")",
... | [
78,
0
] | [
92,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload an GeoNet NZ Volcano component config entry. | Unload an GeoNet NZ Volcano component config entry. | async def async_unload_entry(hass, config_entry):
"""Unload an GeoNet NZ Volcano component config entry."""
manager = hass.data[DOMAIN][FEED].pop(config_entry.entry_id)
await manager.async_stop()
await asyncio.wait(
[hass.config_entries.async_forward_entry_unload(config_entry, "sensor")]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"manager",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"FEED",
"]",
".",
"pop",
"(",
"config_entry",
".",
"entry_id",
")",
"await",
"manager",
".",
"async_stop",
"("... | [
95,
0
] | [
102,
15
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.__init__ | (self, hass, config_entry, radius_in_km, unit_system) | Initialize the Feed Entity Manager. | Initialize the Feed Entity Manager. | def __init__(self, hass, config_entry, radius_in_km, unit_system):
"""Initialize the Feed Entity Manager."""
self._hass = hass
self._config_entry = config_entry
coordinates = (
config_entry.data[CONF_LATITUDE],
config_entry.data[CONF_LONGITUDE],
)
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
",",
"radius_in_km",
",",
"unit_system",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_config_entry",
"=",
"config_entry",
"coordinates",
"=",
"(",
"config_entry",
".",
"data",
... | [
108,
4
] | [
129,
27
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.async_init | (self) | Schedule initial and regular updates based on configured time interval. | Schedule initial and regular updates based on configured time interval. | async def async_init(self):
"""Schedule initial and regular updates based on configured time interval."""
self._hass.async_create_task(
self._hass.config_entries.async_forward_entry_setup(
self._config_entry, "sensor"
)
)
async def update(event_t... | [
"async",
"def",
"async_init",
"(",
"self",
")",
":",
"self",
".",
"_hass",
".",
"async_create_task",
"(",
"self",
".",
"_hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"self",
".",
"_config_entry",
",",
"\"sensor\"",
")",
")",
"async",
... | [
131,
4
] | [
149,
56
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.async_update | (self) | Refresh data. | Refresh data. | async def async_update(self):
"""Refresh data."""
await self._feed_manager.update()
_LOGGER.debug("Feed entity manager updated") | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_feed_manager",
".",
"update",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Feed entity manager updated\"",
")"
] | [
151,
4
] | [
154,
52
] | python | de | ['de', 'sn', 'en'] | False |
GeonetnzVolcanoFeedEntityManager.async_stop | (self) | Stop this feed entity manager from refreshing. | Stop this feed entity manager from refreshing. | async def async_stop(self):
"""Stop this feed entity manager from refreshing."""
for unsub_dispatcher in self.listeners:
unsub_dispatcher()
self.listeners = []
if self._track_time_remove_callback:
self._track_time_remove_callback()
_LOGGER.debug("Feed enti... | [
"async",
"def",
"async_stop",
"(",
"self",
")",
":",
"for",
"unsub_dispatcher",
"in",
"self",
".",
"listeners",
":",
"unsub_dispatcher",
"(",
")",
"self",
".",
"listeners",
"=",
"[",
"]",
"if",
"self",
".",
"_track_time_remove_callback",
":",
"self",
".",
... | [
156,
4
] | [
163,
52
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.async_event_new_entity | (self) | Return manager specific event to signal new entity. | Return manager specific event to signal new entity. | def async_event_new_entity(self):
"""Return manager specific event to signal new entity."""
return f"geonetnz_volcano_new_sensor_{self._config_entry_id}" | [
"def",
"async_event_new_entity",
"(",
"self",
")",
":",
"return",
"f\"geonetnz_volcano_new_sensor_{self._config_entry_id}\""
] | [
166,
4
] | [
168,
69
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.get_entry | (self, external_id) | Get feed entry by external id. | Get feed entry by external id. | def get_entry(self, external_id):
"""Get feed entry by external id."""
return self._feed_manager.feed_entries.get(external_id) | [
"def",
"get_entry",
"(",
"self",
",",
"external_id",
")",
":",
"return",
"self",
".",
"_feed_manager",
".",
"feed_entries",
".",
"get",
"(",
"external_id",
")"
] | [
170,
4
] | [
172,
63
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.last_update | (self) | Return the last update of this feed. | Return the last update of this feed. | def last_update(self) -> Optional[datetime]:
"""Return the last update of this feed."""
return self._feed_manager.last_update | [
"def",
"last_update",
"(",
"self",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"return",
"self",
".",
"_feed_manager",
".",
"last_update"
] | [
174,
4
] | [
176,
45
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager.last_update_successful | (self) | Return the last successful update of this feed. | Return the last successful update of this feed. | def last_update_successful(self) -> Optional[datetime]:
"""Return the last successful update of this feed."""
return self._feed_manager.last_update_successful | [
"def",
"last_update_successful",
"(",
"self",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"return",
"self",
".",
"_feed_manager",
".",
"last_update_successful"
] | [
178,
4
] | [
180,
56
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager._generate_entity | (self, external_id) | Generate new entity. | Generate new entity. | async def _generate_entity(self, external_id):
"""Generate new entity."""
async_dispatcher_send(
self._hass,
self.async_event_new_entity(),
self,
external_id,
self._unit_system,
) | [
"async",
"def",
"_generate_entity",
"(",
"self",
",",
"external_id",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"self",
".",
"async_event_new_entity",
"(",
")",
",",
"self",
",",
"external_id",
",",
"self",
".",
"_unit_system",
",",
"... | [
182,
4
] | [
190,
9
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzVolcanoFeedEntityManager._update_entity | (self, external_id) | Update entity. | Update entity. | async def _update_entity(self, external_id):
"""Update entity."""
async_dispatcher_send(self._hass, f"geonetnz_volcano_update_{external_id}") | [
"async",
"def",
"_update_entity",
"(",
"self",
",",
"external_id",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"f\"geonetnz_volcano_update_{external_id}\"",
")"
] | [
192,
4
] | [
194,
83
] | python | en | ['es', 'en', 'en'] | False |
GeonetnzVolcanoFeedEntityManager._remove_entity | (self, external_id) | Ignore removing entity. | Ignore removing entity. | async def _remove_entity(self, external_id):
"""Ignore removing entity.""" | [
"async",
"def",
"_remove_entity",
"(",
"self",
",",
"external_id",
")",
":"
] | [
196,
4
] | [
197,
37
] | python | en | ['en', 'en', 'en'] | True |
DartsTrainer._backward | (self, val_X, val_y) |
Simple backward with gradient descent
|
Simple backward with gradient descent
| def _backward(self, val_X, val_y):
"""
Simple backward with gradient descent
"""
_, loss = self._logits_and_loss(val_X, val_y)
loss.backward() | [
"def",
"_backward",
"(",
"self",
",",
"val_X",
",",
"val_y",
")",
":",
"_",
",",
"loss",
"=",
"self",
".",
"_logits_and_loss",
"(",
"val_X",
",",
"val_y",
")",
"loss",
".",
"backward",
"(",
")"
] | [
134,
4
] | [
139,
23
] | python | en | ['en', 'error', 'th'] | False |
DartsTrainer._unrolled_backward | (self, trn_X, trn_y, val_X, val_y) |
Compute unrolled loss and backward its gradients
|
Compute unrolled loss and backward its gradients
| def _unrolled_backward(self, trn_X, trn_y, val_X, val_y):
"""
Compute unrolled loss and backward its gradients
"""
backup_params = copy.deepcopy(tuple(self.model.parameters()))
# do virtual step on training data
lr = self.optimizer.param_groups[0]["lr"]
momentum ... | [
"def",
"_unrolled_backward",
"(",
"self",
",",
"trn_X",
",",
"trn_y",
",",
"val_X",
",",
"val_y",
")",
":",
"backup_params",
"=",
"copy",
".",
"deepcopy",
"(",
"tuple",
"(",
"self",
".",
"model",
".",
"parameters",
"(",
")",
")",
")",
"# do virtual step ... | [
141,
4
] | [
168,
44
] | python | en | ['en', 'error', 'th'] | False |
DartsTrainer._compute_virtual_model | (self, X, y, lr, momentum, weight_decay) |
Compute unrolled weights w`
|
Compute unrolled weights w`
| def _compute_virtual_model(self, X, y, lr, momentum, weight_decay):
"""
Compute unrolled weights w`
"""
# don't need zero_grad, using autograd to calculate gradients
_, loss = self._logits_and_loss(X, y)
gradients = torch.autograd.grad(loss, self.model.parameters())
... | [
"def",
"_compute_virtual_model",
"(",
"self",
",",
"X",
",",
"y",
",",
"lr",
",",
"momentum",
",",
"weight_decay",
")",
":",
"# don't need zero_grad, using autograd to calculate gradients",
"_",
",",
"loss",
"=",
"self",
".",
"_logits_and_loss",
"(",
"X",
",",
"... | [
170,
4
] | [
180,
66
] | python | en | ['en', 'error', 'th'] | False |
DartsTrainer._compute_hessian | (self, backup_params, dw, trn_X, trn_y) |
dw = dw` { L_val(w`, alpha) }
w+ = w + eps * dw
w- = w - eps * dw
hessian = (dalpha { L_trn(w+, alpha) } - dalpha { L_trn(w-, alpha) }) / (2*eps)
eps = 0.01 / ||dw||
|
dw = dw` { L_val(w`, alpha) }
w+ = w + eps * dw
w- = w - eps * dw
hessian = (dalpha { L_trn(w+, alpha) } - dalpha { L_trn(w-, alpha) }) / (2*eps)
eps = 0.01 / ||dw||
| def _compute_hessian(self, backup_params, dw, trn_X, trn_y):
"""
dw = dw` { L_val(w`, alpha) }
w+ = w + eps * dw
w- = w - eps * dw
hessian = (dalpha { L_trn(w+, alpha) } - dalpha { L_trn(w-, alpha) }) / (2*eps)
eps = 0.01 / ||dw||
"""
s... | [
"def",
"_compute_hessian",
"(",
"self",
",",
"backup_params",
",",
"dw",
",",
"trn_X",
",",
"trn_y",
")",
":",
"self",
".",
"_restore_weights",
"(",
"backup_params",
")",
"norm",
"=",
"torch",
".",
"cat",
"(",
"[",
"w",
".",
"view",
"(",
"-",
"1",
")... | [
187,
4
] | [
213,
22
] | python | en | ['en', 'error', 'th'] | False |
XLNetTokenizerFast.build_inputs_with_special_tokens | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format:
- single sequence: ``X <sep> <cls>``
- pair of sequences: ``A <sep> B <sep> <cls>``
Args:
... |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has the following format: | def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An XLNet sequence has... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",
"... | [
167,
4
] | [
190,
58
] | python | en | ['en', 'error', 'th'] | False |
XLNetTokenizerFast.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[int]`,... |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens ... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
192,
4
] | [
221,
48
] | python | en | ['en', 'error', 'th'] | False |
XLNetTokenizerFast.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet
sequence pair mask has the following format:
::
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
| first sequence | second sequence |
If :obj:`token_ids_1` is :ob... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet
sequence pair mask has the following format: | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLNet
sequence pair mask has the following format:
... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
223,
4
] | [
252,
91
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Uptime Robot binary_sensors. | Set up the Uptime Robot binary_sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Uptime Robot binary_sensors."""
up_robot = UptimeRobot()
api_key = config.get(CONF_API_KEY)
monitors = up_robot.getMonitors(api_key)
devices = []
if not monitors or monitors.get("stat") != "ok":
_LOGGER.... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"up_robot",
"=",
"UptimeRobot",
"(",
")",
"api_key",
"=",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"monitors",
"=",
"up_robot",
"... | [
23,
0
] | [
46,
31
] | python | en | ['en', 'ceb', 'en'] | True |
UptimeRobotBinarySensor.__init__ | (self, api_key, up_robot, monitor_id, name, target) | Initialize Uptime Robot the binary sensor. | Initialize Uptime Robot the binary sensor. | def __init__(self, api_key, up_robot, monitor_id, name, target):
"""Initialize Uptime Robot the binary sensor."""
self._api_key = api_key
self._monitor_id = str(monitor_id)
self._name = name
self._target = target
self._up_robot = up_robot
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"api_key",
",",
"up_robot",
",",
"monitor_id",
",",
"name",
",",
"target",
")",
":",
"self",
".",
"_api_key",
"=",
"api_key",
"self",
".",
"_monitor_id",
"=",
"str",
"(",
"monitor_id",
")",
"self",
".",
"_name",
"="... | [
52,
4
] | [
59,
26
] | python | en | ['en', 'en', 'en'] | True |
UptimeRobotBinarySensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self):
"""Return the name of the binary sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
62,
4
] | [
64,
25
] | python | en | ['en', 'mi', 'en'] | True |
UptimeRobotBinarySensor.is_on | (self) | Return the state of the binary sensor. | Return the state of the binary sensor. | def is_on(self):
"""Return the state of the binary sensor."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
67,
4
] | [
69,
26
] | python | en | ['en', 'ig', 'en'] | True |
UptimeRobotBinarySensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_CONNECTIVITY"
] | [
72,
4
] | [
74,
40
] | python | en | ['en', 'en', 'en'] | True |
UptimeRobotBinarySensor.device_state_attributes | (self) | Return the state attributes of the binary sensor. | Return the state attributes of the binary sensor. | def device_state_attributes(self):
"""Return the state attributes of the binary sensor."""
return {ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_TARGET: self._target} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"ATTR_TARGET",
":",
"self",
".",
"_target",
"}"
] | [
77,
4
] | [
79,
73
] | python | en | ['en', 'en', 'en'] | True |
UptimeRobotBinarySensor.update | (self) | Get the latest state of the binary sensor. | Get the latest state of the binary sensor. | def update(self):
"""Get the latest state of the binary sensor."""
monitor = self._up_robot.getMonitors(self._api_key, self._monitor_id)
if not monitor or monitor.get("stat") != "ok":
_LOGGER.warning("Failed to get new state")
return
status = monitor["monitors"][0... | [
"def",
"update",
"(",
"self",
")",
":",
"monitor",
"=",
"self",
".",
"_up_robot",
".",
"getMonitors",
"(",
"self",
".",
"_api_key",
",",
"self",
".",
"_monitor_id",
")",
"if",
"not",
"monitor",
"or",
"monitor",
".",
"get",
"(",
"\"stat\"",
")",
"!=",
... | [
81,
4
] | [
88,
45
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.__init__ | (self) | Create a new instance of the flow handler. | Create a new instance of the flow handler. | def __init__(self):
"""Create a new instance of the flow handler."""
self.access_token = None
self.app_id = None
self.api = None
self.oauth_client_secret = None
self.oauth_client_id = None
self.installed_app_id = None
self.refresh_token = None
self... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"access_token",
"=",
"None",
"self",
".",
"app_id",
"=",
"None",
"self",
".",
"api",
"=",
"None",
"self",
".",
"oauth_client_secret",
"=",
"None",
"self",
".",
"oauth_client_id",
"=",
"None",
"self",... | [
49,
4
] | [
58,
31
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_import | (self, user_input=None) | Occurs when a previously entry setup fails and is re-initiated. | Occurs when a previously entry setup fails and is re-initiated. | async def async_step_import(self, user_input=None):
"""Occurs when a previously entry setup fails and is re-initiated."""
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_input",
")"
] | [
60,
4
] | [
62,
53
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_user | (self, user_input=None) | Validate and confirm webhook setup. | Validate and confirm webhook setup. | async def async_step_user(self, user_input=None):
"""Validate and confirm webhook setup."""
await setup_smartapp_endpoint(self.hass)
webhook_url = get_webhook_url(self.hass)
# Abort if the webhook is invalid
if not validate_webhook_requirements(self.hass):
return sel... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"await",
"setup_smartapp_endpoint",
"(",
"self",
".",
"hass",
")",
"webhook_url",
"=",
"get_webhook_url",
"(",
"self",
".",
"hass",
")",
"# Abort if the webhook is invalid",
... | [
64,
4
] | [
87,
42
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_pat | (self, user_input=None) | Get the Personal Access Token and validate it. | Get the Personal Access Token and validate it. | async def async_step_pat(self, user_input=None):
"""Get the Personal Access Token and validate it."""
errors = {}
if user_input is None or CONF_ACCESS_TOKEN not in user_input:
return self._show_step_pat(errors)
self.access_token = user_input[CONF_ACCESS_TOKEN]
# Ens... | [
"async",
"def",
"async_step_pat",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"None",
"or",
"CONF_ACCESS_TOKEN",
"not",
"in",
"user_input",
":",
"return",
"self",
".",
"_show_step_pat",
"(",
"er... | [
89,
4
] | [
165,
54
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_select_location | (self, user_input=None) | Ask user to select the location to setup. | Ask user to select the location to setup. | async def async_step_select_location(self, user_input=None):
"""Ask user to select the location to setup."""
if user_input is None or CONF_LOCATION_ID not in user_input:
# Get available locations
existing_locations = [
entry.data[CONF_LOCATION_ID] for entry in sel... | [
"async",
"def",
"async_step_select_location",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
"or",
"CONF_LOCATION_ID",
"not",
"in",
"user_input",
":",
"# Get available locations",
"existing_locations",
"=",
"[",
"entry",
"... | [
167,
4
] | [
192,
48
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_authorize | (self, user_input=None) | Wait for the user to authorize the app installation. | Wait for the user to authorize the app installation. | async def async_step_authorize(self, user_input=None):
"""Wait for the user to authorize the app installation."""
user_input = {} if user_input is None else user_input
self.installed_app_id = user_input.get(CONF_INSTALLED_APP_ID)
self.refresh_token = user_input.get(CONF_REFRESH_TOKEN)
... | [
"async",
"def",
"async_step_authorize",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"user_input",
"=",
"{",
"}",
"if",
"user_input",
"is",
"None",
"else",
"user_input",
"self",
".",
"installed_app_id",
"=",
"user_input",
".",
"get",
"(",
"CONF_INS... | [
194,
4
] | [
204,
68
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsFlowHandler.async_step_install | (self, data=None) | Create a config entry at completion of a flow and authorization of the app. | Create a config entry at completion of a flow and authorization of the app. | async def async_step_install(self, data=None):
"""Create a config entry at completion of a flow and authorization of the app."""
data = {
CONF_ACCESS_TOKEN: self.access_token,
CONF_REFRESH_TOKEN: self.refresh_token,
CONF_CLIENT_ID: self.oauth_client_id,
CO... | [
"async",
"def",
"async_step_install",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"data",
"=",
"{",
"CONF_ACCESS_TOKEN",
":",
"self",
".",
"access_token",
",",
"CONF_REFRESH_TOKEN",
":",
"self",
".",
"refresh_token",
",",
"CONF_CLIENT_ID",
":",
"self",
... | [
229,
4
] | [
243,
70
] | python | en | ['en', 'en', 'en'] | True |
mock_handler | (request) | Return if request was authenticated. | Return if request was authenticated. | async def mock_handler(request):
"""Return if request was authenticated."""
if not request[KEY_AUTHENTICATED]:
raise HTTPUnauthorized
user = request.get("hass_user")
user_id = user.id if user else None
return web.json_response(status=200, data={"user_id": user_id}) | [
"async",
"def",
"mock_handler",
"(",
"request",
")",
":",
"if",
"not",
"request",
"[",
"KEY_AUTHENTICATED",
"]",
":",
"raise",
"HTTPUnauthorized",
"user",
"=",
"request",
".",
"get",
"(",
"\"hass_user\"",
")",
"user_id",
"=",
"user",
".",
"id",
"if",
"user... | [
31,
0
] | [
39,
67
] | python | en | ['en', 'en', 'en'] | True |
get_legacy_user | (auth) | Get the user in legacy_api_password auth provider. | Get the user in legacy_api_password auth provider. | async def get_legacy_user(auth):
"""Get the user in legacy_api_password auth provider."""
provider = auth.get_auth_provider("legacy_api_password", None)
return await auth.async_get_or_create_user(
await provider.async_get_or_create_credentials({})
) | [
"async",
"def",
"get_legacy_user",
"(",
"auth",
")",
":",
"provider",
"=",
"auth",
".",
"get_auth_provider",
"(",
"\"legacy_api_password\"",
",",
"None",
")",
"return",
"await",
"auth",
".",
"async_get_or_create_user",
"(",
"await",
"provider",
".",
"async_get_or_... | [
42,
0
] | [
47,
5
] | python | en | ['en', 'en', 'en'] | True |
app | (hass) | Fixture to set up a web.Application. | Fixture to set up a web.Application. | def app(hass):
"""Fixture to set up a web.Application."""
app = web.Application()
app["hass"] = hass
app.router.add_get("/", mock_handler)
async_setup_forwarded(app, [])
return app | [
"def",
"app",
"(",
"hass",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
"[",
"\"hass\"",
"]",
"=",
"hass",
"app",
".",
"router",
".",
"add_get",
"(",
"\"/\"",
",",
"mock_handler",
")",
"async_setup_forwarded",
"(",
"app",
",",
"[... | [
51,
0
] | [
57,
14
] | python | en | ['en', 'en', 'en'] | True |
app2 | (hass) | Fixture to set up a web.Application without real_ip middleware. | Fixture to set up a web.Application without real_ip middleware. | def app2(hass):
"""Fixture to set up a web.Application without real_ip middleware."""
app = web.Application()
app["hass"] = hass
app.router.add_get("/", mock_handler)
return app | [
"def",
"app2",
"(",
"hass",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
"[",
"\"hass\"",
"]",
"=",
"hass",
"app",
".",
"router",
".",
"add_get",
"(",
"\"/\"",
",",
"mock_handler",
")",
"return",
"app"
] | [
61,
0
] | [
66,
14
] | python | en | ['en', 'en', 'en'] | True |
trusted_networks_auth | (hass) | Load trusted networks auth provider. | Load trusted networks auth provider. | def trusted_networks_auth(hass):
"""Load trusted networks auth provider."""
prv = trusted_networks.TrustedNetworksAuthProvider(
hass,
hass.auth._store,
{"type": "trusted_networks", "trusted_networks": TRUSTED_NETWORKS},
)
hass.auth._providers[(prv.type, prv.id)] = prv
return ... | [
"def",
"trusted_networks_auth",
"(",
"hass",
")",
":",
"prv",
"=",
"trusted_networks",
".",
"TrustedNetworksAuthProvider",
"(",
"hass",
",",
"hass",
".",
"auth",
".",
"_store",
",",
"{",
"\"type\"",
":",
"\"trusted_networks\"",
",",
"\"trusted_networks\"",
":",
... | [
70,
0
] | [
78,
14
] | python | en | ['en', 'en', 'en'] | True |
test_auth_middleware_loaded_by_default | (hass) | Test accessing to server from banned IP when feature is off. | Test accessing to server from banned IP when feature is off. | async def test_auth_middleware_loaded_by_default(hass):
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_auth") as mock_setup:
await async_setup_component(hass, "http", {"http": {}})
assert len(mock_setup.mock_calls) == 1 | [
"async",
"def",
"test_auth_middleware_loaded_by_default",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.http.setup_auth\"",
")",
"as",
"mock_setup",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"http\"",
",",
"{",
"\"http\"",
"... | [
81,
0
] | [
86,
42
] | python | en | ['en', 'en', 'en'] | True |
test_cant_access_with_password_in_header | (
app, aiohttp_client, legacy_auth, hass
) | Test access with password in header. | Test access with password in header. | async def test_cant_access_with_password_in_header(
app, aiohttp_client, legacy_auth, hass
):
"""Test access with password in header."""
setup_auth(hass, app)
client = await aiohttp_client(app)
req = await client.get("/", headers={HTTP_HEADER_HA_AUTH: API_PASSWORD})
assert req.status == 401
... | [
"async",
"def",
"test_cant_access_with_password_in_header",
"(",
"app",
",",
"aiohttp_client",
",",
"legacy_auth",
",",
"hass",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app",
")",
"client",
"=",
"await",
"aiohttp_client",
"(",
"app",
")",
"req",
"=",
"await"... | [
89,
0
] | [
100,
28
] | python | en | ['en', 'en', 'en'] | True |
test_cant_access_with_password_in_query | (
app, aiohttp_client, legacy_auth, hass
) | Test access with password in URL. | Test access with password in URL. | async def test_cant_access_with_password_in_query(
app, aiohttp_client, legacy_auth, hass
):
"""Test access with password in URL."""
setup_auth(hass, app)
client = await aiohttp_client(app)
resp = await client.get("/", params={"api_password": API_PASSWORD})
assert resp.status == 401
resp =... | [
"async",
"def",
"test_cant_access_with_password_in_query",
"(",
"app",
",",
"aiohttp_client",
",",
"legacy_auth",
",",
"hass",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app",
")",
"client",
"=",
"await",
"aiohttp_client",
"(",
"app",
")",
"resp",
"=",
"await"... | [
103,
0
] | [
117,
29
] | python | en | ['en', 'en', 'en'] | True |
test_basic_auth_does_not_work | (app, aiohttp_client, hass, legacy_auth) | Test access with basic authentication. | Test access with basic authentication. | async def test_basic_auth_does_not_work(app, aiohttp_client, hass, legacy_auth):
"""Test access with basic authentication."""
setup_auth(hass, app)
client = await aiohttp_client(app)
req = await client.get("/", auth=BasicAuth("homeassistant", API_PASSWORD))
assert req.status == 401
req = await... | [
"async",
"def",
"test_basic_auth_does_not_work",
"(",
"app",
",",
"aiohttp_client",
",",
"hass",
",",
"legacy_auth",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app",
")",
"client",
"=",
"await",
"aiohttp_client",
"(",
"app",
")",
"req",
"=",
"await",
"client... | [
120,
0
] | [
135,
28
] | python | en | ['en', 'en', 'en'] | True |
test_cannot_access_with_trusted_ip | (
hass, app2, trusted_networks_auth, aiohttp_client, hass_owner_user
) | Test access with an untrusted ip address. | Test access with an untrusted ip address. | async def test_cannot_access_with_trusted_ip(
hass, app2, trusted_networks_auth, aiohttp_client, hass_owner_user
):
"""Test access with an untrusted ip address."""
setup_auth(hass, app2)
set_mock_ip = mock_real_ip(app2)
client = await aiohttp_client(app2)
for remote_addr in UNTRUSTED_ADDRESSES... | [
"async",
"def",
"test_cannot_access_with_trusted_ip",
"(",
"hass",
",",
"app2",
",",
"trusted_networks_auth",
",",
"aiohttp_client",
",",
"hass_owner_user",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app2",
")",
"set_mock_ip",
"=",
"mock_real_ip",
"(",
"app2",
")"... | [
138,
0
] | [
155,
72
] | python | en | ['en', 'en', 'en'] | True |
test_auth_active_access_with_access_token_in_header | (
hass, app, aiohttp_client, hass_access_token
) | Test access with access token in header. | Test access with access token in header. | async def test_auth_active_access_with_access_token_in_header(
hass, app, aiohttp_client, hass_access_token
):
"""Test access with access token in header."""
token = hass_access_token
setup_auth(hass, app)
client = await aiohttp_client(app)
refresh_token = await hass.auth.async_validate_access_t... | [
"async",
"def",
"test_auth_active_access_with_access_token_in_header",
"(",
"hass",
",",
"app",
",",
"aiohttp_client",
",",
"hass_access_token",
")",
":",
"token",
"=",
"hass_access_token",
"setup_auth",
"(",
"hass",
",",
"app",
")",
"client",
"=",
"await",
"aiohttp... | [
158,
0
] | [
188,
28
] | python | en | ['en', 'en', 'en'] | True |
test_auth_active_access_with_trusted_ip | (
hass, app2, trusted_networks_auth, aiohttp_client, hass_owner_user
) | Test access with an untrusted ip address. | Test access with an untrusted ip address. | async def test_auth_active_access_with_trusted_ip(
hass, app2, trusted_networks_auth, aiohttp_client, hass_owner_user
):
"""Test access with an untrusted ip address."""
setup_auth(hass, app2)
set_mock_ip = mock_real_ip(app2)
client = await aiohttp_client(app2)
for remote_addr in UNTRUSTED_ADDR... | [
"async",
"def",
"test_auth_active_access_with_trusted_ip",
"(",
"hass",
",",
"app2",
",",
"trusted_networks_auth",
",",
"aiohttp_client",
",",
"hass_owner_user",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app2",
")",
"set_mock_ip",
"=",
"mock_real_ip",
"(",
"app2",
... | [
191,
0
] | [
208,
72
] | python | en | ['en', 'en', 'en'] | True |
test_auth_legacy_support_api_password_cannot_access | (
app, aiohttp_client, legacy_auth, hass
) | Test access using api_password if auth.support_legacy. | Test access using api_password if auth.support_legacy. | async def test_auth_legacy_support_api_password_cannot_access(
app, aiohttp_client, legacy_auth, hass
):
"""Test access using api_password if auth.support_legacy."""
setup_auth(hass, app)
client = await aiohttp_client(app)
req = await client.get("/", headers={HTTP_HEADER_HA_AUTH: API_PASSWORD})
... | [
"async",
"def",
"test_auth_legacy_support_api_password_cannot_access",
"(",
"app",
",",
"aiohttp_client",
",",
"legacy_auth",
",",
"hass",
")",
":",
"setup_auth",
"(",
"hass",
",",
"app",
")",
"client",
"=",
"await",
"aiohttp_client",
"(",
"app",
")",
"req",
"="... | [
211,
0
] | [
225,
28
] | python | en | ['en', 'en', 'en'] | True |
test_auth_access_signed_path | (hass, app, aiohttp_client, hass_access_token) | Test access with signed url. | Test access with signed url. | async def test_auth_access_signed_path(hass, app, aiohttp_client, hass_access_token):
"""Test access with signed url."""
app.router.add_post("/", mock_handler)
app.router.add_get("/another_path", mock_handler)
setup_auth(hass, app)
client = await aiohttp_client(app)
refresh_token = await hass.a... | [
"async",
"def",
"test_auth_access_signed_path",
"(",
"hass",
",",
"app",
",",
"aiohttp_client",
",",
"hass_access_token",
")",
":",
"app",
".",
"router",
".",
"add_post",
"(",
"\"/\"",
",",
"mock_handler",
")",
"app",
".",
"router",
".",
"add_get",
"(",
"\"/... | [
228,
0
] | [
263,
28
] | python | en | ['en', 'en', 'en'] | True |
test_manually_configured_platform | (hass) | Test that we do not set up an access point. | Test that we do not set up an access point. | async def test_manually_configured_platform(hass):
"""Test that we do not set up an access point."""
assert await async_setup_component(
hass, WEATHER_DOMAIN, {WEATHER_DOMAIN: {"platform": HMIPC_DOMAIN}}
)
assert not hass.data.get(HMIPC_DOMAIN) | [
"async",
"def",
"test_manually_configured_platform",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"WEATHER_DOMAIN",
",",
"{",
"WEATHER_DOMAIN",
":",
"{",
"\"platform\"",
":",
"HMIPC_DOMAIN",
"}",
"}",
")",
"assert",
"not",
... | [
15,
0
] | [
20,
42
] | python | en | ['en', 'en', 'en'] | True |
test_hmip_weather_sensor | (hass, default_mock_hap_factory) | Test HomematicipWeatherSensor. | Test HomematicipWeatherSensor. | async def test_hmip_weather_sensor(hass, default_mock_hap_factory):
"""Test HomematicipWeatherSensor."""
entity_id = "weather.weather_sensor_plus"
entity_name = "Weather Sensor – plus"
device_model = "HmIP-SWO-PL"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[en... | [
"async",
"def",
"test_hmip_weather_sensor",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"weather.weather_sensor_plus\"",
"entity_name",
"=",
"\"Weather Sensor – plus\"",
"device_model",
"=",
"\"HmIP-SWO-PL\"",
"mock_hap",
"=",
"await",
"defau... | [
23,
0
] | [
44,
64
] | python | en | ['en', 'ro', 'en'] | False |
test_hmip_weather_sensor_pro | (hass, default_mock_hap_factory) | Test HomematicipWeatherSensorPro. | Test HomematicipWeatherSensorPro. | async def test_hmip_weather_sensor_pro(hass, default_mock_hap_factory):
"""Test HomematicipWeatherSensorPro."""
entity_id = "weather.wettersensor_pro"
entity_name = "Wettersensor - pro"
device_model = "HmIP-SWO-PR"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[e... | [
"async",
"def",
"test_hmip_weather_sensor_pro",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"weather.wettersensor_pro\"",
"entity_name",
"=",
"\"Wettersensor - pro\"",
"device_model",
"=",
"\"HmIP-SWO-PR\"",
"mock_hap",
"=",
"await",
"default... | [
47,
0
] | [
69,
64
] | python | en | ['en', 'ny', 'en'] | False |
test_hmip_home_weather | (hass, default_mock_hap_factory) | Test HomematicipHomeWeather. | Test HomematicipHomeWeather. | async def test_hmip_home_weather(hass, default_mock_hap_factory):
"""Test HomematicipHomeWeather."""
entity_id = "weather.weather_1010_wien_osterreich"
entity_name = "Weather 1010 Wien, Österreich"
device_model = None
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
ha_state, hmi... | [
"async",
"def",
"test_hmip_home_weather",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"weather.weather_1010_wien_osterreich\"",
"entity_name",
"=",
"\"Weather 1010 Wien, Österreich\"",
"device_model",
"=",
"None",
"mock_hap",
"=",
"await",
"... | [
72,
0
] | [
95,
64
] | python | en | ['en', 'en', 'en'] | False |
_host_validator | (config) | Validate that a host is properly configured. | Validate that a host is properly configured. | def _host_validator(config):
"""Validate that a host is properly configured."""
if config[CONF_HOST].startswith("elks://"):
if CONF_USERNAME not in config or CONF_PASSWORD not in config:
raise vol.Invalid("Specify username and password for elks://")
elif not config[CONF_HOST].startswith(... | [
"def",
"_host_validator",
"(",
"config",
")",
":",
"if",
"config",
"[",
"CONF_HOST",
"]",
".",
"startswith",
"(",
"\"elks://\"",
")",
":",
"if",
"CONF_USERNAME",
"not",
"in",
"config",
"or",
"CONF_PASSWORD",
"not",
"in",
"config",
":",
"raise",
"vol",
".",... | [
77,
0
] | [
86,
17
] | python | en | ['en', 'en', 'en'] | True |
_has_all_unique_prefixes | (value) | Validate that each m1 configured has a unique prefix.
Uniqueness is determined case-independently.
| Validate that each m1 configured has a unique prefix. | def _has_all_unique_prefixes(value):
"""Validate that each m1 configured has a unique prefix.
Uniqueness is determined case-independently.
"""
prefixes = [device[CONF_PREFIX] for device in value]
schema = vol.Schema(vol.Unique())
schema(prefixes)
return value | [
"def",
"_has_all_unique_prefixes",
"(",
"value",
")",
":",
"prefixes",
"=",
"[",
"device",
"[",
"CONF_PREFIX",
"]",
"for",
"device",
"in",
"value",
"]",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"vol",
".",
"Unique",
"(",
")",
")",
"schema",
"(",
"pref... | [
105,
0
] | [
113,
16
] | python | en | ['en', 'fr', 'en'] | True |
async_setup | (hass: HomeAssistant, hass_config: ConfigType) | Set up the Elk M1 platform. | Set up the Elk M1 platform. | async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
"""Set up the Elk M1 platform."""
hass.data.setdefault(DOMAIN, {})
_create_elk_services(hass)
if DOMAIN not in hass_config:
return True
for index, conf in enumerate(hass_config[DOMAIN]):
_LOGGER.debug("Imp... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"hass_config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"_create_elk_services",
"(",
"hass",
")",
"if",
"D... | [
154,
0
] | [
187,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Elk-M1 Control from a config entry. | Set up Elk-M1 Control from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Elk-M1 Control from a config entry."""
conf = entry.data
_LOGGER.debug("Setting up elkm1 %s", conf["host"])
temperature_unit = TEMP_FAHRENHEIT
if conf[CONF_TEMPERATURE_UNIT] in (BARE_TEMP_CELSIUS, TEMP_CELSIUS):
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"conf",
"=",
"entry",
".",
"data",
"_LOGGER",
".",
"debug",
"(",
"\"Setting up elkm1 %s\"",
",",
"conf",
"[",
"\"host\"",
"]",
")",
"temperatu... | [
197,
0
] | [
270,
15
] | python | en | ['en', 'en', 'en'] | True |
_find_elk_by_prefix | (hass, prefix) | Search all config entries for a given prefix. | Search all config entries for a given prefix. | def _find_elk_by_prefix(hass, prefix):
"""Search all config entries for a given prefix."""
for entry_id in hass.data[DOMAIN]:
if hass.data[DOMAIN][entry_id]["prefix"] == prefix:
return hass.data[DOMAIN][entry_id]["elk"] | [
"def",
"_find_elk_by_prefix",
"(",
"hass",
",",
"prefix",
")",
":",
"for",
"entry_id",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
":",
"if",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry_id",
"]",
"[",
"\"prefix\"",
"]",
"==",
"prefix",
":... | [
280,
0
] | [
284,
53
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in SUPPORTED_DOMAINS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
287,
0
] | [
304,
20
] | python | en | ['en', 'es', 'en'] | True |
async_wait_for_elk_to_sync | (elk, timeout, conf_host) | Wait until the elk has finished sync. Can fail login or timeout. | Wait until the elk has finished sync. Can fail login or timeout. | async def async_wait_for_elk_to_sync(elk, timeout, conf_host):
"""Wait until the elk has finished sync. Can fail login or timeout."""
def login_status(succeeded):
nonlocal success
success = succeeded
if succeeded:
_LOGGER.debug("ElkM1 login succeeded")
else:
... | [
"async",
"def",
"async_wait_for_elk_to_sync",
"(",
"elk",
",",
"timeout",
",",
"conf_host",
")",
":",
"def",
"login_status",
"(",
"succeeded",
")",
":",
"nonlocal",
"success",
"success",
"=",
"succeeded",
"if",
"succeeded",
":",
"_LOGGER",
".",
"debug",
"(",
... | [
307,
0
] | [
340,
18
] | python | en | ['en', 'en', 'en'] | True |
create_elk_entities | (elk_data, elk_elements, element_type, class_, entities) | Create the ElkM1 devices of a particular class. | Create the ElkM1 devices of a particular class. | def create_elk_entities(elk_data, elk_elements, element_type, class_, entities):
"""Create the ElkM1 devices of a particular class."""
auto_configure = elk_data["auto_configure"]
if not auto_configure and not elk_data["config"][element_type]["enabled"]:
return
elk = elk_data["elk"]
_LOGGER... | [
"def",
"create_elk_entities",
"(",
"elk_data",
",",
"elk_elements",
",",
"element_type",
",",
"class_",
",",
"entities",
")",
":",
"auto_configure",
"=",
"elk_data",
"[",
"\"auto_configure\"",
"]",
"if",
"not",
"auto_configure",
"and",
"not",
"elk_data",
"[",
"\... | [
371,
0
] | [
390,
19
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.__init__ | (self, element, elk, elk_data) | Initialize the base of all Elk devices. | Initialize the base of all Elk devices. | def __init__(self, element, elk, elk_data):
"""Initialize the base of all Elk devices."""
self._elk = elk
self._element = element
self._prefix = elk_data["prefix"]
self._temperature_unit = elk_data["config"]["temperature_unit"]
# unique_id starts with elkm1_ iff there is ... | [
"def",
"__init__",
"(",
"self",
",",
"element",
",",
"elk",
",",
"elk_data",
")",
":",
"self",
".",
"_elk",
"=",
"elk",
"self",
".",
"_element",
"=",
"element",
"self",
".",
"_prefix",
"=",
"elk_data",
"[",
"\"prefix\"",
"]",
"self",
".",
"_temperature... | [
396,
4
] | [
414,
82
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.name | (self) | Name of the element. | Name of the element. | def name(self):
"""Name of the element."""
return f"{self._prefix}{self._element.name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._prefix}{self._element.name}\""
] | [
417,
4
] | [
419,
52
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.unique_id | (self) | Return unique id of the element. | Return unique id of the element. | def unique_id(self):
"""Return unique id of the element."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
422,
4
] | [
424,
30
] | python | en | ['en', 'la', 'en'] | True |
ElkEntity.should_poll | (self) | Don't poll this device. | Don't poll this device. | def should_poll(self) -> bool:
"""Don't poll this device."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
427,
4
] | [
429,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.device_state_attributes | (self) | Return the default attributes of the element. | Return the default attributes of the element. | def device_state_attributes(self):
"""Return the default attributes of the element."""
return {**self._element.as_dict(), **self.initial_attrs()} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"*",
"*",
"self",
".",
"_element",
".",
"as_dict",
"(",
")",
",",
"*",
"*",
"self",
".",
"initial_attrs",
"(",
")",
"}"
] | [
432,
4
] | [
434,
66
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.available | (self) | Is the entity available to be updated. | Is the entity available to be updated. | def available(self):
"""Is the entity available to be updated."""
return self._elk.is_connected() | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_elk",
".",
"is_connected",
"(",
")"
] | [
437,
4
] | [
439,
39
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.initial_attrs | (self) | Return the underlying element's attributes as a dict. | Return the underlying element's attributes as a dict. | def initial_attrs(self):
"""Return the underlying element's attributes as a dict."""
attrs = {}
attrs["index"] = self._element.index + 1
return attrs | [
"def",
"initial_attrs",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"attrs",
"[",
"\"index\"",
"]",
"=",
"self",
".",
"_element",
".",
"index",
"+",
"1",
"return",
"attrs"
] | [
441,
4
] | [
445,
20
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity._element_callback | (self, element, changeset) | Handle callback from an Elk element that has changed. | Handle callback from an Elk element that has changed. | def _element_callback(self, element, changeset):
"""Handle callback from an Elk element that has changed."""
self._element_changed(element, changeset)
self.async_write_ha_state() | [
"def",
"_element_callback",
"(",
"self",
",",
"element",
",",
"changeset",
")",
":",
"self",
".",
"_element_changed",
"(",
"element",
",",
"changeset",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
451,
4
] | [
454,
35
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.async_added_to_hass | (self) | Register callback for ElkM1 changes and update entity state. | Register callback for ElkM1 changes and update entity state. | async def async_added_to_hass(self):
"""Register callback for ElkM1 changes and update entity state."""
self._element.add_callback(self._element_callback)
self._element_callback(self._element, {}) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_element",
".",
"add_callback",
"(",
"self",
".",
"_element_callback",
")",
"self",
".",
"_element_callback",
"(",
"self",
".",
"_element",
",",
"{",
"}",
")"
] | [
456,
4
] | [
459,
49
] | python | en | ['en', 'en', 'en'] | True |
ElkEntity.device_info | (self) | Device info connecting via the ElkM1 system. | Device info connecting via the ElkM1 system. | def device_info(self):
"""Device info connecting via the ElkM1 system."""
return {
"via_device": (DOMAIN, f"{self._prefix}_system"),
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"via_device\"",
":",
"(",
"DOMAIN",
",",
"f\"{self._prefix}_system\"",
")",
",",
"}"
] | [
462,
4
] | [
466,
9
] | python | en | ['en', 'en', 'en'] | True |
ElkAttachedEntity.device_info | (self) | Device info for the underlying ElkM1 system. | Device info for the underlying ElkM1 system. | def device_info(self):
"""Device info for the underlying ElkM1 system."""
device_name = "ElkM1"
if self._prefix:
device_name += f" {self._prefix}"
return {
"name": device_name,
"identifiers": {(DOMAIN, f"{self._prefix}_system")},
"sw_versio... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_name",
"=",
"\"ElkM1\"",
"if",
"self",
".",
"_prefix",
":",
"device_name",
"+=",
"f\" {self._prefix}\"",
"return",
"{",
"\"name\"",
":",
"device_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
... | [
473,
4
] | [
484,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_google_setup | (hass) | Mock the google set up functions. | Mock the google set up functions. | def mock_google_setup(hass):
"""Mock the google set up functions."""
p_auth = patch(
"homeassistant.components.google.do_authentication", side_effect=google.do_setup
)
p_service = patch("homeassistant.components.google.GoogleCalendarService.get")
p_discovery = patch("homeassistant.components... | [
"def",
"mock_google_setup",
"(",
"hass",
")",
":",
"p_auth",
"=",
"patch",
"(",
"\"homeassistant.components.google.do_authentication\"",
",",
"side_effect",
"=",
"google",
".",
"do_setup",
")",
"p_service",
"=",
"patch",
"(",
"\"homeassistant.components.google.GoogleCalen... | [
11,
0
] | [
22,
13
] | python | en | ['en', 'en', 'en'] | True |
test_setup_component | (hass, google_setup) | Test setup component. | Test setup component. | async def test_setup_component(hass, google_setup):
"""Test setup component."""
config = {"google": {CONF_CLIENT_ID: "id", CONF_CLIENT_SECRET: "secret"}}
assert await async_setup_component(hass, "google", config) | [
"async",
"def",
"test_setup_component",
"(",
"hass",
",",
"google_setup",
")",
":",
"config",
"=",
"{",
"\"google\"",
":",
"{",
"CONF_CLIENT_ID",
":",
"\"id\"",
",",
"CONF_CLIENT_SECRET",
":",
"\"secret\"",
"}",
"}",
"assert",
"await",
"async_setup_component",
"... | [
25,
0
] | [
29,
62
] | python | en | ['en', 'da', 'en'] | True |
test_get_calendar_info | (hass, test_calendar) | Test getting the calendar info. | Test getting the calendar info. | async def test_get_calendar_info(hass, test_calendar):
"""Test getting the calendar info."""
calendar_info = await hass.async_add_executor_job(
google.get_calendar_info, hass, test_calendar
)
assert calendar_info == {
"cal_id": "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com",
... | [
"async",
"def",
"test_get_calendar_info",
"(",
"hass",
",",
"test_calendar",
")",
":",
"calendar_info",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"google",
".",
"get_calendar_info",
",",
"hass",
",",
"test_calendar",
")",
"assert",
"calendar_info",
... | [
32,
0
] | [
47,
5
] | python | en | ['en', 'lb', 'en'] | True |
test_found_calendar | (hass, google_setup, mock_next_event, test_calendar) | Test when a calendar is found. | Test when a calendar is found. | async def test_found_calendar(hass, google_setup, mock_next_event, test_calendar):
"""Test when a calendar is found."""
config = {
"google": {
CONF_CLIENT_ID: "id",
CONF_CLIENT_SECRET: "secret",
"track_new_calendar": True,
}
}
assert await async_setup_... | [
"async",
"def",
"test_found_calendar",
"(",
"hass",
",",
"google_setup",
",",
"mock_next_event",
",",
"test_calendar",
")",
":",
"config",
"=",
"{",
"\"google\"",
":",
"{",
"CONF_CLIENT_ID",
":",
"\"id\"",
",",
"CONF_CLIENT_SECRET",
":",
"\"secret\"",
",",
"\"tr... | [
50,
0
] | [
66,
76
] | python | en | ['en', 'de', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the available Repetier Server sensors. | Set up the available Repetier Server sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the available Repetier Server sensors."""
if discovery_info is None:
return
sensor_map = {
"bed_temperature": RepetierTempSensor,
"extruder_temperature": RepetierTempSensor,
"chamber_temperature":... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"sensor_map",
"=",
"{",
"\"bed_temperature\"",
":",
"RepetierTempSensor",
",",
"\"extrude... | [
15,
0
] | [
45,
32
] | python | en | ['en', 'en', 'en'] | True |
RepetierSensor.__init__ | (self, api, temp_id, name, printer_id, sensor_type) | Init new sensor. | Init new sensor. | def __init__(self, api, temp_id, name, printer_id, sensor_type):
"""Init new sensor."""
self._api = api
self._attributes = {}
self._available = False
self._temp_id = temp_id
self._name = name
self._printer_id = printer_id
self._sensor_type = sensor_type
... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"temp_id",
",",
"name",
",",
"printer_id",
",",
"sensor_type",
")",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_attributes",
"=",
"{",
"}",
"self",
".",
"_available",
"=",
"False",
"self",
"."... | [
51,
4
] | [
60,
26
] | python | ca | ['pl', 'ca', 'en'] | False |
RepetierSensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
63,
4
] | [
65,
30
] | python | en | ['en', 'en', 'en'] | True |
RepetierSensor.device_state_attributes | (self) | Return sensor attributes. | Return sensor attributes. | def device_state_attributes(self):
"""Return sensor attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
68,
4
] | [
70,
31
] | python | en | ['sv', 'id', 'en'] | False |
RepetierSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
73,
4
] | [
75,
25
] | python | en | ['en', 'mi', 'en'] | True |
RepetierSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return SENSOR_TYPES[self._sensor_type][1] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_sensor_type",
"]",
"[",
"1",
"]"
] | [
78,
4
] | [
80,
49
] | python | en | ['en', 'en', 'en'] | True |
RepetierSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return SENSOR_TYPES[self._sensor_type][2] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_sensor_type",
"]",
"[",
"2",
"]"
] | [
83,
4
] | [
85,
49
] | python | en | ['en', 'en', 'en'] | True |
RepetierSensor.should_poll | (self) | Return False as entity is updated from the component. | Return False as entity is updated from the component. | def should_poll(self):
"""Return False as entity is updated from the component."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
88,
4
] | [
90,
20
] | python | en | ['en', 'en', 'en'] | True |
RepetierSensor.state | (self) | Return sensor state. | Return sensor state. | def state(self):
"""Return sensor state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
93,
4
] | [
95,
26
] | python | en | ['en', 'bs', 'en'] | True |
RepetierSensor.update_callback | (self) | Get new data and update state. | Get new data and update state. | def update_callback(self):
"""Get new data and update state."""
self.async_schedule_update_ha_state(True) | [
"def",
"update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
98,
4
] | [
100,
49
] | 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.