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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SwitchmateEntity.update | (self) | Synchronize state with switch. | Synchronize state with switch. | def update(self) -> None:
"""Synchronize state with switch."""
self._device.update() | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_device",
".",
"update",
"(",
")"
] | [
58,
4
] | [
60,
29
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.is_on | (self) | Return true if it is on. | Return true if it is on. | def is_on(self) -> bool:
"""Return true if it is on."""
return self._device.state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
63,
4
] | [
65,
33
] | python | en | ['en', 'fy', 'en'] | True |
SwitchmateEntity.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs) -> None:
"""Turn the switch on."""
self._device.turn_on() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_device",
".",
"turn_on",
"(",
")"
] | [
67,
4
] | [
69,
30
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs) -> None:
"""Turn the switch off."""
self._device.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_device",
".",
"turn_off",
"(",
")"
] | [
71,
4
] | [
73,
31
] | python | en | ['en', 'en', 'en'] | True |
create_position_ids_from_input_ids | (input_ids, padding_idx, past_key_values_length=0) |
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.
Args:
input_ids (:obj:`torch.LongTensor`):
Indices of input sequence tokens in the vocabulary.
Returns:... |
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`. | def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_length=0):
"""
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.
Args:
input_ids (:obj:... | [
"def",
"create_position_ids_from_input_ids",
"(",
"input_ids",
",",
"padding_idx",
",",
"past_key_values_length",
"=",
"0",
")",
":",
"# The series of casts and type-conversions here are carefully balanced to both work with ONNX export and XLA.",
"mask",
"=",
"input_ids",
".",
"ne"... | [
1354,
0
] | [
1368,
51
] | python | en | ['en', 'error', 'th'] | False |
IBertEmbeddings.create_position_ids_from_inputs_embeds | (self, inputs_embeds) |
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
Args:
inputs_embeds: torch.Tensor
Returns: torch.Tensor
|
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. | def create_position_ids_from_inputs_embeds(self, inputs_embeds):
"""
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
Args:
inputs_embeds: torch.Tensor
Returns: torch.Tensor
"""
input_shape = inp... | [
"def",
"create_position_ids_from_inputs_embeds",
"(",
"self",
",",
"inputs_embeds",
")",
":",
"input_shape",
"=",
"inputs_embeds",
".",
"size",
"(",
")",
"[",
":",
"-",
"1",
"]",
"sequence_length",
"=",
"input_shape",
"[",
"1",
"]",
"position_ids",
"=",
"torch... | [
158,
4
] | [
173,
60
] | python | en | ['en', 'error', 'th'] | False |
IBertPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, (QuantLinear, nn.Linear)):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.dat... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"(",
"QuantLinear",
",",
"nn",
".",
"Linear",
")",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://gi... | [
646,
4
] | [
660,
41
] | python | en | ['en', 'en', 'en'] | True |
test_works | (hass) | Test safe mode works. | Test safe mode works. | async def test_works(hass):
"""Test safe mode works."""
assert await async_setup_component(hass, "safe_mode", {})
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 1 | [
"async",
"def",
"test_works",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"safe_mode\"",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".... | [
4,
0
] | [
8,
51
] | python | da | ['nl', 'da', 'en'] | False |
get_static_resource | () | Get the job with job_name.
Returns:
None.
| Get the job with job_name. | def get_static_resource():
"""Get the job with job_name.
Returns:
None.
"""
name_to_node_resources = redis_controller.get_name_to_node_resources()
return name_to_node_resources | [
"def",
"get_static_resource",
"(",
")",
":",
"name_to_node_resources",
"=",
"redis_controller",
".",
"get_name_to_node_resources",
"(",
")",
"return",
"name_to_node_resources"
] | [
15,
0
] | [
23,
33
] | python | en | ['en', 'su', 'en'] | True |
get_dynamic_resource | (previous_length: str) | Get the job with job_name.
Returns:
None.
| Get the job with job_name. | def get_dynamic_resource(previous_length: str):
"""Get the job with job_name.
Returns:
None.
"""
name_to_node_usage = redis_controller.get_resource_usage(
previous_length=int(previous_length)
)
return name_to_node_usage | [
"def",
"get_dynamic_resource",
"(",
"previous_length",
":",
"str",
")",
":",
"name_to_node_usage",
"=",
"redis_controller",
".",
"get_resource_usage",
"(",
"previous_length",
"=",
"int",
"(",
"previous_length",
")",
")",
"return",
"name_to_node_usage"
] | [
28,
0
] | [
38,
29
] | python | en | ['en', 'su', 'en'] | True |
url_slug | (value: Any) | Validate value is a valid url slug. | Validate value is a valid url slug. | def url_slug(value: Any) -> str:
"""Validate value is a valid url slug."""
if value is None:
raise vol.Invalid("Slug should not be None")
if "-" not in value:
raise vol.Invalid("Url path needs to contain a hyphen (-)")
str_value = str(value)
slg = slugify(str_value, separator="-")
... | [
"def",
"url_slug",
"(",
"value",
":",
"Any",
")",
"->",
"str",
":",
"if",
"value",
"is",
"None",
":",
"raise",
"vol",
".",
"Invalid",
"(",
"\"Slug should not be None\"",
")",
"if",
"\"-\"",
"not",
"in",
"value",
":",
"raise",
"vol",
".",
"Invalid",
"("... | [
77,
0
] | [
87,
58
] | python | en | ['en', 'et', 'en'] | True |
base_unique_id | (latitude, longitude) | Return unique id for entries in configuration. | Return unique id for entries in configuration. | def base_unique_id(latitude, longitude):
"""Return unique id for entries in configuration."""
return f"{latitude}_{longitude}" | [
"def",
"base_unique_id",
"(",
"latitude",
",",
"longitude",
")",
":",
"return",
"f\"{latitude}_{longitude}\""
] | [
35,
0
] | [
37,
36
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the National Weather Service (NWS) component. | Set up the National Weather Service (NWS) component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the National Weather Service (NWS) component."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"return",
"True"
] | [
40,
0
] | [
42,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up a National Weather Service entry. | Set up a National Weather Service entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up a National Weather Service entry."""
latitude = entry.data[CONF_LATITUDE]
longitude = entry.data[CONF_LONGITUDE]
api_key = entry.data[CONF_API_KEY]
station = entry.data[CONF_STATION]
client_session = async_get_clien... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"latitude",
"=",
"entry",
".",
"data",
"[",
"CONF_LATITUDE",
"]",
"longitude",
"=",
"entry",
".",
"data",
"[",
"CONF_LONGITUDE",
"]",
"api_key... | [
98,
0
] | [
163,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
166,
0
] | [
180,
20
] | python | en | ['en', 'es', 'en'] | True |
NwsDataUpdateCoordinator.__init__ | (
self,
hass: HomeAssistant,
logger: logging.Logger,
*,
name: str,
update_interval: datetime.timedelta,
failed_update_interval: datetime.timedelta,
update_method: Optional[Callable[[], Awaitable]] = None,
request_refresh_debouncer: Optional[debounc... | Initialize NWS coordinator. | Initialize NWS coordinator. | def __init__(
self,
hass: HomeAssistant,
logger: logging.Logger,
*,
name: str,
update_interval: datetime.timedelta,
failed_update_interval: datetime.timedelta,
update_method: Optional[Callable[[], Awaitable]] = None,
request_refresh_debouncer: Opti... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"logger",
":",
"logging",
".",
"Logger",
",",
"*",
",",
"name",
":",
"str",
",",
"update_interval",
":",
"datetime",
".",
"timedelta",
",",
"failed_update_interval",
":",
"datetime",
"... | [
52,
4
] | [
73,
44
] | python | it | ['it', 'en', 'it'] | True |
NwsDataUpdateCoordinator._schedule_refresh | (self) | Schedule a refresh. | Schedule a refresh. | def _schedule_refresh(self) -> None:
"""Schedule a refresh."""
if self._unsub_refresh:
self._unsub_refresh()
self._unsub_refresh = None
# We _floor_ utcnow to create a schedule on a rounded second,
# minimizing the time between the point and the real activation.
... | [
"def",
"_schedule_refresh",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_unsub_refresh",
":",
"self",
".",
"_unsub_refresh",
"(",
")",
"self",
".",
"_unsub_refresh",
"=",
"None",
"# We _floor_ utcnow to create a schedule on a rounded second,",
"# minimizi... | [
76,
4
] | [
95,
9
] | python | en | ['en', 'de', 'en'] | True |
test_owserver_setup_valid_device | (owproxy, hass, device_id, platform) | Test for 1-Wire device.
As they would be on a clean setup: all binary-sensors and switches disabled.
| Test for 1-Wire device. | async def test_owserver_setup_valid_device(owproxy, hass, device_id, platform):
"""Test for 1-Wire device.
As they would be on a clean setup: all binary-sensors and switches disabled.
"""
await async_setup_component(hass, "persistent_notification", {})
entity_registry = mock_registry(hass)
devi... | [
"async",
"def",
"test_owserver_setup_valid_device",
"(",
"owproxy",
",",
"hass",
",",
"device_id",
",",
"platform",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entity_registry",
"=",
"mock_registr... | [
699,
0
] | [
753,
59
] | python | en | ['fr', 'en', 'en'] | True |
new_profile_config | (
profile: str,
user_id: int,
api_response_user_get_device: Optional[
Union[UserGetDeviceResponse, Exception]
] = None,
api_response_measure_get_meas: Optional[
Union[MeasureGetMeasResponse, Exception]
] = None,
api_response_sleep_get_summary: Optional[
Union[SleepGet... | Create a new profile config immutable object. | Create a new profile config immutable object. | def new_profile_config(
profile: str,
user_id: int,
api_response_user_get_device: Optional[
Union[UserGetDeviceResponse, Exception]
] = None,
api_response_measure_get_meas: Optional[
Union[MeasureGetMeasResponse, Exception]
] = None,
api_response_sleep_get_summary: Optional[
... | [
"def",
"new_profile_config",
"(",
"profile",
":",
"str",
",",
"user_id",
":",
"int",
",",
"api_response_user_get_device",
":",
"Optional",
"[",
"Union",
"[",
"UserGetDeviceResponse",
",",
"Exception",
"]",
"]",
"=",
"None",
",",
"api_response_measure_get_meas",
":... | [
58,
0
] | [
92,
5
] | python | en | ['en', 'en', 'en'] | True |
get_config_entries_for_user_id | (
hass: HomeAssistant, user_id: int
) | Get a list of config entries that apply to a specific withings user. | Get a list of config entries that apply to a specific withings user. | def get_config_entries_for_user_id(
hass: HomeAssistant, user_id: int
) -> Tuple[ConfigEntry]:
"""Get a list of config entries that apply to a specific withings user."""
return tuple(
[
config_entry
for config_entry in hass.config_entries.async_entries(const.DOMAIN)
... | [
"def",
"get_config_entries_for_user_id",
"(",
"hass",
":",
"HomeAssistant",
",",
"user_id",
":",
"int",
")",
"->",
"Tuple",
"[",
"ConfigEntry",
"]",
":",
"return",
"tuple",
"(",
"[",
"config_entry",
"for",
"config_entry",
"in",
"hass",
".",
"config_entries",
"... | [
290,
0
] | [
300,
5
] | python | en | ['en', 'en', 'en'] | True |
async_get_flow_for_user_id | (hass: HomeAssistant, user_id: int) | Get a flow for a user id. | Get a flow for a user id. | def async_get_flow_for_user_id(hass: HomeAssistant, user_id: int) -> List[dict]:
"""Get a flow for a user id."""
return [
flow
for flow in hass.config_entries.flow.async_progress()
if flow["handler"] == const.DOMAIN and flow["context"].get("userid") == user_id
] | [
"def",
"async_get_flow_for_user_id",
"(",
"hass",
":",
"HomeAssistant",
",",
"user_id",
":",
"int",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"[",
"flow",
"for",
"flow",
"in",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_progress",
"("... | [
303,
0
] | [
309,
5
] | python | en | ['en', 'en', 'en'] | True |
get_data_manager_by_user_id | (
hass: HomeAssistant, user_id: int
) | Get a data manager by the user id. | Get a data manager by the user id. | def get_data_manager_by_user_id(
hass: HomeAssistant, user_id: int
) -> Optional[DataManager]:
"""Get a data manager by the user id."""
return next(
iter(
[
data_manager
for data_manager in get_all_data_managers(hass)
if data_manager.user_i... | [
"def",
"get_data_manager_by_user_id",
"(",
"hass",
":",
"HomeAssistant",
",",
"user_id",
":",
"int",
")",
"->",
"Optional",
"[",
"DataManager",
"]",
":",
"return",
"next",
"(",
"iter",
"(",
"[",
"data_manager",
"for",
"data_manager",
"in",
"get_all_data_managers... | [
312,
0
] | [
325,
5
] | python | en | ['en', 'en', 'en'] | True |
ComponentFactory.__init__ | (
self,
hass: HomeAssistant,
api_class_mock: MagicMock,
aiohttp_client,
aioclient_mock: AiohttpClientMocker,
) | Initialize the object. | Initialize the object. | def __init__(
self,
hass: HomeAssistant,
api_class_mock: MagicMock,
aiohttp_client,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Initialize the object."""
self._hass = hass
self._api_class_mock = api_class_mock
self._aiohttp_client = aioh... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"api_class_mock",
":",
"MagicMock",
",",
"aiohttp_client",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
")",
"->",
"None",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",... | [
106,
4
] | [
120,
61
] | python | en | ['en', 'en', 'en'] | True |
ComponentFactory.configure_component | (
self,
client_id: str = "my_client_id",
client_secret: str = "my_client_secret",
profile_configs: Tuple[ProfileConfig, ...] = (),
) | Configure the wihings component. | Configure the wihings component. | async def configure_component(
self,
client_id: str = "my_client_id",
client_secret: str = "my_client_secret",
profile_configs: Tuple[ProfileConfig, ...] = (),
) -> None:
"""Configure the wihings component."""
self._client_id = client_id
self._client_secret = ... | [
"async",
"def",
"configure_component",
"(",
"self",
",",
"client_id",
":",
"str",
"=",
"\"my_client_id\"",
",",
"client_secret",
":",
"str",
"=",
"\"my_client_secret\"",
",",
"profile_configs",
":",
"Tuple",
"[",
"ProfileConfig",
",",
"...",
"]",
"=",
"(",
")"... | [
122,
4
] | [
151,
48
] | python | en | ['en', 'en', 'en'] | True |
ComponentFactory.setup_profile | (self, user_id: int) | Set up a user profile through config flows. | Set up a user profile through config flows. | async def setup_profile(self, user_id: int) -> ConfigEntryWithingsApi:
"""Set up a user profile through config flows."""
profile_config = next(
iter(
[
profile_config
for profile_config in self._profile_configs
if pr... | [
"async",
"def",
"setup_profile",
"(",
"self",
",",
"user_id",
":",
"int",
")",
"->",
"ConfigEntryWithingsApi",
":",
"profile_config",
"=",
"next",
"(",
"iter",
"(",
"[",
"profile_config",
"for",
"profile_config",
"in",
"self",
".",
"_profile_configs",
"if",
"p... | [
160,
4
] | [
258,
48
] | python | en | ['en', 'gl', 'en'] | True |
ComponentFactory.call_webhook | (self, user_id: int, appli: NotifyAppli) | Call the webhook to notify of data changes. | Call the webhook to notify of data changes. | async def call_webhook(self, user_id: int, appli: NotifyAppli) -> WebhookResponse:
"""Call the webhook to notify of data changes."""
client: TestClient = await self._aiohttp_client(self._hass.http.app)
data_manager = get_data_manager_by_user_id(self._hass, user_id)
resp = await client.p... | [
"async",
"def",
"call_webhook",
"(",
"self",
",",
"user_id",
":",
"int",
",",
"appli",
":",
"NotifyAppli",
")",
"->",
"WebhookResponse",
":",
"client",
":",
"TestClient",
"=",
"await",
"self",
".",
"_aiohttp_client",
"(",
"self",
".",
"_hass",
".",
"http",... | [
260,
4
] | [
276,
82
] | python | en | ['en', 'en', 'en'] | True |
ComponentFactory.unload | (self, profile: ProfileConfig) | Unload the component for a specific user. | Unload the component for a specific user. | async def unload(self, profile: ProfileConfig) -> None:
"""Unload the component for a specific user."""
config_entries = get_config_entries_for_user_id(self._hass, profile.user_id)
for config_entry in config_entries:
await async_unload_entry(self._hass, config_entry)
await ... | [
"async",
"def",
"unload",
"(",
"self",
",",
"profile",
":",
"ProfileConfig",
")",
"->",
"None",
":",
"config_entries",
"=",
"get_config_entries_for_user_id",
"(",
"self",
".",
"_hass",
",",
"profile",
".",
"user_id",
")",
"for",
"config_entry",
"in",
"config_e... | [
278,
4
] | [
287,
75
] | python | en | ['en', 'en', 'en'] | True |
generate | (module_name, code) | Generate search space.
Return a serializable search space object.
module_name: name of the module (str)
code: user code (str)
| Generate search space.
Return a serializable search space object.
module_name: name of the module (str)
code: user code (str)
| def generate(module_name, code):
"""Generate search space.
Return a serializable search space object.
module_name: name of the module (str)
code: user code (str)
"""
try:
ast_tree = ast.parse(code)
except Exception:
raise RuntimeError('Bad Python code')
visitor = SearchS... | [
"def",
"generate",
"(",
"module_name",
",",
"code",
")",
":",
"try",
":",
"ast_tree",
"=",
"ast",
".",
"parse",
"(",
"code",
")",
"except",
"Exception",
":",
"raise",
"RuntimeError",
"(",
"'Bad Python code'",
")",
"visitor",
"=",
"SearchSpaceGenerator",
"(",... | [
118,
0
] | [
134,
58
] | python | en | ['en', 'en', 'en'] | True |
async_setup_sdm_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up the sensors. | Set up the sensors. | async def async_setup_sdm_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the sensors."""
subscriber = hass.data[DOMAIN][entry.entry_id]
try:
device_manager = await subscriber.async_get_device_manager()
except GoogleNestException as err:
_... | [
"async",
"def",
"async_setup_sdm_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"subscriber",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]... | [
35,
0
] | [
55,
32
] | python | en | ['en', 'bg', 'en'] | True |
SensorBase.__init__ | (self, device: Device) | Initialize the sensor. | Initialize the sensor. | def __init__(self, device: Device):
"""Initialize the sensor."""
self._device = device
self._device_info = DeviceInfo(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"Device",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_device_info",
"=",
"DeviceInfo",
"(",
"device",
")"
] | [
61,
4
] | [
64,
46
] | python | en | ['en', 'en', 'en'] | True |
SensorBase.should_poll | (self) | Disable polling since entities have state pushed via pubsub. | Disable polling since entities have state pushed via pubsub. | def should_poll(self) -> bool:
"""Disable polling since entities have state pushed via pubsub."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
67,
4
] | [
69,
20
] | python | en | ['en', 'en', 'en'] | True |
SensorBase.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
# The API "name" field is a unique device identifier.
return f"{self._device.name}-{self.device_class}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# The API \"name\" field is a unique device identifier.",
"return",
"f\"{self._device.name}-{self.device_class}\""
] | [
72,
4
] | [
75,
57
] | python | ca | ['fr', 'ca', 'en'] | False |
SensorBase.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self):
"""Return device specific attributes."""
return self._device_info.device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_info",
".",
"device_info"
] | [
78,
4
] | [
80,
44
] | python | en | ['fr', 'it', 'en'] | False |
SensorBase.async_added_to_hass | (self) | Run when entity is added to register update signal handler. | Run when entity is added to register update signal handler. | async def async_added_to_hass(self):
"""Run when entity is added to register update signal handler."""
# Event messages trigger the SIGNAL_NEST_UPDATE, which is intercepted
# here to re-fresh the signals from _device. Unregister this callback
# when the entity is removed.
self.a... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"# Event messages trigger the SIGNAL_NEST_UPDATE, which is intercepted",
"# here to re-fresh the signals from _device. Unregister this callback",
"# when the entity is removed.",
"self",
".",
"async_on_remove",
"(",
"async_di... | [
82,
4
] | [
93,
9
] | python | en | ['en', 'en', 'en'] | True |
TemperatureSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._device_info.device_name} Temperature" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._device_info.device_name} Temperature\""
] | [
100,
4
] | [
102,
61
] | python | en | ['en', 'mi', 'en'] | True |
TemperatureSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
trait = self._device.traits[TemperatureTrait.NAME]
return trait.ambient_temperature_celsius | [
"def",
"state",
"(",
"self",
")",
":",
"trait",
"=",
"self",
".",
"_device",
".",
"traits",
"[",
"TemperatureTrait",
".",
"NAME",
"]",
"return",
"trait",
".",
"ambient_temperature_celsius"
] | [
105,
4
] | [
108,
48
] | python | en | ['en', 'en', 'en'] | True |
TemperatureSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
111,
4
] | [
113,
27
] | python | en | ['en', 'la', 'en'] | True |
TemperatureSensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self):
"""Return the class of this device."""
return DEVICE_CLASS_TEMPERATURE | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TEMPERATURE"
] | [
116,
4
] | [
118,
39
] | python | en | ['en', 'en', 'en'] | True |
HumiditySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
# The API returns the identifier under the name field.
return f"{self._device.name}-humidity" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# The API returns the identifier under the name field.",
"return",
"f\"{self._device.name}-humidity\""
] | [
125,
4
] | [
128,
46
] | python | ca | ['fr', 'ca', 'en'] | False |
HumiditySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._device_info.device_name} Humidity" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._device_info.device_name} Humidity\""
] | [
131,
4
] | [
133,
58
] | python | en | ['en', 'mi', 'en'] | True |
HumiditySensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
trait = self._device.traits[HumidityTrait.NAME]
return trait.ambient_humidity_percent | [
"def",
"state",
"(",
"self",
")",
":",
"trait",
"=",
"self",
".",
"_device",
".",
"traits",
"[",
"HumidityTrait",
".",
"NAME",
"]",
"return",
"trait",
".",
"ambient_humidity_percent"
] | [
136,
4
] | [
139,
45
] | python | en | ['en', 'en', 'en'] | True |
HumiditySensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return PERCENTAGE | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"PERCENTAGE"
] | [
142,
4
] | [
144,
25
] | python | en | ['en', 'la', 'en'] | True |
HumiditySensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self):
"""Return the class of this device."""
return DEVICE_CLASS_HUMIDITY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_HUMIDITY"
] | [
147,
4
] | [
149,
36
] | python | en | ['en', 'en', 'en'] | True |
test_scanner_entity_device_tracker | (hass) | Test ScannerEntity based device tracker. | Test ScannerEntity based device tracker. | async def test_scanner_entity_device_tracker(hass):
"""Test ScannerEntity based device tracker."""
config_entry = MockConfigEntry(domain="test")
config_entry.add_to_hass(hass)
await hass.config_entries.async_forward_entry_setup(config_entry, DOMAIN)
await hass.async_block_till_done()
entity_id... | [
"async",
"def",
"test_scanner_entity_device_tracker",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_forw... | [
17,
0
] | [
38,
43
] | python | en | ['en', 'en', 'en'] | True |
test_scanner_entity | () | Test coverage for base ScannerEntity entity class. | Test coverage for base ScannerEntity entity class. | def test_scanner_entity():
"""Test coverage for base ScannerEntity entity class."""
entity = ScannerEntity()
with pytest.raises(NotImplementedError):
assert entity.source_type is None
with pytest.raises(NotImplementedError):
assert entity.is_connected is None
with pytest.raises(NotIm... | [
"def",
"test_scanner_entity",
"(",
")",
":",
"entity",
"=",
"ScannerEntity",
"(",
")",
"with",
"pytest",
".",
"raises",
"(",
"NotImplementedError",
")",
":",
"assert",
"entity",
".",
"source_type",
"is",
"None",
"with",
"pytest",
".",
"raises",
"(",
"NotImpl... | [
41,
0
] | [
50,
39
] | python | en | ['en', 'en', 'en'] | True |
test_base_tracker_entity | () | Test coverage for base BaseTrackerEntity entity class. | Test coverage for base BaseTrackerEntity entity class. | def test_base_tracker_entity():
"""Test coverage for base BaseTrackerEntity entity class."""
entity = BaseTrackerEntity()
with pytest.raises(NotImplementedError):
assert entity.source_type is None
assert entity.battery_level is None
with pytest.raises(NotImplementedError):
assert ent... | [
"def",
"test_base_tracker_entity",
"(",
")",
":",
"entity",
"=",
"BaseTrackerEntity",
"(",
")",
"with",
"pytest",
".",
"raises",
"(",
"NotImplementedError",
")",
":",
"assert",
"entity",
".",
"source_type",
"is",
"None",
"assert",
"entity",
".",
"battery_level",... | [
53,
0
] | [
60,
46
] | python | en | ['en', 'en', 'en'] | True |
nonlinear_transform | (ex_rois, gt_rois) |
compute bounding box regression targets from ex_rois to gt_rois
:param ex_rois: [k, 4] ([x1, y1, x2, y2])
:param gt_rois: [k, 4] (corresponding gt_boxes [x1, y1, x2, y2] )
:return: bbox_targets: [k, 4]
|
compute bounding box regression targets from ex_rois to gt_rois
:param ex_rois: [k, 4] ([x1, y1, x2, y2])
:param gt_rois: [k, 4] (corresponding gt_boxes [x1, y1, x2, y2] )
:return: bbox_targets: [k, 4]
| def nonlinear_transform(ex_rois, gt_rois):
"""
compute bounding box regression targets from ex_rois to gt_rois
:param ex_rois: [k, 4] ([x1, y1, x2, y2])
:param gt_rois: [k, 4] (corresponding gt_boxes [x1, y1, x2, y2] )
:return: bbox_targets: [k, 4]
"""
assert ex_rois.shape[0] == gt_rois.shap... | [
"def",
"nonlinear_transform",
"(",
"ex_rois",
",",
"gt_rois",
")",
":",
"assert",
"ex_rois",
".",
"shape",
"[",
"0",
"]",
"==",
"gt_rois",
".",
"shape",
"[",
"0",
"]",
",",
"'inconsistent rois number'",
"ex_widths",
"=",
"ex_rois",
"[",
":",
",",
"2",
"]... | [
3,
0
] | [
29,
18
] | python | en | ['en', 'error', 'th'] | False |
coordinate_embeddings | (boxes, dim) |
Coordinate embeddings of bounding boxes
:param boxes: [K, 6] ([x1, y1, x2, y2, w_image, h_image])
:param dim: sin/cos embedding dimension
:return: [K, 4, 2 * dim]
|
Coordinate embeddings of bounding boxes
:param boxes: [K, 6] ([x1, y1, x2, y2, w_image, h_image])
:param dim: sin/cos embedding dimension
:return: [K, 4, 2 * dim]
| def coordinate_embeddings(boxes, dim):
"""
Coordinate embeddings of bounding boxes
:param boxes: [K, 6] ([x1, y1, x2, y2, w_image, h_image])
:param dim: sin/cos embedding dimension
:return: [K, 4, 2 * dim]
"""
num_boxes = boxes.shape[0]
w = boxes[:, 4]
h = boxes[:, 5]
# transfo... | [
"def",
"coordinate_embeddings",
"(",
"boxes",
",",
"dim",
")",
":",
"num_boxes",
"=",
"boxes",
".",
"shape",
"[",
"0",
"]",
"w",
"=",
"boxes",
"[",
":",
",",
"4",
"]",
"h",
"=",
"boxes",
"[",
":",
",",
"5",
"]",
"# transform to (x_c, y_c, w, h) format"... | [
32,
0
] | [
64,
60
] | python | en | ['en', 'error', 'th'] | False |
RegularizedDartsMutator.reset | (self) |
Warnings
--------
Renamed :func:`~reset_with_loss` to return regularization loss on reset.
|
Warnings
--------
Renamed :func:`~reset_with_loss` to return regularization loss on reset.
| def reset(self):
"""
Warnings
--------
Renamed :func:`~reset_with_loss` to return regularization loss on reset.
"""
raise ValueError("You should probably call `reset_with_loss`.") | [
"def",
"reset",
"(",
"self",
")",
":",
"raise",
"ValueError",
"(",
"\"You should probably call `reset_with_loss`.\"",
")"
] | [
21,
4
] | [
27,
71
] | python | en | ['en', 'error', 'th'] | False |
RegularizedDartsMutator.cut_choices | (self, cut_num=2) |
Cut the choices with the smallest weights.
``cut_num`` should be the accumulative number of cutting, e.g., if first time cutting
is 2, the second time should be 4 to cut another two.
Parameters
----------
cut_num : int
Number of choices to cut, so far.
... |
Cut the choices with the smallest weights.
``cut_num`` should be the accumulative number of cutting, e.g., if first time cutting
is 2, the second time should be 4 to cut another two. | def cut_choices(self, cut_num=2):
"""
Cut the choices with the smallest weights.
``cut_num`` should be the accumulative number of cutting, e.g., if first time cutting
is 2, the second time should be 4 to cut another two.
Parameters
----------
cut_num : int
... | [
"def",
"cut_choices",
"(",
"self",
",",
"cut_num",
"=",
"2",
")",
":",
"# `cut_choices` is implemented but not used in current implementation of CdartsTrainer",
"for",
"mutable",
"in",
"self",
".",
"mutables",
":",
"if",
"isinstance",
"(",
"mutable",
",",
"LayerChoice",... | [
29,
4
] | [
52,
68
] | python | en | ['en', 'error', 'th'] | False |
RegularizedDartsMutator.reset_with_loss | (self) |
Resample and return loss. If loss is 0, to avoid device issue, it will return ``None``.
Currently loss penalty are proportional to the L1-norm of parameters corresponding
to modules if their type name contains certain substrings. These substrings include: ``poolwithoutbn``,
``identity`... |
Resample and return loss. If loss is 0, to avoid device issue, it will return ``None``. | def reset_with_loss(self):
"""
Resample and return loss. If loss is 0, to avoid device issue, it will return ``None``.
Currently loss penalty are proportional to the L1-norm of parameters corresponding
to modules if their type name contains certain substrings. These substrings include: ... | [
"def",
"reset_with_loss",
"(",
"self",
")",
":",
"self",
".",
"_cache",
",",
"reg_loss",
"=",
"self",
".",
"sample_search",
"(",
")",
"return",
"reg_loss"
] | [
54,
4
] | [
63,
23
] | python | en | ['en', 'error', 'th'] | False |
RegularizedDartsMutator.export | (self, logger=None) |
Export an architecture with logger. Genotype will be printed with logger.
Returns
-------
dict
A mapping from mutable keys to decisions.
|
Export an architecture with logger. Genotype will be printed with logger. | def export(self, logger=None):
"""
Export an architecture with logger. Genotype will be printed with logger.
Returns
-------
dict
A mapping from mutable keys to decisions.
"""
result = self.sample_final()
if hasattr(self.model, "plot_genotype"... | [
"def",
"export",
"(",
"self",
",",
"logger",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"sample_final",
"(",
")",
"if",
"hasattr",
"(",
"self",
".",
"model",
",",
"\"plot_genotype\"",
")",
"and",
"logger",
"is",
"not",
"None",
":",
"genotypes",... | [
82,
4
] | [
94,
32
] | python | en | ['en', 'error', 'th'] | False |
RegularizedMutatorParallel.reset_with_loss | (self) |
Parallelized :func:`~RegularizedDartsMutator.reset_with_loss`.
|
Parallelized :func:`~RegularizedDartsMutator.reset_with_loss`.
| def reset_with_loss(self):
"""
Parallelized :func:`~RegularizedDartsMutator.reset_with_loss`.
"""
result = self.module.reset_with_loss()
self.callback_queued = False
return result | [
"def",
"reset_with_loss",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"module",
".",
"reset_with_loss",
"(",
")",
"self",
".",
"callback_queued",
"=",
"False",
"return",
"result"
] | [
105,
4
] | [
111,
21
] | python | en | ['en', 'error', 'th'] | False |
RegularizedMutatorParallel.cut_choices | (self, *args, **kwargs) |
Parallelized :func:`~RegularizedDartsMutator.cut_choices`.
|
Parallelized :func:`~RegularizedDartsMutator.cut_choices`.
| def cut_choices(self, *args, **kwargs):
"""
Parallelized :func:`~RegularizedDartsMutator.cut_choices`.
"""
self.module.cut_choices(*args, **kwargs) | [
"def",
"cut_choices",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"module",
".",
"cut_choices",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
113,
4
] | [
117,
48
] | python | en | ['en', 'error', 'th'] | False |
RegularizedMutatorParallel.export | (self, logger) |
Parallelized :func:`~RegularizedDartsMutator.export`.
|
Parallelized :func:`~RegularizedDartsMutator.export`.
| def export(self, logger):
"""
Parallelized :func:`~RegularizedDartsMutator.export`.
"""
return self.module.export(logger) | [
"def",
"export",
"(",
"self",
",",
"logger",
")",
":",
"return",
"self",
".",
"module",
".",
"export",
"(",
"logger",
")"
] | [
119,
4
] | [
123,
41
] | python | en | ['en', 'error', 'th'] | False |
VesselFutureStopsPrediction.__getitem__ | (self, key) | Used to support querying future stops by vessel index, last location index, next location index. | Used to support querying future stops by vessel index, last location index, next location index. | def __getitem__(self, key):
"""Used to support querying future stops by vessel index, last location index, next location index."""
assert type(key) == tuple or type(key) == list
assert len(key) == 3
vessel_idx = key[0]
last_loc_idx = key[1]
next_loc_idx = key[2]
... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"assert",
"type",
"(",
"key",
")",
"==",
"tuple",
"or",
"type",
"(",
"key",
")",
"==",
"list",
"assert",
"len",
"(",
"key",
")",
"==",
"3",
"vessel_idx",
"=",
"key",
"[",
"0",
"]",
"last_lo... | [
27,
4
] | [
46,
110
] | python | en | ['en', 'en', 'en'] | True |
VesselFutureStopsPrediction._predict_future_stops | (self, vessel_idx: int, last_port_idx: int, last_port_arrive_tick: int, stop_number: int) | Do predict future stops.
| Do predict future stops.
| def _predict_future_stops(self, vessel_idx: int, last_port_idx: int, last_port_arrive_tick: int, stop_number: int):
"""Do predict future stops.
"""
vessel = self._vessels[vessel_idx]
speed = vessel.sailing_speed
duration = vessel.parking_duration
route_name = vessel.route... | [
"def",
"_predict_future_stops",
"(",
"self",
",",
"vessel_idx",
":",
"int",
",",
"last_port_idx",
":",
"int",
",",
"last_port_arrive_tick",
":",
"int",
",",
"stop_number",
":",
"int",
")",
":",
"vessel",
"=",
"self",
".",
"_vessels",
"[",
"vessel_idx",
"]",
... | [
48,
4
] | [
90,
37
] | python | en | ['sl', 'it', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the HDDTemp sensor. | Set up the HDDTemp sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the HDDTemp sensor."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
disks = config.get(CONF_DISKS)
hddtemp = HddTempData(host, port)
hddtemp.update()
if not disks:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"co... | [
42,
0
] | [
59,
27
] | python | en | ['en', 'da', 'en'] | True |
HddTempSensor.__init__ | (self, name, disk, hddtemp) | Initialize a HDDTemp sensor. | Initialize a HDDTemp sensor. | def __init__(self, name, disk, hddtemp):
"""Initialize a HDDTemp sensor."""
self.hddtemp = hddtemp
self.disk = disk
self._name = f"{name} {disk}"
self._state = None
self._details = None
self._unit = None | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"disk",
",",
"hddtemp",
")",
":",
"self",
".",
"hddtemp",
"=",
"hddtemp",
"self",
".",
"disk",
"=",
"disk",
"self",
".",
"_name",
"=",
"f\"{name} {disk}\"",
"self",
".",
"_state",
"=",
"None",
"self",
... | [
65,
4
] | [
72,
25
] | python | co | ['en', 'co', 'it'] | False |
HddTempSensor.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"
] | [
75,
4
] | [
77,
25
] | python | en | ['en', 'mi', 'en'] | True |
HddTempSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
80,
4
] | [
82,
26
] | python | en | ['en', 'en', 'en'] | True |
HddTempSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
85,
4
] | [
87,
25
] | python | en | ['en', 'en', 'en'] | True |
HddTempSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
if self._details is not None:
return {ATTR_DEVICE: self._details[0], ATTR_MODEL: self._details[1]} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_details",
"is",
"not",
"None",
":",
"return",
"{",
"ATTR_DEVICE",
":",
"self",
".",
"_details",
"[",
"0",
"]",
",",
"ATTR_MODEL",
":",
"self",
".",
"_details",
"[",
"1",
"]",... | [
90,
4
] | [
93,
80
] | python | en | ['en', 'en', 'en'] | True |
HddTempSensor.update | (self) | Get the latest data from HDDTemp daemon and updates the state. | Get the latest data from HDDTemp daemon and updates the state. | def update(self):
"""Get the latest data from HDDTemp daemon and updates the state."""
self.hddtemp.update()
if self.hddtemp.data and self.disk in self.hddtemp.data:
self._details = self.hddtemp.data[self.disk].split("|")
self._state = self._details[2]
if sel... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"hddtemp",
".",
"update",
"(",
")",
"if",
"self",
".",
"hddtemp",
".",
"data",
"and",
"self",
".",
"disk",
"in",
"self",
".",
"hddtemp",
".",
"data",
":",
"self",
".",
"_details",
"=",
"self",
... | [
95,
4
] | [
107,
30
] | python | en | ['en', 'en', 'en'] | True |
HddTempData.__init__ | (self, host, port) | Initialize the data object. | Initialize the data object. | def __init__(self, host, port):
"""Initialize the data object."""
self.host = host
self.port = port
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"self",
".",
"host",
"=",
"host",
"self",
".",
"port",
"=",
"port",
"self",
".",
"data",
"=",
"None"
] | [
113,
4
] | [
117,
24
] | python | en | ['en', 'en', 'en'] | True |
HddTempData.update | (self) | Get the latest data from HDDTemp running as daemon. | Get the latest data from HDDTemp running as daemon. | def update(self):
"""Get the latest data from HDDTemp running as daemon."""
try:
connection = Telnet(host=self.host, port=self.port, timeout=DEFAULT_TIMEOUT)
data = (
connection.read_all()
.decode("ascii")
.lstrip("|")
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"connection",
"=",
"Telnet",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
"data",
"=",
"(",
"connection",
".",
"read_all... | [
119,
4
] | [
136,
28
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Stub to allow setting up this component.
Configuration through YAML is not supported at this time.
| Stub to allow setting up this component. | async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Stub to allow setting up this component.
Configuration through YAML is not supported at this time.
"""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"return",
"True"
] | [
53,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up the esphome component. | Set up the esphome component. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up the esphome component."""
hass.data.setdefault(DATA_KEY, {})
host = entry.data[CONF_HOST]
port = entry.data[CONF_PORT]
password = entry.data[CONF_PASSWORD]
device_id = None
zeroconf_instance = await... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DATA_KEY",
",",
"{",
"}",
")",
"host",
"=",
"entry",
".",
"data",
"[",
"... | [
61,
0
] | [
213,
15
] | python | en | ['en', 'en', 'en'] | True |
_setup_auto_reconnect_logic | (
hass: HomeAssistantType, cli: APIClient, entry: ConfigEntry, host: str, on_login
) | Set up the re-connect logic for the API client. | Set up the re-connect logic for the API client. | async def _setup_auto_reconnect_logic(
hass: HomeAssistantType, cli: APIClient, entry: ConfigEntry, host: str, on_login
):
"""Set up the re-connect logic for the API client."""
async def try_connect(tries: int = 0, is_disconnect: bool = True) -> None:
"""Try connecting to the API client. Will retry... | [
"async",
"def",
"_setup_auto_reconnect_logic",
"(",
"hass",
":",
"HomeAssistantType",
",",
"cli",
":",
"APIClient",
",",
"entry",
":",
"ConfigEntry",
",",
"host",
":",
"str",
",",
"on_login",
")",
":",
"async",
"def",
"try_connect",
"(",
"tries",
":",
"int",... | [
216,
0
] | [
269,
22
] | python | en | ['en', 'en', 'en'] | True |
_async_setup_device_registry | (
hass: HomeAssistantType, entry: ConfigEntry, device_info: DeviceInfo
) | Set up device registry feature for a particular config entry. | Set up device registry feature for a particular config entry. | async def _async_setup_device_registry(
hass: HomeAssistantType, entry: ConfigEntry, device_info: DeviceInfo
):
"""Set up device registry feature for a particular config entry."""
sw_version = device_info.esphome_version
if device_info.compilation_time:
sw_version += f" ({device_info.compilation... | [
"async",
"def",
"_async_setup_device_registry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"device_info",
":",
"DeviceInfo",
")",
":",
"sw_version",
"=",
"device_info",
".",
"esphome_version",
"if",
"device_info",
".",
"compilation... | [
272,
0
] | [
288,
19
] | python | en | ['en', 'en', 'en'] | True |
_cleanup_instance | (
hass: HomeAssistantType, entry: ConfigEntry
) | Cleanup the esphome client if it exists. | Cleanup the esphome client if it exists. | async def _cleanup_instance(
hass: HomeAssistantType, entry: ConfigEntry
) -> RuntimeEntryData:
"""Cleanup the esphome client if it exists."""
data: RuntimeEntryData = hass.data[DATA_KEY].pop(entry.entry_id)
if data.reconnect_task is not None:
data.reconnect_task.cancel()
for disconnect_cb i... | [
"async",
"def",
"_cleanup_instance",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"RuntimeEntryData",
":",
"data",
":",
"RuntimeEntryData",
"=",
"hass",
".",
"data",
"[",
"DATA_KEY",
"]",
".",
"pop",
"(",
"entry",
".",
... | [
347,
0
] | [
359,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload an esphome config entry. | Unload an esphome config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Unload an esphome config entry."""
entry_data = await _cleanup_instance(hass, entry)
tasks = []
for platform in entry_data.loaded_platforms:
tasks.append(hass.config_entries.async_forward_entry_unload(entry, pl... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"entry_data",
"=",
"await",
"_cleanup_instance",
"(",
"hass",
",",
"entry",
")",
"tasks",
"=",
"[",
"]",
"for",
"platform",... | [
362,
0
] | [
370,
15
] | python | br | ['br', 'gl', 'en'] | False |
platform_async_setup_entry | (
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities,
*,
component_key: str,
info_type,
entity_type,
state_type,
) | Set up an esphome platform.
This method is in charge of receiving, distributing and storing
info and state updates.
| Set up an esphome platform. | async def platform_async_setup_entry(
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities,
*,
component_key: str,
info_type,
entity_type,
state_type,
) -> None:
"""Set up an esphome platform.
This method is in charge of receiving, distributing and storing
info an... | [
"async",
"def",
"platform_async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
",",
"*",
",",
"component_key",
":",
"str",
",",
"info_type",
",",
"entity_type",
",",
"state_type",
",",
")",
"->",... | [
373,
0
] | [
441,
5
] | python | en | ['en', 'lb', 'en'] | True |
esphome_state_property | (func) | Wrap a state property of an esphome entity.
This checks if the state object in the entity is set, and
prevents writing NAN values to the Home Assistant state machine.
| Wrap a state property of an esphome entity. | def esphome_state_property(func):
"""Wrap a state property of an esphome entity.
This checks if the state object in the entity is set, and
prevents writing NAN values to the Home Assistant state machine.
"""
@property
def _wrapper(self):
if self._state is None:
return None
... | [
"def",
"esphome_state_property",
"(",
"func",
")",
":",
"@",
"property",
"def",
"_wrapper",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"return",
"None",
"val",
"=",
"func",
"(",
"self",
")",
"if",
"isinstance",
"(",
"val",
... | [
444,
0
] | [
462,
19
] | python | en | ['en', 'en', 'en'] | True |
esphome_map_enum | (func: Callable[[], Dict[int, str]]) | Map esphome int enum values to hass string constants.
This class has to be used as a decorator. This ensures the aioesphomeapi
import is only happening at runtime.
| Map esphome int enum values to hass string constants. | def esphome_map_enum(func: Callable[[], Dict[int, str]]):
"""Map esphome int enum values to hass string constants.
This class has to be used as a decorator. This ensures the aioesphomeapi
import is only happening at runtime.
"""
return EsphomeEnumMapper(func) | [
"def",
"esphome_map_enum",
"(",
"func",
":",
"Callable",
"[",
"[",
"]",
",",
"Dict",
"[",
"int",
",",
"str",
"]",
"]",
")",
":",
"return",
"EsphomeEnumMapper",
"(",
"func",
")"
] | [
482,
0
] | [
488,
34
] | python | en | ['en', 'en', 'en'] | True |
EsphomeEnumMapper.__init__ | (self, func: Callable[[], Dict[int, str]]) | Construct a EsphomeEnumMapper. | Construct a EsphomeEnumMapper. | def __init__(self, func: Callable[[], Dict[int, str]]):
"""Construct a EsphomeEnumMapper."""
self._func = func | [
"def",
"__init__",
"(",
"self",
",",
"func",
":",
"Callable",
"[",
"[",
"]",
",",
"Dict",
"[",
"int",
",",
"str",
"]",
"]",
")",
":",
"self",
".",
"_func",
"=",
"func"
] | [
468,
4
] | [
470,
25
] | python | ca | ['es', 'ca', 'pt'] | False |
EsphomeEnumMapper.from_esphome | (self, value: int) | Convert from an esphome int representation to a hass string. | Convert from an esphome int representation to a hass string. | def from_esphome(self, value: int) -> str:
"""Convert from an esphome int representation to a hass string."""
return self._func()[value] | [
"def",
"from_esphome",
"(",
"self",
",",
"value",
":",
"int",
")",
"->",
"str",
":",
"return",
"self",
".",
"_func",
"(",
")",
"[",
"value",
"]"
] | [
472,
4
] | [
474,
34
] | python | en | ['en', 'en', 'en'] | True |
EsphomeEnumMapper.from_hass | (self, value: str) | Convert from a hass string to a esphome int representation. | Convert from a hass string to a esphome int representation. | def from_hass(self, value: str) -> int:
"""Convert from a hass string to a esphome int representation."""
inverse = {v: k for k, v in self._func().items()}
return inverse[value] | [
"def",
"from_hass",
"(",
"self",
",",
"value",
":",
"str",
")",
"->",
"int",
":",
"inverse",
"=",
"{",
"v",
":",
"k",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_func",
"(",
")",
".",
"items",
"(",
")",
"}",
"return",
"inverse",
"[",
"value",
... | [
476,
4
] | [
479,
29
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBaseEntity.__init__ | (self, entry_id: str, component_key: str, key: int) | Initialize. | Initialize. | def __init__(self, entry_id: str, component_key: str, key: int):
"""Initialize."""
self._entry_id = entry_id
self._component_key = component_key
self._key = key | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"component_key",
":",
"str",
",",
"key",
":",
"int",
")",
":",
"self",
".",
"_entry_id",
"=",
"entry_id",
"self",
".",
"_component_key",
"=",
"component_key",
"self",
".",
"_key",
"=",
"... | [
494,
4
] | [
498,
23
] | python | en | ['en', 'en', 'it'] | False |
EsphomeBaseEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self) -> None:
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
(
f"esphome_{self._entry_id}_remove_"
f"{self._component_key}_{self._key}"
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"(",
"f\"esphome_{self._entry_id}_remove_\"",
"f\"{self._component_key}_{self._key}\"",
")",
",",
... | [
500,
4
] | [
519,
9
] | python | en | ['en', 'no', 'en'] | False |
EsphomeBaseEntity._on_device_update | (self) | Update the entity state when device info has changed. | Update the entity state when device info has changed. | def _on_device_update(self) -> None:
"""Update the entity state when device info has changed."""
if self._entry_data.available:
# Don't update the HA state yet when the device comes online.
# Only update the HA state when the full state arrives
# through the next enti... | [
"def",
"_on_device_update",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_entry_data",
".",
"available",
":",
"# Don't update the HA state yet when the device comes online.",
"# Only update the HA state when the full state arrives",
"# through the next entity state pack... | [
522,
4
] | [
529,
35
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBaseEntity.available | (self) | Return if the entity is available. | Return if the entity is available. | def available(self) -> bool:
"""Return if the entity is available."""
device = self._device_info
if device.has_deep_sleep:
# During deep sleep the ESP will not be connectable (by design)
# For these cases, show it as available
return True
return self... | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"device",
"=",
"self",
".",
"_device_info",
"if",
"device",
".",
"has_deep_sleep",
":",
"# During deep sleep the ESP will not be connectable (by design)",
"# For these cases, show it as available",
"return",
"True",
... | [
561,
4
] | [
570,
41
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBaseEntity.unique_id | (self) | Return a unique id identifying the entity. | Return a unique id identifying the entity. | def unique_id(self) -> Optional[str]:
"""Return a unique id identifying the entity."""
if not self._static_info.unique_id:
return None
return self._static_info.unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"_static_info",
".",
"unique_id",
":",
"return",
"None",
"return",
"self",
".",
"_static_info",
".",
"unique_id"
] | [
573,
4
] | [
577,
42
] | python | en | ['en', 'cy', 'en'] | True |
EsphomeBaseEntity.device_info | (self) | Return device registry information for this entity. | Return device registry information for this entity. | def device_info(self) -> Dict[str, Any]:
"""Return device registry information for this entity."""
return {
"connections": {(dr.CONNECTION_NETWORK_MAC, self._device_info.mac_address)}
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"dr",
".",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"_device_info",
".",
"mac_address",
")",
"}",
"}"
] | [
580,
4
] | [
584,
9
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBaseEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._static_info.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_static_info",
".",
"name"
] | [
587,
4
] | [
589,
37
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBaseEntity.should_poll | (self) | Disable polling. | Disable polling. | def should_poll(self) -> bool:
"""Disable polling."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
592,
4
] | [
594,
20
] | python | en | ['fr', 'en', 'en'] | False |
EsphomeEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self) -> None:
"""Register callbacks."""
await super().async_added_to_hass()
self.async_on_remove(
async_dispatcher_connect(
self.hass,
(
f"esphome_{self._entry_id}"
f"_update_{sel... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"(",
"f\"esphome_{self... | [
600,
4
] | [
614,
9
] | python | en | ['en', 'no', 'en'] | False |
check_valid_state | (state, tariff: str, value=None, key_attr=None) | Ensure that sensor has a valid state and attributes. | Ensure that sensor has a valid state and attributes. | def check_valid_state(state, tariff: str, value=None, key_attr=None):
"""Ensure that sensor has a valid state and attributes."""
assert state
assert (
state.attributes[ATTR_UNIT_OF_MEASUREMENT]
== f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}"
)
try:
_ = float(state.state)
... | [
"def",
"check_valid_state",
"(",
"state",
",",
"tariff",
":",
"str",
",",
"value",
"=",
"None",
",",
"key_attr",
"=",
"None",
")",
":",
"assert",
"state",
"assert",
"(",
"state",
".",
"attributes",
"[",
"ATTR_UNIT_OF_MEASUREMENT",
"]",
"==",
"f\"{CURRENCY_EU... | [
18,
0
] | [
38,
74
] | python | en | ['en', 'en', 'en'] | True |
pvpc_aioclient_mock | (aioclient_mock: AiohttpClientMocker) | Create a mock config entry. | Create a mock config entry. | def pvpc_aioclient_mock(aioclient_mock: AiohttpClientMocker):
"""Create a mock config entry."""
aioclient_mock.get(
"https://api.esios.ree.es/archives/70/download_json?locale=es&date=2019-10-26",
text=load_fixture(f"{DOMAIN}/{FIXTURE_JSON_DATA_2019_10_26}"),
)
aioclient_mock.get(
... | [
"def",
"pvpc_aioclient_mock",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"https://api.esios.ree.es/archives/70/download_json?locale=es&date=2019-10-26\"",
",",
"text",
"=",
"load_fixture",
"(",
"f\"{DOMAIN}/{FIXTURE_JSON_DATA... | [
42,
0
] | [
62,
25
] | python | en | ['en', 'gl', 'en'] | True |
LocalCorrelation.initialize_model | (self, mc, **kwargs) | A special kind of initialization is required for this module, since it has to take a second dataset
and check the correspondence with the points
| A special kind of initialization is required for this module, since it has to take a second dataset
and check the correspondence with the points | def initialize_model(self, mc, **kwargs):
""" A special kind of initialization is required for this module, since it has to take a second dataset
and check the correspondence with the points
"""
dataset_ref = mc.dataset_dict[kwargs['reference']]
dataset_asc = mc.dataset_dict[kwa... | [
"def",
"initialize_model",
"(",
"self",
",",
"mc",
",",
"*",
"*",
"kwargs",
")",
":",
"dataset_ref",
"=",
"mc",
".",
"dataset_dict",
"[",
"kwargs",
"[",
"'reference'",
"]",
"]",
"dataset_asc",
"=",
"mc",
".",
"dataset_dict",
"[",
"kwargs",
"[",
"'associa... | [
25,
4
] | [
70,
62
] | python | en | ['en', 'en', 'en'] | True |
LocalCorrelation.compute | (self, variable_value, dataset, x0_input=None) | In our array, coefficient are sorted from the lowest degree to the higher
This is the order accepted by NumPy.polynomial.polynomial.polyval ,
which is reversed with respect to from NumPy.polyval
| In our array, coefficient are sorted from the lowest degree to the higher
This is the order accepted by NumPy.polynomial.polynomial.polyval ,
which is reversed with respect to from NumPy.polyval
| def compute(self, variable_value, dataset, x0_input=None):
coeff = np.zeros(self.order+1)
for i_order in range(1, self.order+1):
var = 'c'+repr(i_order)
coeff[i_order] = variable_value[var]
x_zero = variable_value['x_zero']
""" In our array, coefficient are sort... | [
"def",
"compute",
"(",
"self",
",",
"variable_value",
",",
"dataset",
",",
"x0_input",
"=",
"None",
")",
":",
"coeff",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"order",
"+",
"1",
")",
"for",
"i_order",
"in",
"range",
"(",
"1",
",",
"self",
".",
... | [
72,
4
] | [
87,
78
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Linode component. | Set up the Linode component. | def setup(hass, config):
"""Set up the Linode component."""
conf = config[DOMAIN]
access_token = conf.get(CONF_ACCESS_TOKEN)
_linode = Linode(access_token)
try:
_LOGGER.info("Linode Profile %s", _linode.manager.get_profile().username)
except linode.errors.ApiError as _ex:
_LOGG... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"access_token",
"=",
"conf",
".",
"get",
"(",
"CONF_ACCESS_TOKEN",
")",
"_linode",
"=",
"Linode",
"(",
"access_token",
")",
"try",
":",
"_LOGGER",
".",
"in... | [
36,
0
] | [
51,
15
] | python | en | ['en', 'en', 'en'] | True |
Linode.__init__ | (self, access_token) | Initialize the Linode connection. | Initialize the Linode connection. | def __init__(self, access_token):
"""Initialize the Linode connection."""
self._access_token = access_token
self.data = None
self.manager = linode.LinodeClient(token=self._access_token) | [
"def",
"__init__",
"(",
"self",
",",
"access_token",
")",
":",
"self",
".",
"_access_token",
"=",
"access_token",
"self",
".",
"data",
"=",
"None",
"self",
".",
"manager",
"=",
"linode",
".",
"LinodeClient",
"(",
"token",
"=",
"self",
".",
"_access_token",... | [
57,
4
] | [
61,
68
] | python | en | ['en', 'en', 'en'] | True |
Linode.get_node_id | (self, node_name) | Get the status of a Linode Instance. | Get the status of a Linode Instance. | def get_node_id(self, node_name):
"""Get the status of a Linode Instance."""
node_id = None
try:
all_nodes = self.manager.linode.get_instances()
for node in all_nodes:
if node_name == node.label:
node_id = node.id
except linode... | [
"def",
"get_node_id",
"(",
"self",
",",
"node_name",
")",
":",
"node_id",
"=",
"None",
"try",
":",
"all_nodes",
"=",
"self",
".",
"manager",
".",
"linode",
".",
"get_instances",
"(",
")",
"for",
"node",
"in",
"all_nodes",
":",
"if",
"node_name",
"==",
... | [
63,
4
] | [
75,
22
] | python | en | ['en', 'en', 'en'] | True |
Linode.update | (self) | Use the data from Linode API. | Use the data from Linode API. | def update(self):
"""Use the data from Linode API."""
try:
self.data = self.manager.linode.get_instances()
except linode.errors.ApiError as _ex:
_LOGGER.error(_ex) | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"data",
"=",
"self",
".",
"manager",
".",
"linode",
".",
"get_instances",
"(",
")",
"except",
"linode",
".",
"errors",
".",
"ApiError",
"as",
"_ex",
":",
"_LOGGER",
".",
"error",
"(",
... | [
78,
4
] | [
83,
30
] | python | en | ['en', 'en', 'en'] | True |
tempsensor_fixture | () | Return a default sensor mock. | Return a default sensor mock. | def tempsensor_fixture():
"""Return a default sensor mock."""
feature = mock_feature(
"sensors",
blebox_uniapi.sensor.Temperature,
unique_id="BleBox-tempSensor-1afe34db9437-0.temperature",
full_name="tempSensor-0.temperature",
device_class="temperature",
unit="cel... | [
"def",
"tempsensor_fixture",
"(",
")",
":",
"feature",
"=",
"mock_feature",
"(",
"\"sensors\"",
",",
"blebox_uniapi",
".",
"sensor",
".",
"Temperature",
",",
"unique_id",
"=",
"\"BleBox-tempSensor-1afe34db9437-0.temperature\"",
",",
"full_name",
"=",
"\"tempSensor-0.tem... | [
21,
0
] | [
35,
55
] | python | ca | ['ca', 'ca', 'en'] | True |
test_init | (tempsensor, hass, config) | Test sensor default state. | Test sensor default state. | async def test_init(tempsensor, hass, config):
"""Test sensor default state."""
_, entity_id = tempsensor
entry = await async_setup_entity(hass, config, entity_id)
assert entry.unique_id == "BleBox-tempSensor-1afe34db9437-0.temperature"
state = hass.states.get(entity_id)
assert state.name == "... | [
"async",
"def",
"test_init",
"(",
"tempsensor",
",",
"hass",
",",
"config",
")",
":",
"_",
",",
"entity_id",
"=",
"tempsensor",
"entry",
"=",
"await",
"async_setup_entity",
"(",
"hass",
",",
"config",
",",
"entity_id",
")",
"assert",
"entry",
".",
"unique_... | [
38,
0
] | [
59,
38
] | python | ca | ['ca', 'da', 'en'] | False |
test_update | (tempsensor, hass, config) | Test sensor update. | Test sensor update. | async def test_update(tempsensor, hass, config):
"""Test sensor update."""
feature_mock, entity_id = tempsensor
def initial_update():
feature_mock.current = 25.18
feature_mock.async_update = AsyncMock(side_effect=initial_update)
await async_setup_entity(hass, config, entity_id)
state... | [
"async",
"def",
"test_update",
"(",
"tempsensor",
",",
"hass",
",",
"config",
")",
":",
"feature_mock",
",",
"entity_id",
"=",
"tempsensor",
"def",
"initial_update",
"(",
")",
":",
"feature_mock",
".",
"current",
"=",
"25.18",
"feature_mock",
".",
"async_updat... | [
62,
0
] | [
75,
33
] | python | en | ['en', 'lb', 'en'] | True |
test_update_failure | (tempsensor, hass, config, caplog) | Test that update failures are logged. | Test that update failures are logged. | async def test_update_failure(tempsensor, hass, config, caplog):
"""Test that update failures are logged."""
caplog.set_level(logging.ERROR)
feature_mock, entity_id = tempsensor
feature_mock.async_update = AsyncMock(side_effect=blebox_uniapi.error.ClientError)
await async_setup_entity(hass, config... | [
"async",
"def",
"test_update_failure",
"(",
"tempsensor",
",",
"hass",
",",
"config",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"feature_mock",
",",
"entity_id",
"=",
"tempsensor",
"feature_mock",
".",
"async_updat... | [
78,
0
] | [
87,
73
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the SignalMessenger notification service. | Get the SignalMessenger notification service. | def get_service(hass, config, discovery_info=None):
"""Get the SignalMessenger notification service."""
sender_nr = config[CONF_SENDER_NR]
recp_nrs = config[CONF_RECP_NR]
signal_cli_rest_api_url = config[CONF_SIGNAL_CLI_REST_API]
signal_cli_rest_api = SignalCliRestApi(signal_cli_rest_api_url, send... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"sender_nr",
"=",
"config",
"[",
"CONF_SENDER_NR",
"]",
"recp_nrs",
"=",
"config",
"[",
"CONF_RECP_NR",
"]",
"signal_cli_rest_api_url",
"=",
"config",
"[",
"CONF_SI... | [
30,
0
] | [
39,
67
] | 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.