Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_singleton | (mock_hass) | Test singleton with function. | Test singleton with function. | def test_singleton(mock_hass):
"""Test singleton with function."""
@singleton.singleton("test_key")
def something(hass):
return object()
result1 = something(mock_hass)
result2 = something(mock_hass)
assert result1 is result2
assert "test_key" in mock_hass.data
assert mock_hass.... | [
"def",
"test_singleton",
"(",
"mock_hass",
")",
":",
"@",
"singleton",
".",
"singleton",
"(",
"\"test_key\"",
")",
"def",
"something",
"(",
"hass",
")",
":",
"return",
"object",
"(",
")",
"result1",
"=",
"something",
"(",
"mock_hass",
")",
"result2",
"=",
... | [
28,
0
] | [
39,
48
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the RPi cover platform. | Set up the RPi cover platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the RPi cover platform."""
setup_reload_service(hass, DOMAIN, PLATFORMS)
relay_time = config.get(CONF_RELAY_TIME)
state_pull_mode = config.get(CONF_STATE_PULL_MODE)
invert_state = config.get(CONF_INVERT_STATE)
inver... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"relay_time",
"=",
"config",
".",
"get",
"(",
"CONF_RELAY_TIME",
... | [
49,
0
] | [
73,
24
] | python | en | ['en', 'da', 'en'] | True |
RPiGPIOCover.__init__ | (
self,
name,
relay_pin,
state_pin,
state_pull_mode,
relay_time,
invert_state,
invert_relay,
) | Initialize the cover. | Initialize the cover. | def __init__(
self,
name,
relay_pin,
state_pin,
state_pull_mode,
relay_time,
invert_state,
invert_relay,
):
"""Initialize the cover."""
self._name = name
self._state = False
self._relay_pin = relay_pin
self._stat... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"relay_pin",
",",
"state_pin",
",",
"state_pull_mode",
",",
"relay_time",
",",
"invert_state",
",",
"invert_relay",
",",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"False",
"... | [
79,
4
] | [
100,
78
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover.name | (self) | Return the name of the cover if any. | Return the name of the cover if any. | def name(self):
"""Return the name of the cover if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
103,
4
] | [
105,
25
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover.update | (self) | Update the state of the cover. | Update the state of the cover. | def update(self):
"""Update the state of the cover."""
self._state = rpi_gpio.read_input(self._state_pin) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"rpi_gpio",
".",
"read_input",
"(",
"self",
".",
"_state_pin",
")"
] | [
107,
4
] | [
109,
58
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover.is_closed | (self) | Return true if cover is closed. | Return true if cover is closed. | def is_closed(self):
"""Return true if cover is closed."""
return self._state != self._invert_state | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"!=",
"self",
".",
"_invert_state"
] | [
112,
4
] | [
114,
48
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover._trigger | (self) | Trigger the cover. | Trigger the cover. | def _trigger(self):
"""Trigger the cover."""
rpi_gpio.write_output(self._relay_pin, 1 if self._invert_relay else 0)
sleep(self._relay_time)
rpi_gpio.write_output(self._relay_pin, 0 if self._invert_relay else 1) | [
"def",
"_trigger",
"(",
"self",
")",
":",
"rpi_gpio",
".",
"write_output",
"(",
"self",
".",
"_relay_pin",
",",
"1",
"if",
"self",
".",
"_invert_relay",
"else",
"0",
")",
"sleep",
"(",
"self",
".",
"_relay_time",
")",
"rpi_gpio",
".",
"write_output",
"("... | [
116,
4
] | [
120,
78
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover.close_cover | (self, **kwargs) | Close the cover. | Close the cover. | def close_cover(self, **kwargs):
"""Close the cover."""
if not self.is_closed:
self._trigger() | [
"def",
"close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_closed",
":",
"self",
".",
"_trigger",
"(",
")"
] | [
122,
4
] | [
125,
27
] | python | en | ['en', 'en', 'en'] | True |
RPiGPIOCover.open_cover | (self, **kwargs) | Open the cover. | Open the cover. | def open_cover(self, **kwargs):
"""Open the cover."""
if self.is_closed:
self._trigger() | [
"def",
"open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_closed",
":",
"self",
".",
"_trigger",
"(",
")"
] | [
127,
4
] | [
130,
27
] | python | en | ['en', 'en', 'en'] | True |
convert_slow_tokenizer | (transformer_tokenizer) |
Utilities to convert a slow tokenizer instance in a fast tokenizer instance.
Args:
transformer_tokenizer (:class:`~transformers.tokenization_utils_base.PreTrainedTokenizer`):
Instance of a slow tokenizer to convert in the backend tokenizer for
:class:`~transformers.tokenization... |
Utilities to convert a slow tokenizer instance in a fast tokenizer instance. | def convert_slow_tokenizer(transformer_tokenizer) -> Tokenizer:
"""
Utilities to convert a slow tokenizer instance in a fast tokenizer instance.
Args:
transformer_tokenizer (:class:`~transformers.tokenization_utils_base.PreTrainedTokenizer`):
Instance of a slow tokenizer to convert in t... | [
"def",
"convert_slow_tokenizer",
"(",
"transformer_tokenizer",
")",
"->",
"Tokenizer",
":",
"tokenizer_class_name",
"=",
"transformer_tokenizer",
".",
"__class__",
".",
"__name__",
"if",
"tokenizer_class_name",
"not",
"in",
"SLOW_TO_FAST_CONVERTERS",
":",
"raise",
"ValueE... | [
683,
0
] | [
707,
61
] | python | en | ['en', 'error', 'th'] | False |
entity_sources | (hass: HomeAssistant) | Get the entity sources. | Get the entity sources. | def entity_sources(hass: HomeAssistant) -> Dict[str, Dict[str, str]]:
"""Get the entity sources."""
return hass.data.get(DATA_ENTITY_SOURCE, {}) | [
"def",
"entity_sources",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"return",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_ENTITY_SOURCE",
",",
"{",
"}",
")"
] | [
44,
0
] | [
46,
48
] | python | en | ['en', 'en', 'en'] | True |
generate_entity_id | (
entity_id_format: str,
name: Optional[str],
current_ids: Optional[List[str]] = None,
hass: Optional[HomeAssistant] = None,
) | Generate a unique entity ID based on given entity IDs or used IDs. | Generate a unique entity ID based on given entity IDs or used IDs. | def generate_entity_id(
entity_id_format: str,
name: Optional[str],
current_ids: Optional[List[str]] = None,
hass: Optional[HomeAssistant] = None,
) -> str:
"""Generate a unique entity ID based on given entity IDs or used IDs."""
return async_generate_entity_id(entity_id_format, name, current_id... | [
"def",
"generate_entity_id",
"(",
"entity_id_format",
":",
"str",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
",",
"current_ids",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"hass",
":",
"Optional",
"[",
"HomeAssistant",
"]",... | [
49,
0
] | [
56,
78
] | python | en | ['en', 'en', 'en'] | True |
async_generate_entity_id | (
entity_id_format: str,
name: Optional[str],
current_ids: Optional[Iterable[str]] = None,
hass: Optional[HomeAssistant] = None,
) | Generate a unique entity ID based on given entity IDs or used IDs. | Generate a unique entity ID based on given entity IDs or used IDs. | def async_generate_entity_id(
entity_id_format: str,
name: Optional[str],
current_ids: Optional[Iterable[str]] = None,
hass: Optional[HomeAssistant] = None,
) -> str:
"""Generate a unique entity ID based on given entity IDs or used IDs."""
name = (name or DEVICE_DEFAULT_NAME).lower()
prefer... | [
"def",
"async_generate_entity_id",
"(",
"entity_id_format",
":",
"str",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
",",
"current_ids",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"hass",
":",
"Optional",
"[",
"HomeAssistan... | [
60,
0
] | [
83,
22
] | python | en | ['en', 'en', 'en'] | True |
Entity.should_poll | (self) | Return True if entity has to be polled for state.
False if entity pushes its state to HA.
| Return True if entity has to be polled for state. | def should_poll(self) -> bool:
"""Return True if entity has to be polled for state.
False if entity pushes its state to HA.
"""
return True | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
126,
4
] | [
131,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
return None | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
134,
4
] | [
136,
19
] | python | ca | ['fr', 'ca', 'en'] | False |
Entity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> Optional[str]:
"""Return the name of the entity."""
return None | [
"def",
"name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
139,
4
] | [
141,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self) -> StateType:
"""Return the state of the entity."""
return STATE_UNKNOWN | [
"def",
"state",
"(",
"self",
")",
"->",
"StateType",
":",
"return",
"STATE_UNKNOWN"
] | [
144,
4
] | [
146,
28
] | python | en | ['en', 'en', 'en'] | True |
Entity.capability_attributes | (self) | Return the capability attributes.
Attributes that explain the capabilities of an entity.
Implemented by component base class. Convention for attribute names
is lowercase snake_case.
| Return the capability attributes. | def capability_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the capability attributes.
Attributes that explain the capabilities of an entity.
Implemented by component base class. Convention for attribute names
is lowercase snake_case.
"""
return None | [
"def",
"capability_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"None"
] | [
149,
4
] | [
157,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.state_attributes | (self) | Return the state attributes.
Implemented by component base class. Convention for attribute names
is lowercase snake_case.
| Return the state attributes. | def state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes.
Implemented by component base class. Convention for attribute names
is lowercase snake_case.
"""
return None | [
"def",
"state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"None"
] | [
160,
4
] | [
166,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.device_state_attributes | (self) | Return device specific state attributes.
Implemented by platform classes. Convention for attribute names
is lowercase snake_case.
| Return device specific state attributes. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return device specific state attributes.
Implemented by platform classes. Convention for attribute names
is lowercase snake_case.
"""
return None | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"None"
] | [
169,
4
] | [
175,
19
] | python | en | ['fr', 'en', 'en'] | True |
Entity.device_info | (self) | Return device specific attributes.
Implemented by platform classes.
| Return device specific attributes. | def device_info(self) -> Optional[Dict[str, Any]]:
"""Return device specific attributes.
Implemented by platform classes.
"""
return None | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"None"
] | [
178,
4
] | [
183,
19
] | python | en | ['fr', 'it', 'en'] | False |
Entity.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) -> Optional[str]:
"""Return the class of this device, from component DEVICE_CLASSES."""
return None | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
186,
4
] | [
188,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.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) -> Optional[str]:
"""Return the unit of measurement of this entity, if any."""
return None | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
191,
4
] | [
193,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self) -> Optional[str]:
"""Return the icon to use in the frontend, if any."""
return None | [
"def",
"icon",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
196,
4
] | [
198,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.entity_picture | (self) | Return the entity picture to use in the frontend, if any. | Return the entity picture to use in the frontend, if any. | def entity_picture(self) -> Optional[str]:
"""Return the entity picture to use in the frontend, if any."""
return None | [
"def",
"entity_picture",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"None"
] | [
201,
4
] | [
203,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.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 True | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
206,
4
] | [
208,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.assumed_state | (self) | Return True if unable to access real state of the entity. | Return True if unable to access real state of the entity. | def assumed_state(self) -> bool:
"""Return True if unable to access real state of the entity."""
return False | [
"def",
"assumed_state",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
211,
4
] | [
213,
20
] | python | en | ['en', 'en', 'en'] | True |
Entity.force_update | (self) | Return True if state updates should be forced.
If True, a state change will be triggered anytime the state property is
updated, not just when the value changes.
| Return True if state updates should be forced. | def force_update(self) -> bool:
"""Return True if state updates should be forced.
If True, a state change will be triggered anytime the state property is
updated, not just when the value changes.
"""
return False | [
"def",
"force_update",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
216,
4
] | [
222,
20
] | python | en | ['en', 'en', 'en'] | True |
Entity.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> Optional[int]:
"""Flag supported features."""
return None | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"None"
] | [
225,
4
] | [
227,
19
] | python | en | ['da', 'en', 'en'] | True |
Entity.context_recent_time | (self) | Time that a context is considered recent. | Time that a context is considered recent. | def context_recent_time(self) -> timedelta:
"""Time that a context is considered recent."""
return timedelta(seconds=5) | [
"def",
"context_recent_time",
"(",
"self",
")",
"->",
"timedelta",
":",
"return",
"timedelta",
"(",
"seconds",
"=",
"5",
")"
] | [
230,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
Entity.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return True | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
235,
4
] | [
237,
19
] | python | en | ['en', 'en', 'en'] | True |
Entity.enabled | (self) | Return if the entity is enabled in the entity registry.
If an entity is not part of the registry, it cannot be disabled
and will therefore always be enabled.
| Return if the entity is enabled in the entity registry. | def enabled(self) -> bool:
"""Return if the entity is enabled in the entity registry.
If an entity is not part of the registry, it cannot be disabled
and will therefore always be enabled.
"""
return self.registry_entry is None or not self.registry_entry.disabled | [
"def",
"enabled",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"registry_entry",
"is",
"None",
"or",
"not",
"self",
".",
"registry_entry",
".",
"disabled"
] | [
245,
4
] | [
251,
78
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_set_context | (self, context: Context) | Set the context the entity currently operates under. | Set the context the entity currently operates under. | def async_set_context(self, context: Context) -> None:
"""Set the context the entity currently operates under."""
self._context = context
self._context_set = dt_util.utcnow() | [
"def",
"async_set_context",
"(",
"self",
",",
"context",
":",
"Context",
")",
"->",
"None",
":",
"self",
".",
"_context",
"=",
"context",
"self",
".",
"_context_set",
"=",
"dt_util",
".",
"utcnow",
"(",
")"
] | [
254,
4
] | [
257,
44
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_update_ha_state | (self, force_refresh: bool = False) | Update Home Assistant with current state of entity.
If force_refresh == True will update entity before setting state.
This method must be run in the event loop.
| Update Home Assistant with current state of entity. | async def async_update_ha_state(self, force_refresh: bool = False) -> None:
"""Update Home Assistant with current state of entity.
If force_refresh == True will update entity before setting state.
This method must be run in the event loop.
"""
if self.hass is None:
... | [
"async",
"def",
"async_update_ha_state",
"(",
"self",
",",
"force_refresh",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"self",
".",
"hass",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"Attribute hass is None for {self}\"",
")",
"if",
"sel... | [
259,
4
] | [
282,
36
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_write_ha_state | (self) | Write the state to the state machine. | Write the state to the state machine. | def async_write_ha_state(self) -> None:
"""Write the state to the state machine."""
if self.hass is None:
raise RuntimeError(f"Attribute hass is None for {self}")
if self.entity_id is None:
raise NoEntitySpecifiedError(
f"No entity id specified for entity... | [
"def",
"async_write_ha_state",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"hass",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"Attribute hass is None for {self}\"",
")",
"if",
"self",
".",
"entity_id",
"is",
"None",
":",
"raise",
"NoEntity... | [
285,
4
] | [
295,
36
] | python | en | ['en', 'en', 'en'] | True |
Entity._async_write_ha_state | (self) | Write the state to the state machine. | Write the state to the state machine. | def _async_write_ha_state(self) -> None:
"""Write the state to the state machine."""
if self.registry_entry and self.registry_entry.disabled_by:
if not self._disabled_reported:
self._disabled_reported = True
assert self.platform is not None
_LO... | [
"def",
"_async_write_ha_state",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"registry_entry",
"and",
"self",
".",
"registry_entry",
".",
"disabled_by",
":",
"if",
"not",
"self",
".",
"_disabled_reported",
":",
"self",
".",
"_disabled_reported",
"="... | [
298,
4
] | [
409,
9
] | python | en | ['en', 'en', 'en'] | True |
Entity.schedule_update_ha_state | (self, force_refresh: bool = False) | Schedule an update ha state change task.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
task is executed.
If state is changed more than once before the ha state change task has
been executed, the intermediat... | Schedule an update ha state change task. | def schedule_update_ha_state(self, force_refresh: bool = False) -> None:
"""Schedule an update ha state change task.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
task is executed.
If state is changed more ... | [
"def",
"schedule_update_ha_state",
"(",
"self",
",",
"force_refresh",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"self",
".",
"hass",
".",
"add_job",
"(",
"self",
".",
"async_update_ha_state",
"("... | [
411,
4
] | [
422,
68
] | python | en | ['br', 'en', 'en'] | True |
Entity.async_schedule_update_ha_state | (self, force_refresh: bool = False) | Schedule an update ha state change task.
This method must be run in the event loop.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
task is executed.
If state is changed more than once before the ha state cha... | Schedule an update ha state change task. | def async_schedule_update_ha_state(self, force_refresh: bool = False) -> None:
"""Schedule an update ha state change task.
This method must be run in the event loop.
Scheduling the update avoids executor deadlocks.
Entity state and attributes are read when the update ha state change
... | [
"def",
"async_schedule_update_ha_state",
"(",
"self",
",",
"force_refresh",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"force_refresh",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"self",
".",
"hass",
".",
"async_create_task",
"(",... | [
425,
4
] | [
440,
39
] | python | en | ['br', 'en', 'en'] | True |
Entity.async_device_update | (self, warning: bool = True) | Process 'update' or 'async_update' from entity.
This method is a coroutine.
| Process 'update' or 'async_update' from entity. | async def async_device_update(self, warning: bool = True) -> None:
"""Process 'update' or 'async_update' from entity.
This method is a coroutine.
"""
if self._update_staged:
return
self._update_staged = True
# Process update sequential
if self.parall... | [
"async",
"def",
"async_device_update",
"(",
"self",
",",
"warning",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"if",
"self",
".",
"_update_staged",
":",
"return",
"self",
".",
"_update_staged",
"=",
"True",
"# Process update sequential",
"if",
"self",
... | [
442,
4
] | [
485,
47
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_on_remove | (self, func: CALLBACK_TYPE) | Add a function to call when entity removed. | Add a function to call when entity removed. | def async_on_remove(self, func: CALLBACK_TYPE) -> None:
"""Add a function to call when entity removed."""
if self._on_remove is None:
self._on_remove = []
self._on_remove.append(func) | [
"def",
"async_on_remove",
"(",
"self",
",",
"func",
":",
"CALLBACK_TYPE",
")",
"->",
"None",
":",
"if",
"self",
".",
"_on_remove",
"is",
"None",
":",
"self",
".",
"_on_remove",
"=",
"[",
"]",
"self",
".",
"_on_remove",
".",
"append",
"(",
"func",
")"
] | [
488,
4
] | [
492,
36
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_removed_from_registry | (self) | Run when entity has been removed from entity registry.
To be extended by integrations.
| Run when entity has been removed from entity registry. | async def async_removed_from_registry(self) -> None:
"""Run when entity has been removed from entity registry.
To be extended by integrations.
""" | [
"async",
"def",
"async_removed_from_registry",
"(",
"self",
")",
"->",
"None",
":"
] | [
494,
4
] | [
498,
11
] | python | en | ['en', 'en', 'en'] | True |
Entity.add_to_platform_start | (
self,
hass: HomeAssistant,
platform: EntityPlatform,
parallel_updates: Optional[asyncio.Semaphore],
) | Start adding an entity to a platform. | Start adding an entity to a platform. | def add_to_platform_start(
self,
hass: HomeAssistant,
platform: EntityPlatform,
parallel_updates: Optional[asyncio.Semaphore],
) -> None:
"""Start adding an entity to a platform."""
if self._added:
raise HomeAssistantError(
f"Entity {self.e... | [
"def",
"add_to_platform_start",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"platform",
":",
"EntityPlatform",
",",
"parallel_updates",
":",
"Optional",
"[",
"asyncio",
".",
"Semaphore",
"]",
",",
")",
"->",
"None",
":",
"if",
"self",
".",
"_added",... | [
501,
4
] | [
516,
26
] | python | en | ['en', 'lb', 'en'] | True |
Entity.add_to_platform_abort | (self) | Abort adding an entity to a platform. | Abort adding an entity to a platform. | def add_to_platform_abort(self) -> None:
"""Abort adding an entity to a platform."""
self.hass = None
self.platform = None
self.parallel_updates = None
self._added = False | [
"def",
"add_to_platform_abort",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"None",
"self",
".",
"platform",
"=",
"None",
"self",
".",
"parallel_updates",
"=",
"None",
"self",
".",
"_added",
"=",
"False"
] | [
519,
4
] | [
524,
27
] | python | en | ['en', 'cy', 'en'] | True |
Entity.add_to_platform_finish | (self) | Finish adding an entity to a platform. | Finish adding an entity to a platform. | async def add_to_platform_finish(self) -> None:
"""Finish adding an entity to a platform."""
await self.async_internal_added_to_hass()
await self.async_added_to_hass()
self.async_write_ha_state() | [
"async",
"def",
"add_to_platform_finish",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"async_internal_added_to_hass",
"(",
")",
"await",
"self",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
526,
4
] | [
530,
35
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_remove | (self) | Remove entity from Home Assistant. | Remove entity from Home Assistant. | async def async_remove(self) -> None:
"""Remove entity from Home Assistant."""
assert self.hass is not None
if self.platform and not self._added:
raise HomeAssistantError(
f"Entity {self.entity_id} async_remove called twice"
)
self._added = False... | [
"async",
"def",
"async_remove",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"if",
"self",
".",
"platform",
"and",
"not",
"self",
".",
"_added",
":",
"raise",
"HomeAssistantError",
"(",
"f\"Entity {self.entity_id} ... | [
532,
4
] | [
550,
76
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_added_to_hass | (self) | Run when entity about to be added to hass.
To be extended by integrations.
| Run when entity about to be added to hass. | async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass.
To be extended by integrations.
""" | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":"
] | [
552,
4
] | [
556,
11
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_will_remove_from_hass | (self) | Run when entity will be removed from hass.
To be extended by integrations.
| Run when entity will be removed from hass. | async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass.
To be extended by integrations.
""" | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":"
] | [
558,
4
] | [
562,
11
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_internal_added_to_hass | (self) | Run when entity about to be added to hass.
Not to be extended by integrations.
| Run when entity about to be added to hass. | async def async_internal_added_to_hass(self) -> None:
"""Run when entity about to be added to hass.
Not to be extended by integrations.
"""
assert self.hass is not None
if self.platform:
info = {"domain": self.platform.platform_name}
if self.platform.co... | [
"async",
"def",
"async_internal_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"if",
"self",
".",
"platform",
":",
"info",
"=",
"{",
"\"domain\"",
":",
"self",
".",
"platform",
".",
"platform_name",... | [
564,
4
] | [
592,
13
] | python | en | ['en', 'en', 'en'] | True |
Entity.async_internal_will_remove_from_hass | (self) | Run when entity will be removed from hass.
Not to be extended by integrations.
| Run when entity will be removed from hass. | async def async_internal_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass.
Not to be extended by integrations.
"""
if self.platform:
assert self.hass is not None
self.hass.data[DATA_ENTITY_SOURCE].pop(self.entity_id) | [
"async",
"def",
"async_internal_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"platform",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_ENTITY_SOURCE",
"]",
".",
"pop... | [
594,
4
] | [
601,
66
] | python | en | ['en', 'en', 'en'] | True |
Entity._async_registry_updated | (self, event: Event) | Handle entity registry update. | Handle entity registry update. | async def _async_registry_updated(self, event: Event) -> None:
"""Handle entity registry update."""
data = event.data
if data["action"] == "remove":
await self.async_removed_from_registry()
await self.async_remove()
if data["action"] != "update":
retu... | [
"async",
"def",
"_async_registry_updated",
"(",
"self",
",",
"event",
":",
"Event",
")",
"->",
"None",
":",
"data",
"=",
"event",
".",
"data",
"if",
"data",
"[",
"\"action\"",
"]",
"==",
"\"remove\"",
":",
"await",
"self",
".",
"async_removed_from_registry",... | [
603,
4
] | [
632,
54
] | python | en | ['en', 'af', 'en'] | True |
Entity.__eq__ | (self, other: Any) | Return the comparison. | Return the comparison. | def __eq__(self, other: Any) -> bool:
"""Return the comparison."""
if not isinstance(other, self.__class__):
return False
# Can only decide equality if both have a unique id
if self.unique_id is None or other.unique_id is None:
return False
# Ensure they... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
":",
"Any",
")",
"->",
"bool",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"return",
"False",
"# Can only decide equality if both have a unique id",
"if",
"self",
".",
"un... | [
634,
4
] | [
651,
48
] | python | en | ['en', 'it', 'en'] | True |
Entity.__repr__ | (self) | Return the representation. | Return the representation. | def __repr__(self) -> str:
"""Return the representation."""
return f"<Entity {self.name}: {self.state}>" | [
"def",
"__repr__",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"<Entity {self.name}: {self.state}>\""
] | [
653,
4
] | [
655,
52
] | python | en | ['en', 'id', 'en'] | True |
Entity.async_request_call | (self, coro: Awaitable) | Process request batched. | Process request batched. | async def async_request_call(self, coro: Awaitable) -> None:
"""Process request batched."""
if self.parallel_updates:
await self.parallel_updates.acquire()
try:
await coro
finally:
if self.parallel_updates:
self.parallel_updates.releas... | [
"async",
"def",
"async_request_call",
"(",
"self",
",",
"coro",
":",
"Awaitable",
")",
"->",
"None",
":",
"if",
"self",
".",
"parallel_updates",
":",
"await",
"self",
".",
"parallel_updates",
".",
"acquire",
"(",
")",
"try",
":",
"await",
"coro",
"finally"... | [
657,
4
] | [
666,
47
] | python | en | ['en', 'fr', 'en'] | True |
ToggleEntity.state | (self) | Return the state. | Return the state. | def state(self) -> str:
"""Return the state."""
return STATE_ON if self.is_on else STATE_OFF | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"return",
"STATE_ON",
"if",
"self",
".",
"is_on",
"else",
"STATE_OFF"
] | [
673,
4
] | [
675,
52
] | python | en | ['en', 'en', 'en'] | True |
ToggleEntity.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self) -> bool:
"""Return True if entity is on."""
raise NotImplementedError() | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
678,
4
] | [
680,
35
] | python | en | ['en', 'cy', 'en'] | True |
ToggleEntity.turn_on | (self, **kwargs: Any) | Turn the entity on. | Turn the entity on. | def turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
raise NotImplementedError() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
682,
4
] | [
684,
35
] | python | en | ['en', 'en', 'en'] | True |
ToggleEntity.async_turn_on | (self, **kwargs: Any) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
assert self.hass is not None
await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs)) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
... | [
686,
4
] | [
689,
82
] | python | en | ['en', 'en', 'en'] | True |
ToggleEntity.turn_off | (self, **kwargs: Any) | Turn the entity off. | Turn the entity off. | def turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
raise NotImplementedError() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
691,
4
] | [
693,
35
] | python | en | ['en', 'en', 'en'] | True |
ToggleEntity.async_turn_off | (self, **kwargs: Any) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
assert self.hass is not None
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs)) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",... | [
695,
4
] | [
698,
83
] | python | en | ['en', 'en', 'en'] | True |
ToggleEntity.toggle | (self, **kwargs: Any) | Toggle the entity. | Toggle the entity. | def toggle(self, **kwargs: Any) -> None:
"""Toggle the entity."""
if self.is_on:
self.turn_off(**kwargs)
else:
self.turn_on(**kwargs) | [
"def",
"toggle",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"is_on",
":",
"self",
".",
"turn_off",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"self",
".",
"turn_on",
"(",
"*",
"*",
"kwargs",
")"... | [
700,
4
] | [
705,
34
] | python | en | ['en', 'sm', 'en'] | True |
ToggleEntity.async_toggle | (self, **kwargs: Any) | Toggle the entity. | Toggle the entity. | async def async_toggle(self, **kwargs: Any) -> None:
"""Toggle the entity."""
if self.is_on:
await self.async_turn_off(**kwargs)
else:
await self.async_turn_on(**kwargs) | [
"async",
"def",
"async_toggle",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"is_on",
":",
"await",
"self",
".",
"async_turn_off",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"await",
"self",
".",
"asy... | [
707,
4
] | [
712,
46
] | python | en | ['en', 'sm', 'en'] | True |
main | () | Main Function | Main Function | def main():
'''Main Function'''
parser = argparse.ArgumentParser(description='translate.py')
parser.add_argument('-model', required=True,
help='Path to model weight file')
parser.add_argument('-data_pkl', required=True,
help='Pickle file with both instan... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'translate.py'",
")",
"parser",
".",
"add_argument",
"(",
"'-model'",
",",
"required",
"=",
"True",
",",
"help",
"=",
"'Path to model weight file'",
")",
... | [
41,
0
] | [
102,
29
] | python | en | ['en', 'ja', 'en'] | False |
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, SWITCH_DOMAIN, {SWITCH_DOMAIN: {"platform": HMIPC_DOMAIN}}
)
assert not hass.data.get(HMIPC_DOMAIN) | [
"async",
"def",
"test_manually_configured_platform",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SWITCH_DOMAIN",
",",
"{",
"SWITCH_DOMAIN",
":",
"{",
"\"platform\"",
":",
"HMIPC_DOMAIN",
"}",
"}",
")",
"assert",
"not",
"... | [
16,
0
] | [
21,
42
] | python | en | ['en', 'en', 'en'] | True |
test_hmip_switch | (hass, default_mock_hap_factory) | Test HomematicipSwitch. | Test HomematicipSwitch. | async def test_hmip_switch(hass, default_mock_hap_factory):
"""Test HomematicipSwitch."""
entity_id = "switch.schrank"
entity_name = "Schrank"
device_model = "HMIP-PS"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip_device = ... | [
"async",
"def",
"test_hmip_switch",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.schrank\"",
"entity_name",
"=",
"\"Schrank\"",
"device_model",
"=",
"\"HMIP-PS\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_g... | [
24,
0
] | [
58,
37
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_switch_input | (hass, default_mock_hap_factory) | Test HomematicipSwitch. | Test HomematicipSwitch. | async def test_hmip_switch_input(hass, default_mock_hap_factory):
"""Test HomematicipSwitch."""
entity_id = "switch.wohnzimmer_beleuchtung"
entity_name = "Wohnzimmer Beleuchtung"
device_model = "HmIP-FSI16"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_na... | [
"async",
"def",
"test_hmip_switch_input",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.wohnzimmer_beleuchtung\"",
"entity_name",
"=",
"\"Wohnzimmer Beleuchtung\"",
"device_model",
"=",
"\"HmIP-FSI16\"",
"mock_hap",
"=",
"await",
"defau... | [
61,
0
] | [
95,
37
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_switch_measuring | (hass, default_mock_hap_factory) | Test HomematicipSwitchMeasuring. | Test HomematicipSwitchMeasuring. | async def test_hmip_switch_measuring(hass, default_mock_hap_factory):
"""Test HomematicipSwitchMeasuring."""
entity_id = "switch.pc"
entity_name = "Pc"
device_model = "HMIP-PSM"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_state, hmip... | [
"async",
"def",
"test_hmip_switch_measuring",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.pc\"",
"entity_name",
"=",
"\"Pc\"",
"device_model",
"=",
"\"HMIP-PSM\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_... | [
98,
0
] | [
139,
61
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_group_switch | (hass, default_mock_hap_factory) | Test HomematicipGroupSwitch. | Test HomematicipGroupSwitch. | async def test_hmip_group_switch(hass, default_mock_hap_factory):
"""Test HomematicipGroupSwitch."""
entity_id = "switch.strom_group"
entity_name = "Strom Group"
device_model = None
mock_hap = await default_mock_hap_factory.async_get_mock_hap(test_groups=["Strom"])
ha_state, hmip_device = get_a... | [
"async",
"def",
"test_hmip_group_switch",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.strom_group\"",
"entity_name",
"=",
"\"Strom Group\"",
"device_model",
"=",
"None",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"... | [
142,
0
] | [
179,
61
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_multi_switch | (hass, default_mock_hap_factory) | Test HomematicipMultiSwitch. | Test HomematicipMultiSwitch. | async def test_hmip_multi_switch(hass, default_mock_hap_factory):
"""Test HomematicipMultiSwitch."""
entity_id = "switch.jalousien_1_kizi_2_schlazi_channel1"
entity_name = "Jalousien - 1 KiZi, 2 SchlaZi Channel1"
device_model = "HmIP-PCBS2"
mock_hap = await default_mock_hap_factory.async_get_mock_ha... | [
"async",
"def",
"test_hmip_multi_switch",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.jalousien_1_kizi_2_schlazi_channel1\"",
"entity_name",
"=",
"\"Jalousien - 1 KiZi, 2 SchlaZi Channel1\"",
"device_model",
"=",
"\"HmIP-PCBS2\"",
"mock_hap... | [
182,
0
] | [
221,
38
] | python | en | ['en', 'en', 'en'] | False |
test_hmip_wired_multi_switch | (hass, default_mock_hap_factory) | Test HomematicipMultiSwitch. | Test HomematicipMultiSwitch. | async def test_hmip_wired_multi_switch(hass, default_mock_hap_factory):
"""Test HomematicipMultiSwitch."""
entity_id = "switch.fernseher_wohnzimmer"
entity_name = "Fernseher (Wohnzimmer)"
device_model = "HmIPW-DRS8"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[... | [
"async",
"def",
"test_hmip_wired_multi_switch",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"switch.fernseher_wohnzimmer\"",
"entity_name",
"=",
"\"Fernseher (Wohnzimmer)\"",
"device_model",
"=",
"\"HmIPW-DRS8\"",
"mock_hap",
"=",
"await",
"d... | [
224,
0
] | [
260,
37
] | python | en | ['en', 'en', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Waze travel time sensor platform. | Set up the Waze travel time sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Waze travel time sensor platform."""
destination = config.get(CONF_DESTINATION)
name = config.get(CONF_NAME)
origin = config.get(CONF_ORIGIN)
region = config.get(CONF_REGION)
incl_filter = config.get(CONF_INCL_FIL... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"destination",
"=",
"config",
".",
"get",
"(",
"CONF_DESTINATION",
")",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"origi... | [
85,
0
] | [
119,
78
] | python | en | ['en', 'pt', 'en'] | True |
_get_location_from_attributes | (state) | Get the lat/long string from an states attributes. | Get the lat/long string from an states attributes. | def _get_location_from_attributes(state):
"""Get the lat/long string from an states attributes."""
attr = state.attributes
return "{},{}".format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)) | [
"def",
"_get_location_from_attributes",
"(",
"state",
")",
":",
"attr",
"=",
"state",
".",
"attributes",
"return",
"\"{},{}\"",
".",
"format",
"(",
"attr",
".",
"get",
"(",
"ATTR_LATITUDE",
")",
",",
"attr",
".",
"get",
"(",
"ATTR_LONGITUDE",
")",
")"
] | [
122,
0
] | [
125,
76
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime.__init__ | (self, name, origin, destination, waze_data) | Initialize the Waze travel time sensor. | Initialize the Waze travel time sensor. | def __init__(self, name, origin, destination, waze_data):
"""Initialize the Waze travel time sensor."""
self._name = name
self._waze_data = waze_data
self._state = None
self._origin_entity_id = None
self._destination_entity_id = None
# Attempt to find entity_id w... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"origin",
",",
"destination",
",",
"waze_data",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_waze_data",
"=",
"waze_data",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_origin_entity_i... | [
131,
4
] | [
152,
53
] | python | en | ['en', 'pt', 'en'] | True |
WazeTravelTime.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
155,
4
] | [
157,
25
] | python | en | ['en', 'mi', 'en'] | True |
WazeTravelTime.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self._waze_data.duration is not None:
return round(self._waze_data.duration)
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_waze_data",
".",
"duration",
"is",
"not",
"None",
":",
"return",
"round",
"(",
"self",
".",
"_waze_data",
".",
"duration",
")",
"return",
"None"
] | [
160,
4
] | [
165,
19
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime.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 TIME_MINUTES | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"TIME_MINUTES"
] | [
168,
4
] | [
170,
27
] | python | en | ['en', 'la', 'en'] | True |
WazeTravelTime.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
173,
4
] | [
175,
19
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime.device_state_attributes | (self) | Return the state attributes of the last update. | Return the state attributes of the last update. | def device_state_attributes(self):
"""Return the state attributes of the last update."""
if self._waze_data.duration is None:
return None
res = {ATTR_ATTRIBUTION: ATTRIBUTION}
res[ATTR_DURATION] = self._waze_data.duration
res[ATTR_DISTANCE] = self._waze_data.distance... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_waze_data",
".",
"duration",
"is",
"None",
":",
"return",
"None",
"res",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}",
"res",
"[",
"ATTR_DURATION",
"]",
"=",
"self",
"."... | [
178,
4
] | [
189,
18
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime._get_location_from_entity | (self, entity_id) | Get the location from the entity_id. | Get the location from the entity_id. | def _get_location_from_entity(self, entity_id):
"""Get the location from the entity_id."""
state = self.hass.states.get(entity_id)
if state is None:
_LOGGER.error("Unable to find entity %s", entity_id)
return None
# Check if the entity has location attributes.
... | [
"def",
"_get_location_from_entity",
"(",
"self",
",",
"entity_id",
")",
":",
"state",
"=",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"if",
"state",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"Unable to find entity %s\"",
... | [
191,
4
] | [
217,
19
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime._resolve_zone | (self, friendly_name) | Get a lat/long from a zones friendly_name. | Get a lat/long from a zones friendly_name. | def _resolve_zone(self, friendly_name):
"""Get a lat/long from a zones friendly_name."""
states = self.hass.states.all()
for state in states:
if state.domain == "zone" and state.name == friendly_name:
return _get_location_from_attributes(state)
return friendl... | [
"def",
"_resolve_zone",
"(",
"self",
",",
"friendly_name",
")",
":",
"states",
"=",
"self",
".",
"hass",
".",
"states",
".",
"all",
"(",
")",
"for",
"state",
"in",
"states",
":",
"if",
"state",
".",
"domain",
"==",
"\"zone\"",
"and",
"state",
".",
"n... | [
219,
4
] | [
226,
28
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTime.update | (self) | Fetch new state data for the sensor. | Fetch new state data for the sensor. | def update(self):
"""Fetch new state data for the sensor."""
_LOGGER.debug("Fetching Route for %s", self._name)
# Get origin latitude and longitude from entity_id.
if self._origin_entity_id is not None:
self._waze_data.origin = self._get_location_from_entity(
... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching Route for %s\"",
",",
"self",
".",
"_name",
")",
"# Get origin latitude and longitude from entity_id.",
"if",
"self",
".",
"_origin_entity_id",
"is",
"not",
"None",
":",
"self",
".",... | [
228,
4
] | [
249,
32
] | python | en | ['en', 'en', 'en'] | True |
WazeTravelTimeData.__init__ | (
self,
origin,
destination,
region,
include,
exclude,
realtime,
units,
vehicle_type,
avoid_toll_roads,
avoid_subscription_roads,
avoid_ferries,
) | Set up WazeRouteCalculator. | Set up WazeRouteCalculator. | def __init__(
self,
origin,
destination,
region,
include,
exclude,
realtime,
units,
vehicle_type,
avoid_toll_roads,
avoid_subscription_roads,
avoid_ferries,
):
"""Set up WazeRouteCalculator."""
self._cal... | [
"def",
"__init__",
"(",
"self",
",",
"origin",
",",
"destination",
",",
"region",
",",
"include",
",",
"exclude",
",",
"realtime",
",",
"units",
",",
"vehicle_type",
",",
"avoid_toll_roads",
",",
"avoid_subscription_roads",
",",
"avoid_ferries",
",",
")",
":",... | [
255,
4
] | [
292,
52
] | python | en | ['en', 'ny', 'it'] | False |
WazeTravelTimeData.update | (self) | Update WazeRouteCalculator Sensor. | Update WazeRouteCalculator Sensor. | def update(self):
"""Update WazeRouteCalculator Sensor."""
if self.origin is not None and self.destination is not None:
try:
params = self._calc.WazeRouteCalculator(
self.origin,
self.destination,
self.region,
... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"origin",
"is",
"not",
"None",
"and",
"self",
".",
"destination",
"is",
"not",
"None",
":",
"try",
":",
"params",
"=",
"self",
".",
"_calc",
".",
"WazeRouteCalculator",
"(",
"self",
".",
"ori... | [
294,
4
] | [
339,
22
] | python | en | ['en', 'eu', 'it'] | False |
test_setup_loads_platforms | (hass) | Test the loading of the platforms. | Test the loading of the platforms. | async def test_setup_loads_platforms(hass):
"""Test the loading of the platforms."""
component_setup = Mock(return_value=True)
platform_setup = Mock(return_value=None)
mock_integration(hass, MockModule("test_component", setup=component_setup))
# mock the dependencies
mock_integration(hass, Mock... | [
"async",
"def",
"test_setup_loads_platforms",
"(",
"hass",
")",
":",
"component_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"True",
")",
"platform_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"None",
")",
"mock_integration",
"(",
"hass",
",",
"MockModule",
... | [
32,
0
] | [
51,
32
] | python | en | ['en', 'en', 'en'] | True |
test_setup_recovers_when_setup_raises | (hass) | Test the setup if exceptions are happening. | Test the setup if exceptions are happening. | async def test_setup_recovers_when_setup_raises(hass):
"""Test the setup if exceptions are happening."""
platform1_setup = Mock(side_effect=Exception("Broken"))
platform2_setup = Mock(return_value=None)
mock_entity_platform(hass, "test_domain.mod1", MockPlatform(platform1_setup))
mock_entity_platfo... | [
"async",
"def",
"test_setup_recovers_when_setup_raises",
"(",
"hass",
")",
":",
"platform1_setup",
"=",
"Mock",
"(",
"side_effect",
"=",
"Exception",
"(",
"\"Broken\"",
")",
")",
"platform2_setup",
"=",
"Mock",
"(",
"return_value",
"=",
"None",
")",
"mock_entity_p... | [
54,
0
] | [
79,
33
] | python | en | ['en', 'en', 'en'] | True |
test_setup_does_discovery | (mock_setup_component, mock_setup, hass) | Test setup for discovery. | Test setup for discovery. | async def test_setup_does_discovery(mock_setup_component, mock_setup, hass):
"""Test setup for discovery."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
component.setup({})
discovery.load_platform(
hass, DOMAIN, "platform_test", {"msg": "discovery_info"}, {DOMAIN: {}}
)
await h... | [
"async",
"def",
"test_setup_does_discovery",
"(",
"mock_setup_component",
",",
"mock_setup",
",",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"component",
".",
"setup",
"(",
"{",
"}",
")",
"discovery"... | [
86,
0
] | [
99,
86
] | python | en | ['en', 'en', 'en'] | True |
test_set_scan_interval_via_config | (mock_track, hass) | Test the setting of the scan interval via configuration. | Test the setting of the scan interval via configuration. | async def test_set_scan_interval_via_config(mock_track, hass):
"""Test the setting of the scan interval via configuration."""
def platform_setup(hass, config, add_entities, discovery_info=None):
"""Test the platform setup."""
add_entities([MockEntity(should_poll=True)])
mock_entity_platfor... | [
"async",
"def",
"test_set_scan_interval_via_config",
"(",
"mock_track",
",",
"hass",
")",
":",
"def",
"platform_setup",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"\"\"\"Test the platform setup.\"\"\"",
"add_entities... | [
103,
0
] | [
120,
62
] | python | en | ['en', 'en', 'en'] | True |
test_set_entity_namespace_via_config | (hass) | Test setting an entity namespace. | Test setting an entity namespace. | async def test_set_entity_namespace_via_config(hass):
"""Test setting an entity namespace."""
def platform_setup(hass, config, add_entities, discovery_info=None):
"""Test the platform setup."""
add_entities([MockEntity(name="beer"), MockEntity(name=None)])
platform = MockPlatform(platform_... | [
"async",
"def",
"test_set_entity_namespace_via_config",
"(",
"hass",
")",
":",
"def",
"platform_setup",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"\"\"\"Test the platform setup.\"\"\"",
"add_entities",
"(",
"[",
"... | [
123,
0
] | [
143,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_available_device | (hass) | Test the extraction of entity from service and device is available. | Test the extraction of entity from service and device is available. | async def test_extract_from_service_available_device(hass):
"""Test the extraction of entity from service and device is available."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
await component.async_add_entities(
[
MockEntity(name="test_1"),
MockEntity(name="test_2", ... | [
"async",
"def",
"test_extract_from_service_available_device",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"await",
"component",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"name",
"=",
... | [
146,
0
] | [
172,
5
] | python | en | ['en', 'en', 'en'] | True |
test_platform_not_ready | (hass, legacy_patchable_time) | Test that we retry when platform not ready. | Test that we retry when platform not ready. | async def test_platform_not_ready(hass, legacy_patchable_time):
"""Test that we retry when platform not ready."""
platform1_setup = Mock(side_effect=[PlatformNotReady, PlatformNotReady, None])
mock_integration(hass, MockModule("mod1"))
mock_entity_platform(hass, "test_domain.mod1", MockPlatform(platform... | [
"async",
"def",
"test_platform_not_ready",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"platform1_setup",
"=",
"Mock",
"(",
"side_effect",
"=",
"[",
"PlatformNotReady",
",",
"PlatformNotReady",
",",
"None",
"]",
")",
"mock_integration",
"(",
"hass",
",",
... | [
175,
0
] | [
211,
59
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_fails_if_no_entity_id | (hass) | Test the extraction of everything from service. | Test the extraction of everything from service. | async def test_extract_from_service_fails_if_no_entity_id(hass):
"""Test the extraction of everything from service."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
await component.async_add_entities(
[MockEntity(name="test_1"), MockEntity(name="test_2")]
)
assert (
await compo... | [
"async",
"def",
"test_extract_from_service_fails_if_no_entity_id",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"await",
"component",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"name",
"=... | [
214,
0
] | [
236,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_filter_out_non_existing_entities | (hass) | Test the extraction of non existing entities from service. | Test the extraction of non existing entities from service. | async def test_extract_from_service_filter_out_non_existing_entities(hass):
"""Test the extraction of non existing entities from service."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
await component.async_add_entities(
[MockEntity(name="test_1"), MockEntity(name="test_2")]
)
call =... | [
"async",
"def",
"test_extract_from_service_filter_out_non_existing_entities",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"await",
"component",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"... | [
239,
0
] | [
254,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_no_group_expand | (hass) | Test not expanding a group. | Test not expanding a group. | async def test_extract_from_service_no_group_expand(hass):
"""Test not expanding a group."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
await component.async_add_entities([MockEntity(entity_id="group.test_group")])
call = ha.ServiceCall("test", "service", {"entity_id": ["group.test_group"]})
... | [
"async",
"def",
"test_extract_from_service_no_group_expand",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"await",
"component",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"entity_id",
"="... | [
257,
0
] | [
266,
55
] | python | en | ['en', 'en', 'en'] | True |
test_setup_dependencies_platform | (hass) | Test we setup the dependencies of a platform.
We're explicitly testing that we process dependencies even if a component
with the same name has already been loaded.
| Test we setup the dependencies of a platform. | async def test_setup_dependencies_platform(hass):
"""Test we setup the dependencies of a platform.
We're explicitly testing that we process dependencies even if a component
with the same name has already been loaded.
"""
mock_integration(
hass, MockModule("test_component", dependencies=["te... | [
"async",
"def",
"test_setup_dependencies_platform",
"(",
"hass",
")",
":",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"\"test_component\"",
",",
"dependencies",
"=",
"[",
"\"test_component2\"",
"]",
")",
")",
"mock_integration",
"(",
"hass",
",",
"Mo... | [
269,
0
] | [
287,
65
] | python | en | ['en', 'da', 'en'] | True |
test_setup_entry | (hass) | Test setup entry calls async_setup_entry on platform. | Test setup entry calls async_setup_entry on platform. | async def test_setup_entry(hass):
"""Test setup entry calls async_setup_entry on platform."""
mock_setup_entry = AsyncMock(return_value=True)
mock_entity_platform(
hass,
"test_domain.entry_domain",
MockPlatform(
async_setup_entry=mock_setup_entry, scan_interval=timedelta(... | [
"async",
"def",
"test_setup_entry",
"(",
"hass",
")",
":",
"mock_setup_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_entity_platform",
"(",
"hass",
",",
"\"test_domain.entry_domain\"",
",",
"MockPlatform",
"(",
"async_setup_entry",
"=",
"moc... | [
290,
0
] | [
310,
85
] | python | en | ['en', 'da', 'en'] | True |
test_setup_entry_platform_not_exist | (hass) | Test setup entry fails if platform does not exist. | Test setup entry fails if platform does not exist. | async def test_setup_entry_platform_not_exist(hass):
"""Test setup entry fails if platform does not exist."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
entry = MockConfigEntry(domain="non_existing")
assert (await component.async_setup_entry(entry)) is False | [
"async",
"def",
"test_setup_entry_platform_not_exist",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"non_existing\"",
")",
"assert",
"(",
"awai... | [
313,
0
] | [
318,
62
] | python | en | ['en', 'da', 'en'] | True |
test_setup_entry_fails_duplicate | (hass) | Test we don't allow setting up a config entry twice. | Test we don't allow setting up a config entry twice. | async def test_setup_entry_fails_duplicate(hass):
"""Test we don't allow setting up a config entry twice."""
mock_setup_entry = AsyncMock(return_value=True)
mock_entity_platform(
hass,
"test_domain.entry_domain",
MockPlatform(async_setup_entry=mock_setup_entry),
)
component ... | [
"async",
"def",
"test_setup_entry_fails_duplicate",
"(",
"hass",
")",
":",
"mock_setup_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_entity_platform",
"(",
"hass",
",",
"\"test_domain.entry_domain\"",
",",
"MockPlatform",
"(",
"async_setup_entry... | [
321,
0
] | [
336,
48
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry_resets_platform | (hass) | Test unloading an entry removes all entities. | Test unloading an entry removes all entities. | async def test_unload_entry_resets_platform(hass):
"""Test unloading an entry removes all entities."""
mock_setup_entry = AsyncMock(return_value=True)
mock_entity_platform(
hass,
"test_domain.entry_domain",
MockPlatform(async_setup_entry=mock_setup_entry),
)
component = Enti... | [
"async",
"def",
"test_unload_entry_resets_platform",
"(",
"hass",
")",
":",
"mock_setup_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_entity_platform",
"(",
"hass",
",",
"\"test_domain.entry_domain\"",
",",
"MockPlatform",
"(",
"async_setup_entr... | [
339,
0
] | [
360,
51
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity | (hass) | Test that we can update an entity with the helper. | Test that we can update an entity with the helper. | async def test_update_entity(hass):
"""Test that we can update an entity with the helper."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
entity = MockEntity()
entity.async_write_ha_state = Mock()
entity.async_update_ha_state = AsyncMock(return_value=None)
await component.async_add_entitie... | [
"async",
"def",
"test_update_entity",
"(",
"hass",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"entity",
"=",
"MockEntity",
"(",
")",
"entity",
".",
"async_write_ha_state",
"=",
"Mock",
"(",
")",
"entity",
... | [
372,
0
] | [
386,
68
] | python | en | ['en', 'en', 'en'] | True |
test_set_service_race | (hass) | Test race condition on setting service. | Test race condition on setting service. | async def test_set_service_race(hass):
"""Test race condition on setting service."""
exception = False
def async_loop_exception_handler(_, _2) -> None:
"""Handle all exception inside the core loop."""
nonlocal exception
exception = True
hass.loop.set_exception_handler(async_loo... | [
"async",
"def",
"test_set_service_race",
"(",
"hass",
")",
":",
"exception",
"=",
"False",
"def",
"async_loop_exception_handler",
"(",
"_",
",",
"_2",
")",
"->",
"None",
":",
"\"\"\"Handle all exception inside the core loop.\"\"\"",
"nonlocal",
"exception",
"exception",... | [
389,
0
] | [
407,
24
] | python | en | ['en', 'en', 'en'] | True |
test_extract_all_omit_entity_id | (hass, caplog) | Test extract all with None and *. | Test extract all with None and *. | async def test_extract_all_omit_entity_id(hass, caplog):
"""Test extract all with None and *."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
await component.async_add_entities(
[MockEntity(name="test_1"), MockEntity(name="test_2")]
)
call = ha.ServiceCall("test", "service")
asse... | [
"async",
"def",
"test_extract_all_omit_entity_id",
"(",
"hass",
",",
"caplog",
")",
":",
"component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"await",
"component",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"name",
... | [
410,
0
] | [
421,
5
] | 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.