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_dataSet1 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet1(hass):
"""Test derivative sensor state."""
await setup_tests(
hass,
{"unit_time": TIME_SECONDS},
times=[20, 30, 40, 50],
values=[10, 30, 5, 0],
expected_state=-0.5,
) | [
"async",
"def",
"test_dataSet1",
"(",
"hass",
")",
":",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"\"unit_time\"",
":",
"TIME_SECONDS",
"}",
",",
"times",
"=",
"[",
"20",
",",
"30",
",",
"40",
",",
"50",
"]",
",",
"values",
"=",
"[",
"10",
","... | [
79,
0
] | [
87,
5
] | python | bs | ['fr', 'bs', 'en'] | False |
test_dataSet2 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet2(hass):
"""Test derivative sensor state."""
await setup_tests(
hass,
{"unit_time": TIME_SECONDS},
times=[20, 30],
values=[5, 0],
expected_state=-0.5,
) | [
"async",
"def",
"test_dataSet2",
"(",
"hass",
")",
":",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"\"unit_time\"",
":",
"TIME_SECONDS",
"}",
",",
"times",
"=",
"[",
"20",
",",
"30",
"]",
",",
"values",
"=",
"[",
"5",
",",
"0",
"]",
",",
"expec... | [
90,
0
] | [
98,
5
] | python | bs | ['fr', 'bs', 'en'] | False |
test_dataSet3 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet3(hass):
"""Test derivative sensor state."""
state = await setup_tests(
hass,
{"unit_time": TIME_SECONDS},
times=[20, 30],
values=[5, 10],
expected_state=0.5,
)
assert state.attributes.get("unit_of_measurement") == f"/{TIME_SECONDS}" | [
"async",
"def",
"test_dataSet3",
"(",
"hass",
")",
":",
"state",
"=",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"\"unit_time\"",
":",
"TIME_SECONDS",
"}",
",",
"times",
"=",
"[",
"20",
",",
"30",
"]",
",",
"values",
"=",
"[",
"5",
",",
"10",
"... | [
101,
0
] | [
111,
76
] | python | bs | ['fr', 'bs', 'en'] | False |
test_dataSet4 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet4(hass):
"""Test derivative sensor state."""
await setup_tests(
hass,
{"unit_time": TIME_SECONDS},
times=[20, 30],
values=[5, 5],
expected_state=0,
) | [
"async",
"def",
"test_dataSet4",
"(",
"hass",
")",
":",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"\"unit_time\"",
":",
"TIME_SECONDS",
"}",
",",
"times",
"=",
"[",
"20",
",",
"30",
"]",
",",
"values",
"=",
"[",
"5",
",",
"5",
"]",
",",
"expec... | [
114,
0
] | [
122,
5
] | python | bs | ['fr', 'bs', 'en'] | False |
test_dataSet5 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet5(hass):
"""Test derivative sensor state."""
await setup_tests(
hass,
{"unit_time": TIME_SECONDS},
times=[20, 30],
values=[10, -10],
expected_state=-2,
) | [
"async",
"def",
"test_dataSet5",
"(",
"hass",
")",
":",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"\"unit_time\"",
":",
"TIME_SECONDS",
"}",
",",
"times",
"=",
"[",
"20",
",",
"30",
"]",
",",
"values",
"=",
"[",
"10",
",",
"-",
"10",
"]",
",",... | [
125,
0
] | [
133,
5
] | python | bs | ['fr', 'bs', 'en'] | False |
test_dataSet6 | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_dataSet6(hass):
"""Test derivative sensor state."""
await setup_tests(hass, {}, times=[0, 60], values=[0, 1 / 60], expected_state=1) | [
"async",
"def",
"test_dataSet6",
"(",
"hass",
")",
":",
"await",
"setup_tests",
"(",
"hass",
",",
"{",
"}",
",",
"times",
"=",
"[",
"0",
",",
"60",
"]",
",",
"values",
"=",
"[",
"0",
",",
"1",
"/",
"60",
"]",
",",
"expected_state",
"=",
"1",
")... | [
136,
0
] | [
138,
84
] | python | bs | ['fr', 'bs', 'en'] | False |
test_data_moving_average_for_discrete_sensor | (hass) | Test derivative sensor state. | Test derivative sensor state. | async def test_data_moving_average_for_discrete_sensor(hass):
"""Test derivative sensor state."""
# We simulate the following situation:
# The temperature rises 1 °C per minute for 30 minutes long.
# There is a data point every 30 seconds, however, the sensor returns
# the temperature rounded down t... | [
"async",
"def",
"test_data_moving_average_for_discrete_sensor",
"(",
"hass",
")",
":",
"# We simulate the following situation:",
"# The temperature rises 1 °C per minute for 30 minutes long.",
"# There is a data point every 30 seconds, however, the sensor returns",
"# the temperature rounded dow... | [
141,
0
] | [
176,
52
] | python | bs | ['fr', 'bs', 'en'] | False |
test_prefix | (hass) | Test derivative sensor state using a power source. | Test derivative sensor state using a power source. | async def test_prefix(hass):
"""Test derivative sensor state using a power source."""
config = {
"sensor": {
"platform": "derivative",
"name": "derivative",
"source": "sensor.power",
"round": 2,
"unit_prefix": "k",
}
}
assert a... | [
"async",
"def",
"test_prefix",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"derivative\"",
",",
"\"name\"",
":",
"\"derivative\"",
",",
"\"source\"",
":",
"\"sensor.power\"",
",",
"\"round\"",
":",
"2",
",",
"\"u... | [
179,
0
] | [
211,
76
] | python | en | ['en', 'en', 'en'] | True |
test_suffix | (hass) | Test derivative sensor state using a network counter source. | Test derivative sensor state using a network counter source. | async def test_suffix(hass):
"""Test derivative sensor state using a network counter source."""
config = {
"sensor": {
"platform": "derivative",
"name": "derivative",
"source": "sensor.bytes_per_second",
"round": 2,
"unit_prefix": "k",
... | [
"async",
"def",
"test_suffix",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"derivative\"",
",",
"\"name\"",
":",
"\"derivative\"",
",",
"\"source\"",
":",
"\"sensor.bytes_per_second\"",
",",
"\"round\"",
":",
"2",
... | [
214,
0
] | [
242,
70
] | python | en | ['fr', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the scenes for Velux platform. | Set up the scenes for Velux platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the scenes for Velux platform."""
entities = [VeluxScene(scene) for scene in hass.data[DATA_VELUX].pyvlx.scenes]
async_add_entities(entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"VeluxScene",
"(",
"scene",
")",
"for",
"scene",
"in",
"hass",
".",
"data",
"[",
"DATA_VELUX",
... | [
8,
0
] | [
11,
32
] | python | en | ['en', 'da', 'en'] | True |
VeluxScene.__init__ | (self, scene) | Init velux scene. | Init velux scene. | def __init__(self, scene):
"""Init velux scene."""
_LOGGER.info("Adding Velux scene: %s", scene)
self.scene = scene | [
"def",
"__init__",
"(",
"self",
",",
"scene",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Adding Velux scene: %s\"",
",",
"scene",
")",
"self",
".",
"scene",
"=",
"scene"
] | [
17,
4
] | [
20,
26
] | python | fr | ['fr', 'sl', 'tr'] | False |
VeluxScene.name | (self) | Return the name of the scene. | Return the name of the scene. | def name(self):
"""Return the name of the scene."""
return self.scene.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"scene",
".",
"name"
] | [
23,
4
] | [
25,
30
] | python | en | ['en', 'ig', 'en'] | True |
VeluxScene.async_activate | (self, **kwargs: Any) | Activate the scene. | Activate the scene. | async def async_activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
await self.scene.run(wait_for_completion=False) | [
"async",
"def",
"async_activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"scene",
".",
"run",
"(",
"wait_for_completion",
"=",
"False",
")"
] | [
27,
4
] | [
29,
55
] | python | en | ['en', 'it', 'en'] | True |
_encode | (value: Any) | Little helper to JSON encode a value. | Little helper to JSON encode a value. | def _encode(value: Any) -> Any:
"""Little helper to JSON encode a value."""
try:
return JSONEncoder.default(
None, # type: ignore
value,
)
except TypeError:
return value | [
"def",
"_encode",
"(",
"value",
":",
"Any",
")",
"->",
"Any",
":",
"try",
":",
"return",
"JSONEncoder",
".",
"default",
"(",
"None",
",",
"# type: ignore",
"value",
",",
")",
"except",
"TypeError",
":",
"return",
"value"
] | [
204,
0
] | [
212,
20
] | python | en | ['en', 'lb', 'en'] | True |
_encode_complex | (value: Any) | Recursively encode all values with the JSONEncoder. | Recursively encode all values with the JSONEncoder. | def _encode_complex(value: Any) -> Any:
"""Recursively encode all values with the JSONEncoder."""
if isinstance(value, dict):
return {_encode(key): _encode_complex(value) for key, value in value.items()}
if isinstance(value, list):
return [_encode_complex(val) for val in value]
new_valu... | [
"def",
"_encode_complex",
"(",
"value",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"return",
"{",
"_encode",
"(",
"key",
")",
":",
"_encode_complex",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in"... | [
215,
0
] | [
227,
37
] | python | en | ['en', 'en', 'en'] | True |
StoredState.__init__ | (self, state: State, last_seen: datetime) | Initialize a new stored state. | Initialize a new stored state. | def __init__(self, state: State, last_seen: datetime) -> None:
"""Initialize a new stored state."""
self.state = state
self.last_seen = last_seen | [
"def",
"__init__",
"(",
"self",
",",
"state",
":",
"State",
",",
"last_seen",
":",
"datetime",
")",
"->",
"None",
":",
"self",
".",
"state",
"=",
"state",
"self",
".",
"last_seen",
"=",
"last_seen"
] | [
40,
4
] | [
43,
34
] | python | en | ['en', 'en', 'en'] | True |
StoredState.as_dict | (self) | Return a dict representation of the stored state. | Return a dict representation of the stored state. | def as_dict(self) -> Dict[str, Any]:
"""Return a dict representation of the stored state."""
return {"state": self.state.as_dict(), "last_seen": self.last_seen} | [
"def",
"as_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"state\"",
":",
"self",
".",
"state",
".",
"as_dict",
"(",
")",
",",
"\"last_seen\"",
":",
"self",
".",
"last_seen",
"}"
] | [
45,
4
] | [
47,
75
] | python | en | ['en', 'en', 'en'] | True |
StoredState.from_dict | (cls, json_dict: Dict) | Initialize a stored state from a dict. | Initialize a stored state from a dict. | def from_dict(cls, json_dict: Dict) -> "StoredState":
"""Initialize a stored state from a dict."""
last_seen = json_dict["last_seen"]
if isinstance(last_seen, str):
last_seen = dt_util.parse_datetime(last_seen)
return cls(State.from_dict(json_dict["state"]), last_seen) | [
"def",
"from_dict",
"(",
"cls",
",",
"json_dict",
":",
"Dict",
")",
"->",
"\"StoredState\"",
":",
"last_seen",
"=",
"json_dict",
"[",
"\"last_seen\"",
"]",
"if",
"isinstance",
"(",
"last_seen",
",",
"str",
")",
":",
"last_seen",
"=",
"dt_util",
".",
"parse... | [
50,
4
] | [
57,
66
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_get_instance | (cls, hass: HomeAssistant) | Get the singleton instance of this data helper. | Get the singleton instance of this data helper. | async def async_get_instance(cls, hass: HomeAssistant) -> "RestoreStateData":
"""Get the singleton instance of this data helper."""
@singleton(DATA_RESTORE_STATE_TASK)
async def load_instance(hass: HomeAssistant) -> "RestoreStateData":
"""Get the singleton instance of this data help... | [
"async",
"def",
"async_get_instance",
"(",
"cls",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"\"RestoreStateData\"",
":",
"@",
"singleton",
"(",
"DATA_RESTORE_STATE_TASK",
")",
"async",
"def",
"load_instance",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"\"... | [
64,
4
] | [
98,
64
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.__init__ | (self, hass: HomeAssistant) | Initialize the restore state data class. | Initialize the restore state data class. | def __init__(self, hass: HomeAssistant) -> None:
"""Initialize the restore state data class."""
self.hass: HomeAssistant = hass
self.store: Store = Store(
hass, STORAGE_VERSION, STORAGE_KEY, encoder=JSONEncoder
)
self.last_states: Dict[str, StoredState] = {}
s... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"self",
".",
"hass",
":",
"HomeAssistant",
"=",
"hass",
"self",
".",
"store",
":",
"Store",
"=",
"Store",
"(",
"hass",
",",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
... | [
100,
4
] | [
107,
41
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_get_stored_states | (self) | Get the set of states which should be stored.
This includes the states of all registered entities, as well as the
stored states from the previous run, which have not been created as
entities on this run, and have not expired.
| Get the set of states which should be stored. | def async_get_stored_states(self) -> List[StoredState]:
"""Get the set of states which should be stored.
This includes the states of all registered entities, as well as the
stored states from the previous run, which have not been created as
entities on this run, and have not expired.
... | [
"def",
"async_get_stored_states",
"(",
"self",
")",
"->",
"List",
"[",
"StoredState",
"]",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"all_states",
"=",
"self",
".",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
"# Entities currently backed by... | [
110,
4
] | [
149,
28
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_dump_states | (self) | Save the current state machine to storage. | Save the current state machine to storage. | async def async_dump_states(self) -> None:
"""Save the current state machine to storage."""
_LOGGER.debug("Dumping states")
try:
await self.store.async_save(
[
stored_state.as_dict()
for stored_state in self.async_get_stored_sta... | [
"async",
"def",
"async_dump_states",
"(",
"self",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Dumping states\"",
")",
"try",
":",
"await",
"self",
".",
"store",
".",
"async_save",
"(",
"[",
"stored_state",
".",
"as_dict",
"(",
")",
"for",
"s... | [
151,
4
] | [
162,
70
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_setup_dump | (self, *args: Any) | Set up the restore state listeners. | Set up the restore state listeners. | def async_setup_dump(self, *args: Any) -> None:
"""Set up the restore state listeners."""
async def _async_dump_states(*_: Any) -> None:
await self.async_dump_states()
# Dump the initial states now. This helps minimize the risk of having
# old states loaded by overwriting t... | [
"def",
"async_setup_dump",
"(",
"self",
",",
"*",
"args",
":",
"Any",
")",
"->",
"None",
":",
"async",
"def",
"_async_dump_states",
"(",
"*",
"_",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"async_dump_states",
"(",
")",
"# Dump the initia... | [
165,
4
] | [
180,
85
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_restore_entity_added | (self, entity_id: str) | Store this entity's state when hass is shutdown. | Store this entity's state when hass is shutdown. | def async_restore_entity_added(self, entity_id: str) -> None:
"""Store this entity's state when hass is shutdown."""
self.entity_ids.add(entity_id) | [
"def",
"async_restore_entity_added",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"entity_ids",
".",
"add",
"(",
"entity_id",
")"
] | [
183,
4
] | [
185,
38
] | python | en | ['en', 'en', 'en'] | True |
RestoreStateData.async_restore_entity_removed | (self, entity_id: str) | Unregister this entity from saving state. | Unregister this entity from saving state. | def async_restore_entity_removed(self, entity_id: str) -> None:
"""Unregister this entity from saving state."""
# When an entity is being removed from hass, store its last state. This
# allows us to support state restoration if the entity is removed, then
# re-added while hass is still r... | [
"def",
"async_restore_entity_removed",
"(",
"self",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"# When an entity is being removed from hass, store its last state. This",
"# allows us to support state restoration if the entity is removed, then",
"# re-added while hass is still ... | [
188,
4
] | [
201,
41
] | python | en | ['en', 'en', 'en'] | True |
RestoreEntity.async_internal_added_to_hass | (self) | Register this entity as a restorable entity. | Register this entity as a restorable entity. | async def async_internal_added_to_hass(self) -> None:
"""Register this entity as a restorable entity."""
assert self.hass is not None
_, data = await asyncio.gather(
super().async_internal_added_to_hass(),
RestoreStateData.async_get_instance(self.hass),
)
... | [
"async",
"def",
"async_internal_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"_",
",",
"data",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"super",
"(",
")",
".",
"async_internal_added_to_hass",
... | [
233,
4
] | [
240,
55
] | python | en | ['en', 'en', 'en'] | True |
RestoreEntity.async_internal_will_remove_from_hass | (self) | Run when entity will be removed from hass. | 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."""
assert self.hass is not None
_, data = await asyncio.gather(
super().async_internal_will_remove_from_hass(),
RestoreStateData.async_get_instance(self.hass),
... | [
"async",
"def",
"async_internal_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"_",
",",
"data",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"super",
"(",
")",
".",
"async_internal_will_remov... | [
242,
4
] | [
249,
57
] | python | en | ['en', 'en', 'en'] | True |
RestoreEntity.async_get_last_state | (self) | Get the entity state from the previous run. | Get the entity state from the previous run. | async def async_get_last_state(self) -> Optional[State]:
"""Get the entity state from the previous run."""
if self.hass is None or self.entity_id is None:
# Return None if this entity isn't added to hass yet
_LOGGER.warning("Cannot get last state. Entity not added to hass")
... | [
"async",
"def",
"async_get_last_state",
"(",
"self",
")",
"->",
"Optional",
"[",
"State",
"]",
":",
"if",
"self",
".",
"hass",
"is",
"None",
"or",
"self",
".",
"entity_id",
"is",
"None",
":",
"# Return None if this entity isn't added to hass yet",
"_LOGGER",
"."... | [
251,
4
] | [
260,
53
] | python | en | ['en', 'en', 'en'] | True |
ShoppingListFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
# Check if already configured
await self.async_set_unique_id(DOMAIN)
self._abort_if_unique_id_configured()
if user_input is not None:
return self.async_create_entry(title="... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"# Check if already configured",
"await",
"self",
".",
"async_set_unique_id",
"(",
"DOMAIN",
")",
"self",
".",
"_abort_if_unique_id_configured",
"(",
")",
"if",
"user_input",
... | [
12,
4
] | [
21,
51
] | python | en | ['en', 'en', 'en'] | True |
mock_connection_fixture | () | Return a mocked connection. | Return a mocked connection. | def mock_connection_fixture() -> AsyncConnection:
"""Return a mocked connection."""
connection = MagicMock(spec=AsyncConnection)
def _rest_call_side_effect(path, body=None):
return path, body
connection._restCall.side_effect = ( # pylint: disable=protected-access
_rest_call_side_effec... | [
"def",
"mock_connection_fixture",
"(",
")",
"->",
"AsyncConnection",
":",
"connection",
"=",
"MagicMock",
"(",
"spec",
"=",
"AsyncConnection",
")",
"def",
"_rest_call_side_effect",
"(",
"path",
",",
"body",
"=",
"None",
")",
":",
"return",
"path",
",",
"body",... | [
30,
0
] | [
43,
21
] | python | en | ['en', 'en', 'en'] | True |
hmip_config_entry_fixture | () | Create a mock config entriy for homematic ip cloud. | Create a mock config entriy for homematic ip cloud. | def hmip_config_entry_fixture() -> config_entries.ConfigEntry:
"""Create a mock config entriy for homematic ip cloud."""
entry_data = {
HMIPC_HAPID: HAPID,
HMIPC_AUTHTOKEN: AUTH_TOKEN,
HMIPC_NAME: "",
HMIPC_PIN: HAPPIN,
}
config_entry = MockConfigEntry(
version=1,... | [
"def",
"hmip_config_entry_fixture",
"(",
")",
"->",
"config_entries",
".",
"ConfigEntry",
":",
"entry_data",
"=",
"{",
"HMIPC_HAPID",
":",
"HAPID",
",",
"HMIPC_AUTHTOKEN",
":",
"AUTH_TOKEN",
",",
"HMIPC_NAME",
":",
"\"\"",
",",
"HMIPC_PIN",
":",
"HAPPIN",
",",
... | [
47,
0
] | [
66,
23
] | python | en | ['en', 'en', 'en'] | True |
default_mock_hap_factory_fixture | (
hass: HomeAssistantType, mock_connection, hmip_config_entry
) | Create a mocked homematic access point. | Create a mocked homematic access point. | async def default_mock_hap_factory_fixture(
hass: HomeAssistantType, mock_connection, hmip_config_entry
) -> HomematicipHAP:
"""Create a mocked homematic access point."""
return HomeFactory(hass, mock_connection, hmip_config_entry) | [
"async",
"def",
"default_mock_hap_factory_fixture",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_connection",
",",
"hmip_config_entry",
")",
"->",
"HomematicipHAP",
":",
"return",
"HomeFactory",
"(",
"hass",
",",
"mock_connection",
",",
"hmip_config_entry",
")"
] | [
70,
0
] | [
74,
64
] | python | en | ['en', 'en', 'en'] | True |
hmip_config_fixture | () | Create a config for homematic ip cloud. | Create a config for homematic ip cloud. | def hmip_config_fixture() -> ConfigType:
"""Create a config for homematic ip cloud."""
entry_data = {
HMIPC_HAPID: HAPID,
HMIPC_AUTHTOKEN: AUTH_TOKEN,
HMIPC_NAME: "",
HMIPC_PIN: HAPPIN,
}
return {HMIPC_DOMAIN: [entry_data]} | [
"def",
"hmip_config_fixture",
"(",
")",
"->",
"ConfigType",
":",
"entry_data",
"=",
"{",
"HMIPC_HAPID",
":",
"HAPID",
",",
"HMIPC_AUTHTOKEN",
":",
"AUTH_TOKEN",
",",
"HMIPC_NAME",
":",
"\"\"",
",",
"HMIPC_PIN",
":",
"HAPPIN",
",",
"}",
"return",
"{",
"HMIPC_... | [
78,
0
] | [
88,
39
] | python | en | ['en', 'en', 'en'] | True |
dummy_config_fixture | () | Create a dummy config. | Create a dummy config. | def dummy_config_fixture() -> ConfigType:
"""Create a dummy config."""
return {"blabla": None} | [
"def",
"dummy_config_fixture",
"(",
")",
"->",
"ConfigType",
":",
"return",
"{",
"\"blabla\"",
":",
"None",
"}"
] | [
92,
0
] | [
94,
27
] | python | en | ['en', 'ga', 'en'] | True |
mock_hap_with_service_fixture | (
hass: HomeAssistantType, default_mock_hap_factory, dummy_config
) | Create a fake homematic access point with hass services. | Create a fake homematic access point with hass services. | async def mock_hap_with_service_fixture(
hass: HomeAssistantType, default_mock_hap_factory, dummy_config
) -> HomematicipHAP:
"""Create a fake homematic access point with hass services."""
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
await hmip_async_setup(hass, dummy_config)
await... | [
"async",
"def",
"mock_hap_with_service_fixture",
"(",
"hass",
":",
"HomeAssistantType",
",",
"default_mock_hap_factory",
",",
"dummy_config",
")",
"->",
"HomematicipHAP",
":",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"async_get_mock_hap",
"(",
")",
"aw... | [
98,
0
] | [
106,
19
] | python | en | ['en', 'en', 'en'] | True |
simple_mock_home_fixture | () | Return a simple mocked connection. | Return a simple mocked connection. | def simple_mock_home_fixture():
"""Return a simple mocked connection."""
mock_home = Mock(
spec=AsyncHome,
name="Demo",
devices=[],
groups=[],
location=Mock(),
weather=Mock(
temperature=0.0,
weatherCondition=WeatherCondition.UNKNOWN,
... | [
"def",
"simple_mock_home_fixture",
"(",
")",
":",
"mock_home",
"=",
"Mock",
"(",
"spec",
"=",
"AsyncHome",
",",
"name",
"=",
"\"Demo\"",
",",
"devices",
"=",
"[",
"]",
",",
"groups",
"=",
"[",
"]",
",",
"location",
"=",
"Mock",
"(",
")",
",",
"weathe... | [
110,
0
] | [
141,
13
] | python | en | ['en', 'en', 'en'] | True |
mock_connection_init_fixture | () | Return a simple mocked connection. | Return a simple mocked connection. | def mock_connection_init_fixture():
"""Return a simple mocked connection."""
with patch(
"homeassistant.components.homematicip_cloud.hap.AsyncHome.init",
return_value=None,
), patch(
"homeassistant.components.homematicip_cloud.hap.AsyncAuth.init",
return_value=None,
):
... | [
"def",
"mock_connection_init_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.homematicip_cloud.hap.AsyncHome.init\"",
",",
"return_value",
"=",
"None",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.homematicip_cloud.hap.AsyncAuth.init\"",
"... | [
145,
0
] | [
155,
13
] | python | en | ['en', 'en', 'en'] | True |
simple_mock_auth_fixture | () | Return a simple AsyncAuth Mock. | Return a simple AsyncAuth Mock. | def simple_mock_auth_fixture() -> AsyncAuth:
"""Return a simple AsyncAuth Mock."""
return Mock(spec=AsyncAuth, pin=HAPPIN, create=True) | [
"def",
"simple_mock_auth_fixture",
"(",
")",
"->",
"AsyncAuth",
":",
"return",
"Mock",
"(",
"spec",
"=",
"AsyncAuth",
",",
"pin",
"=",
"HAPPIN",
",",
"create",
"=",
"True",
")"
] | [
159,
0
] | [
161,
56
] | python | en | ['en', 'cy', 'en'] | True |
AxisEntityBase.__init__ | (self, device) | Initialize the Axis event. | Initialize the Axis event. | def __init__(self, device):
"""Initialize the Axis event."""
self.device = device | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"device",
"=",
"device"
] | [
12,
4
] | [
14,
28
] | python | en | ['en', 'en', 'en'] | True |
AxisEntityBase.async_added_to_hass | (self) | Subscribe device events. | Subscribe device events. | async def async_added_to_hass(self):
"""Subscribe device events."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, self.device.signal_reachable, self.update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"device",
".",
"signal_reachable",
",",
"self",
".",
"update_callback",
")",
")"
] | [
16,
4
] | [
22,
9
] | python | en | ['it', 'en', 'en'] | True |
AxisEntityBase.available | (self) | Return True if device is available. | Return True if device is available. | def available(self):
"""Return True if device is available."""
return self.device.available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"available"
] | [
25,
4
] | [
27,
36
] | python | en | ['en', 'en', 'en'] | True |
AxisEntityBase.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return {"identifiers": {(AXIS_DOMAIN, self.device.serial)}} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"AXIS_DOMAIN",
",",
"self",
".",
"device",
".",
"serial",
")",
"}",
"}"
] | [
30,
4
] | [
32,
67
] | python | en | ['ro', 'fr', 'en'] | False |
AxisEntityBase.update_callback | (self, no_delay=None) | Update the entities state. | Update the entities state. | def update_callback(self, no_delay=None):
"""Update the entities state."""
self.async_write_ha_state() | [
"def",
"update_callback",
"(",
"self",
",",
"no_delay",
"=",
"None",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
35,
4
] | [
37,
35
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.__init__ | (self, event, device) | Initialize the Axis event. | Initialize the Axis event. | def __init__(self, event, device):
"""Initialize the Axis event."""
super().__init__(device)
self.event = event | [
"def",
"__init__",
"(",
"self",
",",
"event",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"event",
"=",
"event"
] | [
43,
4
] | [
46,
26
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.async_added_to_hass | (self) | Subscribe sensors events. | Subscribe sensors events. | async def async_added_to_hass(self) -> None:
"""Subscribe sensors events."""
self.event.register_callback(self.update_callback)
await super().async_added_to_hass() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"event",
".",
"register_callback",
"(",
"self",
".",
"update_callback",
")",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")"
] | [
48,
4
] | [
51,
43
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.async_will_remove_from_hass | (self) | Disconnect device object when removed. | Disconnect device object when removed. | async def async_will_remove_from_hass(self) -> None:
"""Disconnect device object when removed."""
self.event.remove_callback(self.update_callback) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"event",
".",
"remove_callback",
"(",
"self",
".",
"update_callback",
")"
] | [
53,
4
] | [
55,
56
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.device_class | (self) | Return the class of the event. | Return the class of the event. | def device_class(self):
"""Return the class of the event."""
return self.event.CLASS | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"event",
".",
"CLASS"
] | [
58,
4
] | [
60,
31
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.name | (self) | Return the name of the event. | Return the name of the event. | def name(self):
"""Return the name of the event."""
return f"{self.device.name} {self.event.TYPE} {self.event.id}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.device.name} {self.event.TYPE} {self.event.id}\""
] | [
63,
4
] | [
65,
70
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
68,
4
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
AxisEventBase.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}-{self.event.topic}-{self.event.id}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.device.serial}-{self.event.topic}-{self.event.id}\""
] | [
73,
4
] | [
75,
73
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Neato component. | Set up the Neato component. | async def async_setup(hass, config):
"""Set up the Neato component."""
if NEATO_DOMAIN not in config:
# There is an entry and nothing in configuration.yaml
return True
entries = hass.config_entries.async_entries(NEATO_DOMAIN)
hass.data[NEATO_CONFIG] = config[NEATO_DOMAIN]
if entri... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"NEATO_DOMAIN",
"not",
"in",
"config",
":",
"# There is an entry and nothing in configuration.yaml",
"return",
"True",
"entries",
"=",
"hass",
".",
"config_entries",
".",
"async_entries",
"("... | [
44,
0
] | [
89,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up config entry. | Set up config entry. | async def async_setup_entry(hass, entry):
"""Set up config entry."""
hub = NeatoHub(hass, entry.data, Account)
await hass.async_add_executor_job(hub.login)
if not hub.logged_in:
_LOGGER.debug("Failed to login to Neato API")
return False
try:
await hass.async_add_executor_jo... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hub",
"=",
"NeatoHub",
"(",
"hass",
",",
"entry",
".",
"data",
",",
"Account",
")",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"hub",
".",
"login",
")",
"if",
"not",
"... | [
92,
0
] | [
114,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload config entry. | Unload config entry. | async def async_unload_entry(hass, entry):
"""Unload config entry."""
hass.data.pop(NEATO_LOGIN)
await asyncio.gather(
hass.config_entries.async_forward_entry_unload(entry, "camera"),
hass.config_entries.async_forward_entry_unload(entry, "vacuum"),
hass.config_entries.async_forward_e... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"data",
".",
"pop",
"(",
"NEATO_LOGIN",
")",
"await",
"asyncio",
".",
"gather",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
... | [
117,
0
] | [
126,
15
] | python | da | ['da', 'es', 'en'] | False |
NeatoHub.__init__ | (self, hass, domain_config, neato) | Initialize the Neato hub. | Initialize the Neato hub. | def __init__(self, hass, domain_config, neato):
"""Initialize the Neato hub."""
self.config = domain_config
self._neato = neato
self._hass = hass
if self.config[CONF_VENDOR] == "vorwerk":
self._vendor = Vorwerk()
else: # Neato
self._vendor = Neat... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"domain_config",
",",
"neato",
")",
":",
"self",
".",
"config",
"=",
"domain_config",
"self",
".",
"_neato",
"=",
"neato",
"self",
".",
"_hass",
"=",
"hass",
"if",
"self",
".",
"config",
"[",
"CONF_VEND... | [
132,
4
] | [
144,
30
] | python | en | ['en', 'en', 'en'] | True |
NeatoHub.login | (self) | Login to My Neato. | Login to My Neato. | def login(self):
"""Login to My Neato."""
_LOGGER.debug("Trying to connect to Neato API")
try:
self.my_neato = self._neato(
self.config[CONF_USERNAME], self.config[CONF_PASSWORD], self._vendor
)
except NeatoException as ex:
if isinstanc... | [
"def",
"login",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Trying to connect to Neato API\"",
")",
"try",
":",
"self",
".",
"my_neato",
"=",
"self",
".",
"_neato",
"(",
"self",
".",
"config",
"[",
"CONF_USERNAME",
"]",
",",
"self",
".",
"con... | [
146,
4
] | [
163,
60
] | python | en | ['en', 'ne', 'en'] | True |
NeatoHub.update_robots | (self) | Update the robot states. | Update the robot states. | def update_robots(self):
"""Update the robot states."""
_LOGGER.debug("Running HUB.update_robots %s", self._hass.data.get(NEATO_ROBOTS))
self._hass.data[NEATO_ROBOTS] = self.my_neato.robots
self._hass.data[NEATO_PERSISTENT_MAPS] = self.my_neato.persistent_maps
self._hass.data[NEA... | [
"def",
"update_robots",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Running HUB.update_robots %s\"",
",",
"self",
".",
"_hass",
".",
"data",
".",
"get",
"(",
"NEATO_ROBOTS",
")",
")",
"self",
".",
"_hass",
".",
"data",
"[",
"NEATO_ROBOTS",
"]",... | [
166,
4
] | [
171,
60
] | python | en | ['en', 'en', 'en'] | True |
NeatoHub.download_map | (self, url) | Download a new map image. | Download a new map image. | def download_map(self, url):
"""Download a new map image."""
map_image_data = self.my_neato.get_map_image(url)
return map_image_data | [
"def",
"download_map",
"(",
"self",
",",
"url",
")",
":",
"map_image_data",
"=",
"self",
".",
"my_neato",
".",
"get_map_image",
"(",
"url",
")",
"return",
"map_image_data"
] | [
173,
4
] | [
176,
29
] | python | en | ['en', 'en', 'en'] | True |
_async_create_cast_device | (hass: HomeAssistantType, info: ChromecastInfo) | Create a CastDevice Entity from the chromecast object.
Returns None if the cast device has already been added.
| Create a CastDevice Entity from the chromecast object. | def _async_create_cast_device(hass: HomeAssistantType, info: ChromecastInfo):
"""Create a CastDevice Entity from the chromecast object.
Returns None if the cast device has already been added.
"""
_LOGGER.debug("_async_create_cast_device: %s", info)
if info.uuid is None:
_LOGGER.error("_asyn... | [
"def",
"_async_create_cast_device",
"(",
"hass",
":",
"HomeAssistantType",
",",
"info",
":",
"ChromecastInfo",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"_async_create_cast_device: %s\"",
",",
"info",
")",
"if",
"info",
".",
"uuid",
"is",
"None",
":",
"_LOGGER",... | [
99,
0
] | [
117,
27
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Cast from a config entry. | Set up Cast from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Cast from a config entry."""
config = hass.data[CAST_DOMAIN].get("media_player") or {}
if not isinstance(config, list):
config = [config]
# no pending task
done, _ = await asyncio.wait(
[
_asy... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"config",
"=",
"hass",
".",
"data",
"[",
"CAST_DOMAIN",
"]",
".",
"get",
"(",
"\"media_player\"",
")",
"or",
"{",
"}",
"if",
"not",
"isinstance",
"(... | [
120,
0
] | [
137,
30
] | python | en | ['en', 'en', 'en'] | True |
_async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities
) | Set up the cast platform. | Set up the cast platform. | async def _async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities
):
"""Set up the cast platform."""
# Import CEC IGNORE attributes
pychromecast.IGNORE_CEC += config.get(CONF_IGNORE_CEC, [])
hass.data.setdefault(ADDED_CAST_DEVICES_KEY, set())
hass.data.setdefault(K... | [
"async",
"def",
"_async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
")",
":",
"# Import CEC IGNORE attributes",
"pychromecast",
".",
"IGNORE_CEC",
"+=",
"config",
".",
"get",
"(",
"CONF_IGNORE_CE... | [
140,
0
] | [
172,
63
] | python | en | ['en', 'da', 'en'] | True |
CastDevice.__init__ | (self, cast_info: ChromecastInfo) | Initialize the cast device. | Initialize the cast device. | def __init__(self, cast_info: ChromecastInfo):
"""Initialize the cast device."""
self._cast_info = cast_info
self.services = cast_info.services
self._chromecast: Optional[pychromecast.Chromecast] = None
self.cast_status = None
self.media_status = None
self.media_... | [
"def",
"__init__",
"(",
"self",
",",
"cast_info",
":",
"ChromecastInfo",
")",
":",
"self",
".",
"_cast_info",
"=",
"cast_info",
"self",
".",
"services",
"=",
"cast_info",
".",
"services",
"self",
".",
"_chromecast",
":",
"Optional",
"[",
"pychromecast",
".",... | [
183,
4
] | [
200,
45
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.async_added_to_hass | (self) | Create chromecast object when added to hass. | Create chromecast object when added to hass. | async def async_added_to_hass(self):
"""Create chromecast object when added to hass."""
self._add_remove_handler = async_dispatcher_connect(
self.hass, SIGNAL_CAST_DISCOVERED, self._async_cast_discovered
)
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_add_remove_handler",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_CAST_DISCOVERED",
",",
"self",
".",
"_async_cast_discovered",
")",
"self",
".",
"hass",
".",
... | [
202,
4
] | [
214,
9
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.async_will_remove_from_hass | (self) | Disconnect Chromecast object when removed. | Disconnect Chromecast object when removed. | async def async_will_remove_from_hass(self) -> None:
"""Disconnect Chromecast object when removed."""
await self._async_disconnect()
if self._cast_info.uuid is not None:
# Remove the entity from the added casts so that it can dynamically
# be re-added again.
s... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_async_disconnect",
"(",
")",
"if",
"self",
".",
"_cast_info",
".",
"uuid",
"is",
"not",
"None",
":",
"# Remove the entity from the added casts so that it can ... | [
216,
4
] | [
228,
49
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.async_set_cast_info | (self, cast_info) | Set the cast information and set up the chromecast object. | Set the cast information and set up the chromecast object. | async def async_set_cast_info(self, cast_info):
"""Set the cast information and set up the chromecast object."""
self._cast_info = cast_info
if self._chromecast is not None:
# Only setup the chromecast once, added elements to services
# will automatically be picked up.
... | [
"async",
"def",
"async_set_cast_info",
"(",
"self",
",",
"cast_info",
")",
":",
"self",
".",
"_cast_info",
"=",
"cast_info",
"if",
"self",
".",
"_chromecast",
"is",
"not",
"None",
":",
"# Only setup the chromecast once, added elements to services",
"# will automatically... | [
230,
4
] | [
270,
35
] | python | en | ['en', 'en', 'en'] | True |
CastDevice._async_disconnect | (self) | Disconnect Chromecast object if it is set. | Disconnect Chromecast object if it is set. | async def _async_disconnect(self):
"""Disconnect Chromecast object if it is set."""
if self._chromecast is None:
# Can't disconnect if not connected.
return
_LOGGER.debug(
"[%s %s] Disconnecting from chromecast socket",
self.entity_id,
... | [
"async",
"def",
"_async_disconnect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_chromecast",
"is",
"None",
":",
"# Can't disconnect if not connected.",
"return",
"_LOGGER",
".",
"debug",
"(",
"\"[%s %s] Disconnecting from chromecast socket\"",
",",
"self",
".",
"enti... | [
272,
4
] | [
289,
35
] | python | en | ['en', 'en', 'en'] | True |
CastDevice._invalidate | (self) | Invalidate some attributes. | Invalidate some attributes. | def _invalidate(self):
"""Invalidate some attributes."""
self._chromecast = None
self.cast_status = None
self.media_status = None
self.media_status_received = None
self.mz_media_status = {}
self.mz_media_status_received = {}
self.mz_mgr = None
self... | [
"def",
"_invalidate",
"(",
"self",
")",
":",
"self",
".",
"_chromecast",
"=",
"None",
"self",
".",
"cast_status",
"=",
"None",
"self",
".",
"media_status",
"=",
"None",
"self",
".",
"media_status_received",
"=",
"None",
"self",
".",
"mz_media_status",
"=",
... | [
291,
4
] | [
303,
40
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.new_cast_status | (self, cast_status) | Handle updates of the cast status. | Handle updates of the cast status. | def new_cast_status(self, cast_status):
"""Handle updates of the cast status."""
self.cast_status = cast_status
self.schedule_update_ha_state() | [
"def",
"new_cast_status",
"(",
"self",
",",
"cast_status",
")",
":",
"self",
".",
"cast_status",
"=",
"cast_status",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
306,
4
] | [
309,
39
] | python | en | ['en', 'la', 'en'] | True |
CastDevice.new_media_status | (self, media_status) | Handle updates of the media status. | Handle updates of the media status. | def new_media_status(self, media_status):
"""Handle updates of the media status."""
if (
media_status
and media_status.player_is_idle
and media_status.idle_reason == "ERROR"
):
external_url = None
internal_url = None
tts_bas... | [
"def",
"new_media_status",
"(",
"self",
",",
"media_status",
")",
":",
"if",
"(",
"media_status",
"and",
"media_status",
".",
"player_is_idle",
"and",
"media_status",
".",
"idle_reason",
"==",
"\"ERROR\"",
")",
":",
"external_url",
"=",
"None",
"internal_url",
"... | [
311,
4
] | [
357,
39
] | python | en | ['en', 'la', 'en'] | True |
CastDevice.new_connection_status | (self, connection_status) | Handle updates of connection status. | Handle updates of connection status. | def new_connection_status(self, connection_status):
"""Handle updates of connection status."""
_LOGGER.debug(
"[%s %s] Received cast device connection status: %s",
self.entity_id,
self._cast_info.friendly_name,
connection_status.status,
)
i... | [
"def",
"new_connection_status",
"(",
"self",
",",
"connection_status",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"[%s %s] Received cast device connection status: %s\"",
",",
"self",
".",
"entity_id",
",",
"self",
".",
"_cast_info",
".",
"friendly_name",
",",
"connecti... | [
359,
4
] | [
385,
43
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.multizone_new_media_status | (self, group_uuid, media_status) | Handle updates of audio group media status. | Handle updates of audio group media status. | def multizone_new_media_status(self, group_uuid, media_status):
"""Handle updates of audio group media status."""
_LOGGER.debug(
"[%s %s] Multizone %s media status: %s",
self.entity_id,
self._cast_info.friendly_name,
group_uuid,
media_status,
... | [
"def",
"multizone_new_media_status",
"(",
"self",
",",
"group_uuid",
",",
"media_status",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"[%s %s] Multizone %s media status: %s\"",
",",
"self",
".",
"entity_id",
",",
"self",
".",
"_cast_info",
".",
"friendly_name",
",",
... | [
387,
4
] | [
398,
39
] | python | en | ['en', 'la', 'en'] | True |
CastDevice._media_controller | (self) |
Return media controller.
First try from our own cast, then groups which our cast is a member in.
|
Return media controller. | def _media_controller(self):
"""
Return media controller.
First try from our own cast, then groups which our cast is a member in.
"""
media_status = self.media_status
media_controller = self._chromecast.media_controller
if media_status is None or media_status.pl... | [
"def",
"_media_controller",
"(",
"self",
")",
":",
"media_status",
"=",
"self",
".",
"media_status",
"media_controller",
"=",
"self",
".",
"_chromecast",
".",
"media_controller",
"if",
"media_status",
"is",
"None",
"or",
"media_status",
".",
"player_state",
"==",
... | [
401,
4
] | [
417,
31
] | python | en | ['en', 'error', 'th'] | False |
CastDevice.turn_on | (self) | Turn on the cast device. | Turn on the cast device. | def turn_on(self):
"""Turn on the cast device."""
if not self._chromecast.is_idle:
# Already turned on
return
if self._chromecast.app_id is not None:
# Quit the previous app before starting splash screen
self._chromecast.quit_app()
# The... | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_chromecast",
".",
"is_idle",
":",
"# Already turned on",
"return",
"if",
"self",
".",
"_chromecast",
".",
"app_id",
"is",
"not",
"None",
":",
"# Quit the previous app before starting splash scree... | [
419,
4
] | [
431,
83
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.turn_off | (self) | Turn off the cast device. | Turn off the cast device. | def turn_off(self):
"""Turn off the cast device."""
self._chromecast.quit_app() | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_chromecast",
".",
"quit_app",
"(",
")"
] | [
433,
4
] | [
435,
35
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.mute_volume | (self, mute) | Mute the volume. | Mute the volume. | def mute_volume(self, mute):
"""Mute the volume."""
self._chromecast.set_volume_muted(mute) | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"_chromecast",
".",
"set_volume_muted",
"(",
"mute",
")"
] | [
437,
4
] | [
439,
47
] | python | en | ['en', 'sn', 'en'] | True |
CastDevice.set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
self._chromecast.set_volume(volume) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"self",
".",
"_chromecast",
".",
"set_volume",
"(",
"volume",
")"
] | [
441,
4
] | [
443,
43
] | python | en | ['fr', 'zu', 'en'] | False |
CastDevice.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
media_controller = self._media_controller()
media_controller.play() | [
"def",
"media_play",
"(",
"self",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"play",
"(",
")"
] | [
445,
4
] | [
448,
31
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_pause | (self) | Send pause command. | Send pause command. | def media_pause(self):
"""Send pause command."""
media_controller = self._media_controller()
media_controller.pause() | [
"def",
"media_pause",
"(",
"self",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"pause",
"(",
")"
] | [
450,
4
] | [
453,
32
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_stop | (self) | Send stop command. | Send stop command. | def media_stop(self):
"""Send stop command."""
media_controller = self._media_controller()
media_controller.stop() | [
"def",
"media_stop",
"(",
"self",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"stop",
"(",
")"
] | [
455,
4
] | [
458,
31
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_previous_track | (self) | Send previous track command. | Send previous track command. | def media_previous_track(self):
"""Send previous track command."""
media_controller = self._media_controller()
media_controller.queue_prev() | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"queue_prev",
"(",
")"
] | [
460,
4
] | [
463,
37
] | python | en | ['en', 'it', 'en'] | True |
CastDevice.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
media_controller = self._media_controller()
media_controller.queue_next() | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"queue_next",
"(",
")"
] | [
465,
4
] | [
468,
37
] | python | en | ['en', 'pt', 'en'] | True |
CastDevice.media_seek | (self, position) | Seek the media to a specific location. | Seek the media to a specific location. | def media_seek(self, position):
"""Seek the media to a specific location."""
media_controller = self._media_controller()
media_controller.seek(position) | [
"def",
"media_seek",
"(",
"self",
",",
"position",
")",
":",
"media_controller",
"=",
"self",
".",
"_media_controller",
"(",
")",
"media_controller",
".",
"seek",
"(",
"position",
")"
] | [
470,
4
] | [
473,
39
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.async_browse_media | (self, media_content_type=None, media_content_id=None) | Implement the websocket media browsing helper. | Implement the websocket media browsing helper. | async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper."""
result = await media_source.async_browse_media(self.hass, media_content_id)
return result | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
"=",
"None",
",",
"media_content_id",
"=",
"None",
")",
":",
"result",
"=",
"await",
"media_source",
".",
"async_browse_media",
"(",
"self",
".",
"hass",
",",
"media_content_id",
")",
... | [
475,
4
] | [
478,
21
] | python | en | ['en', 'af', 'en'] | True |
CastDevice.async_play_media | (self, media_type, media_id, **kwargs) | Play a piece of media. | Play a piece of media. | async def async_play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
# Handle media_source
if media_source.is_media_source_id(media_id):
sourced_media = await media_source.async_resolve_media(self.hass, media_id)
media_type = sourced_media.mime_t... | [
"async",
"def",
"async_play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"# Handle media_source",
"if",
"media_source",
".",
"is_media_source_id",
"(",
"media_id",
")",
":",
"sourced_media",
"=",
"await",
"media_sou... | [
480,
4
] | [
511,
9
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.play_media | (self, media_type, media_id, **kwargs) | Play media from a URL. | Play media from a URL. | def play_media(self, media_type, media_id, **kwargs):
"""Play media from a URL."""
# We do not want this to be forwarded to a group
if media_type == CAST_DOMAIN:
try:
app_data = json.loads(media_id)
except json.JSONDecodeError:
_LOGGER.erro... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"# We do not want this to be forwarded to a group",
"if",
"media_type",
"==",
"CAST_DOMAIN",
":",
"try",
":",
"app_data",
"=",
"json",
".",
"loads",
"(",
"... | [
513,
4
] | [
553,
13
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
557,
4
] | [
559,
20
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._cast_info.friendly_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cast_info",
".",
"friendly_name"
] | [
562,
4
] | [
564,
44
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.device_info | (self) | Return information about the device. | Return information about the device. | def device_info(self):
"""Return information about the device."""
cast_info = self._cast_info
if cast_info.model_name == "Google Cast Group":
return None
return {
"name": cast_info.friendly_name,
"identifiers": {(CAST_DOMAIN, cast_info.uuid.replace("... | [
"def",
"device_info",
"(",
"self",
")",
":",
"cast_info",
"=",
"self",
".",
"_cast_info",
"if",
"cast_info",
".",
"model_name",
"==",
"\"Google Cast Group\"",
":",
"return",
"None",
"return",
"{",
"\"name\"",
":",
"cast_info",
".",
"friendly_name",
",",
"\"ide... | [
567,
4
] | [
579,
9
] | python | en | ['en', 'en', 'en'] | True |
CastDevice._media_status | (self) |
Return media status.
First try from our own cast, then groups which our cast is a member in.
|
Return media status. | def _media_status(self):
"""
Return media status.
First try from our own cast, then groups which our cast is a member in.
"""
media_status = self.media_status
media_status_received = self.media_status_received
if media_status is None or media_status.player_state... | [
"def",
"_media_status",
"(",
"self",
")",
":",
"media_status",
"=",
"self",
".",
"media_status",
"media_status_received",
"=",
"self",
".",
"media_status_received",
"if",
"media_status",
"is",
"None",
"or",
"media_status",
".",
"player_state",
"==",
"\"UNKNOWN\"",
... | [
581,
4
] | [
598,
52
] | python | en | ['en', 'error', 'th'] | False |
CastDevice.state | (self) | Return the state of the player. | Return the state of the player. | def state(self):
"""Return the state of the player."""
media_status, _ = self._media_status()
if media_status is None:
return None
if media_status.player_is_playing:
return STATE_PLAYING
if media_status.player_is_paused:
return STATE_PAUSED
... | [
"def",
"state",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"if",
"media_status",
"is",
"None",
":",
"return",
"None",
"if",
"media_status",
".",
"player_is_playing",
":",
"return",
"STATE_PLAYING",
"if",
"... | [
601,
4
] | [
615,
19
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.available | (self) | Return True if the cast device is connected. | Return True if the cast device is connected. | def available(self):
"""Return True if the cast device is connected."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
618,
4
] | [
620,
30
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
return self.cast_status.volume_level if self.cast_status else None | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"cast_status",
".",
"volume_level",
"if",
"self",
".",
"cast_status",
"else",
"None"
] | [
623,
4
] | [
625,
74
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self.cast_status.volume_muted if self.cast_status else None | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"cast_status",
".",
"volume_muted",
"if",
"self",
".",
"cast_status",
"else",
"None"
] | [
628,
4
] | [
630,
74
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_content_id | (self) | Content ID of current playing media. | Content ID of current playing media. | def media_content_id(self):
"""Content ID of current playing media."""
media_status, _ = self._media_status()
return media_status.content_id if media_status else None | [
"def",
"media_content_id",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"content_id",
"if",
"media_status",
"else",
"None"
] | [
633,
4
] | [
636,
64
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_content_type | (self) | Content type of current playing media. | Content type of current playing media. | def media_content_type(self):
"""Content type of current playing media."""
media_status, _ = self._media_status()
if media_status is None:
return None
if media_status.media_is_tvshow:
return MEDIA_TYPE_TVSHOW
if media_status.media_is_movie:
ret... | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"if",
"media_status",
"is",
"None",
":",
"return",
"None",
"if",
"media_status",
".",
"media_is_tvshow",
":",
"return",
"MEDIA_TYPE_TVSHO... | [
639,
4
] | [
650,
19
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_duration | (self) | Duration of current playing media in seconds. | Duration of current playing media in seconds. | def media_duration(self):
"""Duration of current playing media in seconds."""
media_status, _ = self._media_status()
return media_status.duration if media_status else None | [
"def",
"media_duration",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"duration",
"if",
"media_status",
"else",
"None"
] | [
653,
4
] | [
656,
62
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_image_url | (self) | Image url of current playing media. | Image url of current playing media. | def media_image_url(self):
"""Image url of current playing media."""
media_status, _ = self._media_status()
if media_status is None:
return None
images = media_status.images
return (
images[0].url.replace("http://", "//") if images and images[0].url else... | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"if",
"media_status",
"is",
"None",
":",
"return",
"None",
"images",
"=",
"media_status",
".",
"images",
"return",
"(",
"images",
"[",
... | [
659,
4
] | [
669,
9
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_image_remotely_accessible | (self) | If the image url is remotely accessible. | If the image url is remotely accessible. | def media_image_remotely_accessible(self) -> bool:
"""If the image url is remotely accessible."""
return True | [
"def",
"media_image_remotely_accessible",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
672,
4
] | [
674,
19
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
media_status, _ = self._media_status()
return media_status.title if media_status else None | [
"def",
"media_title",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"title",
"if",
"media_status",
"else",
"None"
] | [
677,
4
] | [
680,
59
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_artist | (self) | Artist of current playing media (Music track only). | Artist of current playing media (Music track only). | def media_artist(self):
"""Artist of current playing media (Music track only)."""
media_status, _ = self._media_status()
return media_status.artist if media_status else None | [
"def",
"media_artist",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"artist",
"if",
"media_status",
"else",
"None"
] | [
683,
4
] | [
686,
60
] | python | en | ['en', 'en', 'en'] | True |
CastDevice.media_album_name | (self) | Album of current playing media (Music track only). | Album of current playing media (Music track only). | def media_album_name(self):
"""Album of current playing media (Music track only)."""
media_status, _ = self._media_status()
return media_status.album_name if media_status else None | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"media_status",
",",
"_",
"=",
"self",
".",
"_media_status",
"(",
")",
"return",
"media_status",
".",
"album_name",
"if",
"media_status",
"else",
"None"
] | [
689,
4
] | [
692,
64
] | 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.