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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
State.__eq__ | (self, other: Any) | Return the comparison of the state. | Return the comparison of the state. | def __eq__(self, other: Any) -> bool:
"""Return the comparison of the state."""
return ( # type: ignore
self.__class__ == other.__class__
and self.entity_id == other.entity_id
and self.state == other.state
and self.attributes == other.attributes
... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
":",
"Any",
")",
"->",
"bool",
":",
"return",
"(",
"# type: ignore",
"self",
".",
"__class__",
"==",
"other",
".",
"__class__",
"and",
"self",
".",
"entity_id",
"==",
"other",
".",
"entity_id",
"and",
"self",
... | [
941,
4
] | [
949,
9
] | python | en | ['en', 'en', 'en'] | True |
State.__repr__ | (self) | Return the representation of the states. | Return the representation of the states. | def __repr__(self) -> str:
"""Return the representation of the states."""
attrs = f"; {util.repr_helper(self.attributes)}" if self.attributes else ""
return (
f"<state {self.entity_id}={self.state}{attrs}"
f" @ {dt_util.as_local(self.last_changed).isoformat()}>"
... | [
"def",
"__repr__",
"(",
"self",
")",
"->",
"str",
":",
"attrs",
"=",
"f\"; {util.repr_helper(self.attributes)}\"",
"if",
"self",
".",
"attributes",
"else",
"\"\"",
"return",
"(",
"f\"<state {self.entity_id}={self.state}{attrs}\"",
"f\" @ {dt_util.as_local(self.last_changed).i... | [
951,
4
] | [
958,
9
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.__init__ | (self, bus: EventBus, loop: asyncio.events.AbstractEventLoop) | Initialize state machine. | Initialize state machine. | def __init__(self, bus: EventBus, loop: asyncio.events.AbstractEventLoop) -> None:
"""Initialize state machine."""
self._states: Dict[str, State] = {}
self._reservations: Set[str] = set()
self._bus = bus
self._loop = loop | [
"def",
"__init__",
"(",
"self",
",",
"bus",
":",
"EventBus",
",",
"loop",
":",
"asyncio",
".",
"events",
".",
"AbstractEventLoop",
")",
"->",
"None",
":",
"self",
".",
"_states",
":",
"Dict",
"[",
"str",
",",
"State",
"]",
"=",
"{",
"}",
"self",
".... | [
964,
4
] | [
969,
25
] | python | en | ['en', 'co', 'en'] | True |
StateMachine.entity_ids | (self, domain_filter: Optional[str] = None) | List of entity ids that are being tracked. | List of entity ids that are being tracked. | def entity_ids(self, domain_filter: Optional[str] = None) -> List[str]:
"""List of entity ids that are being tracked."""
future = run_callback_threadsafe(
self._loop, self.async_entity_ids, domain_filter
)
return future.result() | [
"def",
"entity_ids",
"(",
"self",
",",
"domain_filter",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"str",
"]",
":",
"future",
"=",
"run_callback_threadsafe",
"(",
"self",
".",
"_loop",
",",
"self",
".",
"async_entity_ids",
","... | [
971,
4
] | [
976,
30
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_entity_ids | (
self, domain_filter: Optional[Union[str, Iterable]] = None
) | List of entity ids that are being tracked.
This method must be run in the event loop.
| List of entity ids that are being tracked. | def async_entity_ids(
self, domain_filter: Optional[Union[str, Iterable]] = None
) -> List[str]:
"""List of entity ids that are being tracked.
This method must be run in the event loop.
"""
if domain_filter is None:
return list(self._states)
if isinstanc... | [
"def",
"async_entity_ids",
"(",
"self",
",",
"domain_filter",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"domain_filter",
"is",
"None",
":",
"return",
"list",
"(",
... | [
979,
4
] | [
996,
9
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_entity_ids_count | (
self, domain_filter: Optional[Union[str, Iterable]] = None
) | Count the entity ids that are being tracked.
This method must be run in the event loop.
| Count the entity ids that are being tracked. | def async_entity_ids_count(
self, domain_filter: Optional[Union[str, Iterable]] = None
) -> int:
"""Count the entity ids that are being tracked.
This method must be run in the event loop.
"""
if domain_filter is None:
return len(self._states)
if isinstan... | [
"def",
"async_entity_ids_count",
"(",
"self",
",",
"domain_filter",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"]",
"]",
"=",
"None",
")",
"->",
"int",
":",
"if",
"domain_filter",
"is",
"None",
":",
"return",
"len",
"(",
"self",
".",
"... | [
999,
4
] | [
1014,
9
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.all | (self, domain_filter: Optional[Union[str, Iterable]] = None) | Create a list of all states. | Create a list of all states. | def all(self, domain_filter: Optional[Union[str, Iterable]] = None) -> List[State]:
"""Create a list of all states."""
return run_callback_threadsafe(
self._loop, self.async_all, domain_filter
).result() | [
"def",
"all",
"(",
"self",
",",
"domain_filter",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"State",
"]",
":",
"return",
"run_callback_threadsafe",
"(",
"self",
".",
"_loop",
",",
"self",
... | [
1016,
4
] | [
1020,
18
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_all | (
self, domain_filter: Optional[Union[str, Iterable]] = None
) | Create a list of all states matching the filter.
This method must be run in the event loop.
| Create a list of all states matching the filter. | def async_all(
self, domain_filter: Optional[Union[str, Iterable]] = None
) -> List[State]:
"""Create a list of all states matching the filter.
This method must be run in the event loop.
"""
if domain_filter is None:
return list(self._states.values())
if... | [
"def",
"async_all",
"(",
"self",
",",
"domain_filter",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"State",
"]",
":",
"if",
"domain_filter",
"is",
"None",
":",
"return",
"list",
"(",
"sel... | [
1023,
4
] | [
1038,
9
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.get | (self, entity_id: str) | Retrieve state of entity_id or None if not found.
Async friendly.
| Retrieve state of entity_id or None if not found. | def get(self, entity_id: str) -> Optional[State]:
"""Retrieve state of entity_id or None if not found.
Async friendly.
"""
return self._states.get(entity_id.lower()) | [
"def",
"get",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"Optional",
"[",
"State",
"]",
":",
"return",
"self",
".",
"_states",
".",
"get",
"(",
"entity_id",
".",
"lower",
"(",
")",
")"
] | [
1040,
4
] | [
1045,
50
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.is_state | (self, entity_id: str, state: str) | Test if entity exists and is in specified state.
Async friendly.
| Test if entity exists and is in specified state. | def is_state(self, entity_id: str, state: str) -> bool:
"""Test if entity exists and is in specified state.
Async friendly.
"""
state_obj = self.get(entity_id)
return state_obj is not None and state_obj.state == state | [
"def",
"is_state",
"(",
"self",
",",
"entity_id",
":",
"str",
",",
"state",
":",
"str",
")",
"->",
"bool",
":",
"state_obj",
"=",
"self",
".",
"get",
"(",
"entity_id",
")",
"return",
"state_obj",
"is",
"not",
"None",
"and",
"state_obj",
".",
"state",
... | [
1047,
4
] | [
1053,
65
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.remove | (self, entity_id: str) | Remove the state of an entity.
Returns boolean to indicate if an entity was removed.
| Remove the state of an entity. | def remove(self, entity_id: str) -> bool:
"""Remove the state of an entity.
Returns boolean to indicate if an entity was removed.
"""
return run_callback_threadsafe(
self._loop, self.async_remove, entity_id
).result() | [
"def",
"remove",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"bool",
":",
"return",
"run_callback_threadsafe",
"(",
"self",
".",
"_loop",
",",
"self",
".",
"async_remove",
",",
"entity_id",
")",
".",
"result",
"(",
")"
] | [
1055,
4
] | [
1062,
18
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_remove | (self, entity_id: str, context: Optional[Context] = None) | Remove the state of an entity.
Returns boolean to indicate if an entity was removed.
This method must be run in the event loop.
| Remove the state of an entity. | def async_remove(self, entity_id: str, context: Optional[Context] = None) -> bool:
"""Remove the state of an entity.
Returns boolean to indicate if an entity was removed.
This method must be run in the event loop.
"""
entity_id = entity_id.lower()
old_state = self._stat... | [
"def",
"async_remove",
"(",
"self",
",",
"entity_id",
":",
"str",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"entity_id",
"=",
"entity_id",
".",
"lower",
"(",
")",
"old_state",
"=",
"self",
".",
"_states"... | [
1065,
4
] | [
1087,
19
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.set | (
self,
entity_id: str,
new_state: str,
attributes: Optional[Dict] = None,
force_update: bool = False,
context: Optional[Context] = None,
) | Set the state of an entity, add entity if it does not exist.
Attributes is an optional dict to specify attributes of this state.
If you just update the attributes and not the state, last changed will
not be affected.
| Set the state of an entity, add entity if it does not exist. | def set(
self,
entity_id: str,
new_state: str,
attributes: Optional[Dict] = None,
force_update: bool = False,
context: Optional[Context] = None,
) -> None:
"""Set the state of an entity, add entity if it does not exist.
Attributes is an optional dict ... | [
"def",
"set",
"(",
"self",
",",
"entity_id",
":",
"str",
",",
"new_state",
":",
"str",
",",
"attributes",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"force_update",
":",
"bool",
"=",
"False",
",",
"context",
":",
"Optional",
"[",
"Context",
... | [
1089,
4
] | [
1112,
18
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_reserve | (self, entity_id: str) | Reserve a state in the state machine for an entity being added.
This must not fire an event when the state is reserved.
This avoids a race condition where multiple entities with the same
entity_id are added.
| Reserve a state in the state machine for an entity being added. | def async_reserve(self, entity_id: str) -> None:
"""Reserve a state in the state machine for an entity being added.
This must not fire an event when the state is reserved.
This avoids a race condition where multiple entities with the same
entity_id are added.
"""
entity... | [
"def",
"async_reserve",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"entity_id",
"=",
"entity_id",
".",
"lower",
"(",
")",
"if",
"entity_id",
"in",
"self",
".",
"_states",
"or",
"entity_id",
"in",
"self",
".",
"_reservations",
":",... | [
1115,
4
] | [
1129,
41
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_available | (self, entity_id: str) | Check to see if an entity_id is available to be used. | Check to see if an entity_id is available to be used. | def async_available(self, entity_id: str) -> bool:
"""Check to see if an entity_id is available to be used."""
entity_id = entity_id.lower()
return entity_id not in self._states and entity_id not in self._reservations | [
"def",
"async_available",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"bool",
":",
"entity_id",
"=",
"entity_id",
".",
"lower",
"(",
")",
"return",
"entity_id",
"not",
"in",
"self",
".",
"_states",
"and",
"entity_id",
"not",
"in",
"self",
".",
... | [
1132,
4
] | [
1135,
84
] | python | en | ['en', 'en', 'en'] | True |
StateMachine.async_set | (
self,
entity_id: str,
new_state: str,
attributes: Optional[Dict] = None,
force_update: bool = False,
context: Optional[Context] = None,
) | Set the state of an entity, add entity if it does not exist.
Attributes is an optional dict to specify attributes of this state.
If you just update the attributes and not the state, last changed will
not be affected.
This method must be run in the event loop.
| Set the state of an entity, add entity if it does not exist. | def async_set(
self,
entity_id: str,
new_state: str,
attributes: Optional[Dict] = None,
force_update: bool = False,
context: Optional[Context] = None,
) -> None:
"""Set the state of an entity, add entity if it does not exist.
Attributes is an optional... | [
"def",
"async_set",
"(",
"self",
",",
"entity_id",
":",
"str",
",",
"new_state",
":",
"str",
",",
"attributes",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"force_update",
":",
"bool",
"=",
"False",
",",
"context",
":",
"Optional",
"[",
"Conte... | [
1138,
4
] | [
1192,
9
] | python | en | ['en', 'en', 'en'] | True |
Service.__init__ | (
self,
func: Callable,
schema: Optional[vol.Schema],
context: Optional[Context] = None,
) | Initialize a service. | Initialize a service. | def __init__(
self,
func: Callable,
schema: Optional[vol.Schema],
context: Optional[Context] = None,
) -> None:
"""Initialize a service."""
self.job = HassJob(func)
self.schema = schema | [
"def",
"__init__",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"schema",
":",
"Optional",
"[",
"vol",
".",
"Schema",
"]",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
"job",
"=",
... | [
1200,
4
] | [
1208,
28
] | python | en | ['en', 'co', 'en'] | True |
ServiceCall.__init__ | (
self,
domain: str,
service: str,
data: Optional[Dict] = None,
context: Optional[Context] = None,
) | Initialize a service call. | Initialize a service call. | def __init__(
self,
domain: str,
service: str,
data: Optional[Dict] = None,
context: Optional[Context] = None,
) -> None:
"""Initialize a service call."""
self.domain = domain.lower()
self.service = service.lower()
self.data = MappingProxyType(... | [
"def",
"__init__",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"data",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"s... | [
1216,
4
] | [
1227,
43
] | python | en | ['en', 'co', 'en'] | True |
ServiceCall.__repr__ | (self) | Return the representation of the service. | Return the representation of the service. | def __repr__(self) -> str:
"""Return the representation of the service."""
if self.data:
return (
f"<ServiceCall {self.domain}.{self.service} "
f"(c:{self.context.id}): {util.repr_helper(self.data)}>"
)
return f"<ServiceCall {self.domain}.... | [
"def",
"__repr__",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"data",
":",
"return",
"(",
"f\"<ServiceCall {self.domain}.{self.service} \"",
"f\"(c:{self.context.id}): {util.repr_helper(self.data)}>\"",
")",
"return",
"f\"<ServiceCall {self.domain}.{self.service} (c... | [
1229,
4
] | [
1237,
82
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.__init__ | (self, hass: HomeAssistant) | Initialize a service registry. | Initialize a service registry. | def __init__(self, hass: HomeAssistant) -> None:
"""Initialize a service registry."""
self._services: Dict[str, Dict[str, Service]] = {}
self._hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"self",
".",
"_services",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Service",
"]",
"]",
"=",
"{",
"}",
"self",
".",
"_hass",
"=",
"hass"
] | [
1243,
4
] | [
1246,
25
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.services | (self) | Return dictionary with per domain a list of available services. | Return dictionary with per domain a list of available services. | def services(self) -> Dict[str, Dict[str, Service]]:
"""Return dictionary with per domain a list of available services."""
return run_callback_threadsafe(self._hass.loop, self.async_services).result() | [
"def",
"services",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Service",
"]",
"]",
":",
"return",
"run_callback_threadsafe",
"(",
"self",
".",
"_hass",
".",
"loop",
",",
"self",
".",
"async_services",
")",
".",
"result",
... | [
1249,
4
] | [
1251,
85
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.async_services | (self) | Return dictionary with per domain a list of available services.
This method must be run in the event loop.
| Return dictionary with per domain a list of available services. | def async_services(self) -> Dict[str, Dict[str, Service]]:
"""Return dictionary with per domain a list of available services.
This method must be run in the event loop.
"""
return {domain: self._services[domain].copy() for domain in self._services} | [
"def",
"async_services",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Service",
"]",
"]",
":",
"return",
"{",
"domain",
":",
"self",
".",
"_services",
"[",
"domain",
"]",
".",
"copy",
"(",
")",
"for",
"domain",
"in",
... | [
1254,
4
] | [
1259,
83
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.has_service | (self, domain: str, service: str) | Test if specified service exists.
Async friendly.
| Test if specified service exists. | def has_service(self, domain: str, service: str) -> bool:
"""Test if specified service exists.
Async friendly.
"""
return service.lower() in self._services.get(domain.lower(), []) | [
"def",
"has_service",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
")",
"->",
"bool",
":",
"return",
"service",
".",
"lower",
"(",
")",
"in",
"self",
".",
"_services",
".",
"get",
"(",
"domain",
".",
"lower",
"(",
")",
",",
... | [
1261,
4
] | [
1266,
72
] | python | en | ['es', 'en', 'en'] | True |
ServiceRegistry.register | (
self,
domain: str,
service: str,
service_func: Callable,
schema: Optional[vol.Schema] = None,
) |
Register a service.
Schema is called to coerce and validate the service data.
|
Register a service. | def register(
self,
domain: str,
service: str,
service_func: Callable,
schema: Optional[vol.Schema] = None,
) -> None:
"""
Register a service.
Schema is called to coerce and validate the service data.
"""
run_callback_threadsafe(
... | [
"def",
"register",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"service_func",
":",
"Callable",
",",
"schema",
":",
"Optional",
"[",
"vol",
".",
"Schema",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"run_callback_threads... | [
1268,
4
] | [
1282,
18
] | python | en | ['en', 'error', 'th'] | False |
ServiceRegistry.async_register | (
self,
domain: str,
service: str,
service_func: Callable,
schema: Optional[vol.Schema] = None,
) |
Register a service.
Schema is called to coerce and validate the service data.
This method must be run in the event loop.
|
Register a service. | def async_register(
self,
domain: str,
service: str,
service_func: Callable,
schema: Optional[vol.Schema] = None,
) -> None:
"""
Register a service.
Schema is called to coerce and validate the service data.
This method must be run in the even... | [
"def",
"async_register",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"service_func",
":",
"Callable",
",",
"schema",
":",
"Optional",
"[",
"vol",
".",
"Schema",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"domain",
"="... | [
1285,
4
] | [
1310,
9
] | python | en | ['en', 'error', 'th'] | False |
ServiceRegistry.remove | (self, domain: str, service: str) | Remove a registered service from service handler. | Remove a registered service from service handler. | def remove(self, domain: str, service: str) -> None:
"""Remove a registered service from service handler."""
run_callback_threadsafe(
self._hass.loop, self.async_remove, domain, service
).result() | [
"def",
"remove",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
")",
"->",
"None",
":",
"run_callback_threadsafe",
"(",
"self",
".",
"_hass",
".",
"loop",
",",
"self",
".",
"async_remove",
",",
"domain",
",",
"service",
")",
".",
... | [
1312,
4
] | [
1316,
18
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.async_remove | (self, domain: str, service: str) | Remove a registered service from service handler.
This method must be run in the event loop.
| Remove a registered service from service handler. | def async_remove(self, domain: str, service: str) -> None:
"""Remove a registered service from service handler.
This method must be run in the event loop.
"""
domain = domain.lower()
service = service.lower()
if service not in self._services.get(domain, {}):
... | [
"def",
"async_remove",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
")",
"->",
"None",
":",
"domain",
"=",
"domain",
".",
"lower",
"(",
")",
"service",
"=",
"service",
".",
"lower",
"(",
")",
"if",
"service",
"not",
"in",
"se... | [
1319,
4
] | [
1338,
9
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry.call | (
self,
domain: str,
service: str,
service_data: Optional[Dict] = None,
blocking: bool = False,
context: Optional[Context] = None,
limit: Optional[float] = SERVICE_CALL_LIMIT,
) |
Call a service.
See description of async_call for details.
|
Call a service. | def call(
self,
domain: str,
service: str,
service_data: Optional[Dict] = None,
blocking: bool = False,
context: Optional[Context] = None,
limit: Optional[float] = SERVICE_CALL_LIMIT,
) -> Optional[bool]:
"""
Call a service.
See descri... | [
"def",
"call",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"service_data",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"blocking",
":",
"bool",
"=",
"False",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
... | [
1340,
4
] | [
1357,
18
] | python | en | ['en', 'error', 'th'] | False |
ServiceRegistry.async_call | (
self,
domain: str,
service: str,
service_data: Optional[Dict] = None,
blocking: bool = False,
context: Optional[Context] = None,
limit: Optional[float] = SERVICE_CALL_LIMIT,
) |
Call a service.
Specify blocking=True to wait until service is executed.
Waits a maximum of limit, which may be None for no timeout.
If blocking = True, will return boolean if service executed
successfully within limit.
This method will fire an event to indicate the s... |
Call a service. | async def async_call(
self,
domain: str,
service: str,
service_data: Optional[Dict] = None,
blocking: bool = False,
context: Optional[Context] = None,
limit: Optional[float] = SERVICE_CALL_LIMIT,
) -> Optional[bool]:
"""
Call a service.
... | [
"async",
"def",
"async_call",
"(",
"self",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"service_data",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"blocking",
":",
"bool",
"=",
"False",
",",
"context",
":",
"Optional",
"[",
"... | [
1359,
4
] | [
1449,
20
] | python | en | ['en', 'error', 'th'] | False |
ServiceRegistry._run_service_in_background | (
self, coro_or_task: Union[Coroutine, asyncio.Task], service_call: ServiceCall
) | Run service call in background, catching and logging any exceptions. | Run service call in background, catching and logging any exceptions. | def _run_service_in_background(
self, coro_or_task: Union[Coroutine, asyncio.Task], service_call: ServiceCall
) -> None:
"""Run service call in background, catching and logging any exceptions."""
async def catch_exceptions() -> None:
try:
await coro_or_task
... | [
"def",
"_run_service_in_background",
"(",
"self",
",",
"coro_or_task",
":",
"Union",
"[",
"Coroutine",
",",
"asyncio",
".",
"Task",
"]",
",",
"service_call",
":",
"ServiceCall",
")",
"->",
"None",
":",
"async",
"def",
"catch_exceptions",
"(",
")",
"->",
"Non... | [
1451,
4
] | [
1470,
56
] | python | en | ['en', 'en', 'en'] | True |
ServiceRegistry._execute_service | (
self, handler: Service, service_call: ServiceCall
) | Execute a service. | Execute a service. | async def _execute_service(
self, handler: Service, service_call: ServiceCall
) -> None:
"""Execute a service."""
if handler.job.job_type == HassJobType.Coroutinefunction:
await handler.job.target(service_call)
elif handler.job.job_type == HassJobType.Callback:
... | [
"async",
"def",
"_execute_service",
"(",
"self",
",",
"handler",
":",
"Service",
",",
"service_call",
":",
"ServiceCall",
")",
"->",
"None",
":",
"if",
"handler",
".",
"job",
".",
"job_type",
"==",
"HassJobType",
".",
"Coroutinefunction",
":",
"await",
"hand... | [
1472,
4
] | [
1481,
85
] | python | en | ['en', 'gl', 'en'] | True |
Config.__init__ | (self, hass: HomeAssistant) | Initialize a new config object. | Initialize a new config object. | def __init__(self, hass: HomeAssistant) -> None:
"""Initialize a new config object."""
self.hass = hass
self.latitude: float = 0
self.longitude: float = 0
self.elevation: int = 0
self.location_name: str = "Home"
self.time_zone: datetime.tzinfo = dt_util.UTC
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"latitude",
":",
"float",
"=",
"0",
"self",
".",
"longitude",
":",
"float",
"=",
"0",
"self",
".",
"elevation",
... | [
1487,
4
] | [
1527,
43
] | python | en | ['en', 'en', 'en'] | True |
Config.distance | (self, lat: float, lon: float) | Calculate distance from Home Assistant.
Async friendly.
| Calculate distance from Home Assistant. | def distance(self, lat: float, lon: float) -> Optional[float]:
"""Calculate distance from Home Assistant.
Async friendly.
"""
return self.units.length(
location.distance(self.latitude, self.longitude, lat, lon), LENGTH_METERS
) | [
"def",
"distance",
"(",
"self",
",",
"lat",
":",
"float",
",",
"lon",
":",
"float",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"units",
".",
"length",
"(",
"location",
".",
"distance",
"(",
"self",
".",
"latitude",
",",
"... | [
1529,
4
] | [
1536,
9
] | python | en | ['en', 'en', 'en'] | True |
Config.path | (self, *path: str) | Generate path to the file within the configuration directory.
Async friendly.
| Generate path to the file within the configuration directory. | def path(self, *path: str) -> str:
"""Generate path to the file within the configuration directory.
Async friendly.
"""
if self.config_dir is None:
raise HomeAssistantError("config_dir is not set")
return os.path.join(self.config_dir, *path) | [
"def",
"path",
"(",
"self",
",",
"*",
"path",
":",
"str",
")",
"->",
"str",
":",
"if",
"self",
".",
"config_dir",
"is",
"None",
":",
"raise",
"HomeAssistantError",
"(",
"\"config_dir is not set\"",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"s... | [
1538,
4
] | [
1545,
51
] | python | en | ['en', 'en', 'en'] | True |
Config.is_allowed_external_url | (self, url: str) | Check if an external URL is allowed. | Check if an external URL is allowed. | def is_allowed_external_url(self, url: str) -> bool:
"""Check if an external URL is allowed."""
parsed_url = f"{str(yarl.URL(url))}/"
return any(
allowed
for allowed in self.allowlist_external_urls
if parsed_url.startswith(allowed)
) | [
"def",
"is_allowed_external_url",
"(",
"self",
",",
"url",
":",
"str",
")",
"->",
"bool",
":",
"parsed_url",
"=",
"f\"{str(yarl.URL(url))}/\"",
"return",
"any",
"(",
"allowed",
"for",
"allowed",
"in",
"self",
".",
"allowlist_external_urls",
"if",
"parsed_url",
"... | [
1547,
4
] | [
1555,
9
] | python | en | ['en', 'lb', 'en'] | True |
Config.is_allowed_path | (self, path: str) | Check if the path is valid for access from outside. | Check if the path is valid for access from outside. | def is_allowed_path(self, path: str) -> bool:
"""Check if the path is valid for access from outside."""
assert path is not None
thepath = pathlib.Path(path)
try:
# The file path does not have to exist (it's parent should)
if thepath.exists():
thep... | [
"def",
"is_allowed_path",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"bool",
":",
"assert",
"path",
"is",
"not",
"None",
"thepath",
"=",
"pathlib",
".",
"Path",
"(",
"path",
")",
"try",
":",
"# The file path does not have to exist (it's parent should)",
... | [
1557,
4
] | [
1578,
20
] | python | en | ['en', 'en', 'en'] | True |
Config.as_dict | (self) | Create a dictionary representation of the configuration.
Async friendly.
| Create a dictionary representation of the configuration. | def as_dict(self) -> Dict:
"""Create a dictionary representation of the configuration.
Async friendly.
"""
time_zone = dt_util.UTC.zone
if self.time_zone and getattr(self.time_zone, "zone"):
time_zone = getattr(self.time_zone, "zone")
return {
"l... | [
"def",
"as_dict",
"(",
"self",
")",
"->",
"Dict",
":",
"time_zone",
"=",
"dt_util",
".",
"UTC",
".",
"zone",
"if",
"self",
".",
"time_zone",
"and",
"getattr",
"(",
"self",
".",
"time_zone",
",",
"\"zone\"",
")",
":",
"time_zone",
"=",
"getattr",
"(",
... | [
1580,
4
] | [
1608,
9
] | python | en | ['en', 'en', 'en'] | True |
Config.set_time_zone | (self, time_zone_str: str) | Help to set the time zone. | Help to set the time zone. | def set_time_zone(self, time_zone_str: str) -> None:
"""Help to set the time zone."""
time_zone = dt_util.get_time_zone(time_zone_str)
if time_zone:
self.time_zone = time_zone
dt_util.set_default_time_zone(time_zone)
else:
raise ValueError(f"Received ... | [
"def",
"set_time_zone",
"(",
"self",
",",
"time_zone_str",
":",
"str",
")",
"->",
"None",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"time_zone_str",
")",
"if",
"time_zone",
":",
"self",
".",
"time_zone",
"=",
"time_zone",
"dt_util",
".",
... | [
1610,
4
] | [
1618,
75
] | python | en | ['en', 'en', 'en'] | True |
Config._update | (
self,
*,
source: str,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
elevation: Optional[int] = None,
unit_system: Optional[str] = None,
location_name: Optional[str] = None,
time_zone: Optional[str] = None,
# pylint:... | Update the configuration from a dictionary. | Update the configuration from a dictionary. | def _update(
self,
*,
source: str,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
elevation: Optional[int] = None,
unit_system: Optional[str] = None,
location_name: Optional[str] = None,
time_zone: Optional[str] = None,
... | [
"def",
"_update",
"(",
"self",
",",
"*",
",",
"source",
":",
"str",
",",
"latitude",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
",",
"longitude",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
",",
"elevation",
":",
"Optional",
"[",
"int",
... | [
1621,
4
] | [
1655,
65
] | python | en | ['en', 'en', 'en'] | True |
Config.async_update | (self, **kwargs: Any) | Update the configuration from a dictionary. | Update the configuration from a dictionary. | async def async_update(self, **kwargs: Any) -> None:
"""Update the configuration from a dictionary."""
self._update(source=SOURCE_STORAGE, **kwargs)
await self.async_store()
self.hass.bus.async_fire(EVENT_CORE_CONFIG_UPDATE, kwargs) | [
"async",
"def",
"async_update",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"_update",
"(",
"source",
"=",
"SOURCE_STORAGE",
",",
"*",
"*",
"kwargs",
")",
"await",
"self",
".",
"async_store",
"(",
")",
"self... | [
1657,
4
] | [
1661,
66
] | python | en | ['en', 'en', 'en'] | True |
Config.async_load | (self) | Load [homeassistant] core config. | Load [homeassistant] core config. | async def async_load(self) -> None:
"""Load [homeassistant] core config."""
store = self.hass.helpers.storage.Store(
CORE_STORAGE_VERSION, CORE_STORAGE_KEY, private=True
)
data = await store.async_load()
async def migrate_base_url(_: Event) -> None:
"""Mi... | [
"async",
"def",
"async_load",
"(",
"self",
")",
"->",
"None",
":",
"store",
"=",
"self",
".",
"hass",
".",
"helpers",
".",
"storage",
".",
"Store",
"(",
"CORE_STORAGE_VERSION",
",",
"CORE_STORAGE_KEY",
",",
"private",
"=",
"True",
")",
"data",
"=",
"awai... | [
1663,
4
] | [
1713,
13
] | python | en | ['en', 'en', 'en'] | True |
Config.async_store | (self) | Store [homeassistant] core config. | Store [homeassistant] core config. | async def async_store(self) -> None:
"""Store [homeassistant] core config."""
time_zone = dt_util.UTC.zone
if self.time_zone and getattr(self.time_zone, "zone"):
time_zone = getattr(self.time_zone, "zone")
data = {
"latitude": self.latitude,
"longitud... | [
"async",
"def",
"async_store",
"(",
"self",
")",
"->",
"None",
":",
"time_zone",
"=",
"dt_util",
".",
"UTC",
".",
"zone",
"if",
"self",
".",
"time_zone",
"and",
"getattr",
"(",
"self",
".",
"time_zone",
",",
"\"zone\"",
")",
":",
"time_zone",
"=",
"get... | [
1715,
4
] | [
1735,
36
] | python | en | ['en', 'en', 'en'] | True |
async_get_engine | (hass, config, discovery_info=None) | Set up VoiceRSS TTS component. | Set up VoiceRSS TTS component. | async def async_get_engine(hass, config, discovery_info=None):
"""Set up VoiceRSS TTS component."""
return VoiceRSSProvider(hass, config) | [
"async",
"def",
"async_get_engine",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"VoiceRSSProvider",
"(",
"hass",
",",
"config",
")"
] | [
156,
0
] | [
158,
41
] | python | en | ['en', 'fr', 'en'] | True |
VoiceRSSProvider.__init__ | (self, hass, conf) | Init VoiceRSS TTS service. | Init VoiceRSS TTS service. | def __init__(self, hass, conf):
"""Init VoiceRSS TTS service."""
self.hass = hass
self._extension = conf[CONF_CODEC]
self._lang = conf[CONF_LANG]
self.name = "VoiceRSS"
self._form_data = {
"key": conf[CONF_API_KEY],
"hl": conf[CONF_LANG],
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"conf",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_extension",
"=",
"conf",
"[",
"CONF_CODEC",
"]",
"self",
".",
"_lang",
"=",
"conf",
"[",
"CONF_LANG",
"]",
"self",
".",
"name",
"="... | [
164,
4
] | [
176,
9
] | python | de | ['de', 'fr', 'en'] | False |
VoiceRSSProvider.default_language | (self) | Return the default language. | Return the default language. | def default_language(self):
"""Return the default language."""
return self._lang | [
"def",
"default_language",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lang"
] | [
179,
4
] | [
181,
25
] | python | en | ['en', 'et', 'en'] | True |
VoiceRSSProvider.supported_languages | (self) | Return list of supported languages. | Return list of supported languages. | def supported_languages(self):
"""Return list of supported languages."""
return SUPPORT_LANGUAGES | [
"def",
"supported_languages",
"(",
"self",
")",
":",
"return",
"SUPPORT_LANGUAGES"
] | [
184,
4
] | [
186,
32
] | python | en | ['en', 'en', 'en'] | True |
VoiceRSSProvider.async_get_tts_audio | (self, message, language, options=None) | Load TTS from VoiceRSS. | Load TTS from VoiceRSS. | async def async_get_tts_audio(self, message, language, options=None):
"""Load TTS from VoiceRSS."""
websession = async_get_clientsession(self.hass)
form_data = self._form_data.copy()
form_data["src"] = message
form_data["hl"] = language
try:
with async_timeo... | [
"async",
"def",
"async_get_tts_audio",
"(",
"self",
",",
"message",
",",
"language",
",",
"options",
"=",
"None",
")",
":",
"websession",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"form_data",
"=",
"self",
".",
"_form_data",
".",
"copy",... | [
188,
4
] | [
215,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Axis camera video stream. | Set up the Axis camera video stream. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Axis camera video stream."""
filter_urllib3_logging()
device = hass.data[AXIS_DOMAIN][config_entry.unique_id]
if not device.api.vapix.params.image_format:
return
async_add_entities([AxisCamera(device)]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"filter_urllib3_logging",
"(",
")",
"device",
"=",
"hass",
".",
"data",
"[",
"AXIS_DOMAIN",
"]",
"[",
"config_entry",
".",
"unique_id",
"]",
"if",
"not"... | [
23,
0
] | [
32,
44
] | python | en | ['en', 'en', 'en'] | True |
AxisCamera.__init__ | (self, device) | Initialize Axis Communications camera component. | Initialize Axis Communications camera component. | def __init__(self, device):
"""Initialize Axis Communications camera component."""
AxisEntityBase.__init__(self, device)
config = {
CONF_NAME: device.config_entry.data[CONF_NAME],
CONF_USERNAME: device.config_entry.data[CONF_USERNAME],
CONF_PASSWORD: device.c... | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"AxisEntityBase",
".",
"__init__",
"(",
"self",
",",
"device",
")",
"config",
"=",
"{",
"CONF_NAME",
":",
"device",
".",
"config_entry",
".",
"data",
"[",
"CONF_NAME",
"]",
",",
"CONF_USERNAME",
":... | [
38,
4
] | [
50,
42
] | python | en | ['ca', 'en', 'en'] | True |
AxisCamera.async_added_to_hass | (self) | Subscribe camera events. | Subscribe camera events. | async def async_added_to_hass(self):
"""Subscribe camera events."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, self.device.signal_new_address, self._new_address
)
)
await super().async_added_to_hass() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"device",
".",
"signal_new_address",
",",
"self",
".",
"_new_address",
")",
")",
"await",... | [
52,
4
] | [
60,
43
] | python | en | ['eu', 'en', 'en'] | True |
AxisCamera.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
return SUPPORT_STREAM | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_STREAM"
] | [
63,
4
] | [
65,
29
] | python | en | ['en', 'en', 'en'] | True |
AxisCamera._new_address | (self) | Set new device address for video stream. | Set new device address for video stream. | def _new_address(self):
"""Set new device address for video stream."""
self._mjpeg_url = self.mjpeg_source
self._still_image_url = self.image_source | [
"def",
"_new_address",
"(",
"self",
")",
":",
"self",
".",
"_mjpeg_url",
"=",
"self",
".",
"mjpeg_source",
"self",
".",
"_still_image_url",
"=",
"self",
".",
"image_source"
] | [
67,
4
] | [
70,
49
] | python | en | ['en', 'en', 'en'] | True |
AxisCamera.unique_id | (self) | Return a unique identifier for this device. | Return a unique identifier for this device. | def unique_id(self):
"""Return a unique identifier for this device."""
return f"{self.device.serial}-camera" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.device.serial}-camera\""
] | [
73,
4
] | [
75,
45
] | python | en | ['en', 'en', 'en'] | True |
AxisCamera.image_source | (self) | Return still image URL for device. | Return still image URL for device. | def image_source(self):
"""Return still image URL for device."""
return f"http://{self.device.host}:{self.device.config_entry.data[CONF_PORT]}/axis-cgi/jpg/image.cgi" | [
"def",
"image_source",
"(",
"self",
")",
":",
"return",
"f\"http://{self.device.host}:{self.device.config_entry.data[CONF_PORT]}/axis-cgi/jpg/image.cgi\""
] | [
78,
4
] | [
80,
109
] | python | en | ['nb', 'no', 'en'] | False |
AxisCamera.mjpeg_source | (self) | Return mjpeg URL for device. | Return mjpeg URL for device. | def mjpeg_source(self):
"""Return mjpeg URL for device."""
options = ""
if self.device.option_stream_profile != DEFAULT_STREAM_PROFILE:
options = f"?&streamprofile={self.device.option_stream_profile}"
return f"http://{self.device.host}:{self.device.config_entry.data[CONF_POR... | [
"def",
"mjpeg_source",
"(",
"self",
")",
":",
"options",
"=",
"\"\"",
"if",
"self",
".",
"device",
".",
"option_stream_profile",
"!=",
"DEFAULT_STREAM_PROFILE",
":",
"options",
"=",
"f\"?&streamprofile={self.device.option_stream_profile}\"",
"return",
"f\"http://{self.dev... | [
83,
4
] | [
89,
119
] | python | da | ['da', 'tr', 'en'] | False |
AxisCamera.stream_source | (self) | Return the stream source. | Return the stream source. | async def stream_source(self):
"""Return the stream source."""
options = ""
if self.device.option_stream_profile != DEFAULT_STREAM_PROFILE:
options = f"&streamprofile={self.device.option_stream_profile}"
return f"rtsp://{self.device.config_entry.data[CONF_USERNAME]}:{self.de... | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"options",
"=",
"\"\"",
"if",
"self",
".",
"device",
".",
"option_stream_profile",
"!=",
"DEFAULT_STREAM_PROFILE",
":",
"options",
"=",
"f\"&streamprofile={self.device.option_stream_profile}\"",
"return",
"f\"rtsp:... | [
91,
4
] | [
97,
183
] | python | en | ['en', 'ig', 'en'] | True |
_match_val_type | (vals, bounds) |
Update values in the array, to match their corresponding type, make sure the value is legal.
Parameters
----------
vals : numpy array
values of parameters
bounds : numpy array
list of dictionary which stores parameters names and legal values.
Returns
-------
vals_new :... |
Update values in the array, to match their corresponding type, make sure the value is legal. | def _match_val_type(vals, bounds):
"""
Update values in the array, to match their corresponding type, make sure the value is legal.
Parameters
----------
vals : numpy array
values of parameters
bounds : numpy array
list of dictionary which stores parameters names and legal value... | [
"def",
"_match_val_type",
"(",
"vals",
",",
"bounds",
")",
":",
"vals_new",
"=",
"[",
"]",
"for",
"i",
",",
"bound",
"in",
"enumerate",
"(",
"bounds",
")",
":",
"_type",
"=",
"bound",
"[",
"'_type'",
"]",
"if",
"_type",
"==",
"\"choice\"",
":",
"# Fi... | [
13,
0
] | [
42,
19
] | python | en | ['en', 'error', 'th'] | False |
acq_max | (f_acq, gp, y_max, bounds, space, num_warmup, num_starting_points) |
A function to find the maximum of the acquisition function
It uses a combination of random sampling (cheap) and the 'L-BFGS-B'
optimization method. First by sampling ``num_warmup`` points at random,
and then running L-BFGS-B from ``num_starting_points`` random starting points.
Parameters
----... |
A function to find the maximum of the acquisition function | def acq_max(f_acq, gp, y_max, bounds, space, num_warmup, num_starting_points):
"""
A function to find the maximum of the acquisition function
It uses a combination of random sampling (cheap) and the 'L-BFGS-B'
optimization method. First by sampling ``num_warmup`` points at random,
and then running ... | [
"def",
"acq_max",
"(",
"f_acq",
",",
"gp",
",",
"y_max",
",",
"bounds",
",",
"space",
",",
"num_warmup",
",",
"num_starting_points",
")",
":",
"# Warm up with random points",
"x_tries",
"=",
"[",
"space",
".",
"random_sample",
"(",
")",
"for",
"_",
"in",
"... | [
45,
0
] | [
111,
67
] | python | en | ['en', 'error', 'th'] | False |
UtilityFunction.utility | (self, x, gp, y_max) |
return utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
Returns
-------
function
return corresponding function,... |
return utility function | def utility(self, x, gp, y_max):
"""
return utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
Returns
-------
functio... | [
"def",
"utility",
"(",
"self",
",",
"x",
",",
"gp",
",",
"y_max",
")",
":",
"if",
"self",
".",
"_kind",
"==",
"'ucb'",
":",
"return",
"self",
".",
"_ucb",
"(",
"x",
",",
"gp",
",",
"self",
".",
"_kappa",
")",
"if",
"self",
".",
"_kind",
"==",
... | [
139,
4
] | [
162,
19
] | python | en | ['en', 'error', 'th'] | False |
UtilityFunction._ucb | (x, gp, kappa) |
Upper Confidence Bound (UCB) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
kappa : float
Returns
-------
float
|
Upper Confidence Bound (UCB) utility function | def _ucb(x, gp, kappa):
"""
Upper Confidence Bound (UCB) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
kappa : float
Returns
-------
float
"""
with warnings.cat... | [
"def",
"_ucb",
"(",
"x",
",",
"gp",
",",
"kappa",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"mean",
",",
"std",
"=",
"gp",
".",
"predict",
"(",
"x",
",",
"return_std",... | [
165,
4
] | [
184,
33
] | python | en | ['en', 'error', 'th'] | False |
UtilityFunction._ei | (x, gp, y_max, xi) |
Expected Improvement (EI) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
xi : float
Returns
-------
float
... |
Expected Improvement (EI) utility function | def _ei(x, gp, y_max, xi):
"""
Expected Improvement (EI) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
xi : float
Returns... | [
"def",
"_ei",
"(",
"x",
",",
"gp",
",",
"y_max",
",",
"xi",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"mean",
",",
"std",
"=",
"gp",
".",
"predict",
"(",
"x",
",",
... | [
187,
4
] | [
209,
68
] | python | en | ['en', 'error', 'th'] | False |
UtilityFunction._poi | (x, gp, y_max, xi) |
Possibility Of Improvement (POI) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
xi : float
Returns
-------
float
... |
Possibility Of Improvement (POI) utility function | def _poi(x, gp, y_max, xi):
"""
Possibility Of Improvement (POI) utility function
Parameters
----------
x : numpy array
parameters
gp : GaussianProcessRegressor
y_max : float
maximum target value observed so far
xi : float
... | [
"def",
"_poi",
"(",
"x",
",",
"gp",
",",
"y_max",
",",
"xi",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"mean",
",",
"std",
"=",
"gp",
".",
"predict",
"(",
"x",
",",
... | [
212,
4
] | [
234,
26
] | python | en | ['en', 'error', 'th'] | False |
get_scanner | (hass, config) | Validate the configuration and return a HUAWEI scanner. | Validate the configuration and return a HUAWEI scanner. | def get_scanner(hass, config):
"""Validate the configuration and return a HUAWEI scanner."""
scanner = HuaweiDeviceScanner(config[DOMAIN])
return scanner | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"HuaweiDeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner"
] | [
28,
0
] | [
32,
18
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
self.host = config[CONF_HOST]
self.username = config[CONF_USERNAME]
self.password = base64.b64encode(bytes(config[CONF_PASSWORD], "utf-8"))
self.last_results = [] | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"self",
".",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"self",
".",
"password",
"=",
"base64",
".",
"b64encode",
"(",
"bytes... | [
54,
4
] | [
60,
30
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
return [client.mac for client in self.last_results] | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_info",
"(",
")",
"return",
"[",
"client",
".",
"mac",
"for",
"client",
"in",
"self",
".",
"last_results",
"]"
] | [
62,
4
] | [
65,
59
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
if not self.last_results:
return None
for client in self.last_results:
if client.mac == device:
return client.name
return None | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"self",
".",
"last_results",
":",
"return",
"None",
"for",
"client",
"in",
"self",
".",
"last_results",
":",
"if",
"client",
".",
"mac",
"==",
"device",
":",
"return",
"client",... | [
67,
4
] | [
74,
19
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner._update_info | (self) | Ensure the information from the router is up to date.
Return boolean if scanning successful.
| Ensure the information from the router is up to date. | def _update_info(self):
"""Ensure the information from the router is up to date.
Return boolean if scanning successful.
"""
data = self._get_data()
if not data:
return False
active_clients = [client for client in data if client.state]
self.last_resul... | [
"def",
"_update_info",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_get_data",
"(",
")",
"if",
"not",
"data",
":",
"return",
"False",
"active_clients",
"=",
"[",
"client",
"for",
"client",
"in",
"data",
"if",
"client",
".",
"state",
"]",
"self",
... | [
76,
4
] | [
92,
19
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner._get_data | (self) | Get the devices' data from the router.
Returns a list with all the devices known to the router DHCP server.
| Get the devices' data from the router. | def _get_data(self):
"""Get the devices' data from the router.
Returns a list with all the devices known to the router DHCP server.
"""
array_regex_res = self.ARRAY_REGEX.search(self._get_devices_response())
devices = []
if array_regex_res:
device_regex_res ... | [
"def",
"_get_data",
"(",
"self",
")",
":",
"array_regex_res",
"=",
"self",
".",
"ARRAY_REGEX",
".",
"search",
"(",
"self",
".",
"_get_devices_response",
"(",
")",
")",
"devices",
"=",
"[",
"]",
"if",
"array_regex_res",
":",
"device_regex_res",
"=",
"self",
... | [
94,
4
] | [
117,
22
] | python | en | ['en', 'en', 'en'] | True |
HuaweiDeviceScanner._get_devices_response | (self) | Get the raw string with the devices from the router. | Get the raw string with the devices from the router. | def _get_devices_response(self):
"""Get the raw string with the devices from the router."""
cnt = requests.post(f"http://{self.host}/asp/GetRandCount.asp")
cnt_str = str(cnt.content, cnt.apparent_encoding, errors="replace")
_LOGGER.debug("Logging in")
cookie = requests.post(
... | [
"def",
"_get_devices_response",
"(",
"self",
")",
":",
"cnt",
"=",
"requests",
".",
"post",
"(",
"f\"http://{self.host}/asp/GetRandCount.asp\"",
")",
"cnt_str",
"=",
"str",
"(",
"cnt",
".",
"content",
",",
"cnt",
".",
"apparent_encoding",
",",
"errors",
"=",
"... | [
119,
4
] | [
155,
9
] | python | en | ['en', 'en', 'en'] | True |
test_weather_without_forecast | (hass) | Test states of the weather without forecast. | Test states of the weather without forecast. | async def test_weather_without_forecast(hass):
"""Test states of the weather without forecast."""
await init_integration(hass)
registry = await hass.helpers.entity_registry.async_get_registry()
state = hass.states.get("weather.home")
assert state
assert state.state == "sunny"
assert not sta... | [
"async",
"def",
"test_weather_without_forecast",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"state",
"=",
"hass",
".",
"st... | [
32,
0
] | [
52,
39
] | python | en | ['en', 'en', 'en'] | True |
test_weather_with_forecast | (hass) | Test states of the weather with forecast. | Test states of the weather with forecast. | async def test_weather_with_forecast(hass):
"""Test states of the weather with forecast."""
await init_integration(hass, forecast=True)
registry = await hass.helpers.entity_registry.async_get_registry()
state = hass.states.get("weather.home")
assert state
assert state.state == "sunny"
asser... | [
"async",
"def",
"test_weather_with_forecast",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
",",
"forecast",
"=",
"True",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"st... | [
55,
0
] | [
83,
39
] | python | en | ['en', 'en', 'en'] | True |
test_availability | (hass) | Ensure that we mark the entities unavailable correctly when service is offline. | Ensure that we mark the entities unavailable correctly when service is offline. | async def test_availability(hass):
"""Ensure that we mark the entities unavailable correctly when service is offline."""
await init_integration(hass)
state = hass.states.get("weather.home")
assert state
assert state.state != STATE_UNAVAILABLE
assert state.state == "sunny"
future = utcnow()... | [
"async",
"def",
"test_availability",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"weather.home\"",
")",
"assert",
"state",
"assert",
"state",
".",
"state",
"!=",
"STATE_UNAVAIL... | [
86,
0
] | [
120,
37
] | python | en | ['en', 'en', 'en'] | True |
test_manual_update_entity | (hass) | Test manual update entity via service homeasasistant/update_entity. | Test manual update entity via service homeasasistant/update_entity. | async def test_manual_update_entity(hass):
"""Test manual update entity via service homeasasistant/update_entity."""
await init_integration(hass, forecast=True)
await async_setup_component(hass, "homeassistant", {})
current = json.loads(load_fixture("accuweather/current_conditions_data.json"))
for... | [
"async",
"def",
"test_manual_update_entity",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
",",
"forecast",
"=",
"True",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"current",
"=",
"json"... | [
123,
0
] | [
146,
40
] | python | en | ['en', 'en', 'en'] | True |
test_unsupported_condition_icon_data | (hass) | Test with unsupported condition icon data. | Test with unsupported condition icon data. | async def test_unsupported_condition_icon_data(hass):
"""Test with unsupported condition icon data."""
await init_integration(hass, forecast=True, unsupported_icon=True)
state = hass.states.get("weather.home")
assert state.attributes.get(ATTR_FORECAST_CONDITION) is None | [
"async",
"def",
"test_unsupported_condition_icon_data",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
",",
"forecast",
"=",
"True",
",",
"unsupported_icon",
"=",
"True",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"weather.h... | [
149,
0
] | [
154,
64
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up an InComfort/InTouch sensor device. | Set up an InComfort/InTouch sensor device. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up an InComfort/InTouch sensor device."""
if discovery_info is None:
return
client = hass.data[DOMAIN]["client"]
heaters = hass.data[DOMAIN]["heaters"]
async_add_entities(
[IncomfortPressu... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"... | [
25,
0
] | [
37,
5
] | python | en | ['en', 'en', 'en'] | True |
IncomfortSensor.__init__ | (self, client, heater, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, client, heater, name) -> None:
"""Initialize the sensor."""
super().__init__()
self._client = client
self._heater = heater
self._unique_id = f"{heater.serial_no}_{slugify(name)}"
self.entity_id = f"{SENSOR_DOMAIN}.{DOMAIN}_{slugify(name)}"
sel... | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"heater",
",",
"name",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_heater",
"=",
"heater",
"self",
".",
"_unique_id",
... | [
43,
4
] | [
56,
40
] | python | en | ['en', 'en', 'en'] | True |
IncomfortSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> Optional[str]:
"""Return the state of the sensor."""
return self._heater.status[self._state_attr] | [
"def",
"state",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_heater",
".",
"status",
"[",
"self",
".",
"_state_attr",
"]"
] | [
59,
4
] | [
61,
52
] | python | en | ['en', 'en', 'en'] | True |
IncomfortSensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> Optional[str]:
"""Return the device class of the sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_device_class"
] | [
64,
4
] | [
66,
33
] | python | en | ['en', 'en', 'en'] | True |
IncomfortSensor.unit_of_measurement | (self) | Return the unit of measurement of the sensor. | Return the unit of measurement of the sensor. | def unit_of_measurement(self) -> Optional[str]:
"""Return the unit of measurement of the sensor."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
69,
4
] | [
71,
40
] | python | en | ['en', 'bg', 'en'] | True |
IncomfortPressure.__init__ | (self, client, heater, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, client, heater, name) -> None:
"""Initialize the sensor."""
super().__init__(client, heater, name)
self._device_class = DEVICE_CLASS_PRESSURE
self._unit_of_measurement = PRESSURE_BAR | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"heater",
",",
"name",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"client",
",",
"heater",
",",
"name",
")",
"self",
".",
"_device_class",
"=",
"DEVICE_CLASS_PRESSURE",
"self",
"... | [
77,
4
] | [
82,
48
] | python | en | ['en', 'en', 'en'] | True |
IncomfortTemperature.__init__ | (self, client, heater, name) | Initialize the signal strength sensor. | Initialize the signal strength sensor. | def __init__(self, client, heater, name) -> None:
"""Initialize the signal strength sensor."""
super().__init__(client, heater, name)
self._attr = INCOMFORT_MAP_ATTRS[name][1]
self._device_class = DEVICE_CLASS_TEMPERATURE
self._unit_of_measurement = TEMP_CELSIUS | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"heater",
",",
"name",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"client",
",",
"heater",
",",
"name",
")",
"self",
".",
"_attr",
"=",
"INCOMFORT_MAP_ATTRS",
"[",
"name",
"]",... | [
88,
4
] | [
94,
48
] | python | en | ['en', 'pt', 'en'] | True |
IncomfortTemperature.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the device state attributes."""
return {self._attr: self._heater.status[self._attr]} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"self",
".",
"_attr",
":",
"self",
".",
"_heater",
".",
"status",
"[",
"self",
".",
"_attr",
"]",
"}"
] | [
97,
4
] | [
99,
60
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Hive water heater devices. | Set up the Hive water heater devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Hive water heater devices."""
if discovery_info is None:
return
session = hass.data.get(DATA_HIVE)
devs = []
for dev in discovery_info:
devs.append(HiveWaterHeater(session, dev))
add_entities(devs... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"session",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_HIVE",
")",
"devs",
"... | [
19,
0
] | [
28,
22
] | python | en | ['en', 'en', 'en'] | True |
HiveWaterHeater.unique_id | (self) | Return unique ID of entity. | Return unique ID of entity. | def unique_id(self):
"""Return unique ID of entity."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
35,
4
] | [
37,
30
] | python | en | ['en', 'cy', 'en'] | True |
HiveWaterHeater.device_info | (self) | Return device information. | Return device information. | def device_info(self):
"""Return device information."""
return {"identifiers": {(DOMAIN, self.unique_id)}, "name": self.name} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
"}"
] | [
40,
4
] | [
42,
77
] | python | da | ['es', 'da', 'en'] | False |
HiveWaterHeater.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_FLAGS_HEATER | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_FLAGS_HEATER"
] | [
45,
4
] | [
47,
35
] | python | en | ['en', 'en', 'en'] | True |
HiveWaterHeater.name | (self) | Return the name of the water heater. | Return the name of the water heater. | def name(self):
"""Return the name of the water heater."""
if self.node_name is None:
self.node_name = "Hot Water"
return self.node_name | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"node_name",
"is",
"None",
":",
"self",
".",
"node_name",
"=",
"\"Hot Water\"",
"return",
"self",
".",
"node_name"
] | [
50,
4
] | [
54,
29
] | python | en | ['en', 'en', 'en'] | True |
HiveWaterHeater.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
57,
4
] | [
59,
27
] | python | en | ['en', 'la', 'en'] | True |
HiveWaterHeater.current_operation | (self) | Return current operation. | Return current operation. | def current_operation(self):
"""Return current operation."""
return HIVE_TO_HASS_STATE[self.session.hotwater.get_mode(self.node_id)] | [
"def",
"current_operation",
"(",
"self",
")",
":",
"return",
"HIVE_TO_HASS_STATE",
"[",
"self",
".",
"session",
".",
"hotwater",
".",
"get_mode",
"(",
"self",
".",
"node_id",
")",
"]"
] | [
62,
4
] | [
64,
79
] | python | bg | ['nl', 'bg', 'en'] | False |
HiveWaterHeater.operation_list | (self) | List of available operation modes. | List of available operation modes. | def operation_list(self):
"""List of available operation modes."""
return SUPPORT_WATER_HEATER | [
"def",
"operation_list",
"(",
"self",
")",
":",
"return",
"SUPPORT_WATER_HEATER"
] | [
67,
4
] | [
69,
35
] | python | en | ['en', 'en', 'en'] | True |
HiveWaterHeater.set_operation_mode | (self, operation_mode) | Set operation mode. | Set operation mode. | def set_operation_mode(self, operation_mode):
"""Set operation mode."""
new_mode = HASS_TO_HIVE_STATE[operation_mode]
self.session.hotwater.set_mode(self.node_id, new_mode) | [
"def",
"set_operation_mode",
"(",
"self",
",",
"operation_mode",
")",
":",
"new_mode",
"=",
"HASS_TO_HIVE_STATE",
"[",
"operation_mode",
"]",
"self",
".",
"session",
".",
"hotwater",
".",
"set_mode",
"(",
"self",
".",
"node_id",
",",
"new_mode",
")"
] | [
72,
4
] | [
75,
62
] | python | en | ['nl', 'ny', 'en'] | False |
HiveWaterHeater.update | (self) | Update all Node data from Hive. | Update all Node data from Hive. | def update(self):
"""Update all Node data from Hive."""
self.session.core.update_data(self.node_id) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"session",
".",
"core",
".",
"update_data",
"(",
"self",
".",
"node_id",
")"
] | [
77,
4
] | [
79,
51
] | python | en | ['en', 'en', 'en'] | True |
test_entity_registry | (hass, requests_mock) | Tests that the devices are registered in the entity registry. | Tests that the devices are registered in the entity registry. | async def test_entity_registry(hass, requests_mock):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, SWITCH_DOMAIN)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
entry = entity_registry.async_get("switch.front_siren")
assert... | [
"async",
"def",
"test_entity_registry",
"(",
"hass",
",",
"requests_mock",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SWITCH_DOMAIN",
")",
"entity_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",... | [
8,
0
] | [
17,
44
] | python | en | ['en', 'en', 'en'] | True |
test_siren_off_reports_correctly | (hass, requests_mock) | Tests that the initial state of a device that should be off is correct. | Tests that the initial state of a device that should be off is correct. | async def test_siren_off_reports_correctly(hass, requests_mock):
"""Tests that the initial state of a device that should be off is correct."""
await setup_platform(hass, SWITCH_DOMAIN)
state = hass.states.get("switch.front_siren")
assert state.state == "off"
assert state.attributes.get("friendly_na... | [
"async",
"def",
"test_siren_off_reports_correctly",
"(",
"hass",
",",
"requests_mock",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SWITCH_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"switch.front_siren\"",
")",
"assert",
"st... | [
20,
0
] | [
26,
65
] | python | en | ['en', 'en', 'en'] | True |
test_siren_on_reports_correctly | (hass, requests_mock) | Tests that the initial state of a device that should be on is correct. | Tests that the initial state of a device that should be on is correct. | async def test_siren_on_reports_correctly(hass, requests_mock):
"""Tests that the initial state of a device that should be on is correct."""
await setup_platform(hass, SWITCH_DOMAIN)
state = hass.states.get("switch.internal_siren")
assert state.state == "on"
assert state.attributes.get("friendly_na... | [
"async",
"def",
"test_siren_on_reports_correctly",
"(",
"hass",
",",
"requests_mock",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SWITCH_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"switch.internal_siren\"",
")",
"assert",
"... | [
29,
0
] | [
36,
59
] | python | en | ['en', 'en', 'en'] | True |
test_siren_can_be_turned_on | (hass, requests_mock) | Tests the siren turns on correctly. | Tests the siren turns on correctly. | async def test_siren_can_be_turned_on(hass, requests_mock):
"""Tests the siren turns on correctly."""
await setup_platform(hass, SWITCH_DOMAIN)
# Mocks the response for turning a siren on
requests_mock.put(
"https://api.ring.com/clients_api/doorbots/765432/siren_on",
text=load_fixture("... | [
"async",
"def",
"test_siren_can_be_turned_on",
"(",
"hass",
",",
"requests_mock",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SWITCH_DOMAIN",
")",
"# Mocks the response for turning a siren on",
"requests_mock",
".",
"put",
"(",
"\"https://api.ring.com/clients_ap... | [
39,
0
] | [
58,
30
] | python | en | ['en', 'en', 'en'] | True |
test_updates_work | (hass, requests_mock) | Tests the update service works correctly. | Tests the update service works correctly. | async def test_updates_work(hass, requests_mock):
"""Tests the update service works correctly."""
await setup_platform(hass, SWITCH_DOMAIN)
state = hass.states.get("switch.front_siren")
assert state.state == "off"
# Changes the return to indicate that the siren is now on.
requests_mock.get(
... | [
"async",
"def",
"test_updates_work",
"(",
"hass",
",",
"requests_mock",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SWITCH_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"switch.front_siren\"",
")",
"assert",
"state",
".",
... | [
61,
0
] | [
77,
30
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the GreenEye Monitor component. | Set up the GreenEye Monitor component. | async def async_setup(hass, config):
"""Set up the GreenEye Monitor component."""
monitors = Monitors()
hass.data[DATA_GREENEYE_MONITOR] = monitors
server_config = config[DOMAIN]
server = await monitors.start_server(server_config[CONF_PORT])
async def close_server(*args):
"""Close the... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"monitors",
"=",
"Monitors",
"(",
")",
"hass",
".",
"data",
"[",
"DATA_GREENEYE_MONITOR",
"]",
"=",
"monitors",
"server_config",
"=",
"config",
"[",
"DOMAIN",
"]",
"server",
"=",
"await",... | [
119,
0
] | [
196,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the tankerkoenig sensors. | Set up the tankerkoenig sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the tankerkoenig sensors."""
if discovery_info is None:
return
tankerkoenig = hass.data[DOMAIN]
async def async_update_data():
"""Fetch data from API endpoint."""
try:
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"tankerkoenig",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"a... | [
33,
0
] | [
78,
32
] | python | en | ['en', 'no', 'en'] | True |
FuelPriceSensor.__init__ | (self, fuel_type, station, coordinator, name, show_on_map) | Initialize the sensor. | Initialize the sensor. | def __init__(self, fuel_type, station, coordinator, name, show_on_map):
"""Initialize the sensor."""
super().__init__(coordinator)
self._station = station
self._station_id = station["id"]
self._fuel_type = fuel_type
self._name = name
self._latitude = station["lat"... | [
"def",
"__init__",
"(",
"self",
",",
"fuel_type",
",",
"station",
",",
"coordinator",
",",
"name",
",",
"show_on_map",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_station",
"=",
"station",
"self",
".",
"_station_... | [
84,
4
] | [
98,
39
] | 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.