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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
client = hass.data[DOMAIN][entry.entry_id].pop(DATA_DEVICE_REGISTER)
client.stop()
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
if hass.data[DOMAIN][entry.entry_id]:
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
".",
"pop",
"(",
"DATA_DEVICE_REGISTER",
")",
"client",
".",
"stop",
"(",
")",
"unloa... | [
124,
0
] | [
134,
20
] | python | en | ['en', 'es', 'en'] | True |
SW16Device.__init__ | (self, device_port, entry_id, client) | Initialize the device. | Initialize the device. | def __init__(self, device_port, entry_id, client):
"""Initialize the device."""
# HLK-SW16 specific attributes for every component type
self._entry_id = entry_id
self._device_port = device_port
self._is_on = None
self._client = client
self._name = device_port | [
"def",
"__init__",
"(",
"self",
",",
"device_port",
",",
"entry_id",
",",
"client",
")",
":",
"# HLK-SW16 specific attributes for every component type",
"self",
".",
"_entry_id",
"=",
"entry_id",
"self",
".",
"_device_port",
"=",
"device_port",
"self",
".",
"_is_on"... | [
143,
4
] | [
150,
32
] | python | en | ['en', 'en', 'en'] | True |
SW16Device.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return f"{self._entry_id}_{self._device_port}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._entry_id}_{self._device_port}\""
] | [
153,
4
] | [
155,
54
] | python | ca | ['fr', 'ca', 'en'] | False |
SW16Device.handle_event_callback | (self, event) | Propagate changes through ha. | Propagate changes through ha. | def handle_event_callback(self, event):
"""Propagate changes through ha."""
_LOGGER.debug("Relay %s new state callback: %r", self.unique_id, event)
self._is_on = event
self.async_write_ha_state() | [
"def",
"handle_event_callback",
"(",
"self",
",",
"event",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Relay %s new state callback: %r\"",
",",
"self",
".",
"unique_id",
",",
"event",
")",
"self",
".",
"_is_on",
"=",
"event",
"self",
".",
"async_write_ha_state",
... | [
158,
4
] | [
162,
35
] | python | en | ['en', 'gd', 'en'] | True |
SW16Device.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
165,
4
] | [
167,
20
] | python | en | ['en', 'en', 'en'] | True |
SW16Device.name | (self) | Return a name for the device. | Return a name for the device. | def name(self):
"""Return a name for the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
170,
4
] | [
172,
25
] | python | en | ['en', 'en', 'en'] | True |
SW16Device.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return bool(self._client.is_connected) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_client",
".",
"is_connected",
")"
] | [
175,
4
] | [
177,
46
] | python | en | ['en', 'en', 'en'] | True |
SW16Device._availability_callback | (self, availability) | Update availability state. | Update availability state. | def _availability_callback(self, availability):
"""Update availability state."""
self.async_write_ha_state() | [
"def",
"_availability_callback",
"(",
"self",
",",
"availability",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
180,
4
] | [
182,
35
] | python | en | ['en', 'en', 'en'] | True |
SW16Device.async_added_to_hass | (self) | Register update callback. | Register update callback. | async def async_added_to_hass(self):
"""Register update callback."""
self._client.register_status_callback(
self.handle_event_callback, self._device_port
)
self._is_on = await self._client.status(self._device_port)
self.async_on_remove(
async_dispatcher_co... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"register_status_callback",
"(",
"self",
".",
"handle_event_callback",
",",
"self",
".",
"_device_port",
")",
"self",
".",
"_is_on",
"=",
"await",
"self",
".",
"_client"... | [
184,
4
] | [
196,
9
] | python | en | ['fr', 'no', 'en'] | False |
async_setup_entry | (hass, entry, async_add_entities) | Set up Freedompro climate. | Set up Freedompro climate. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Freedompro climate."""
api_key = entry.data[CONF_API_KEY]
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
Device(
aiohttp_client.async_get_clientsession(hass), api_key, device, coordinator
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"api_key",
"=",
"entry",
".",
"data",
"[",
"CONF_API_KEY",
"]",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",... | [
34,
0
] | [
44,
5
] | python | en | ['en', 'zu', 'en'] | True |
Device.__init__ | (self, session, api_key, device, coordinator) | Initialize the Freedompro climate. | Initialize the Freedompro climate. | def __init__(self, session, api_key, device, coordinator):
"""Initialize the Freedompro climate."""
super().__init__(coordinator)
self._session = session
self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._characteri... | [
"def",
"__init__",
"(",
"self",
",",
"session",
",",
"api_key",
",",
"device",
",",
"coordinator",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_session",
"=",
"session",
"self",
".",
"_api_key",
"=",
"api_key",
... | [
53,
4
] | [
72,
44
] | python | en | ['en', 'en', 'en'] | True |
Device._handle_coordinator_update | (self) | Handle updated data from the coordinator. | Handle updated data from the coordinator. | def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
device = next(
(
device
for device in self.coordinator.data
if device["uid"] == self._attr_unique_id
),
None,
)
... | [
"def",
"_handle_coordinator_update",
"(",
"self",
")",
"->",
"None",
":",
"device",
"=",
"next",
"(",
"(",
"device",
"for",
"device",
"in",
"self",
".",
"coordinator",
".",
"data",
"if",
"device",
"[",
"\"uid\"",
"]",
"==",
"self",
".",
"_attr_unique_id",
... | [
75,
4
] | [
93,
44
] | python | en | ['en', 'en', 'en'] | True |
Device.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self) -> None:
"""When entity is added to hass."""
await super().async_added_to_hass()
self._handle_coordinator_update() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_handle_coordinator_update",
"(",
")"
] | [
95,
4
] | [
98,
41
] | python | en | ['en', 'en', 'en'] | True |
Device.async_set_hvac_mode | (self, hvac_mode) | Async function to set mode to climate. | Async function to set mode to climate. | async def async_set_hvac_mode(self, hvac_mode):
"""Async function to set mode to climate."""
if hvac_mode not in SUPPORTED_HVAC_MODES:
raise ValueError(f"Got unsupported hvac_mode {hvac_mode}")
payload = {}
payload["heatingCoolingState"] = HVAC_INVERT_MAP[hvac_mode]
... | [
"async",
"def",
"async_set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"if",
"hvac_mode",
"not",
"in",
"SUPPORTED_HVAC_MODES",
":",
"raise",
"ValueError",
"(",
"f\"Got unsupported hvac_mode {hvac_mode}\"",
")",
"payload",
"=",
"{",
"}",
"payload",
"[",
"\... | [
100,
4
] | [
114,
54
] | python | en | ['en', 'en', 'en'] | True |
Device.async_set_temperature | (self, **kwargs) | Async function to set temperarture to climate. | Async function to set temperarture to climate. | async def async_set_temperature(self, **kwargs):
"""Async function to set temperarture to climate."""
payload = {}
if ATTR_HVAC_MODE in kwargs:
if kwargs[ATTR_HVAC_MODE] not in SUPPORTED_HVAC_MODES:
_LOGGER.error(
"Got unsupported hvac_mode %s, exp... | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"}",
"if",
"ATTR_HVAC_MODE",
"in",
"kwargs",
":",
"if",
"kwargs",
"[",
"ATTR_HVAC_MODE",
"]",
"not",
"in",
"SUPPORTED_HVAC_MODES",
":",
"_LOGGER",
... | [
116,
4
] | [
137,
54
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Pilight Binary Sensor. | Set up Pilight Binary Sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Pilight Binary Sensor."""
disarm = config.get(CONF_DISARM_AFTER_TRIGGER)
if disarm:
add_entities(
[
PilightTriggerSensor(
hass=hass,
name=config.get(CONF... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"disarm",
"=",
"config",
".",
"get",
"(",
"CONF_DISARM_AFTER_TRIGGER",
")",
"if",
"disarm",
":",
"add_entities",
"(",
"[",
"PilightTriggerSe... | [
39,
0
] | [
68,
9
] | python | en | ['en', 'su', 'en'] | True |
PilightBinarySensor.__init__ | (self, hass, name, variable, payload, on_value, off_value) | Initialize the sensor. | Initialize the sensor. | def __init__(self, hass, name, variable, payload, on_value, off_value):
"""Initialize the sensor."""
self._state = False
self._hass = hass
self._name = name
self._variable = variable
self._payload = payload
self._on_value = on_value
self._off_value = off_v... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"variable",
",",
"payload",
",",
"on_value",
",",
"off_value",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_name",
"=",
"name",
"self",... | [
74,
4
] | [
84,
57
] | python | en | ['en', 'en', 'en'] | True |
PilightBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
87,
4
] | [
89,
25
] | python | en | ['en', 'mi', 'en'] | True |
PilightBinarySensor.is_on | (self) | Return True if the binary sensor is on. | Return True if the binary sensor is on. | def is_on(self):
"""Return True if the binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
92,
4
] | [
94,
26
] | python | en | ['en', 'fy', 'en'] | True |
PilightBinarySensor._handle_code | (self, call) | Handle received code by the pilight-daemon.
If the code matches the defined payload
of this sensor the sensor state is changed accordingly.
| Handle received code by the pilight-daemon. | def _handle_code(self, call):
"""Handle received code by the pilight-daemon.
If the code matches the defined payload
of this sensor the sensor state is changed accordingly.
"""
# Check if received code matches defined playoad
# True if payload is contained in received co... | [
"def",
"_handle_code",
"(",
"self",
",",
"call",
")",
":",
"# Check if received code matches defined playoad",
"# True if payload is contained in received code dict",
"payload_ok",
"=",
"True",
"for",
"key",
"in",
"self",
".",
"_payload",
":",
"if",
"key",
"not",
"in",
... | [
96,
4
] | [
117,
43
] | python | en | ['en', 'en', 'en'] | True |
PilightTriggerSensor.__init__ | (
self, hass, name, variable, payload, on_value, off_value, rst_dly_sec=30
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, hass, name, variable, payload, on_value, off_value, rst_dly_sec=30
):
"""Initialize the sensor."""
self._state = False
self._hass = hass
self._name = name
self._variable = variable
self._payload = payload
self._on_value = on_value
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"variable",
",",
"payload",
",",
"on_value",
",",
"off_value",
",",
"rst_dly_sec",
"=",
"30",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_hass",
"=",
"hass",
"self",
"."... | [
123,
4
] | [
138,
57
] | python | en | ['en', 'en', 'en'] | True |
PilightTriggerSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
141,
4
] | [
143,
25
] | python | en | ['en', 'mi', 'en'] | True |
PilightTriggerSensor.is_on | (self) | Return True if the binary sensor is on. | Return True if the binary sensor is on. | def is_on(self):
"""Return True if the binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
146,
4
] | [
148,
26
] | python | en | ['en', 'fy', 'en'] | True |
PilightTriggerSensor._handle_code | (self, call) | Handle received code by the pilight-daemon.
If the code matches the defined payload
of this sensor the sensor state is changed accordingly.
| Handle received code by the pilight-daemon. | def _handle_code(self, call):
"""Handle received code by the pilight-daemon.
If the code matches the defined payload
of this sensor the sensor state is changed accordingly.
"""
# Check if received code matches defined payload
# True if payload is contained in received co... | [
"def",
"_handle_code",
"(",
"self",
",",
"call",
")",
":",
"# Check if received code matches defined payload",
"# True if payload is contained in received code dict",
"payload_ok",
"=",
"True",
"for",
"key",
"in",
"self",
".",
"_payload",
":",
"if",
"key",
"not",
"in",
... | [
155,
4
] | [
181,
43
] | python | en | ['en', 'en', 'en'] | True |
async_is_onboarded | (hass) | Return if Home Assistant has been onboarded. | Return if Home Assistant has been onboarded. | def async_is_onboarded(hass):
"""Return if Home Assistant has been onboarded."""
data = hass.data.get(DOMAIN)
return data is None or data is True | [
"def",
"async_is_onboarded",
"(",
"hass",
")",
":",
"data",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DOMAIN",
")",
"return",
"data",
"is",
"None",
"or",
"data",
"is",
"True"
] | [
36,
0
] | [
39,
39
] | python | en | ['en', 'en', 'en'] | True |
async_is_user_onboarded | (hass) | Return if a user has been created as part of onboarding. | Return if a user has been created as part of onboarding. | def async_is_user_onboarded(hass):
"""Return if a user has been created as part of onboarding."""
return async_is_onboarded(hass) or STEP_USER in hass.data[DOMAIN]["done"] | [
"def",
"async_is_user_onboarded",
"(",
"hass",
")",
":",
"return",
"async_is_onboarded",
"(",
"hass",
")",
"or",
"STEP_USER",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"done\"",
"]"
] | [
44,
0
] | [
46,
77
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the onboarding component. | Set up the onboarding component. | async def async_setup(hass, config):
"""Set up the onboarding component."""
store = OnboadingStorage(hass, STORAGE_VERSION, STORAGE_KEY, private=True)
data = await store.async_load()
if data is None:
data = {"done": []}
if STEP_USER not in data["done"]:
# Users can already have cre... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"store",
"=",
"OnboadingStorage",
"(",
"hass",
",",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
",",
"private",
"=",
"True",
")",
"data",
"=",
"await",
"store",
".",
"async_load",
"(",
")",
... | [
49,
0
] | [
78,
15
] | python | en | ['en', 'en', 'en'] | True |
OnboadingStorage._async_migrate_func | (self, old_version, old_data) | Migrate to the new version. | Migrate to the new version. | async def _async_migrate_func(self, old_version, old_data):
"""Migrate to the new version."""
# From version 1 -> 2, we automatically mark the integration step done
if old_version < 2:
old_data["done"].append(STEP_INTEGRATION)
if old_version < 3:
old_data["done"].... | [
"async",
"def",
"_async_migrate_func",
"(",
"self",
",",
"old_version",
",",
"old_data",
")",
":",
"# From version 1 -> 2, we automatically mark the integration step done",
"if",
"old_version",
"<",
"2",
":",
"old_data",
"[",
"\"done\"",
"]",
".",
"append",
"(",
"STEP... | [
22,
4
] | [
31,
23
] | python | en | ['en', 'en', 'en'] | True |
_get_entry_type | (config: dict) | Get entry type from the configuration. | Get entry type from the configuration. | def _get_entry_type(config: dict) -> str:
"""Get entry type from the configuration."""
if CONF_LATITUDE in config:
return TYPE_SPECIFY_COORDINATES
if CONF_COUNTRY_CODE in config:
return TYPE_SPECIFY_COUNTRY
return TYPE_USE_HOME | [
"def",
"_get_entry_type",
"(",
"config",
":",
"dict",
")",
"->",
"str",
":",
"if",
"CONF_LATITUDE",
"in",
"config",
":",
"return",
"TYPE_SPECIFY_COORDINATES",
"if",
"CONF_COUNTRY_CODE",
"in",
"config",
":",
"return",
"TYPE_SPECIFY_COUNTRY",
"return",
"TYPE_USE_HOME"... | [
24,
0
] | [
32,
24
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, import_info) | Set the config entry up from yaml. | Set the config entry up from yaml. | async def async_step_import(self, import_info):
"""Set the config entry up from yaml."""
data = {CONF_API_KEY: import_info[CONF_TOKEN]}
if CONF_COUNTRY_CODE in import_info:
data[CONF_COUNTRY_CODE] = import_info[CONF_COUNTRY_CODE]
new_entry_type = TYPE_SPECIFY_COUNTRY
... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_info",
")",
":",
"data",
"=",
"{",
"CONF_API_KEY",
":",
"import_info",
"[",
"CONF_TOKEN",
"]",
"}",
"if",
"CONF_COUNTRY_CODE",
"in",
"import_info",
":",
"data",
"[",
"CONF_COUNTRY_CODE",
"]",
"=",
... | [
41,
4
] | [
87,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle the initial step. | Handle the initial step. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
data_schema = vol.Schema(
{
vol.Required("location", default=TYPE_USE_HOME): vol.In(
(
TYPE_USE_HO... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"\"l... | [
89,
4
] | [
122,
73
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_coordinates | (
self, user_input: dict[str, Any] | None = None
) | Validate coordinates. | Validate coordinates. | async def async_step_coordinates(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Validate coordinates."""
data_schema = vol.Schema(
{
vol.Required(
CONF_LATITUDE,
): cv.latitude,
vol.Required(... | [
"async",
"def",
"async_step_coordinates",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",... | [
124,
4
] | [
145,
9
] | python | en | ['en', 'la', 'en'] | False |
ConfigFlow.async_step_country | (
self, user_input: dict[str, Any] | None = None
) | Validate country. | Validate country. | async def async_step_country(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Validate country."""
data_schema = vol.Schema(
{
vol.Required(CONF_COUNTRY_CODE): cv.string,
}
)
if user_input is None:
return ... | [
"async",
"def",
"async_step_country",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"... | [
147,
4
] | [
163,
9
] | python | en | ['en', 'en', 'en'] | False |
ConfigFlow._validate_and_create | (
self, step_id: str, data_schema: vol.Schema, data: dict
) | Validate data and show form if it is invalid. | Validate data and show form if it is invalid. | async def _validate_and_create(
self, step_id: str, data_schema: vol.Schema, data: dict
) -> FlowResult:
"""Validate data and show form if it is invalid."""
errors: dict[str, str] = {}
try:
await self.hass.async_add_executor_job(get_data, self.hass, data)
except ... | [
"async",
"def",
"_validate_and_create",
"(",
"self",
",",
"step_id",
":",
"str",
",",
"data_schema",
":",
"vol",
".",
"Schema",
",",
"data",
":",
"dict",
")",
"->",
"FlowResult",
":",
"errors",
":",
"dict",
"[",
"str",
",",
"str",
"]",
"=",
"{",
"}",... | [
165,
4
] | [
189,
9
] | python | en | ['en', 'en', 'en'] | True |
test_migration_creates_new_flow | (hass, smartthings_mock, config_entry) | Test migration deletes app and creates new flow. | Test migration deletes app and creates new flow. | async def test_migration_creates_new_flow(hass, smartthings_mock, config_entry):
"""Test migration deletes app and creates new flow."""
assert await async_setup_component(hass, "persistent_notification", {})
config_entry.version = 1
config_entry.add_to_hass(hass)
await smartthings.async_migrate_ent... | [
"async",
"def",
"test_migration_creates_new_flow",
"(",
"hass",
",",
"smartthings_mock",
",",
"config_entry",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
".",
"version",
"... | [
29,
0
] | [
44,
74
] | python | en | ['en', 'en', 'en'] | True |
test_unrecoverable_api_errors_create_new_flow | (
hass, config_entry, smartthings_mock
) |
Test a new config flow is initiated when there are API errors.
401 (unauthorized): Occurs when the access token is no longer valid.
403 (forbidden/not found): Occurs when the app or installed app could
not be retrieved/found (likely deleted?)
|
Test a new config flow is initiated when there are API errors. | async def test_unrecoverable_api_errors_create_new_flow(
hass, config_entry, smartthings_mock
):
"""
Test a new config flow is initiated when there are API errors.
401 (unauthorized): Occurs when the access token is no longer valid.
403 (forbidden/not found): Occurs when the app or installed app co... | [
"async",
"def",
"test_unrecoverable_api_errors_create_new_flow",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
".",
... | [
47,
0
] | [
75,
61
] | python | en | ['en', 'error', 'th'] | False |
test_recoverable_api_errors_raise_not_ready | (
hass, config_entry, smartthings_mock
) | Test config entry not ready raised for recoverable API errors. | Test config entry not ready raised for recoverable API errors. | async def test_recoverable_api_errors_raise_not_ready(
hass, config_entry, smartthings_mock
):
"""Test config entry not ready raised for recoverable API errors."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://example.com")
smartthings_mock.app.side_effect = ClientResponseError... | [
"async",
"def",
"test_recoverable_api_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
... | [
78,
0
] | [
89,
63
] | python | en | ['en', 'en', 'en'] | True |
test_scenes_api_errors_raise_not_ready | (
hass, config_entry, app, installed_app, smartthings_mock
) | Test if scenes are unauthorized we continue to load platforms. | Test if scenes are unauthorized we continue to load platforms. | async def test_scenes_api_errors_raise_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://example.com")
smartthings_mock.app.return_value = app... | [
"async",
"def",
"test_scenes_api_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"="... | [
92,
0
] | [
104,
63
] | python | en | ['en', 'en', 'en'] | True |
test_connection_errors_raise_not_ready | (hass, config_entry, smartthings_mock) | Test config entry not ready raised for connection errors. | Test config entry not ready raised for connection errors. | async def test_connection_errors_raise_not_ready(hass, config_entry, smartthings_mock):
"""Test config entry not ready raised for connection errors."""
config_entry.add_to_hass(hass)
smartthings_mock.app.side_effect = ClientConnectionError()
with pytest.raises(ConfigEntryNotReady):
await smartt... | [
"async",
"def",
"test_connection_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"smartthings_mock",
".",
"app",
".",
"side_effect",
"=",
"ClientConnectionError",
"(",
... | [
107,
0
] | [
113,
63
] | python | en | ['en', 'en', 'en'] | True |
test_base_url_no_longer_https_does_not_load | (
hass, config_entry, app, smartthings_mock
) | Test base_url no longer valid creates a new flow. | Test base_url no longer valid creates a new flow. | async def test_base_url_no_longer_https_does_not_load(
hass, config_entry, app, smartthings_mock
):
"""Test base_url no longer valid creates a new flow."""
await async_process_ha_core_config(
hass,
{"external_url": "http://example.local:8123"},
)
config_entry.add_to_hass(hass)
sm... | [
"async",
"def",
"test_base_url_no_longer_https_does_not_load",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"smartthings_mock",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"http://example.local:8123\"",
"}",
... | [
116,
0
] | [
129,
21
] | python | en | ['en', 'fr', 'en'] | True |
test_unauthorized_installed_app_raises_not_ready | (
hass, config_entry, app, installed_app, smartthings_mock
) | Test config entry not ready raised when the app isn't authorized. | Test config entry not ready raised when the app isn't authorized. | async def test_unauthorized_installed_app_raises_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test config entry not ready raised when the app isn't authorized."""
config_entry.add_to_hass(hass)
installed_app.installed_app_status = InstalledAppStatus.PENDING
smartthings_... | [
"async",
"def",
"test_unauthorized_installed_app_raises_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"installed_app",
".",
"installed_app_status",... | [
132,
0
] | [
143,
63
] | python | en | ['en', 'en', 'en'] | True |
test_scenes_unauthorized_loads_platforms | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
) | Test if scenes are unauthorized we continue to load platforms. | Test if scenes are unauthorized we continue to load platforms. | async def test_scenes_unauthorized_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://... | [
"async",
"def",
"test_scenes_unauthorized_loads_platforms",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
146,
0
] | [
177,
56
] | python | en | ['en', 'en', 'en'] | True |
test_config_entry_loads_platforms | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
) | Test config entry loads properly and proxies to platforms. | Test config entry loads properly and proxies to platforms. | async def test_config_entry_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test config entry loads properly and proxies to platforms."""
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = a... | [
"async",
"def",
"test_config_entry_loads_platforms",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
"scene",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"has... | [
180,
0
] | [
209,
56
] | python | en | ['en', 'en', 'en'] | True |
test_config_entry_loads_unconnected_cloud | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
) | Test entry loads during startup when cloud isn't connected. | Test entry loads during startup when cloud isn't connected. | async def test_config_entry_loads_unconnected_cloud(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test entry loads during startup when cloud isn't connected."""
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUD... | [
"async",
"def",
"test_config_entry_loads_unconnected_cloud",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
"scene",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"("... | [
212,
0
] | [
240,
56
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass, config_entry) | Test entries are unloaded correctly. | Test entries are unloaded correctly. | async def test_unload_entry(hass, config_entry):
"""Test entries are unloaded correctly."""
connect_disconnect = Mock()
smart_app = Mock()
smart_app.connect_event.return_value = connect_disconnect
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), smart_app, [], [])
broker.connect()
... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"connect_disconnect",
"=",
"Mock",
"(",
")",
"smart_app",
"=",
"Mock",
"(",
")",
"smart_app",
".",
"connect_event",
".",
"return_value",
"=",
"connect_disconnect",
"broker",
"=",
... | [
243,
0
] | [
261,
56
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry | (hass, config_entry, smartthings_mock) | Test that the installed app and app are removed up. | Test that the installed app and app are removed up. | async def test_remove_entry(hass, config_entry, smartthings_mock):
"""Test that the installed app and app are removed up."""
# Act
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.cal... | [
"async",
"def",
"test_remove_entry",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Act",
"await",
"smartthings",
".",
"async_remove_entry",
"(",
"hass",
",",
"config_entry",
")",
"# Assert",
"assert",
"smartthings_mock",
".",
"delete_instal... | [
264,
0
] | [
270,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_cloudhook | (hass, config_entry, smartthings_mock) | Test that the installed app, app, and cloudhook are removed up. | Test that the installed app, app, and cloudhook are removed up. | async def test_remove_entry_cloudhook(hass, config_entry, smartthings_mock):
"""Test that the installed app, app, and cloudhook are removed up."""
hass.config.components.add("cloud")
# Arrange
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUDHOOK_URL] = "https://test.cloud"
# Act
w... | [
"async",
"def",
"test_remove_entry_cloudhook",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"cloud\"",
")",
"# Arrange",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
273,
0
] | [
290,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_in_use | (hass, config_entry, smartthings_mock) | Test app is not removed if in use by another config entry. | Test app is not removed if in use by another config entry. | async def test_remove_entry_app_in_use(hass, config_entry, smartthings_mock):
"""Test app is not removed if in use by another config entry."""
# Arrange
config_entry.add_to_hass(hass)
data = config_entry.data.copy()
data[CONF_INSTALLED_APP_ID] = str(uuid4())
entry2 = MockConfigEntry(version=2, d... | [
"async",
"def",
"test_remove_entry_app_in_use",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"data",
"=",
"config_entry",
".",
"data",
".",
"copy",
"(",
")",
"data",
"["... | [
293,
0
] | [
305,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_already_deleted | (hass, config_entry, smartthings_mock) | Test handles when the apps have already been removed. | Test handles when the apps have already been removed. | async def test_remove_entry_already_deleted(hass, config_entry, smartthings_mock):
"""Test handles when the apps have already been removed."""
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_info=reques... | [
"async",
"def",
"test_remove_entry_already_deleted",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",
".",... | [
308,
0
] | [
322,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_installedapp_api_error | (
hass, config_entry, smartthings_mock
) | Test raises exceptions removing the installed app. | Test raises exceptions removing the installed app. | async def test_remove_entry_installedapp_api_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_i... | [
"async",
"def",
"test_remove_entry_installedapp_api_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",... | [
325,
0
] | [
339,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_installedapp_unknown_error | (
hass, config_entry, smartthings_mock
) | Test raises exceptions removing the installed app. | Test raises exceptions removing the installed app. | async def test_remove_entry_installedapp_unknown_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
# Arrange
smartthings_mock.delete_installed_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_re... | [
"async",
"def",
"test_remove_entry_installedapp_unknown_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",
".",
"side_effect",
"=",
"Exception",
"# Act",
"with",
"pytest",
".",
"rais... | [
342,
0
] | [
353,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_api_error | (hass, config_entry, smartthings_mock) | Test raises exceptions removing the app. | Test raises exceptions removing the app. | async def test_remove_entry_app_api_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
request_info = Mock(real_url="http://example.com")
smartthings_mock.delete_app.side_effect = ClientResponseError(
request_info=request_info, history=None, sta... | [
"async",
"def",
"test_remove_entry_app_api_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"smartthings_mock",
".",
"delete_app",
".",
"side_eff... | [
356,
0
] | [
368,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_unknown_error | (hass, config_entry, smartthings_mock) | Test raises exceptions removing the app. | Test raises exceptions removing the app. | async def test_remove_entry_app_unknown_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
smartthings_mock.delete_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_remove_entry(hass, config_entry)
... | [
"async",
"def",
"test_remove_entry_app_unknown_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"smartthings_mock",
".",
"delete_app",
".",
"side_effect",
"=",
"Exception",
"# Act",
"with",
"pytest",
".",
"raises",
"(",
"Exce... | [
371,
0
] | [
380,
54
] | python | en | ['en', 'en', 'en'] | True |
test_broker_regenerates_token | (hass, config_entry) | Test the device broker regenerates the refresh token. | Test the device broker regenerates the refresh token. | async def test_broker_regenerates_token(hass, config_entry):
"""Test the device broker regenerates the refresh token."""
token = Mock(OAuthToken)
token.refresh_token = str(uuid4())
stored_action = None
def async_track_time_interval(hass, action, interval):
nonlocal stored_action
sto... | [
"async",
"def",
"test_broker_regenerates_token",
"(",
"hass",
",",
"config_entry",
")",
":",
"token",
"=",
"Mock",
"(",
"OAuthToken",
")",
"token",
".",
"refresh_token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"stored_action",
"=",
"None",
"def",
"async_tra... | [
383,
0
] | [
403,
71
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_dispatches_updated_devices | (
hass, config_entry, device_factory, event_request_factory, event_factory
) | Test the event handler dispatches updated devices. | Test the event handler dispatches updated devices. | async def test_event_handler_dispatches_updated_devices(
hass, config_entry, device_factory, event_request_factory, event_factory
):
"""Test the event handler dispatches updated devices."""
devices = [
device_factory("Bedroom 1 Switch", ["switch"]),
device_factory("Bathroom 1", ["switch"]),
... | [
"async",
"def",
"test_event_handler_dispatches_updated_devices",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_request_factory",
",",
"event_factory",
")",
":",
"devices",
"=",
"[",
"device_factory",
"(",
"\"Bedroom 1 Switch\"",
",",
"[",
"\"switc... | [
406,
0
] | [
454,
71
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_ignores_other_installed_app | (
hass, config_entry, device_factory, event_request_factory
) | Test the event handler dispatches updated devices. | Test the event handler dispatches updated devices. | async def test_event_handler_ignores_other_installed_app(
hass, config_entry, device_factory, event_request_factory
):
"""Test the event handler dispatches updated devices."""
device = device_factory("Bedroom 1 Switch", ["switch"])
request = event_request_factory([device.device_id])
called = False
... | [
"async",
"def",
"test_event_handler_ignores_other_installed_app",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_request_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Bedroom 1 Switch\"",
",",
"[",
"\"switch\"",
"]",
")",
"request",
... | [
457,
0
] | [
477,
21
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_fires_button_events | (
hass, config_entry, device_factory, event_factory, event_request_factory
) | Test the event handler fires button events. | Test the event handler fires button events. | async def test_event_handler_fires_button_events(
hass, config_entry, device_factory, event_factory, event_request_factory
):
"""Test the event handler fires button events."""
device = device_factory("Button 1", ["button"])
event = event_factory(
device.device_id, capability="button", attribute=... | [
"async",
"def",
"test_event_handler_fires_button_events",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_factory",
",",
"event_request_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Button 1\"",
",",
"[",
"\"button\"",
"]",
")",
"... | [
480,
0
] | [
515,
17
] | python | en | ['en', 'en', 'en'] | True |
parse_distutils_args | (args) | Parse provided arguments, returning an object that has the
matched arguments.
Any unknown arguments are ignored.
| Parse provided arguments, returning an object that has the
matched arguments. | def parse_distutils_args(args):
# type: (List[str]) -> Dict[str, str]
"""Parse provided arguments, returning an object that has the
matched arguments.
Any unknown arguments are ignored.
"""
result = {}
for arg in args:
try:
_, match = _distutils_getopt.getopt(args=[arg])... | [
"def",
"parse_distutils_args",
"(",
"args",
")",
":",
"# type: (List[str]) -> Dict[str, str]",
"result",
"=",
"{",
"}",
"for",
"arg",
"in",
"args",
":",
"try",
":",
"_",
",",
"match",
"=",
"_distutils_getopt",
".",
"getopt",
"(",
"args",
"=",
"[",
"arg",
"... | [
29,
0
] | [
47,
17
] | python | en | ['en', 'en', 'en'] | True |
async_get_conditions | (
hass: HomeAssistant, device_id: str
) | List device conditions for Media player devices. | List device conditions for Media player devices. | async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Media player devices."""
registry = await entity_registry.async_get_registry(hass)
conditions = []
# Get all the integrations entities for this device
for entry in entity... | [
"async",
"def",
"async_get_conditions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"ha... | [
35,
0
] | [
57,
21
] | python | en | ['fr', 'en', 'en'] | True |
async_condition_from_config | (
config: ConfigType, config_validation: bool
) | Create a function to test a device condition. | Create a function to test a device condition. | def async_condition_from_config(
config: ConfigType, config_validation: bool
) -> condition.ConditionCheckerType:
"""Create a function to test a device condition."""
if config_validation:
config = CONDITION_SCHEMA(config)
if config[CONF_TYPE] == "is_playing":
state = STATE_PLAYING
el... | [
"def",
"async_condition_from_config",
"(",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
")",
"->",
"condition",
".",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"CONDITION_SCHEMA",
"(",
"config",
")",
"if",
"c... | [
61,
0
] | [
82,
24
] | python | en | ['en', 'en', 'en'] | True |
AirtouchConfigFlow.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."""
if user_input is None:
return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA)
errors = {}
host = user_input[CONF_HOST]
self._async_abort_entries_match({CONF_... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"DATA_SCHEMA",
")",
"errors",... | [
17,
4
] | [
49,
9
] | python | en | ['en', 'en', 'en'] | True |
OpenUvFlowHandler.config_schema | (self) | Return the config schema. | Return the config schema. | def config_schema(self) -> vol.Schema:
"""Return the config schema."""
return vol.Schema(
{
vol.Required(CONF_API_KEY): str,
vol.Inclusive(
CONF_LATITUDE, "coords", default=self.hass.config.latitude
): cv.latitude,
... | [
"def",
"config_schema",
"(",
"self",
")",
"->",
"vol",
".",
"Schema",
":",
"return",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_API_KEY",
")",
":",
"str",
",",
"vol",
".",
"Inclusive",
"(",
"CONF_LATITUDE",
",",
"\"coords\"",
",... | [
36,
4
] | [
51,
9
] | python | en | ['en', 'de', 'en'] | True |
OpenUvFlowHandler._show_form | (self, errors: dict[str, Any] | None = None) | Show the form to the user. | Show the form to the user. | async def _show_form(self, errors: dict[str, Any] | None = None) -> FlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
data_schema=self.config_schema,
errors=errors if errors else {},
) | [
"async",
"def",
"_show_form",
"(",
"self",
",",
"errors",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"... | [
53,
4
] | [
59,
9
] | python | en | ['en', 'en', 'en'] | True |
OpenUvFlowHandler.async_get_options_flow | (config_entry: ConfigEntry) | Define the config flow to handle options. | Define the config flow to handle options. | def async_get_options_flow(config_entry: ConfigEntry) -> OpenUvOptionsFlowHandler:
"""Define the config flow to handle options."""
return OpenUvOptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"OpenUvOptionsFlowHandler",
":",
"return",
"OpenUvOptionsFlowHandler",
"(",
"config_entry",
")"
] | [
63,
4
] | [
65,
53
] | python | en | ['en', 'en', 'en'] | True |
OpenUvFlowHandler.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle the start of the config flow. | Handle the start of the config flow. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the start of the config flow."""
if not user_input:
return await self._show_form()
identifier = f"{user_input[CONF_LATITUDE]}, {user_input[CONF_LONGITUDE]}"
await... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"not",
"user_input",
":",
"return",
"await",
"self",
".",
"_show_form",
"(",
")",... | [
67,
4
] | [
86,
73
] | python | en | ['en', 'en', 'en'] | True |
OpenUvOptionsFlowHandler.__init__ | (self, config_entry: ConfigEntry) | Initialize. | Initialize. | def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
92,
4
] | [
94,
40
] | python | en | ['en', 'en', 'it'] | False |
OpenUvOptionsFlowHandler.async_step_init | (
self, user_input: dict[str, Any] | None = None
) | Manage the options. | Manage the options. | async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
return self.async_show_form(
step_id="init",
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry"... | [
96,
4
] | [
125,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a sensor for a Hydrawise device. | Set up a sensor for a Hydrawise device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a sensor for a Hydrawise device."""
hydrawise = hass.data[DATA_HYDRAWISE].data
sensors = []
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
if sensor_type == "status":
sensors.append(
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"hydrawise",
"=",
"hass",
".",
"data",
"[",
"DATA_HYDRAWISE",
"]",
".",
"data",
"sensors",
"=",
"[",
"]",
"for",
"sensor_type",
"in",
... | [
22,
0
] | [
37,
31
] | python | en | ['en', 'en', 'en'] | True |
HydrawiseBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
44,
4
] | [
46,
26
] | python | en | ['en', 'fy', 'en'] | True |
HydrawiseBinarySensor.update | (self) | Get the latest data and updates the state. | Get the latest data and updates the state. | def update(self):
"""Get the latest data and updates the state."""
_LOGGER.debug("Updating Hydrawise binary sensor: %s", self._name)
mydata = self.hass.data[DATA_HYDRAWISE].data
if self._sensor_type == "status":
self._state = mydata.status == "All good!"
elif self._se... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating Hydrawise binary sensor: %s\"",
",",
"self",
".",
"_name",
")",
"mydata",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_HYDRAWISE",
"]",
".",
"data",
"if",
"self",
".",
... | [
48,
4
] | [
56,
56
] | python | en | ['en', 'en', 'en'] | True |
test_config_flow | (hass) | Test we can finish a config flow. | Test we can finish a config flow. | async def test_config_flow(hass):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
result = await hass.config_entries.flow.async_configure(result["f... | [
"async",
"def",
"test_config_flow",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"assert",
"result",
"[",
... | [
8,
0
] | [
20,
16
] | python | en | ['en', 'en', 'en'] | True |
test_already_setup | (hass) | Test we abort if already setup. | Test we abort if already setup. | async def test_already_setup(hass):
"""Test we abort if already setup."""
MockConfigEntry(
domain=DOMAIN,
data={},
).add_to_hass(hass)
# Should fail, same NAME
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result... | [
"async",
"def",
"test_already_setup",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"}",
",",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"# Should fail, same NAME",
"result",
"=",
"await",
"hass",
".",
"conf... | [
23,
0
] | [
35,
56
] | python | en | ['en', 'zu', 'en'] | True |
mock_connection | (
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
error: bool = False,
invalid_auth: bool = False,
server_error: bool = False,
) | Mock Sonarr connection. | Mock Sonarr connection. | def mock_connection(
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
error: bool = False,
invalid_auth: bool = False,
server_error: bool = False,
) -> None:
"""Mock Sonarr connection."""
if error:
mock_connection_error(
... | [
"def",
"mock_connection",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"host",
":",
"str",
"=",
"HOST",
",",
"port",
":",
"str",
"=",
"PORT",
",",
"base_path",
":",
"str",
"=",
"BASE_PATH",
",",
"error",
":",
"bool",
"=",
"False",
",",
"invali... | [
41,
0
] | [
120,
5
] | python | en | ['en', 'da', 'en'] | True |
mock_connection_error | (
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) | Mock Sonarr connection errors. | Mock Sonarr connection errors. | def mock_connection_error(
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) -> None:
"""Mock Sonarr connection errors."""
sonarr_url = f"http://{host}:{port}{base_path}"
aioclient_mock.get(f"{sonarr_url}/system/status", exc=SocketGIAErro... | [
"def",
"mock_connection_error",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"host",
":",
"str",
"=",
"HOST",
",",
"port",
":",
"str",
"=",
"PORT",
",",
"base_path",
":",
"str",
"=",
"BASE_PATH",
",",
")",
"->",
"None",
":",
"sonarr_url",
"=",
... | [
123,
0
] | [
138,
74
] | python | en | ['eu', 'en', 'en'] | True |
mock_connection_invalid_auth | (
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) | Mock Sonarr invalid auth errors. | Mock Sonarr invalid auth errors. | def mock_connection_invalid_auth(
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) -> None:
"""Mock Sonarr invalid auth errors."""
sonarr_url = f"http://{host}:{port}{base_path}"
aioclient_mock.get(f"{sonarr_url}/system/status", status=4... | [
"def",
"mock_connection_invalid_auth",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"host",
":",
"str",
"=",
"HOST",
",",
"port",
":",
"str",
"=",
"PORT",
",",
"base_path",
":",
"str",
"=",
"BASE_PATH",
",",
")",
"->",
"None",
":",
"sonarr_url",
... | [
141,
0
] | [
156,
66
] | python | en | ['en', 'et', 'en'] | True |
mock_connection_server_error | (
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) | Mock Sonarr server errors. | Mock Sonarr server errors. | def mock_connection_server_error(
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
) -> None:
"""Mock Sonarr server errors."""
sonarr_url = f"http://{host}:{port}{base_path}"
aioclient_mock.get(f"{sonarr_url}/system/status", status=500)
... | [
"def",
"mock_connection_server_error",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"host",
":",
"str",
"=",
"HOST",
",",
"port",
":",
"str",
"=",
"PORT",
",",
"base_path",
":",
"str",
"=",
"BASE_PATH",
",",
")",
"->",
"None",
":",
"sonarr_url",
... | [
159,
0
] | [
174,
66
] | python | da | ['da', 'no', 'en'] | False |
setup_integration | (
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
api_key: str = API_KEY,
unique_id: str = None,
skip_entry_setup: bool = False,
connection_error: bool = False,
invalid_auth: bool = False,
server_error:... | Set up the Sonarr integration in Home Assistant. | Set up the Sonarr integration in Home Assistant. | async def setup_integration(
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
host: str = HOST,
port: str = PORT,
base_path: str = BASE_PATH,
api_key: str = API_KEY,
unique_id: str = None,
skip_entry_setup: bool = False,
connection_error: bool = False,
invalid_auth: bool... | [
"async",
"def",
"setup_integration",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"host",
":",
"str",
"=",
"HOST",
",",
"port",
":",
"str",
"=",
"PORT",
",",
"base_path",
":",
"str",
"=",
"BASE_PATH",
",",
"api... | [
177,
0
] | [
226,
16
] | python | en | ['en', 'en', 'en'] | True |
_patch_async_setup_entry | (return_value=True) | Patch the async entry setup of sonarr. | Patch the async entry setup of sonarr. | def _patch_async_setup_entry(return_value=True):
"""Patch the async entry setup of sonarr."""
return patch(
"homeassistant.components.sonarr.async_setup_entry",
return_value=return_value,
) | [
"def",
"_patch_async_setup_entry",
"(",
"return_value",
"=",
"True",
")",
":",
"return",
"patch",
"(",
"\"homeassistant.components.sonarr.async_setup_entry\"",
",",
"return_value",
"=",
"return_value",
",",
")"
] | [
229,
0
] | [
234,
5
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler._create_entry | (self, username: str, token: str) | Register new entry. | Register new entry. | async def _create_entry(self, username: str, token: str):
"""Register new entry."""
await self.async_set_unique_id(username)
self._abort_if_unique_id_configured({CONF_TOKEN: token})
return self.async_create_entry(
title=username, data={CONF_USERNAME: username, CONF_TOKEN: tok... | [
"async",
"def",
"_create_entry",
"(",
"self",
",",
"username",
":",
"str",
",",
"token",
":",
"str",
")",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"username",
")",
"self",
".",
"_abort_if_unique_id_configured",
"(",
"{",
"CONF_TOKEN",
":",
"tok... | [
27,
4
] | [
33,
9
] | python | en | ['en', 'no', 'en'] | True |
FlowHandler._create_client | (
self,
username: str,
*,
password: str | None = None,
token: str | None = None,
) | Create client. | Create client. | async def _create_client(
self,
username: str,
*,
password: str | None = None,
token: str | None = None,
):
"""Create client."""
if password is None and token is None:
raise ValueError(
"Invalid internal state. Called without either... | [
"async",
"def",
"_create_client",
"(",
"self",
",",
"username",
":",
"str",
",",
"*",
",",
"password",
":",
"str",
"|",
"None",
"=",
"None",
",",
"token",
":",
"str",
"|",
"None",
"=",
"None",
",",
")",
":",
"if",
"password",
"is",
"None",
"and",
... | [
35,
4
] | [
68,
65
] | python | en | ['en', 'la', 'en'] | False |
FlowHandler.async_step_user | (self, user_input=None) | User initiated config flow. | User initiated config flow. | async def async_step_user(self, user_input=None):
"""User initiated config flow."""
if user_input is None:
return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): ... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
... | [
70,
4
] | [
80,
86
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_step_import | (self, user_input) | Import a config entry. | Import a config entry. | async def async_step_import(self, user_input):
"""Import a config entry."""
return await self._create_client(
user_input[CONF_USERNAME], token=user_input[CONF_TOKEN]
) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"return",
"await",
"self",
".",
"_create_client",
"(",
"user_input",
"[",
"CONF_USERNAME",
"]",
",",
"token",
"=",
"user_input",
"[",
"CONF_TOKEN",
"]",
")"
] | [
82,
4
] | [
86,
9
] | python | en | ['en', 'en', 'en'] | True |
hassio_env_fixture | () | Fixture to inject hassio env. | Fixture to inject hassio env. | def hassio_env_fixture():
"""Fixture to inject hassio env."""
with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch(
"homeassistant.components.hassio.HassIO.is_connected",
return_value={"result": "ok", "data": {}},
), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}):
yield | [
"def",
"hassio_env_fixture",
"(",
")",
":",
"with",
"patch",
".",
"dict",
"(",
"os",
".",
"environ",
",",
"{",
"\"HASSIO\"",
":",
"\"127.0.0.1\"",
"}",
")",
",",
"patch",
"(",
"\"homeassistant.components.hassio.HassIO.is_connected\"",
",",
"return_value",
"=",
"... | [
34,
0
] | [
40,
13
] | python | en | ['en', 'en', 'en'] | True |
gethostbyaddr_mock | () | Fixture to mock out I/O on getting host by address. | Fixture to mock out I/O on getting host by address. | def gethostbyaddr_mock():
"""Fixture to mock out I/O on getting host by address."""
with patch(
"homeassistant.components.http.ban.gethostbyaddr",
return_value=("example.com", ["0.0.0.0.in-addr.arpa"], ["0.0.0.0"]),
):
yield | [
"def",
"gethostbyaddr_mock",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.http.ban.gethostbyaddr\"",
",",
"return_value",
"=",
"(",
"\"example.com\"",
",",
"[",
"\"0.0.0.0.in-addr.arpa\"",
"]",
",",
"[",
"\"0.0.0.0\"",
"]",
")",
",",
")",
":",
... | [
44,
0
] | [
50,
13
] | python | en | ['en', 'en', 'en'] | True |
test_access_from_banned_ip | (hass, aiohttp_client) | Test accessing to server from banned IP. Both trusted and not. | Test accessing to server from banned IP. Both trusted and not. | async def test_access_from_banned_ip(hass, aiohttp_client):
"""Test accessing to server from banned IP. Both trusted and not."""
app = web.Application()
app["hass"] = hass
setup_bans(hass, app, 5)
set_real_ip = mock_real_ip(app)
with patch(
"homeassistant.components.http.ban.async_load_... | [
"async",
"def",
"test_access_from_banned_ip",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
"[",
"\"hass\"",
"]",
"=",
"hass",
"setup_bans",
"(",
"hass",
",",
"app",
",",
"5",
")",
"set_real_ip",
"=... | [
53,
0
] | [
69,
44
] | python | en | ['en', 'en', 'en'] | True |
test_access_from_supervisor_ip | (
remote_addr, bans, status, hass, aiohttp_client, hassio_env
) | Test accessing to server from supervisor IP. | Test accessing to server from supervisor IP. | async def test_access_from_supervisor_ip(
remote_addr, bans, status, hass, aiohttp_client, hassio_env
):
"""Test accessing to server from supervisor IP."""
app = web.Application()
app["hass"] = hass
async def unauth_handler(request):
"""Return a mock web response."""
raise HTTPUnaut... | [
"async",
"def",
"test_access_from_supervisor_ip",
"(",
"remote_addr",
",",
"bans",
",",
"status",
",",
"hass",
",",
"aiohttp_client",
",",
"hassio_env",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
"[",
"\"hass\"",
"]",
"=",
"hass",
"a... | [
80,
0
] | [
115,
47
] | python | en | ['en', 'en', 'en'] | True |
test_ban_middleware_not_loaded_by_config | (hass) | Test accessing to server from banned IP when feature is off. | Test accessing to server from banned IP when feature is off. | async def test_ban_middleware_not_loaded_by_config(hass):
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_bans") as mock_setup:
await async_setup_component(
hass, "http", {"http": {http.CONF_IP_BAN_ENABLED: False}}
)
... | [
"async",
"def",
"test_ban_middleware_not_loaded_by_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.http.setup_bans\"",
")",
"as",
"mock_setup",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"http\"",
",",
"{",
"\"http\"",
... | [
118,
0
] | [
125,
42
] | python | en | ['en', 'en', 'en'] | True |
test_ban_middleware_loaded_by_default | (hass) | Test accessing to server from banned IP when feature is off. | Test accessing to server from banned IP when feature is off. | async def test_ban_middleware_loaded_by_default(hass):
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_bans") as mock_setup:
await async_setup_component(hass, "http", {"http": {}})
assert len(mock_setup.mock_calls) == 1 | [
"async",
"def",
"test_ban_middleware_loaded_by_default",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.http.setup_bans\"",
")",
"as",
"mock_setup",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"http\"",
",",
"{",
"\"http\"",
":... | [
128,
0
] | [
133,
42
] | python | en | ['en', 'en', 'en'] | True |
test_ip_bans_file_creation | (hass, aiohttp_client) | Testing if banned IP file created. | Testing if banned IP file created. | async def test_ip_bans_file_creation(hass, aiohttp_client):
"""Testing if banned IP file created."""
notification_calls = async_mock_service(hass, "persistent_notification", "create")
app = web.Application()
app["hass"] = hass
async def unauth_handler(request):
"""Return a mock web respons... | [
"async",
"def",
"test_ip_bans_file_creation",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"notification_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"\"create\"",
")",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"... | [
136,
0
] | [
180,
9
] | python | en | ['en', 'en', 'en'] | True |
test_failed_login_attempts_counter | (hass, aiohttp_client) | Testing if failed login attempts counter increased. | Testing if failed login attempts counter increased. | async def test_failed_login_attempts_counter(hass, aiohttp_client):
"""Testing if failed login attempts counter increased."""
app = web.Application()
app["hass"] = hass
async def auth_handler(request):
"""Return 200 status code."""
return None, 200
app.router.add_get(
"/aut... | [
"async",
"def",
"test_failed_login_attempts_counter",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
"[",
"\"hass\"",
"]",
"=",
"hass",
"async",
"def",
"auth_handler",
"(",
"request",
")",
":",
"\"\"\"Re... | [
183,
0
] | [
235,
57
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up the Axis component. | Set up the Axis component. | async def async_setup_entry(hass, config_entry):
"""Set up the Axis component."""
hass.data.setdefault(AXIS_DOMAIN, {})
device = AxisNetworkDevice(hass, config_entry)
if not await device.async_setup():
return False
hass.data[AXIS_DOMAIN][config_entry.unique_id] = device
await device.... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"AXIS_DOMAIN",
",",
"{",
"}",
")",
"device",
"=",
"AxisNetworkDevice",
"(",
"hass",
",",
"config_entry",
")",
"if",
"not",
"await"... | [
15,
0
] | [
32,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload Axis device config entry. | Unload Axis device config entry. | async def async_unload_entry(hass, config_entry):
"""Unload Axis device config entry."""
device = hass.data[AXIS_DOMAIN].pop(config_entry.unique_id)
return await device.async_reset() | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"device",
"=",
"hass",
".",
"data",
"[",
"AXIS_DOMAIN",
"]",
".",
"pop",
"(",
"config_entry",
".",
"unique_id",
")",
"return",
"await",
"device",
".",
"async_reset",
"(",
")"... | [
35,
0
] | [
38,
37
] | python | en | ['da', 'en', 'en'] | True |
async_migrate_entry | (hass, config_entry) | Migrate old entry. | Migrate old entry. | async def async_migrate_entry(hass, config_entry):
"""Migrate old entry."""
_LOGGER.debug("Migrating from version %s", config_entry.version)
# Flatten configuration but keep old data if user rollbacks HASS prior to 0.106
if config_entry.version == 1:
unique_id = config_entry.data[CONF_MAC]
... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Migrating from version %s\"",
",",
"config_entry",
".",
"version",
")",
"# Flatten configuration but keep old data if user rollbacks HASS prior to 0.106",
"if"... | [
41,
0
] | [
77,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up the isy994 integration from YAML. | Set up the isy994 integration from YAML. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the isy994 integration from YAML."""
isy_config: ConfigType | None = config.get(DOMAIN)
hass.data.setdefault(DOMAIN, {})
if not isy_config:
return True
# Only import if we haven't before.
config_entry = _... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"isy_config",
":",
"ConfigType",
"|",
"None",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"hass",
".",
"data",
".",
"setdefault... | [
75,
0
] | [
97,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Set up the ISY 994 integration. | Set up the ISY 994 integration. | async def async_setup_entry(
hass: HomeAssistant, entry: config_entries.ConfigEntry
) -> bool:
"""Set up the ISY 994 integration."""
# As there currently is no way to import options from yaml
# when setting up a config entry, we fallback to adding
# the options to the config entry and pull them out ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"bool",
":",
"# As there currently is no way to import options from yaml",
"# when setting up a config entry, we fallback to adding",
"# t... | [
107,
0
] | [
230,
15
] | python | en | ['en', 'en', 'en'] | True |
_async_update_listener | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Handle options update. | Handle options update. | async def _async_update_listener(
hass: HomeAssistant, entry: config_entries.ConfigEntry
):
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"_async_update_listener",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
233,
0
] | [
237,
58
] | python | en | ['en', 'nl', 'en'] | True |
async_unload_entry | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(
hass: HomeAssistant, entry: config_entries.ConfigEntry
) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
hass_isy_data = hass.data[DOMAIN][entry.entry_id]
isy = hass_isy_data[ISY994_ISY]
def _st... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"await",
"hass",
".",
"config_entries",
".",
"async_unload_platforms",
"(",
"entry",
",",
... | [
275,
0
] | [
299,
20
] | python | en | ['en', 'es', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Add switches for a config entry. | Add switches for a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add switches for a config entry."""
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
async_add_entities([SmartThingsScene(scene) for scene in broker.scenes.values()]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"broker",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_BROKERS",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"async_add_entities",
"(",
... | [
8,
0
] | [
11,
85
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsScene.__init__ | (self, scene) | Init the scene class. | Init the scene class. | def __init__(self, scene):
"""Init the scene class."""
self._scene = scene | [
"def",
"__init__",
"(",
"self",
",",
"scene",
")",
":",
"self",
".",
"_scene",
"=",
"scene"
] | [
17,
4
] | [
19,
27
] | python | en | ['en', 'it', 'en'] | True |
SmartThingsScene.async_activate | (self, **kwargs: Any) | Activate scene. | Activate scene. | async def async_activate(self, **kwargs: Any) -> None:
"""Activate scene."""
await self._scene.execute() | [
"async",
"def",
"async_activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_scene",
".",
"execute",
"(",
")"
] | [
21,
4
] | [
23,
35
] | python | en | ['it', 'la', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.