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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Dyson360EyeDevice.turn_on | (self, **kwargs) | Turn the vacuum on. | Turn the vacuum on. | def turn_on(self, **kwargs):
"""Turn the vacuum on."""
_LOGGER.debug("Turn on device %s", self.name)
if self._device.state.state in [Dyson360EyeMode.FULL_CLEAN_PAUSED]:
self._device.resume()
else:
self._device.start() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn on device %s\"",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"_device",
".",
"state",
".",
"state",
"in",
"[",
"Dyson360EyeMode",
".",
"FULL_C... | [
128,
4
] | [
134,
32
] | python | en | ['en', 'et', 'en'] | True |
Dyson360EyeDevice.turn_off | (self, **kwargs) | Turn the vacuum off and return to home. | Turn the vacuum off and return to home. | def turn_off(self, **kwargs):
"""Turn the vacuum off and return to home."""
_LOGGER.debug("Turn off device %s", self.name)
self._device.pause() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn off device %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_device",
".",
"pause",
"(",
")"
] | [
136,
4
] | [
139,
28
] | python | en | ['en', 'en', 'en'] | True |
Dyson360EyeDevice.stop | (self, **kwargs) | Stop the vacuum cleaner. | Stop the vacuum cleaner. | def stop(self, **kwargs):
"""Stop the vacuum cleaner."""
_LOGGER.debug("Stop device %s", self.name)
self._device.pause() | [
"def",
"stop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Stop device %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_device",
".",
"pause",
"(",
")"
] | [
141,
4
] | [
144,
28
] | python | en | ['en', 'en', 'en'] | True |
Dyson360EyeDevice.set_fan_speed | (self, fan_speed, **kwargs) | Set fan speed. | Set fan speed. | def set_fan_speed(self, fan_speed, **kwargs):
"""Set fan speed."""
_LOGGER.debug("Set fan speed %s on device %s", fan_speed, self.name)
power_modes = {"Quiet": PowerMode.QUIET, "Max": PowerMode.MAX}
self._device.set_power_mode(power_modes[fan_speed]) | [
"def",
"set_fan_speed",
"(",
"self",
",",
"fan_speed",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Set fan speed %s on device %s\"",
",",
"fan_speed",
",",
"self",
".",
"name",
")",
"power_modes",
"=",
"{",
"\"Quiet\"",
":",
"PowerMod... | [
146,
4
] | [
150,
59
] | python | fy | ['sv', 'fy', 'ur'] | False |
Dyson360EyeDevice.start_pause | (self, **kwargs) | Start, pause or resume the cleaning task. | Start, pause or resume the cleaning task. | def start_pause(self, **kwargs):
"""Start, pause or resume the cleaning task."""
if self._device.state.state in [Dyson360EyeMode.FULL_CLEAN_PAUSED]:
_LOGGER.debug("Resume device %s", self.name)
self._device.resume()
elif self._device.state.state in [
Dyson360E... | [
"def",
"start_pause",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_device",
".",
"state",
".",
"state",
"in",
"[",
"Dyson360EyeMode",
".",
"FULL_CLEAN_PAUSED",
"]",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Resume device %s\"",
",",
"... | [
152,
4
] | [
165,
32
] | python | en | ['en', 'en', 'en'] | True |
Dyson360EyeDevice.return_to_base | (self, **kwargs) | Set the vacuum cleaner to return to the dock. | Set the vacuum cleaner to return to the dock. | def return_to_base(self, **kwargs):
"""Set the vacuum cleaner to return to the dock."""
_LOGGER.debug("Return to base device %s", self.name)
self._device.abort() | [
"def",
"return_to_base",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Return to base device %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_device",
".",
"abort",
"(",
")"
] | [
167,
4
] | [
170,
28
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass) | Enable the Area Registry views. | Enable the Area Registry views. | async def async_setup(hass):
"""Enable the Area Registry views."""
hass.components.websocket_api.async_register_command(
WS_TYPE_LIST, websocket_list_areas, SCHEMA_WS_LIST
)
hass.components.websocket_api.async_register_command(
WS_TYPE_CREATE, websocket_create_area, SCHEMA_WS_CREATE
... | [
"async",
"def",
"async_setup",
"(",
"hass",
")",
":",
"hass",
".",
"components",
".",
"websocket_api",
".",
"async_register_command",
"(",
"WS_TYPE_LIST",
",",
"websocket_list_areas",
",",
"SCHEMA_WS_LIST",
")",
"hass",
".",
"components",
".",
"websocket_api",
"."... | [
36,
0
] | [
50,
15
] | python | en | ['en', 'en', 'en'] | True |
websocket_list_areas | (hass, connection, msg) | Handle list areas command. | Handle list areas command. | async def websocket_list_areas(hass, connection, msg):
"""Handle list areas command."""
registry = await async_get_registry(hass)
connection.send_message(
websocket_api.result_message(
msg["id"],
[
{"name": entry.name, "area_id": entry.id}
for ... | [
"async",
"def",
"websocket_list_areas",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"connection",
".",
"send_message",
"(",
"websocket_api",
".",
"result_message",
"(",
"msg",
"[",
"\"... | [
54,
0
] | [
65,
5
] | python | en | ['en', 'en', 'en'] | True |
websocket_create_area | (hass, connection, msg) | Create area command. | Create area command. | async def websocket_create_area(hass, connection, msg):
"""Create area command."""
registry = await async_get_registry(hass)
try:
entry = registry.async_create(msg["name"])
except ValueError as err:
connection.send_message(
websocket_api.error_message(msg["id"], "invalid_info... | [
"async",
"def",
"websocket_create_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"entry",
"=",
"registry",
".",
"async_create",
"(",
"msg",
"[",
"\"name\"",
"]",
")... | [
70,
0
] | [
82,
9
] | python | en | ['en', 'sm', 'en'] | True |
websocket_delete_area | (hass, connection, msg) | Delete area command. | Delete area command. | async def websocket_delete_area(hass, connection, msg):
"""Delete area command."""
registry = await async_get_registry(hass)
try:
registry.async_delete(msg["area_id"])
except KeyError:
connection.send_message(
websocket_api.error_message(
msg["id"], "invalid_... | [
"async",
"def",
"websocket_delete_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"registry",
".",
"async_delete",
"(",
"msg",
"[",
"\"area_id\"",
"]",
")",
"except",
... | [
87,
0
] | [
100,
83
] | python | en | ['en', 'it', 'en'] | True |
websocket_update_area | (hass, connection, msg) | Handle update area websocket command. | Handle update area websocket command. | async def websocket_update_area(hass, connection, msg):
"""Handle update area websocket command."""
registry = await async_get_registry(hass)
try:
entry = registry.async_update(msg["area_id"], msg["name"])
except ValueError as err:
connection.send_message(
websocket_api.erro... | [
"async",
"def",
"websocket_update_area",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"try",
":",
"entry",
"=",
"registry",
".",
"async_update",
"(",
"msg",
"[",
"\"area_id\"",
"]",
... | [
105,
0
] | [
118,
9
] | python | en | ['en', 'nl', 'en'] | True |
_entry_dict | (entry) | Convert entry to API format. | Convert entry to API format. | def _entry_dict(entry):
"""Convert entry to API format."""
return {"area_id": entry.id, "name": entry.name} | [
"def",
"_entry_dict",
"(",
"entry",
")",
":",
"return",
"{",
"\"area_id\"",
":",
"entry",
".",
"id",
",",
"\"name\"",
":",
"entry",
".",
"name",
"}"
] | [
122,
0
] | [
124,
52
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the sensor config entry."""
controller_data = get_controller_data(hass, entry)
async_add_entities(
[
VeraBinarySensor(device, controller_data)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"controller_data",
"=",
"get_controller_data",
"(",
"hass",
",",
"entry",
... | [
18,
0
] | [
31,
5
] | python | en | ['en', 'pt', 'en'] | True |
VeraBinarySensor.__init__ | (
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
) | Initialize the binary_sensor. | Initialize the binary_sensor. | def __init__(
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
) -> None:
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id) | [
"def",
"__init__",
"(",
"self",
",",
"vera_device",
":",
"veraApi",
".",
"VeraBinarySensor",
",",
"controller_data",
":",
"ControllerData",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"False",
"VeraDevice",
".",
"__init__",
"(",
"self",
",",
"vera_de... | [
37,
4
] | [
43,
62
] | python | en | ['en', 'haw', 'en'] | True |
VeraBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self) -> bool | None:
"""Return true if sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
"|",
"None",
":",
"return",
"self",
".",
"_state"
] | [
46,
4
] | [
48,
26
] | python | en | ['en', 'et', 'en'] | True |
VeraBinarySensor.update | (self) | Get the latest data and update the state. | Get the latest data and update the state. | def update(self) -> None:
"""Get the latest data and update the state."""
super().update()
self._state = self.vera_device.is_tripped | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"vera_device",
".",
"is_tripped"
] | [
50,
4
] | [
53,
49
] | python | en | ['en', 'en', 'en'] | True |
TestNumberWithValidations.testNumberWithValidations | (self) | Test NumberWithValidations | Test NumberWithValidations | def testNumberWithValidations(self):
"""Test NumberWithValidations"""
valid_values = [10.0, 15.0, 20.0]
for valid_value in valid_values:
model = NumberWithValidations(valid_value)
assert model.value == valid_value
invalid_values = [9.0, 21.0]
for invalid_... | [
"def",
"testNumberWithValidations",
"(",
"self",
")",
":",
"valid_values",
"=",
"[",
"10.0",
",",
"15.0",
",",
"20.0",
"]",
"for",
"valid_value",
"in",
"valid_values",
":",
"model",
"=",
"NumberWithValidations",
"(",
"valid_value",
")",
"assert",
"model",
".",... | [
28,
4
] | [
38,
52
] | python | en | ['en', 'en', 'en'] | False |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Set up Verisure alarm control panel from a config entry. | Set up Verisure alarm control panel from a config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Verisure alarm control panel from a config entry."""
coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
Veri... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"coordinator",
":",
"VerisureDataUpdateCoordinator",
"=",
"hass",
".",
"da... | [
16,
0
] | [
26,
5
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartplug.__init__ | (
self, coordinator: VerisureDataUpdateCoordinator, serial_number: str
) | Initialize the Verisure device. | Initialize the Verisure device. | def __init__(
self, coordinator: VerisureDataUpdateCoordinator, serial_number: str
) -> None:
"""Initialize the Verisure device."""
super().__init__(coordinator)
self._attr_name = coordinator.data["smart_plugs"][serial_number]["area"]
self._attr_unique_id = serial_number
... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"VerisureDataUpdateCoordinator",
",",
"serial_number",
":",
"str",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_attr_name",
"=",
"coordinator",
".... | [
34,
4
] | [
45,
27
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartplug.device_info | (self) | Return device information about this entity. | Return device information about this entity. | def device_info(self) -> DeviceInfo:
"""Return device information about this entity."""
area = self.coordinator.data["smart_plugs"][self.serial_number]["area"]
return {
"name": area,
"suggested_area": area,
"manufacturer": "Verisure",
"model": "Sma... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"DeviceInfo",
":",
"area",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"smart_plugs\"",
"]",
"[",
"self",
".",
"serial_number",
"]",
"[",
"\"area\"",
"]",
"return",
"{",
"\"name\"",
":",
"area",
",",... | [
48,
4
] | [
58,
9
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartplug.is_on | (self) | Return true if on. | Return true if on. | def is_on(self) -> bool:
"""Return true if on."""
if monotonic() - self._change_timestamp < 10:
return self._state
self._state = (
self.coordinator.data["smart_plugs"][self.serial_number]["currentState"]
== "ON"
)
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"monotonic",
"(",
")",
"-",
"self",
".",
"_change_timestamp",
"<",
"10",
":",
"return",
"self",
".",
"_state",
"self",
".",
"_state",
"=",
"(",
"self",
".",
"coordinator",
".",
"data",
"[",
... | [
61,
4
] | [
69,
26
] | python | en | ['en', 'mt', 'en'] | True |
VerisureSmartplug.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return (
super().available
and self.serial_number in self.coordinator.data["smart_plugs"]
) | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"super",
"(",
")",
".",
"available",
"and",
"self",
".",
"serial_number",
"in",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"smart_plugs\"",
"]",
")"
] | [
72,
4
] | [
77,
9
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartplug.turn_on | (self, **kwargs) | Set smartplug status on. | Set smartplug status on. | def turn_on(self, **kwargs) -> None:
"""Set smartplug status on."""
self.coordinator.verisure.set_smartplug_state(self.serial_number, True)
self._state = True
self._change_timestamp = monotonic()
self.schedule_update_ha_state() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"coordinator",
".",
"verisure",
".",
"set_smartplug_state",
"(",
"self",
".",
"serial_number",
",",
"True",
")",
"self",
".",
"_state",
"=",
"True",
"self",
".... | [
79,
4
] | [
84,
39
] | python | en | ['en', 'et', 'en'] | True |
VerisureSmartplug.turn_off | (self, **kwargs) | Set smartplug status off. | Set smartplug status off. | def turn_off(self, **kwargs) -> None:
"""Set smartplug status off."""
self.coordinator.verisure.set_smartplug_state(self.serial_number, False)
self._state = False
self._change_timestamp = monotonic()
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"coordinator",
".",
"verisure",
".",
"set_smartplug_state",
"(",
"self",
".",
"serial_number",
",",
"False",
")",
"self",
".",
"_state",
"=",
"False",
"self",
... | [
86,
4
] | [
91,
39
] | python | en | ['en', 'bs', 'en'] | True |
test_async_setup_no_domain_config | (hass: HomeAssistant) | Test setup without configuration is noop. | Test setup without configuration is noop. | async def test_async_setup_no_domain_config(hass: HomeAssistant):
"""Test setup without configuration is noop."""
result = await async_setup_component(hass, DOMAIN, {})
assert result is True
assert DOMAIN not in hass.data | [
"async",
"def",
"test_async_setup_no_domain_config",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"}",
")",
"assert",
"result",
"is",
"True",
"assert",
"DOMAIN",
"not",
"in"... | [
13,
0
] | [
18,
34
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_imports_from_config | (hass: HomeAssistant) | Test that specifying config will setup an entry. | Test that specifying config will setup an entry. | async def test_async_setup_imports_from_config(hass: HomeAssistant):
"""Test that specifying config will setup an entry."""
with patch(
"homeassistant.components.plum_lightpad.utils.Plum.loadCloudData"
) as mock_loadCloudData, patch(
"homeassistant.components.plum_lightpad.async_setup_entry"... | [
"async",
"def",
"test_async_setup_imports_from_config",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.plum_lightpad.utils.Plum.loadCloudData\"",
")",
"as",
"mock_loadCloudData",
",",
"patch",
"(",
"\"homeassistant.components.plum... | [
21,
0
] | [
43,
54
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_sets_up_light | (hass: HomeAssistant) | Test that configuring entry sets up light domain. | Test that configuring entry sets up light domain. | async def test_async_setup_entry_sets_up_light(hass: HomeAssistant):
"""Test that configuring entry sets up light domain."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.add_to_hass(hass)
wit... | [
"async",
"def",
"test_async_setup_entry_sets_up_light",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
":",... | [
46,
0
] | [
65,
60
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_handles_auth_error | (hass: HomeAssistant) | Test that configuring entry handles Plum Cloud authentication error. | Test that configuring entry handles Plum Cloud authentication error. | async def test_async_setup_entry_handles_auth_error(hass: HomeAssistant):
"""Test that configuring entry handles Plum Cloud authentication error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.ad... | [
"async",
"def",
"test_async_setup_entry_handles_auth_error",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
... | [
68,
0
] | [
85,
60
] | python | en | ['en', 'fr', 'en'] | True |
test_async_setup_entry_handles_http_error | (hass: HomeAssistant) | Test that configuring entry handles HTTP error. | Test that configuring entry handles HTTP error. | async def test_async_setup_entry_handles_http_error(hass: HomeAssistant):
"""Test that configuring entry handles HTTP error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"username": "test-plum-username", "password": "test-plum-password"},
)
config_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_async_setup_entry_handles_http_error",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"test-plum-username\"",
",",
"\"password\"",
... | [
88,
0
] | [
105,
60
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up August from a config entry. | Set up August from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up August from a config entry."""
august_gateway = AugustGateway(hass)
try:
await august_gateway.async_setup(entry.data)
return await async_setup_august(hass, entry, august_gateway)
except (RequireValidation, ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"august_gateway",
"=",
"AugustGateway",
"(",
"hass",
")",
"try",
":",
"await",
"august_gateway",
".",
"async_setup",
"(",
"entry",
".",
"data",
... | [
35,
0
] | [
46,
42
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
hass.data[DOMAIN][entry.entry_id][DATA_AUGUST].async_stop()
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"DATA_AUGUST",
"]",
".",
"async_stop",
"(",
")",
"unloa... | [
49,
0
] | [
59,
20
] | python | en | ['en', 'es', 'en'] | True |
async_setup_august | (hass, config_entry, august_gateway) | Set up the August component. | Set up the August component. | async def async_setup_august(hass, config_entry, august_gateway):
"""Set up the August component."""
if CONF_PASSWORD in config_entry.data:
# We no longer need to store passwords since we do not
# support YAML anymore
config_data = config_entry.data.copy()
del config_data[CONF_P... | [
"async",
"def",
"async_setup_august",
"(",
"hass",
",",
"config_entry",
",",
"august_gateway",
")",
":",
"if",
"CONF_PASSWORD",
"in",
"config_entry",
".",
"data",
":",
"# We no longer need to store passwords since we do not",
"# support YAML anymore",
"config_data",
"=",
... | [
62,
0
] | [
82,
15
] | python | en | ['en', 'en', 'en'] | True |
_save_live_attrs | (lock_detail) | Store the attributes that the lock detail api may have an invalid cache for.
Since we are connected to pubnub we may have more current data
then the api so we want to restore the most current data after
updating battery state etc.
| Store the attributes that the lock detail api may have an invalid cache for. | def _save_live_attrs(lock_detail):
"""Store the attributes that the lock detail api may have an invalid cache for.
Since we are connected to pubnub we may have more current data
then the api so we want to restore the most current data after
updating battery state etc.
"""
return {attr: getattr(... | [
"def",
"_save_live_attrs",
"(",
"lock_detail",
")",
":",
"return",
"{",
"attr",
":",
"getattr",
"(",
"lock_detail",
",",
"attr",
")",
"for",
"attr",
"in",
"API_CACHED_ATTRS",
"}"
] | [
316,
0
] | [
323,
74
] | python | en | ['en', 'en', 'en'] | True |
_restore_live_attrs | (lock_detail, attrs) | Restore the non-cache attributes after a cached update. | Restore the non-cache attributes after a cached update. | def _restore_live_attrs(lock_detail, attrs):
"""Restore the non-cache attributes after a cached update."""
for attr, value in attrs.items():
setattr(lock_detail, attr, value) | [
"def",
"_restore_live_attrs",
"(",
"lock_detail",
",",
"attrs",
")",
":",
"for",
"attr",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"lock_detail",
",",
"attr",
",",
"value",
")"
] | [
326,
0
] | [
329,
41
] | python | en | ['en', 'en', 'en'] | True |
AugustData.__init__ | (self, hass, august_gateway) | Init August data object. | Init August data object. | def __init__(self, hass, august_gateway):
"""Init August data object."""
super().__init__(hass, MIN_TIME_BETWEEN_DETAIL_UPDATES)
self._hass = hass
self._august_gateway = august_gateway
self.activity_stream = None
self._api = august_gateway.api
self._device_detail_... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"august_gateway",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"MIN_TIME_BETWEEN_DETAIL_UPDATES",
")",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_august_gateway",
"=",
"august_gatewa... | [
88,
4
] | [
99,
33
] | python | en | ['en', 'en', 'en'] | True |
AugustData.async_setup | (self) | Async setup of august device data and activities. | Async setup of august device data and activities. | async def async_setup(self):
"""Async setup of august device data and activities."""
token = self._august_gateway.access_token
user_data, locks, doorbells = await asyncio.gather(
self._api.async_get_user(token),
self._api.async_get_operable_locks(token),
self.... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"_august_gateway",
".",
"access_token",
"user_data",
",",
"locks",
",",
"doorbells",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"self",
".",
"_api",
".",
"async_get_user",
"... | [
101,
4
] | [
138,
77
] | python | en | ['en', 'en', 'en'] | True |
AugustData.async_pubnub_message | (self, device_id, date_time, message) | Process a pubnub message. | Process a pubnub message. | def async_pubnub_message(self, device_id, date_time, message):
"""Process a pubnub message."""
device = self.get_device_detail(device_id)
activities = activities_from_pubnub_message(device, date_time, message)
if activities:
self.activity_stream.async_process_newer_device_act... | [
"def",
"async_pubnub_message",
"(",
"self",
",",
"device_id",
",",
"date_time",
",",
"message",
")",
":",
"device",
"=",
"self",
".",
"get_device_detail",
"(",
"device_id",
")",
"activities",
"=",
"activities_from_pubnub_message",
"(",
"device",
",",
"date_time",
... | [
141,
4
] | [
148,
77
] | python | en | ['en', 'mt', 'en'] | True |
AugustData.async_stop | (self) | Stop the subscriptions. | Stop the subscriptions. | def async_stop(self):
"""Stop the subscriptions."""
self._pubnub_unsub()
self.activity_stream.async_stop() | [
"def",
"async_stop",
"(",
"self",
")",
":",
"self",
".",
"_pubnub_unsub",
"(",
")",
"self",
".",
"activity_stream",
".",
"async_stop",
"(",
")"
] | [
151,
4
] | [
154,
41
] | python | en | ['en', 'en', 'en'] | True |
AugustData.doorbells | (self) | Return a list of py-august Doorbell objects. | Return a list of py-august Doorbell objects. | def doorbells(self):
"""Return a list of py-august Doorbell objects."""
return self._doorbells_by_id.values() | [
"def",
"doorbells",
"(",
"self",
")",
":",
"return",
"self",
".",
"_doorbells_by_id",
".",
"values",
"(",
")"
] | [
157,
4
] | [
159,
45
] | python | en | ['en', 'en', 'en'] | True |
AugustData.locks | (self) | Return a list of py-august Lock objects. | Return a list of py-august Lock objects. | def locks(self):
"""Return a list of py-august Lock objects."""
return self._locks_by_id.values() | [
"def",
"locks",
"(",
"self",
")",
":",
"return",
"self",
".",
"_locks_by_id",
".",
"values",
"(",
")"
] | [
162,
4
] | [
164,
41
] | python | en | ['en', 'en', 'en'] | True |
AugustData.get_device_detail | (self, device_id) | Return the py-august LockDetail or DoorbellDetail object for a device. | Return the py-august LockDetail or DoorbellDetail object for a device. | def get_device_detail(self, device_id):
"""Return the py-august LockDetail or DoorbellDetail object for a device."""
return self._device_detail_by_id[device_id] | [
"def",
"get_device_detail",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"self",
".",
"_device_detail_by_id",
"[",
"device_id",
"]"
] | [
166,
4
] | [
168,
51
] | python | en | ['en', 'en', 'en'] | True |
AugustData._get_device_name | (self, device_id) | Return doorbell or lock name as August has it stored. | Return doorbell or lock name as August has it stored. | def _get_device_name(self, device_id):
"""Return doorbell or lock name as August has it stored."""
if device_id in self._locks_by_id:
return self._locks_by_id[device_id].device_name
if device_id in self._doorbells_by_id:
return self._doorbells_by_id[device_id].device_name | [
"def",
"_get_device_name",
"(",
"self",
",",
"device_id",
")",
":",
"if",
"device_id",
"in",
"self",
".",
"_locks_by_id",
":",
"return",
"self",
".",
"_locks_by_id",
"[",
"device_id",
"]",
".",
"device_name",
"if",
"device_id",
"in",
"self",
".",
"_doorbells... | [
231,
4
] | [
236,
63
] | python | en | ['en', 'af', 'en'] | True |
AugustData.async_lock | (self, device_id) | Lock the device. | Lock the device. | async def async_lock(self, device_id):
"""Lock the device."""
return await self._async_call_api_op_requires_bridge(
device_id,
self._api.async_lock_return_activities,
self._august_gateway.access_token,
device_id,
) | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"await",
"self",
".",
"_async_call_api_op_requires_bridge",
"(",
"device_id",
",",
"self",
".",
"_api",
".",
"async_lock_return_activities",
",",
"self",
".",
"_august_gateway",
".",
... | [
238,
4
] | [
245,
9
] | python | en | ['en', 'en', 'en'] | True |
AugustData.async_unlock | (self, device_id) | Unlock the device. | Unlock the device. | async def async_unlock(self, device_id):
"""Unlock the device."""
return await self._async_call_api_op_requires_bridge(
device_id,
self._api.async_unlock_return_activities,
self._august_gateway.access_token,
device_id,
) | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"await",
"self",
".",
"_async_call_api_op_requires_bridge",
"(",
"device_id",
",",
"self",
".",
"_api",
".",
"async_unlock_return_activities",
",",
"self",
".",
"_august_gateway",
"... | [
247,
4
] | [
254,
9
] | python | en | ['en', 'zh', 'en'] | True |
AugustData._async_call_api_op_requires_bridge | (
self, device_id, func, *args, **kwargs
) | Call an API that requires the bridge to be online and will change the device state. | Call an API that requires the bridge to be online and will change the device state. | async def _async_call_api_op_requires_bridge(
self, device_id, func, *args, **kwargs
):
"""Call an API that requires the bridge to be online and will change the device state."""
ret = None
try:
ret = await func(*args, **kwargs)
except AugustApiAIOHTTPError as err:... | [
"async",
"def",
"_async_call_api_op_requires_bridge",
"(",
"self",
",",
"device_id",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"None",
"try",
":",
"ret",
"=",
"await",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwar... | [
256,
4
] | [
269,
18
] | python | en | ['en', 'en', 'en'] | True |
session_scope | (
*, hass: HomeAssistant | None = None, session: Session | None = None
) | Provide a transactional scope around a series of operations. | Provide a transactional scope around a series of operations. | def session_scope(
*, hass: HomeAssistant | None = None, session: Session | None = None
) -> Generator[Session, None, None]:
"""Provide a transactional scope around a series of operations."""
if session is None and hass is not None:
session = hass.data[DATA_INSTANCE].get_session()
if session is... | [
"def",
"session_scope",
"(",
"*",
",",
"hass",
":",
"HomeAssistant",
"|",
"None",
"=",
"None",
",",
"session",
":",
"Session",
"|",
"None",
"=",
"None",
")",
"->",
"Generator",
"[",
"Session",
",",
"None",
",",
"None",
"]",
":",
"if",
"session",
"is"... | [
53,
0
] | [
75,
23
] | python | en | ['en', 'en', 'en'] | True |
commit | (session, work) | Commit & retry work: Either a model or in a function. | Commit & retry work: Either a model or in a function. | def commit(session, work):
"""Commit & retry work: Either a model or in a function."""
for _ in range(0, RETRIES):
try:
if callable(work):
work(session)
else:
session.add(work)
session.commit()
return True
except Ope... | [
"def",
"commit",
"(",
"session",
",",
"work",
")",
":",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"RETRIES",
")",
":",
"try",
":",
"if",
"callable",
"(",
"work",
")",
":",
"work",
"(",
"session",
")",
"else",
":",
"session",
".",
"add",
"(",
"w... | [
78,
0
] | [
92,
16
] | python | en | ['en', 'en', 'en'] | True |
execute | (qry, to_native=False, validate_entity_ids=True) | Query the database and convert the objects to HA native form.
This method also retries a few times in the case of stale connections.
| Query the database and convert the objects to HA native form. | def execute(qry, to_native=False, validate_entity_ids=True) -> list | None:
"""Query the database and convert the objects to HA native form.
This method also retries a few times in the case of stale connections.
"""
for tryno in range(0, RETRIES):
try:
timer_start = time.perf_count... | [
"def",
"execute",
"(",
"qry",
",",
"to_native",
"=",
"False",
",",
"validate_entity_ids",
"=",
"True",
")",
"->",
"list",
"|",
"None",
":",
"for",
"tryno",
"in",
"range",
"(",
"0",
",",
"RETRIES",
")",
":",
"try",
":",
"timer_start",
"=",
"time",
"."... | [
95,
0
] | [
139,
15
] | python | en | ['en', 'en', 'en'] | True |
validate_or_move_away_sqlite_database | (dburl: str) | Ensure that the database is valid or move it away. | Ensure that the database is valid or move it away. | def validate_or_move_away_sqlite_database(dburl: str) -> bool:
"""Ensure that the database is valid or move it away."""
dbpath = dburl_to_path(dburl)
if not os.path.exists(dbpath):
# Database does not exist yet, this is OK
return True
if not validate_sqlite_database(dbpath):
mo... | [
"def",
"validate_or_move_away_sqlite_database",
"(",
"dburl",
":",
"str",
")",
"->",
"bool",
":",
"dbpath",
"=",
"dburl_to_path",
"(",
"dburl",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dbpath",
")",
":",
"# Database does not exist yet, this is O... | [
142,
0
] | [
154,
15
] | python | en | ['en', 'en', 'en'] | True |
dburl_to_path | (dburl) | Convert the db url into a filesystem path. | Convert the db url into a filesystem path. | def dburl_to_path(dburl):
"""Convert the db url into a filesystem path."""
return dburl[len(SQLITE_URL_PREFIX) :] | [
"def",
"dburl_to_path",
"(",
"dburl",
")",
":",
"return",
"dburl",
"[",
"len",
"(",
"SQLITE_URL_PREFIX",
")",
":",
"]"
] | [
157,
0
] | [
159,
42
] | python | en | ['en', 'en', 'en'] | True |
last_run_was_recently_clean | (cursor) | Verify the last recorder run was recently clean. | Verify the last recorder run was recently clean. | def last_run_was_recently_clean(cursor):
"""Verify the last recorder run was recently clean."""
cursor.execute("SELECT end FROM recorder_runs ORDER BY start DESC LIMIT 1;")
end_time = cursor.fetchone()
if not end_time or not end_time[0]:
return False
last_run_end_time = process_timestamp(... | [
"def",
"last_run_was_recently_clean",
"(",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"\"SELECT end FROM recorder_runs ORDER BY start DESC LIMIT 1;\"",
")",
"end_time",
"=",
"cursor",
".",
"fetchone",
"(",
")",
"if",
"not",
"end_time",
"or",
"not",
"end_time",... | [
162,
0
] | [
179,
15
] | python | en | ['en', 'en', 'en'] | True |
basic_sanity_check | (cursor) | Check tables to make sure select does not fail. | Check tables to make sure select does not fail. | def basic_sanity_check(cursor):
"""Check tables to make sure select does not fail."""
for table in ALL_TABLES:
# The statistics tables may not be present in old databases
if table in [TABLE_STATISTICS, TABLE_STATISTICS_META, TABLE_STATISTICS_RUNS]:
continue
if table in (TABL... | [
"def",
"basic_sanity_check",
"(",
"cursor",
")",
":",
"for",
"table",
"in",
"ALL_TABLES",
":",
"# The statistics tables may not be present in old databases",
"if",
"table",
"in",
"[",
"TABLE_STATISTICS",
",",
"TABLE_STATISTICS_META",
",",
"TABLE_STATISTICS_RUNS",
"]",
":"... | [
182,
0
] | [
194,
15
] | python | en | ['en', 'en', 'en'] | True |
validate_sqlite_database | (dbpath: str) | Run a quick check on an sqlite database to see if it is corrupt. | Run a quick check on an sqlite database to see if it is corrupt. | def validate_sqlite_database(dbpath: str) -> bool:
"""Run a quick check on an sqlite database to see if it is corrupt."""
import sqlite3 # pylint: disable=import-outside-toplevel
try:
conn = sqlite3.connect(dbpath)
run_checks_on_open_db(dbpath, conn.cursor())
conn.close()
excep... | [
"def",
"validate_sqlite_database",
"(",
"dbpath",
":",
"str",
")",
"->",
"bool",
":",
"import",
"sqlite3",
"# pylint: disable=import-outside-toplevel",
"try",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"dbpath",
")",
"run_checks_on_open_db",
"(",
"dbpath",
... | [
197,
0
] | [
209,
15
] | python | en | ['en', 'en', 'en'] | True |
run_checks_on_open_db | (dbpath, cursor) | Run checks that will generate a sqlite3 exception if there is corruption. | Run checks that will generate a sqlite3 exception if there is corruption. | def run_checks_on_open_db(dbpath, cursor):
"""Run checks that will generate a sqlite3 exception if there is corruption."""
sanity_check_passed = basic_sanity_check(cursor)
last_run_was_clean = last_run_was_recently_clean(cursor)
if sanity_check_passed and last_run_was_clean:
_LOGGER.debug(
... | [
"def",
"run_checks_on_open_db",
"(",
"dbpath",
",",
"cursor",
")",
":",
"sanity_check_passed",
"=",
"basic_sanity_check",
"(",
"cursor",
")",
"last_run_was_clean",
"=",
"last_run_was_recently_clean",
"(",
"cursor",
")",
"if",
"sanity_check_passed",
"and",
"last_run_was_... | [
212,
0
] | [
233,
9
] | python | en | ['en', 'en', 'en'] | True |
move_away_broken_database | (dbfile: str) | Move away a broken sqlite3 database. | Move away a broken sqlite3 database. | def move_away_broken_database(dbfile: str) -> None:
"""Move away a broken sqlite3 database."""
isotime = dt_util.utcnow().isoformat()
corrupt_postfix = f".corrupt.{isotime}"
_LOGGER.error(
"The system will rename the corrupt database file %s to %s in order to allow startup to proceed",
... | [
"def",
"move_away_broken_database",
"(",
"dbfile",
":",
"str",
")",
"->",
"None",
":",
"isotime",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
".",
"isoformat",
"(",
")",
"corrupt_postfix",
"=",
"f\".corrupt.{isotime}\"",
"_LOGGER",
".",
"error",
"(",
"\"The syste... | [
236,
0
] | [
252,
51
] | python | en | ['en', 'nl', 'en'] | True |
execute_on_connection | (dbapi_connection, statement) | Execute a single statement with a dbapi connection. | Execute a single statement with a dbapi connection. | def execute_on_connection(dbapi_connection, statement):
"""Execute a single statement with a dbapi connection."""
cursor = dbapi_connection.cursor()
cursor.execute(statement)
cursor.close() | [
"def",
"execute_on_connection",
"(",
"dbapi_connection",
",",
"statement",
")",
":",
"cursor",
"=",
"dbapi_connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"statement",
")",
"cursor",
".",
"close",
"(",
")"
] | [
255,
0
] | [
259,
18
] | python | en | ['en', 'en', 'en'] | True |
setup_connection_for_dialect | (dialect_name, dbapi_connection, first_connection) | Execute statements needed for dialect connection. | Execute statements needed for dialect connection. | def setup_connection_for_dialect(dialect_name, dbapi_connection, first_connection):
"""Execute statements needed for dialect connection."""
# Returns False if the the connection needs to be setup
# on the next connection, returns True if the connection
# never needs to be setup again.
if dialect_nam... | [
"def",
"setup_connection_for_dialect",
"(",
"dialect_name",
",",
"dbapi_connection",
",",
"first_connection",
")",
":",
"# Returns False if the the connection needs to be setup",
"# on the next connection, returns True if the connection",
"# never needs to be setup again.",
"if",
"dialec... | [
262,
0
] | [
281,
81
] | python | en | ['en', 'en', 'en'] | True |
end_incomplete_runs | (session, start_time) | End any incomplete recorder runs. | End any incomplete recorder runs. | def end_incomplete_runs(session, start_time):
"""End any incomplete recorder runs."""
for run in session.query(RecorderRuns).filter_by(end=None):
run.closed_incorrect = True
run.end = start_time
_LOGGER.warning(
"Ended unfinished session (id=%s from %s)", run.run_id, run.star... | [
"def",
"end_incomplete_runs",
"(",
"session",
",",
"start_time",
")",
":",
"for",
"run",
"in",
"session",
".",
"query",
"(",
"RecorderRuns",
")",
".",
"filter_by",
"(",
"end",
"=",
"None",
")",
":",
"run",
".",
"closed_incorrect",
"=",
"True",
"run",
"."... | [
284,
0
] | [
292,
24
] | python | en | ['en', 'en', 'en'] | True |
retryable_database_job | (description: str) | Try to execute a database job.
The job should return True if it finished, and False if it needs to be rescheduled.
| Try to execute a database job. | def retryable_database_job(description: str) -> Callable:
"""Try to execute a database job.
The job should return True if it finished, and False if it needs to be rescheduled.
"""
def decorator(job: Callable) -> Callable:
@functools.wraps(job)
def wrapper(instance: Recorder, *args, **k... | [
"def",
"retryable_database_job",
"(",
"description",
":",
"str",
")",
"->",
"Callable",
":",
"def",
"decorator",
"(",
"job",
":",
"Callable",
")",
"->",
"Callable",
":",
"@",
"functools",
".",
"wraps",
"(",
"job",
")",
"def",
"wrapper",
"(",
"instance",
... | [
295,
0
] | [
325,
20
] | python | en | ['en', 'en', 'en'] | True |
perodic_db_cleanups | (instance: Recorder) | Run any database cleanups that need to happen perodiclly.
These cleanups will happen nightly or after any purge.
| Run any database cleanups that need to happen perodiclly. | def perodic_db_cleanups(instance: Recorder):
"""Run any database cleanups that need to happen perodiclly.
These cleanups will happen nightly or after any purge.
"""
if instance.engine.dialect.name == "sqlite":
# Execute sqlite to create a wal checkpoint and free up disk space
_LOGGER.d... | [
"def",
"perodic_db_cleanups",
"(",
"instance",
":",
"Recorder",
")",
":",
"if",
"instance",
".",
"engine",
".",
"dialect",
".",
"name",
"==",
"\"sqlite\"",
":",
"# Execute sqlite to create a wal checkpoint and free up disk space",
"_LOGGER",
".",
"debug",
"(",
"\"WAL ... | [
328,
0
] | [
338,
72
] | python | en | ['en', 'en', 'en'] | True |
create_lightbulb_service | (accessory) | Define lightbulb characteristics. | Define lightbulb characteristics. | def create_lightbulb_service(accessory):
"""Define lightbulb characteristics."""
service = accessory.add_service(ServicesTypes.LIGHTBULB, name=LIGHT_BULB_NAME)
on_char = service.add_char(CharacteristicsTypes.ON)
on_char.value = 0
brightness = service.add_char(CharacteristicsTypes.BRIGHTNESS)
b... | [
"def",
"create_lightbulb_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"LIGHTBULB",
",",
"name",
"=",
"LIGHT_BULB_NAME",
")",
"on_char",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes... | [
19,
0
] | [
29,
18
] | python | en | ['en', 'bg', 'en'] | True |
create_lightbulb_service_with_hs | (accessory) | Define a lightbulb service with hue + saturation. | Define a lightbulb service with hue + saturation. | def create_lightbulb_service_with_hs(accessory):
"""Define a lightbulb service with hue + saturation."""
service = create_lightbulb_service(accessory)
hue = service.add_char(CharacteristicsTypes.HUE)
hue.value = 0
saturation = service.add_char(CharacteristicsTypes.SATURATION)
saturation.value ... | [
"def",
"create_lightbulb_service_with_hs",
"(",
"accessory",
")",
":",
"service",
"=",
"create_lightbulb_service",
"(",
"accessory",
")",
"hue",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"HUE",
")",
"hue",
".",
"value",
"=",
"0",
"satura... | [
32,
0
] | [
42,
18
] | python | en | ['en', 'en', 'en'] | True |
create_lightbulb_service_with_color_temp | (accessory) | Define a lightbulb service with color temp. | Define a lightbulb service with color temp. | def create_lightbulb_service_with_color_temp(accessory):
"""Define a lightbulb service with color temp."""
service = create_lightbulb_service(accessory)
color_temp = service.add_char(CharacteristicsTypes.COLOR_TEMPERATURE)
color_temp.value = 0
return service | [
"def",
"create_lightbulb_service_with_color_temp",
"(",
"accessory",
")",
":",
"service",
"=",
"create_lightbulb_service",
"(",
"accessory",
")",
"color_temp",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"COLOR_TEMPERATURE",
")",
"color_temp",
"."... | [
45,
0
] | [
52,
18
] | python | en | ['en', 'ro', 'en'] | True |
test_switch_change_light_state | (hass, utcnow) | Test that we can turn a HomeKit light on and off again. | Test that we can turn a HomeKit light on and off again. | async def test_switch_change_light_state(hass, utcnow):
"""Test that we can turn a HomeKit light on and off again."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
await hass.services.async_call(
"light",
"turn_on",
{"entity_id": "light.testdevice", "br... | [
"async",
"def",
"test_switch_change_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"\"light\"",
... | [
55,
0
] | [
74,
54
] | python | en | ['en', 'en', 'en'] | True |
test_switch_change_light_state_color_temp | (hass, utcnow) | Test that we can turn change color_temp. | Test that we can turn change color_temp. | async def test_switch_change_light_state_color_temp(hass, utcnow):
"""Test that we can turn change color_temp."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
await hass.services.async_call(
"light",
"turn_on",
{"entity_id": "light.testdevice",... | [
"async",
"def",
"test_switch_change_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"... | [
77,
0
] | [
89,
64
] | python | en | ['en', 'en', 'en'] | True |
test_switch_read_light_state | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_read_light_state(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert state.state... | [
"async",
"def",
"test_switch_read_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"# Initial state is that the light is off",
"state",
"=",
"await",
"helper",
... | [
92,
0
] | [
113,
31
] | python | en | ['en', 'en', 'en'] | True |
test_switch_push_light_state | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_push_light_state(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_hs)
# Initial state is that the light is off
state = hass.states.get(LIGHT_BULB_ENTITY_ID)
assert state.s... | [
"async",
"def",
"test_switch_push_light_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_hs",
")",
"# Initial state is that the light is off",
"state",
"=",
"hass",
".",
"state... | [
116,
0
] | [
142,
31
] | python | en | ['en', 'en', 'en'] | True |
test_switch_read_light_state_color_temp | (hass, utcnow) | Test that we can read the color_temp of a light accessory. | Test that we can read the color_temp of a light accessory. | async def test_switch_read_light_state_color_temp(hass, utcnow):
"""Test that we can read the color_temp of a light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
a... | [
"async",
"def",
"test_switch_read_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"awa... | [
145,
0
] | [
161,
48
] | python | en | ['en', 'en', 'en'] | True |
test_switch_push_light_state_color_temp | (hass, utcnow) | Test that we can read the state of a HomeKit light accessory. | Test that we can read the state of a HomeKit light accessory. | async def test_switch_push_light_state_color_temp(hass, utcnow):
"""Test that we can read the state of a HomeKit light accessory."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = hass.states.get(LIGHT_BULB_ENTITY_ID)... | [
"async",
"def",
"test_switch_push_light_state_color_temp",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"has... | [
164,
0
] | [
184,
48
] | python | en | ['en', 'en', 'en'] | True |
test_light_becomes_unavailable_but_recovers | (hass, utcnow) | Test transition to and from unavailable state. | Test transition to and from unavailable state. | async def test_light_becomes_unavailable_but_recovers(hass, utcnow):
"""Test transition to and from unavailable state."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert sta... | [
"async",
"def",
"test_light_becomes_unavailable_but_recovers",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
... | [
187,
0
] | [
209,
48
] | python | en | ['en', 'en', 'en'] | True |
test_light_unloaded_removed | (hass, utcnow) | Test entity and HKDevice are correctly unloaded and removed. | Test entity and HKDevice are correctly unloaded and removed. | async def test_light_unloaded_removed(hass, utcnow):
"""Test entity and HKDevice are correctly unloaded and removed."""
helper = await setup_test_component(hass, create_lightbulb_service_with_color_temp)
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert state... | [
"async",
"def",
"test_light_unloaded_removed",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_lightbulb_service_with_color_temp",
")",
"# Initial state is that the light is off",
"state",
"=",
"await",
"help... | [
212,
0
] | [
234,
71
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the BME280 sensor. | Set up the BME280 sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the BME280 sensor."""
if discovery_info is None:
return
sensor_conf = discovery_info[SENSOR_DOMAIN]
name = sensor_conf[CONF_NAME]
scan_interval = max(sensor_conf[CONF_SCAN_INTERVAL], MIN_TIME_BET... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"sensor_conf",
"=",
"discovery_info",
"[",
"SENSOR_DOMAIN",
"]",
"na... | [
43,
0
] | [
110,
38
] | python | en | ['en', 'da', 'en'] | True |
BME280Sensor.__init__ | (self, name, coordinator, description: SensorEntityDescription) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, coordinator, description: SensorEntityDescription):
"""Initialize the sensor."""
super().__init__(coordinator)
self.entity_description = description
self._attr_name = f"{name} {description.name}" | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"coordinator",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_... | [
116,
4
] | [
120,
54
] | python | en | ['en', 'en', 'en'] | True |
BME280Sensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self):
"""Return the state of the sensor."""
sensor_type = self.entity_description.key
if sensor_type == SENSOR_TEMP:
temperature = round(self.coordinator.data.temperature, 1)
state = temperature
elif sensor_type == SENSOR_HUMID:
state... | [
"def",
"native_value",
"(",
"self",
")",
":",
"sensor_type",
"=",
"self",
".",
"entity_description",
".",
"key",
"if",
"sensor_type",
"==",
"SENSOR_TEMP",
":",
"temperature",
"=",
"round",
"(",
"self",
".",
"coordinator",
".",
"data",
".",
"temperature",
","... | [
123,
4
] | [
133,
20
] | python | en | ['en', 'en', 'en'] | True |
BME280Sensor.should_poll | (self) | Return False if entity should not poll. | Return False if entity should not poll. | def should_poll(self) -> bool:
"""Return False if entity should not poll."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
136,
4
] | [
138,
20
] | python | en | ['en', 'bg', 'en'] | True |
async_get_triggers | (
hass: HomeAssistant, device_id: str
) | List device triggers for Cover devices. | List device triggers for Cover devices. | async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Cover devices."""
registry = await entity_registry.async_get_registry(hass)
triggers = []
# Get all the integrations entities for this device
for entry in entity_registry.asy... | [
"async",
"def",
"async_get_triggers",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass... | [
74,
0
] | [
120,
19
] | python | en | ['da', 'en', 'en'] | True |
async_get_trigger_capabilities | (
hass: HomeAssistant, config: ConfigType
) | List trigger capabilities. | List trigger capabilities. | async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities."""
if config[CONF_TYPE] not in POSITION_TRIGGER_TYPES:
return {
"extra_fields": vol.Schema(
{vol.Optional(CONF_FOR): cv.positive_tim... | [
"async",
"def",
"async_get_trigger_capabilities",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"dict",
"[",
"str",
",",
"vol",
".",
"Schema",
"]",
":",
"if",
"config",
"[",
"CONF_TYPE",
"]",
"not",
"in",
"POSITION_TRIGGER_T... | [
123,
0
] | [
145,
5
] | python | en | ['en', 'la', 'en'] | True |
async_attach_trigger | (
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) | Attach a trigger. | Attach a trigger. | async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) -> CALLBACK_TYPE:
"""Attach a trigger."""
if config[CONF_TYPE] in STATE_TRIGGER_TYPES:
if config[CONF_TYPE] == "opened":
to_state =... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"action",
":",
"AutomationActionType",
",",
"automation_info",
":",
"AutomationTriggerInfo",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"if",
"config",
"["... | [
148,
0
] | [
195,
5
] | python | en | ['en', 'lb', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up scenes for deCONZ component. | Set up scenes for deCONZ component. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up scenes for deCONZ component."""
gateway = get_gateway_from_config_entry(hass, config_entry)
@callback
def async_add_scene(scenes=gateway.api.scenes.values()):
"""Add scene from deCONZ."""
entities = [DeconzSc... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"@",
"callback",
"def",
"async_add_scene",
"(",
"scenes",
"=",
"gate... | [
11,
0
] | [
29,
21
] | python | da | ['da', 'nl', 'en'] | False |
DeconzScene.__init__ | (self, scene, gateway) | Set up a scene. | Set up a scene. | def __init__(self, scene, gateway):
"""Set up a scene."""
self._scene = scene
self.gateway = gateway
self._attr_name = scene.full_name | [
"def",
"__init__",
"(",
"self",
",",
"scene",
",",
"gateway",
")",
":",
"self",
".",
"_scene",
"=",
"scene",
"self",
".",
"gateway",
"=",
"gateway",
"self",
".",
"_attr_name",
"=",
"scene",
".",
"full_name"
] | [
35,
4
] | [
40,
41
] | python | en | ['en', 'cs', 'en'] | True |
DeconzScene.async_added_to_hass | (self) | Subscribe to sensors events. | Subscribe to sensors events. | async def async_added_to_hass(self):
"""Subscribe to sensors events."""
self.gateway.deconz_ids[self.entity_id] = self._scene.deconz_id | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"gateway",
".",
"deconz_ids",
"[",
"self",
".",
"entity_id",
"]",
"=",
"self",
".",
"_scene",
".",
"deconz_id"
] | [
42,
4
] | [
44,
71
] | python | en | ['en', 'en', 'en'] | True |
DeconzScene.async_will_remove_from_hass | (self) | Disconnect scene object when removed. | Disconnect scene object when removed. | async def async_will_remove_from_hass(self) -> None:
"""Disconnect scene object when removed."""
del self.gateway.deconz_ids[self.entity_id]
self._scene = None | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"del",
"self",
".",
"gateway",
".",
"deconz_ids",
"[",
"self",
".",
"entity_id",
"]",
"self",
".",
"_scene",
"=",
"None"
] | [
46,
4
] | [
49,
26
] | python | en | ['en', 'en', 'en'] | True |
DeconzScene.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.async_set_state({}) | [
"async",
"def",
"async_activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_scene",
".",
"async_set_state",
"(",
"{",
"}",
")"
] | [
51,
4
] | [
53,
45
] | python | en | ['en', 'it', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Vultr subscription (server) sensor. | Set up the Vultr subscription (server) sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Vultr subscription (server) sensor."""
vultr = hass.data[DATA_VULTR]
subscription = config[CONF_SUBSCRIPTION]
name = config[CONF_NAME]
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
if subscription not... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"vultr",
"=",
"hass",
".",
"data",
"[",
"DATA_VULTR",
"]",
"subscription",
"=",
"config",
"[",
"CONF_SUBSCRIPTION",
"]",
"name",
"=",
"c... | [
52,
0
] | [
70,
32
] | python | en | ['en', 'da', 'en'] | True |
VultrSensor.__init__ | (self, vultr, subscription, name, description: SensorEntityDescription) | Initialize a new Vultr sensor. | Initialize a new Vultr sensor. | def __init__(self, vultr, subscription, name, description: SensorEntityDescription):
"""Initialize a new Vultr sensor."""
self.entity_description = description
self._vultr = vultr
self._name = name
self.subscription = subscription
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"vultr",
",",
"subscription",
",",
"name",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_vultr",
"=",
"vultr",
"self",
".",
"_name",
"=... | [
76,
4
] | [
83,
24
] | python | en | ['en', 'en', 'en'] | True |
VultrSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
try:
return self._name.format(self.entity_description.name)
except IndexError:
try:
return self._name.format(
self.data["label"], self.entity_description.name
)
... | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_name",
".",
"format",
"(",
"self",
".",
"entity_description",
".",
"name",
")",
"except",
"IndexError",
":",
"try",
":",
"return",
"self",
".",
"_name",
".",
"format",
"(",
"s... | [
86,
4
] | [
96,
33
] | python | en | ['en', 'mi', 'en'] | True |
VultrSensor.native_value | (self) | Return the value of this given sensor type. | Return the value of this given sensor type. | def native_value(self):
"""Return the value of this given sensor type."""
try:
return round(float(self.data.get(self.entity_description.key)), 2)
except (TypeError, ValueError):
return self.data.get(self.entity_description.key) | [
"def",
"native_value",
"(",
"self",
")",
":",
"try",
":",
"return",
"round",
"(",
"float",
"(",
"self",
".",
"data",
".",
"get",
"(",
"self",
".",
"entity_description",
".",
"key",
")",
")",
",",
"2",
")",
"except",
"(",
"TypeError",
",",
"ValueError... | [
99,
4
] | [
104,
61
] | python | en | ['en', 'en', 'en'] | True |
VultrSensor.update | (self) | Update state of sensor. | Update state of sensor. | def update(self):
"""Update state of sensor."""
self._vultr.update()
self.data = self._vultr.data[self.subscription] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_vultr",
".",
"update",
"(",
")",
"self",
".",
"data",
"=",
"self",
".",
"_vultr",
".",
"data",
"[",
"self",
".",
"subscription",
"]"
] | [
106,
4
] | [
109,
55
] | python | en | ['en', 'co', 'en'] | True |
mock_controller_assert | () | Mock the velbus controller with an assert. | Mock the velbus controller with an assert. | def mock_controller_assert():
"""Mock the velbus controller with an assert."""
with patch("velbus.Controller", side_effect=Exception()):
yield | [
"def",
"mock_controller_assert",
"(",
")",
":",
"with",
"patch",
"(",
"\"velbus.Controller\"",
",",
"side_effect",
"=",
"Exception",
"(",
")",
")",
":",
"yield"
] | [
16,
0
] | [
19,
13
] | python | en | ['en', 'en', 'en'] | True |
mock_controller | () | Mock a successful velbus controller. | Mock a successful velbus controller. | def mock_controller():
"""Mock a successful velbus controller."""
controller = Mock()
with patch("velbus.Controller", return_value=controller):
yield controller | [
"def",
"mock_controller",
"(",
")",
":",
"controller",
"=",
"Mock",
"(",
")",
"with",
"patch",
"(",
"\"velbus.Controller\"",
",",
"return_value",
"=",
"controller",
")",
":",
"yield",
"controller"
] | [
23,
0
] | [
27,
24
] | python | cs | ['cs', 'ro', 'en'] | False |
init_config_flow | (hass) | Init a configuration flow. | Init a configuration flow. | def init_config_flow(hass):
"""Init a configuration flow."""
flow = config_flow.VelbusConfigFlow()
flow.hass = hass
return flow | [
"def",
"init_config_flow",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"VelbusConfigFlow",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"return",
"flow"
] | [
30,
0
] | [
34,
15
] | python | en | ['es', 'fr', 'en'] | False |
test_user | (hass, controller) | Test user config. | Test user config. | async def test_user(hass, controller):
"""Test user config."""
flow = init_config_flow(hass)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = await flow.async_step_user(
{CONF_NAME: "Velbus Test ... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"controller",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
"data_entry_flow",
"... | [
37,
0
] | [
57,
48
] | python | en | ['en', 'da', 'en'] | True |
test_user_fail | (hass, controller_assert) | Test user config. | Test user config. | async def test_user_fail(hass, controller_assert):
"""Test user config."""
flow = init_config_flow(hass)
result = await flow.async_step_user(
{CONF_NAME: "Velbus Test Serial", CONF_PORT: PORT_SERIAL}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["errors"] == ... | [
"async",
"def",
"test_user_fail",
"(",
"hass",
",",
"controller_assert",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
"{",
"CONF_NAME",
":",
"\"Velbus Test Serial\"",
",",
"CONF_PORT",
... | [
60,
0
] | [
74,
60
] | python | en | ['en', 'da', 'en'] | True |
test_import | (hass, controller) | Test import step. | Test import step. | async def test_import(hass, controller):
"""Test import step."""
flow = init_config_flow(hass)
result = await flow.async_step_import({CONF_PORT: PORT_TCP})
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "velbus_import" | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"controller",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
"{",
"CONF_PORT",
":",
"PORT_TCP",
"}",
")",
"assert",
"result",
"[",... | [
77,
0
] | [
83,
45
] | python | de | ['de', 'sd', 'en'] | False |
test_abort_if_already_setup | (hass) | Test we abort if Daikin is already setup. | Test we abort if Daikin is already setup. | async def test_abort_if_already_setup(hass):
"""Test we abort if Daikin is already setup."""
flow = init_config_flow(hass)
MockConfigEntry(
domain="velbus", data={CONF_PORT: PORT_TCP, CONF_NAME: "velbus home"}
).add_to_hass(hass)
result = await flow.async_step_import(
{CONF_PORT: PO... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"MockConfigEntry",
"(",
"domain",
"=",
"\"velbus\"",
",",
"data",
"=",
"{",
"CONF_PORT",
":",
"PORT_TCP",
",",
"CONF_NAME",
":",
"\"velbus ... | [
86,
0
] | [
103,
61
] | python | en | ['en', 'de', 'en'] | True |
MusicCastFlowHandler.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle a flow initiated by the user. | Handle a flow initiated by the user. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult:
"""Handle a flow initiated by the user."""
# Request user input, unless we are preparing discovery flow
if user_input is None:
return self._show_setup_form()
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"data_entry_flow",
".",
"FlowResult",
":",
"# Request user input, unless we are preparing discovery flow",
"if",
"user... | [
32,
4
] | [
73,
44
] | python | en | ['en', 'en', 'en'] | True |
MusicCastFlowHandler._show_setup_form | (
self, errors: dict | None = None
) | Show the setup form to the user. | Show the setup form to the user. | def _show_setup_form(
self, errors: dict | None = None
) -> data_entry_flow.FlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
errors=errors or {},
... | [
"def",
"_show_setup_form",
"(",
"self",
",",
"errors",
":",
"dict",
"|",
"None",
"=",
"None",
")",
"->",
"data_entry_flow",
".",
"FlowResult",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"vol",
"... | [
75,
4
] | [
83,
9
] | python | en | ['en', 'en', 'en'] | True |
MusicCastFlowHandler.async_step_ssdp | (self, discovery_info) | Handle ssdp discoveries. | Handle ssdp discoveries. | async def async_step_ssdp(self, discovery_info) -> data_entry_flow.FlowResult:
"""Handle ssdp discoveries."""
if not await MusicCastDevice.check_yamaha_ssdp(
discovery_info[ssdp.ATTR_SSDP_LOCATION], async_get_clientsession(self.hass)
):
return self.async_abort(reason="yxc... | [
"async",
"def",
"async_step_ssdp",
"(",
"self",
",",
"discovery_info",
")",
"->",
"data_entry_flow",
".",
"FlowResult",
":",
"if",
"not",
"await",
"MusicCastDevice",
".",
"check_yamaha_ssdp",
"(",
"discovery_info",
"[",
"ssdp",
".",
"ATTR_SSDP_LOCATION",
"]",
",",... | [
85,
4
] | [
110,
46
] | python | en | ['nl', 'en', 'en'] | True |
MusicCastFlowHandler.async_step_confirm | (self, user_input=None) | Allow the user to confirm adding the device. | Allow the user to confirm adding the device. | async def async_step_confirm(self, user_input=None) -> data_entry_flow.FlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return self.async_create_entry(
title=self.host,
data={
CONF_HOST: self.host,
... | [
"async",
"def",
"async_step_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
"->",
"data_entry_flow",
".",
"FlowResult",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"self",
"."... | [
112,
4
] | [
124,
54
] | python | en | ['en', 'en', 'en'] | True |
MusicCastFlowHandler.async_step_import | (self, import_data: dict) | Import data from configuration.yaml into the config flow. | Import data from configuration.yaml into the config flow. | async def async_step_import(self, import_data: dict) -> data_entry_flow.FlowResult:
"""Import data from configuration.yaml into the config flow."""
res = await self.async_step_user(import_data)
if res["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY:
_LOGGER.info(
... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_data",
":",
"dict",
")",
"->",
"data_entry_flow",
".",
"FlowResult",
":",
"res",
"=",
"await",
"self",
".",
"async_step_user",
"(",
"import_data",
")",
"if",
"res",
"[",
"\"type\"",
"]",
"==",
... | [
126,
4
] | [
139,
18
] | 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.