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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
get_scanner | (hass, config) | Return a BT Home Hub 5 scanner if successful. | Return a BT Home Hub 5 scanner if successful. | def get_scanner(hass, config):
"""Return a BT Home Hub 5 scanner if successful."""
scanner = BTHomeHub5DeviceScanner(config[DOMAIN])
return scanner if scanner.success_init else None | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"BTHomeHub5DeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner",
"if",
"scanner",
".",
"success_init",
"else",
"None"
] | [
23,
0
] | [
27,
52
] | python | en | ['en', 'co', 'en'] | True |
BTHomeHub5DeviceScanner.__init__ | (self, config) | Initialise the scanner. | Initialise the scanner. | def __init__(self, config):
"""Initialise the scanner."""
_LOGGER.info("Initialising BT Home Hub 5")
self.host = config[CONF_HOST]
self.last_results = {}
# Test the router is accessible
data = bthomehub5_devicelist.get_devicelist(self.host)
self.success_init = d... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Initialising BT Home Hub 5\"",
")",
"self",
".",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"self",
".",
"last_results",
"=",
"{",
"}",
"# Test the router is accessible... | [
33,
4
] | [
42,
44
] | python | en | ['en', 'en', 'en'] | True |
BTHomeHub5DeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self.update_info()
return (device for device in self.last_results) | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"update_info",
"(",
")",
"return",
"(",
"device",
"for",
"device",
"in",
"self",
".",
"last_results",
")"
] | [
44,
4
] | [
48,
55
] | python | en | ['en', 'en', 'en'] | True |
BTHomeHub5DeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
# If not initialised and not already scanned and not found.
if device not in self.last_results:
self.update_info()
if not self.last_results:
return None... | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"# If not initialised and not already scanned and not found.",
"if",
"device",
"not",
"in",
"self",
".",
"last_results",
":",
"self",
".",
"update_info",
"(",
")",
"if",
"not",
"self",
".",
"last_resu... | [
50,
4
] | [
59,
44
] | python | en | ['en', 'en', 'en'] | True |
BTHomeHub5DeviceScanner.update_info | (self) | Ensure the information from the BT Home Hub 5 is up to date. | Ensure the information from the BT Home Hub 5 is up to date. | def update_info(self):
"""Ensure the information from the BT Home Hub 5 is up to date."""
_LOGGER.info("Scanning")
data = bthomehub5_devicelist.get_devicelist(self.host)
if not data:
_LOGGER.warning("Error scanning devices")
return
self.last_results = ... | [
"def",
"update_info",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Scanning\"",
")",
"data",
"=",
"bthomehub5_devicelist",
".",
"get_devicelist",
"(",
"self",
".",
"host",
")",
"if",
"not",
"data",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Error sc... | [
61,
4
] | [
72,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | ( # noqa: C901
hass: HomeAssistant, entry: ConfigEntry
) | Set up Huawei LTE component from config entry. | Set up Huawei LTE component from config entry. | async def async_setup_entry( # noqa: C901
hass: HomeAssistant, entry: ConfigEntry
) -> bool:
"""Set up Huawei LTE component from config entry."""
url = entry.data[CONF_URL]
# Override settings from YAML config, but only if they're changed in it
# Old values are stored as *_from_yaml in the config ... | [
"async",
"def",
"async_setup_entry",
"(",
"# noqa: C901",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"url",
"=",
"entry",
".",
"data",
"[",
"CONF_URL",
"]",
"# Override settings from YAML config, but only if they're changed... | [
307,
0
] | [
486,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Unload config entry. | Unload config entry. | async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Unload config entry."""
# Forward config entry unload to platforms
await hass.config_entries.async_unload_platforms(
config_entry, CONFIG_ENTRY_PLATFORMS
)
# Forget about the router and invoke its clea... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"# Forward config entry unload to platforms",
"await",
"hass",
".",
"config_entries",
".",
"async_unload_platforms",
"(",
"config_en... | [
489,
0
] | [
501,
15
] | python | da | ['da', 'es', 'en'] | False |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up Huawei LTE component. | Set up Huawei LTE component. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Huawei LTE component."""
# dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level.
# https://github.com/quandyfactory/dicttoxml/issues/60
logging.getLogger("dicttoxml").setLevel(logging.WARNING)
# Arrang... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"# dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level.",
"# https://github.com/quandyfactory/dicttoxml/issues/60",
"logging",
".",
"getLo... | [
504,
0
] | [
590,
15
] | python | en | ['en', 'en', 'en'] | True |
async_migrate_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Migrate config entry to new version. | Migrate config entry to new version. | async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate config entry to new version."""
if config_entry.version == 1:
options = dict(config_entry.options)
recipient = options.get(CONF_RECIPIENT)
if isinstance(recipient, str):
options[... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"if",
"config_entry",
".",
"version",
"==",
"1",
":",
"options",
"=",
"dict",
"(",
"config_entry",
".",
"options",
")",... | [
593,
0
] | [
609,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Smappee sensor. | Set up the Smappee sensor. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Smappee sensor."""
smappee_base = hass.data[DOMAIN][config_entry.entry_id]
entities = []
for service_location in smappee_base.smappee.service_locations.values():
# Add all basic sensors (realtime values and aggre... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"smappee_base",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"]",
"for",
"service_lo... | [
155,
0
] | [
274,
38
] | python | en | ['en', 'st', 'en'] | True |
SmappeeSensor.__init__ | (self, smappee_base, service_location, sensor, attributes) | Initialize the Smappee sensor. | Initialize the Smappee sensor. | def __init__(self, smappee_base, service_location, sensor, attributes):
"""Initialize the Smappee sensor."""
self._smappee_base = smappee_base
self._service_location = service_location
self._sensor = sensor
self.data = None
self._state = None
self._name = attribut... | [
"def",
"__init__",
"(",
"self",
",",
"smappee_base",
",",
"service_location",
",",
"sensor",
",",
"attributes",
")",
":",
"self",
".",
"_smappee_base",
"=",
"smappee_base",
"self",
".",
"_service_location",
"=",
"service_location",
"self",
".",
"_sensor",
"=",
... | [
280,
4
] | [
291,
42
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.name | (self) | Return the name for this sensor. | Return the name for this sensor. | def name(self):
"""Return the name for this sensor."""
if self._sensor in ("sensor", "load", "switch"):
return (
f"{self._service_location.service_location_name} - "
f"{self._sensor.title()} - {self._name}"
)
return f"{self._service_locati... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sensor",
"in",
"(",
"\"sensor\"",
",",
"\"load\"",
",",
"\"switch\"",
")",
":",
"return",
"(",
"f\"{self._service_location.service_location_name} - \"",
"f\"{self._sensor.title()} - {self._name}\"",
")",
"retu... | [
294,
4
] | [
302,
79
] | python | en | ['en', 'ceb', 'en'] | True |
SmappeeSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
305,
4
] | [
307,
25
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.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."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
310,
4
] | [
312,
26
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
315,
4
] | [
317,
33
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.state_class | (self) | Return the state class of this device. | Return the state class of this device. | def state_class(self):
"""Return the state class of this device."""
scm = STATE_CLASS_MEASUREMENT
if self._sensor in (
"power_today",
"power_current_hour",
"power_last_5_minutes",
"solar_today",
"solar_current_hour",
"alway... | [
"def",
"state_class",
"(",
"self",
")",
":",
"scm",
"=",
"STATE_CLASS_MEASUREMENT",
"if",
"self",
".",
"_sensor",
"in",
"(",
"\"power_today\"",
",",
"\"power_current_hour\"",
",",
"\"power_last_5_minutes\"",
",",
"\"solar_today\"",
",",
"\"solar_current_hour\"",
",",
... | [
320,
4
] | [
335,
18
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.native_unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def native_unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
338,
4
] | [
340,
40
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.unique_id | (
self,
) | Return the unique ID for this sensor. | Return the unique ID for this sensor. | def unique_id(
self,
):
"""Return the unique ID for this sensor."""
if self._sensor in ("load", "sensor", "switch"):
return (
f"{self._service_location.device_serial_number}-"
f"{self._service_location.service_location_id}-"
f"{self... | [
"def",
"unique_id",
"(",
"self",
",",
")",
":",
"if",
"self",
".",
"_sensor",
"in",
"(",
"\"load\"",
",",
"\"sensor\"",
",",
"\"switch\"",
")",
":",
"return",
"(",
"f\"{self._service_location.device_serial_number}-\"",
"f\"{self._service_location.service_location_id}-\"... | [
343,
4
] | [
358,
9
] | python | en | ['en', 'la', 'en'] | True |
SmappeeSensor.device_info | (self) | Return the device info for this sensor. | Return the device info for this sensor. | def device_info(self):
"""Return the device info for this sensor."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_lo... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_service_location",
".",
"device_serial_number",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_service_location",
".",
"service_location... | [
361,
4
] | [
369,
9
] | python | en | ['en', 'en', 'en'] | True |
SmappeeSensor.async_update | (self) | Get the latest data from Smappee and update the state. | Get the latest data from Smappee and update the state. | async def async_update(self):
"""Get the latest data from Smappee and update the state."""
await self._smappee_base.async_update()
if self._sensor == "total_power":
self._state = self._service_location.total_power
elif self._sensor == "total_reactive_power":
self... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_smappee_base",
".",
"async_update",
"(",
")",
"if",
"self",
".",
"_sensor",
"==",
"\"total_power\"",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_service_location",
".",
"tot... | [
371,
4
] | [
430,
53
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Add a weather entity from map location. | Add a weather entity from map location. | async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add a weather entity from map location."""
location = config_entry.data
name = slugify(location[CONF_NAME])
session = aiohttp_client.async_get_clientsession(ha... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"location",
"=",
"config_entry",
".",
"data",
"name",
"=",
"slugi... | [
77,
0
] | [
96,
38
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.__init__ | (
self,
name: str,
latitude: str,
longitude: str,
session: aiohttp.ClientSession,
) | Initialize the SMHI weather entity. | Initialize the SMHI weather entity. | def __init__(
self,
name: str,
latitude: str,
longitude: str,
session: aiohttp.ClientSession,
) -> None:
"""Initialize the SMHI weather entity."""
self._name = name
self._latitude = latitude
self._longitude = longitude
self._forecasts:... | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
",",
"latitude",
":",
"str",
",",
"longitude",
":",
"str",
",",
"session",
":",
"aiohttp",
".",
"ClientSession",
",",
")",
"->",
"None",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"... | [
102,
4
] | [
116,
79
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.unique_id | (self) | Return a unique id. | Return a unique id. | def unique_id(self) -> str:
"""Return a unique id."""
return f"{self._latitude}, {self._longitude}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._latitude}, {self._longitude}\""
] | [
119,
4
] | [
121,
53
] | python | ca | ['fr', 'ca', 'en'] | False |
SmhiWeather.async_update | (self) | Refresh the forecast data from SMHI weather API. | Refresh the forecast data from SMHI weather API. | async def async_update(self) -> None:
"""Refresh the forecast data from SMHI weather API."""
try:
with async_timeout.timeout(10):
self._forecasts = await self.get_weather_forecast()
self._fail_count = 0
except (asyncio.TimeoutError, SmhiForecastExcept... | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"10",
")",
":",
"self",
".",
"_forecasts",
"=",
"await",
"self",
".",
"get_weather_forecast",
"(",
")",
"self",
".",
"_fail_cou... | [
124,
4
] | [
135,
77
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.retry_update | (self, _: datetime) | Retry refresh weather forecast. | Retry refresh weather forecast. | async def retry_update(self, _: datetime) -> None:
"""Retry refresh weather forecast."""
await self.async_update( # pylint: disable=unexpected-keyword-arg
no_throttle=True
) | [
"async",
"def",
"retry_update",
"(",
"self",
",",
"_",
":",
"datetime",
")",
"->",
"None",
":",
"await",
"self",
".",
"async_update",
"(",
"# pylint: disable=unexpected-keyword-arg",
"no_throttle",
"=",
"True",
")"
] | [
137,
4
] | [
141,
9
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.get_weather_forecast | (self) | Return the current forecasts from SMHI API. | Return the current forecasts from SMHI API. | async def get_weather_forecast(self) -> list[SmhiForecast]:
"""Return the current forecasts from SMHI API."""
return await self._smhi_api.async_get_forecast() | [
"async",
"def",
"get_weather_forecast",
"(",
"self",
")",
"->",
"list",
"[",
"SmhiForecast",
"]",
":",
"return",
"await",
"self",
".",
"_smhi_api",
".",
"async_get_forecast",
"(",
")"
] | [
143,
4
] | [
145,
56
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
148,
4
] | [
150,
25
] | python | en | ['en', 'mi', 'en'] | True |
SmhiWeather.temperature | (self) | Return the temperature. | Return the temperature. | def temperature(self) -> int | None:
"""Return the temperature."""
if self._forecasts is not None:
return self._forecasts[0].temperature
return None | [
"def",
"temperature",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"temperature",
"return",
"None"
] | [
153,
4
] | [
157,
19
] | python | en | ['en', 'la', 'en'] | True |
SmhiWeather.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
160,
4
] | [
162,
27
] | python | en | ['en', 'la', 'en'] | True |
SmhiWeather.humidity | (self) | Return the humidity. | Return the humidity. | def humidity(self) -> int | None:
"""Return the humidity."""
if self._forecasts is not None:
return self._forecasts[0].humidity
return None | [
"def",
"humidity",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"humidity",
"return",
"None"
] | [
165,
4
] | [
169,
19
] | python | en | ['en', 'sw', 'en'] | True |
SmhiWeather.wind_speed | (self) | Return the wind speed. | Return the wind speed. | def wind_speed(self) -> float | None:
"""Return the wind speed."""
if self._forecasts is not None:
# Convert from m/s to km/h
return round(self._forecasts[0].wind_speed * 18 / 5)
return None | [
"def",
"wind_speed",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"# Convert from m/s to km/h",
"return",
"round",
"(",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"wind_speed",
"*",
"18... | [
172,
4
] | [
177,
19
] | python | en | ['en', 'zh', 'en'] | True |
SmhiWeather.wind_gust_speed | (self) | Return the wind gust speed. | Return the wind gust speed. | def wind_gust_speed(self) -> float | None:
"""Return the wind gust speed."""
if self._forecasts is not None:
# Convert from m/s to km/h
return round(self._forecasts[0].wind_gust * 18 / 5)
return None | [
"def",
"wind_gust_speed",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"# Convert from m/s to km/h",
"return",
"round",
"(",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"wind_gust",
"*",
... | [
180,
4
] | [
185,
19
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.wind_bearing | (self) | Return the wind bearing. | Return the wind bearing. | def wind_bearing(self) -> int | None:
"""Return the wind bearing."""
if self._forecasts is not None:
return self._forecasts[0].wind_direction
return None | [
"def",
"wind_bearing",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"wind_direction",
"return",
"None"
] | [
188,
4
] | [
192,
19
] | python | en | ['en', 'ig', 'en'] | True |
SmhiWeather.visibility | (self) | Return the visibility. | Return the visibility. | def visibility(self) -> float | None:
"""Return the visibility."""
if self._forecasts is not None:
return self._forecasts[0].horizontal_visibility
return None | [
"def",
"visibility",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"horizontal_visibility",
"return",
"None"
] | [
195,
4
] | [
199,
19
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.pressure | (self) | Return the pressure. | Return the pressure. | def pressure(self) -> int | None:
"""Return the pressure."""
if self._forecasts is not None:
return self._forecasts[0].pressure
return None | [
"def",
"pressure",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"pressure",
"return",
"None"
] | [
202,
4
] | [
206,
19
] | python | en | ['en', 'ig', 'en'] | True |
SmhiWeather.cloudiness | (self) | Return the cloudiness. | Return the cloudiness. | def cloudiness(self) -> int | None:
"""Return the cloudiness."""
if self._forecasts is not None:
return self._forecasts[0].cloudiness
return None | [
"def",
"cloudiness",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"cloudiness",
"return",
"None"
] | [
209,
4
] | [
213,
19
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.thunder_probability | (self) | Return the chance of thunder, unit Percent. | Return the chance of thunder, unit Percent. | def thunder_probability(self) -> int | None:
"""Return the chance of thunder, unit Percent."""
if self._forecasts is not None:
return self._forecasts[0].thunder
return None | [
"def",
"thunder_probability",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_forecasts",
"[",
"0",
"]",
".",
"thunder",
"return",
"None"
] | [
216,
4
] | [
220,
19
] | python | en | ['en', 'sq', 'en'] | True |
SmhiWeather.condition | (self) | Return the weather condition. | Return the weather condition. | def condition(self) -> str | None:
"""Return the weather condition."""
if self._forecasts is None:
return None
return next(
(k for k, v in CONDITION_CLASSES.items() if self._forecasts[0].symbol in v),
None,
) | [
"def",
"condition",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"None",
":",
"return",
"None",
"return",
"next",
"(",
"(",
"k",
"for",
"k",
",",
"v",
"in",
"CONDITION_CLASSES",
".",
"items",
"(",
")",
"if... | [
223,
4
] | [
230,
9
] | python | en | ['en', 'en', 'en'] | True |
SmhiWeather.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self) -> str:
"""Return the attribution."""
return "Swedish weather institute (SMHI)" | [
"def",
"attribution",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Swedish weather institute (SMHI)\""
] | [
233,
4
] | [
235,
49
] | python | en | ['en', 'ja', 'en'] | True |
SmhiWeather.forecast | (self) | Return the forecast. | Return the forecast. | def forecast(self) -> list[Forecast] | None:
"""Return the forecast."""
if self._forecasts is None or len(self._forecasts) < 2:
return None
data: list[Forecast] = []
for forecast in self._forecasts[1:]:
condition = next(
(k for k, v in CONDITION_... | [
"def",
"forecast",
"(",
"self",
")",
"->",
"list",
"[",
"Forecast",
"]",
"|",
"None",
":",
"if",
"self",
".",
"_forecasts",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"_forecasts",
")",
"<",
"2",
":",
"return",
"None",
"data",
":",
"list",
"[",
... | [
238,
4
] | [
260,
19
] | python | en | ['en', 'no', 'en'] | True |
SmhiWeather.extra_state_attributes | (self) | Return SMHI specific attributes. | Return SMHI specific attributes. | def extra_state_attributes(self) -> ExtraAttributes:
"""Return SMHI specific attributes."""
extra_attributes: ExtraAttributes = {}
if self.cloudiness is not None:
extra_attributes[ATTR_SMHI_CLOUDINESS] = self.cloudiness
if self.wind_gust_speed is not None:
extra_a... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
"->",
"ExtraAttributes",
":",
"extra_attributes",
":",
"ExtraAttributes",
"=",
"{",
"}",
"if",
"self",
".",
"cloudiness",
"is",
"not",
"None",
":",
"extra_attributes",
"[",
"ATTR_SMHI_CLOUDINESS",
"]",
"=",
"sel... | [
263,
4
] | [
272,
31
] | python | en | ['en', 'la', 'en'] | True |
async_setup | (hass, config) | Set up BME280 component. | Set up BME280 component. | async def async_setup(hass, config):
"""Set up BME280 component."""
bme280_config = config[DOMAIN]
for bme280_conf in bme280_config:
discovery_info = {SENSOR_DOMAIN: bme280_conf}
hass.async_create_task(
discovery.async_load_platform(
hass, SENSOR_DOMAIN, DOMAIN, d... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"bme280_config",
"=",
"config",
"[",
"DOMAIN",
"]",
"for",
"bme280_conf",
"in",
"bme280_config",
":",
"discovery_info",
"=",
"{",
"SENSOR_DOMAIN",
":",
"bme280_conf",
"}",
"hass",
".",
"asy... | [
87,
0
] | [
97,
15
] | python | en | ['en', 'fr', 'en'] | True |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from schema with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from schema with values provided by the user.
"""
somfy_mylink = SomfyMyLinkSynergy(
data[CONF_SYSTEM_ID], data[CONF_HOST], data[CONF_PORT]
)
try:
status... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"somfy_mylink",
"=",
"SomfyMyLinkSynergy",
"(",
"data",
"[",
"CONF_SYSTEM_ID",
"]",
",",
"data",
"[",
"CONF_HOST",
"]",
",",
"data",
"[",
"CONF_PORT",
... | [
28,
0
] | [
46,
49
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.__init__ | (self) | Initialize the somfy_mylink flow. | Initialize the somfy_mylink flow. | def __init__(self):
"""Initialize the somfy_mylink flow."""
self.host = None
self.mac = None
self.ip_address = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"host",
"=",
"None",
"self",
".",
"mac",
"=",
"None",
"self",
".",
"ip_address",
"=",
"None"
] | [
54,
4
] | [
58,
30
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_dhcp | (self, discovery_info) | Handle dhcp discovery. | Handle dhcp discovery. | async def async_step_dhcp(self, discovery_info):
"""Handle dhcp discovery."""
self._async_abort_entries_match({CONF_HOST: discovery_info[IP_ADDRESS]})
formatted_mac = format_mac(discovery_info[MAC_ADDRESS])
await self.async_set_unique_id(format_mac(formatted_mac))
self._abort_if... | [
"async",
"def",
"async_step_dhcp",
"(",
"self",
",",
"discovery_info",
")",
":",
"self",
".",
"_async_abort_entries_match",
"(",
"{",
"CONF_HOST",
":",
"discovery_info",
"[",
"IP_ADDRESS",
"]",
"}",
")",
"formatted_mac",
"=",
"format_mac",
"(",
"discovery_info",
... | [
60,
4
] | [
73,
43
] | python | en | ['fr', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]})
try:
info = await validate_input(self.hass, user_input)
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"_async_abort_entries_match",
"(",
"{",
"CONF_HOST",
":",
"user_input",
"[",
"CONF... | [
75,
4
] | [
104,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]})
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"self",
".",
"_async_abort_entries_match",
"(",
"{",
"CONF_HOST",
":",
"user_input",
"[",
"CONF_HOST",
"]",
"}",
")",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_i... | [
106,
4
] | [
109,
53
] | python | en | ['en', 'ja', 'en'] | False |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
113,
4
] | [
115,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
self.options = deepcopy(dict(config_entry.options))
self._target_id = None | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"options",
"=",
"deepcopy",
"(",
"dict",
"(",
"config_entry",
".",
"options... | [
121,
4
] | [
125,
30
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler._async_callback_targets | (self) | Return the list of targets. | Return the list of targets. | def _async_callback_targets(self):
"""Return the list of targets."""
return self.hass.data[DOMAIN][self.config_entry.entry_id][MYLINK_STATUS][
"result"
] | [
"def",
"_async_callback_targets",
"(",
"self",
")",
":",
"return",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"self",
".",
"config_entry",
".",
"entry_id",
"]",
"[",
"MYLINK_STATUS",
"]",
"[",
"\"result\"",
"]"
] | [
128,
4
] | [
132,
9
] | python | en | ['en', 'et', 'en'] | True |
OptionsFlowHandler._async_get_target_name | (self, target_id) | Find the name of a target in the api data. | Find the name of a target in the api data. | def _async_get_target_name(self, target_id) -> str:
"""Find the name of a target in the api data."""
mylink_targets = self._async_callback_targets()
for cover in mylink_targets:
if cover["targetID"] == target_id:
return cover["name"]
raise KeyError | [
"def",
"_async_get_target_name",
"(",
"self",
",",
"target_id",
")",
"->",
"str",
":",
"mylink_targets",
"=",
"self",
".",
"_async_callback_targets",
"(",
")",
"for",
"cover",
"in",
"mylink_targets",
":",
"if",
"cover",
"[",
"\"targetID\"",
"]",
"==",
"target_... | [
135,
4
] | [
141,
22
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if self.config_entry.state is not config_entries.ConfigEntryState.LOADED:
_LOGGER.error("MyLink must be connected to manage device options")
return self.async_abort(reason="cannot_connect")
if ... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"config_entry",
".",
"state",
"is",
"not",
"config_entries",
".",
"ConfigEntryState",
".",
"LOADED",
":",
"_LOGGER",
".",
"error",
"(",
"\"MyLink mus... | [
143,
4
] | [
165,
87
] | python | en | ['en', 'nl', 'en'] | True |
OptionsFlowHandler.async_step_target_config | (self, user_input=None, target_id=None) | Handle options flow for target. | Handle options flow for target. | async def async_step_target_config(self, user_input=None, target_id=None):
"""Handle options flow for target."""
reversed_target_ids = self.options.setdefault(CONF_REVERSED_TARGET_IDS, {})
if user_input is not None:
if user_input[CONF_REVERSE] != reversed_target_ids.get(self._target... | [
"async",
"def",
"async_step_target_config",
"(",
"self",
",",
"user_input",
"=",
"None",
",",
"target_id",
"=",
"None",
")",
":",
"reversed_target_ids",
"=",
"self",
".",
"options",
".",
"setdefault",
"(",
"CONF_REVERSED_TARGET_IDS",
",",
"{",
"}",
")",
"if",
... | [
167,
4
] | [
192,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the aREST switches. | Set up the aREST switches. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the aREST switches."""
resource = config[CONF_RESOURCE]
try:
response = requests.get(resource, timeout=10)
except requests.exceptions.MissingSchema:
_LOGGER.error(
"Missing resource or schema in c... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"resource",
"=",
"config",
"[",
"CONF_RESOURCE",
"]",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"resource",
",",
"timeou... | [
40,
0
] | [
79,
21
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchBase.__init__ | (self, resource, location, name) | Initialize the switch. | Initialize the switch. | def __init__(self, resource, location, name):
"""Initialize the switch."""
self._resource = resource
self._attr_name = f"{location.title()} {name.title()}"
self._attr_available = True
self._attr_is_on = False | [
"def",
"__init__",
"(",
"self",
",",
"resource",
",",
"location",
",",
"name",
")",
":",
"self",
".",
"_resource",
"=",
"resource",
"self",
".",
"_attr_name",
"=",
"f\"{location.title()} {name.title()}\"",
"self",
".",
"_attr_available",
"=",
"True",
"self",
"... | [
85,
4
] | [
90,
32
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchFunction.__init__ | (self, resource, location, name, func) | Initialize the switch. | Initialize the switch. | def __init__(self, resource, location, name, func):
"""Initialize the switch."""
super().__init__(resource, location, name)
self._func = func
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
if request.status_code != HTTP_OK:
_LOGGER.error("Can't... | [
"def",
"__init__",
"(",
"self",
",",
"resource",
",",
"location",
",",
"name",
",",
"func",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"resource",
",",
"location",
",",
"name",
")",
"self",
".",
"_func",
"=",
"func",
"request",
"=",
"requests... | [
96,
4
] | [
112,
45
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchFunction.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
request = requests.get(
f"{self._resource}/{self._func}", timeout=10, params={"params": "1"}
)
if request.status_code == HTTP_OK:
self._attr_is_on = True
else:
_LOGGER.error("Can't turn on... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/{self._func}\"",
",",
"timeout",
"=",
"10",
",",
"params",
"=",
"{",
"\"params\"",
":",
"\"1\"",
"}",
")",
"if",
"request"... | [
114,
4
] | [
123,
88
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchFunction.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
request = requests.get(
f"{self._resource}/{self._func}", timeout=10, params={"params": "0"}
)
if request.status_code == HTTP_OK:
self._attr_is_on = False
else:
_LOGGER.error(
... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/{self._func}\"",
",",
"timeout",
"=",
"10",
",",
"params",
"=",
"{",
"\"params\"",
":",
"\"0\"",
"}",
")",
"if",
"request... | [
125,
4
] | [
136,
13
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchFunction.update | (self) | Get the latest data from aREST API and update the state. | Get the latest data from aREST API and update the state. | def update(self):
"""Get the latest data from aREST API and update the state."""
try:
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
self._attr_is_on = request.json()["return_value"] != 0
self._attr_available = True
except requests.except... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/{self._func}\"",
",",
"timeout",
"=",
"10",
")",
"self",
".",
"_attr_is_on",
"=",
"request",
".",
"json",
"(",
")",
"[",
"\"return_value\"... | [
138,
4
] | [
146,
40
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchPin.__init__ | (self, resource, location, name, pin, invert) | Initialize the switch. | Initialize the switch. | def __init__(self, resource, location, name, pin, invert):
"""Initialize the switch."""
super().__init__(resource, location, name)
self._pin = pin
self.invert = invert
request = requests.get(f"{resource}/mode/{pin}/o", timeout=10)
if request.status_code != HTTP_OK:
... | [
"def",
"__init__",
"(",
"self",
",",
"resource",
",",
"location",
",",
"name",
",",
"pin",
",",
"invert",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"resource",
",",
"location",
",",
"name",
")",
"self",
".",
"_pin",
"=",
"pin",
"self",
"."... | [
152,
4
] | [
161,
40
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchPin.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
turn_on_payload = int(not self.invert)
request = requests.get(
f"{self._resource}/digital/{self._pin}/{turn_on_payload}", timeout=10
)
if request.status_code == HTTP_OK:
self._attr_is_on = True
... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"turn_on_payload",
"=",
"int",
"(",
"not",
"self",
".",
"invert",
")",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/digital/{self._pin}/{turn_on_payload}\"",
",",
"timeout",
... | [
163,
4
] | [
172,
82
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchPin.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
turn_off_payload = int(self.invert)
request = requests.get(
f"{self._resource}/digital/{self._pin}/{turn_off_payload}", timeout=10
)
if request.status_code == HTTP_OK:
self._attr_is_on = False
... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"turn_off_payload",
"=",
"int",
"(",
"self",
".",
"invert",
")",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/digital/{self._pin}/{turn_off_payload}\"",
",",
"timeout",
"=",
... | [
174,
4
] | [
183,
83
] | python | en | ['en', 'en', 'en'] | True |
ArestSwitchPin.update | (self) | Get the latest data from aREST API and update the state. | Get the latest data from aREST API and update the state. | def update(self):
"""Get the latest data from aREST API and update the state."""
try:
request = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10)
status_value = int(self.invert)
self._attr_is_on = request.json()["return_value"] != status_value
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"f\"{self._resource}/digital/{self._pin}\"",
",",
"timeout",
"=",
"10",
")",
"status_value",
"=",
"int",
"(",
"self",
".",
"invert",
")",
"self",
".",
"_attr_i... | [
185,
4
] | [
194,
40
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the FFmpeg binary motion sensor. | Set up the FFmpeg binary motion sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the FFmpeg binary motion sensor."""
manager = hass.data[DATA_FFMPEG]
entity = FFmpegMotion(hass, manager, config)
async_add_entities([entity]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"manager",
"=",
"hass",
".",
"data",
"[",
"DATA_FFMPEG",
"]",
"entity",
"=",
"FFmpegMotion",
"(",
"hass",
",",
"manag... | [
49,
0
] | [
53,
32
] | python | en | ['en', 'haw', 'en'] | True |
FFmpegBinarySensor.__init__ | (self, config) | Init for the binary sensor noise detection. | Init for the binary sensor noise detection. | def __init__(self, config):
"""Init for the binary sensor noise detection."""
super().__init__(config.get(CONF_INITIAL_STATE))
self._state = False
self._config = config
self._name = config.get(CONF_NAME) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
".",
"get",
"(",
"CONF_INITIAL_STATE",
")",
")",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_na... | [
59,
4
] | [
65,
42
] | python | en | ['en', 'en', 'en'] | True |
FFmpegBinarySensor._async_callback | (self, state) | HA-FFmpeg callback for noise detection. | HA-FFmpeg callback for noise detection. | def _async_callback(self, state):
"""HA-FFmpeg callback for noise detection."""
self._state = state
self.async_write_ha_state() | [
"def",
"_async_callback",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_state",
"=",
"state",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
68,
4
] | [
71,
35
] | python | en | ['nb', 'no', 'en'] | False |
FFmpegBinarySensor.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"
] | [
74,
4
] | [
76,
26
] | python | en | ['en', 'fy', 'en'] | True |
FFmpegBinarySensor.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
79,
4
] | [
81,
25
] | python | en | ['en', 'en', 'en'] | True |
FFmpegMotion.__init__ | (self, hass, manager, config) | Initialize FFmpeg motion binary sensor. | Initialize FFmpeg motion binary sensor. | def __init__(self, hass, manager, config):
"""Initialize FFmpeg motion binary sensor."""
super().__init__(config)
self.ffmpeg = ffmpeg_sensor.SensorMotion(manager.binary, self._async_callback) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"manager",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
")",
"self",
".",
"ffmpeg",
"=",
"ffmpeg_sensor",
".",
"SensorMotion",
"(",
"manager",
".",
"binary",
",",
"self",
... | [
87,
4
] | [
90,
86
] | python | en | ['en', 'ny', 'en'] | True |
FFmpegMotion._async_start_ffmpeg | (self, entity_ids) | Start a FFmpeg instance.
This method is a coroutine.
| Start a FFmpeg instance. | async def _async_start_ffmpeg(self, entity_ids):
"""Start a FFmpeg instance.
This method is a coroutine.
"""
if entity_ids is not None and self.entity_id not in entity_ids:
return
# init config
self.ffmpeg.set_options(
time_reset=self._config.get... | [
"async",
"def",
"_async_start_ffmpeg",
"(",
"self",
",",
"entity_ids",
")",
":",
"if",
"entity_ids",
"is",
"not",
"None",
"and",
"self",
".",
"entity_id",
"not",
"in",
"entity_ids",
":",
"return",
"# init config",
"self",
".",
"ffmpeg",
".",
"set_options",
"... | [
92,
4
] | [
112,
9
] | python | en | ['hu', 'lb', 'en'] | False |
FFmpegMotion.device_class | (self) | Return the class of this sensor, from DEVICE_CLASSES. | Return the class of this sensor, from DEVICE_CLASSES. | def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return DEVICE_CLASS_MOTION | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_MOTION"
] | [
115,
4
] | [
117,
34
] | python | en | ['en', 'en', 'en'] | True |
registered_flow | (hass) | Mock a registered flow. | Mock a registered flow. | def registered_flow(hass):
"""Mock a registered flow."""
local_auth.initialize(hass, "TEST-CLIENT-ID", "TEST-CLIENT-SECRET")
return hass.data[config_flow.DATA_FLOW_IMPL][const.DOMAIN] | [
"def",
"registered_flow",
"(",
"hass",
")",
":",
"local_auth",
".",
"initialize",
"(",
"hass",
",",
"\"TEST-CLIENT-ID\"",
",",
"\"TEST-CLIENT-SECRET\"",
")",
"return",
"hass",
".",
"data",
"[",
"config_flow",
".",
"DATA_FLOW_IMPL",
"]",
"[",
"const",
".",
"DOM... | [
11,
0
] | [
14,
62
] | python | en | ['en', 'da', 'en'] | True |
test_generate_auth_url | (registered_flow) | Test generating an auth url.
Mainly testing that it doesn't blow up.
| Test generating an auth url. | async def test_generate_auth_url(registered_flow):
"""Test generating an auth url.
Mainly testing that it doesn't blow up.
"""
url = await registered_flow["gen_authorize_url"]("TEST-FLOW-ID")
assert url is not None | [
"async",
"def",
"test_generate_auth_url",
"(",
"registered_flow",
")",
":",
"url",
"=",
"await",
"registered_flow",
"[",
"\"gen_authorize_url\"",
"]",
"(",
"\"TEST-FLOW-ID\"",
")",
"assert",
"url",
"is",
"not",
"None"
] | [
17,
0
] | [
23,
26
] | python | de | ['de', 'en', 'it'] | False |
test_convert_code | (requests_mock, registered_flow) | Test converting a code. | Test converting a code. | async def test_convert_code(requests_mock, registered_flow):
"""Test converting a code."""
from nest.nest import ACCESS_TOKEN_URL
def token_matcher(request):
"""Match a fetch token request."""
if request.url != ACCESS_TOKEN_URL:
return None
assert dict(parse_qsl(request... | [
"async",
"def",
"test_convert_code",
"(",
"requests_mock",
",",
"registered_flow",
")",
":",
"from",
"nest",
".",
"nest",
"import",
"ACCESS_TOKEN_URL",
"def",
"token_matcher",
"(",
"request",
")",
":",
"\"\"\"Match a fetch token request.\"\"\"",
"if",
"request",
".",
... | [
26,
0
] | [
49,
58
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_devices, discovery_info=None) | Set up the Environment Canada camera. | Set up the Environment Canada camera. | def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Environment Canada camera."""
if config.get(CONF_STATION):
radar_object = ECRadar(
station_id=config[CONF_STATION], precip_type=config.get(CONF_PRECIP_TYPE)
)
else:
lat = config.get(CONF_LA... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_devices",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"config",
".",
"get",
"(",
"CONF_STATION",
")",
":",
"radar_object",
"=",
"ECRadar",
"(",
"station_id",
"=",
"config",
"[",
"CONF_S... | [
39,
0
] | [
55,
5
] | python | en | ['en', 'fil', 'en'] | True |
ECCamera.__init__ | (self, radar_object, camera_name, is_loop) | Initialize the camera. | Initialize the camera. | def __init__(self, radar_object, camera_name, is_loop):
"""Initialize the camera."""
super().__init__()
self.radar_object = radar_object
self.camera_name = camera_name
self.is_loop = is_loop
self.content_type = "image/gif"
self.image = None
self.timestamp... | [
"def",
"__init__",
"(",
"self",
",",
"radar_object",
",",
"camera_name",
",",
"is_loop",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"radar_object",
"=",
"radar_object",
"self",
".",
"camera_name",
"=",
"camera_name",
"self",
".",
... | [
61,
4
] | [
70,
29
] | python | en | ['en', 'en', 'en'] | True |
ECCamera.camera_image | (
self, width: int | None = None, height: int | None = None
) | Return bytes of camera image. | Return bytes of camera image. | def camera_image(
self, width: int | None = None, height: int | None = None
) -> bytes | None:
"""Return bytes of camera image."""
self.update()
return self.image | [
"def",
"camera_image",
"(",
"self",
",",
"width",
":",
"int",
"|",
"None",
"=",
"None",
",",
"height",
":",
"int",
"|",
"None",
"=",
"None",
")",
"->",
"bytes",
"|",
"None",
":",
"self",
".",
"update",
"(",
")",
"return",
"self",
".",
"image"
] | [
72,
4
] | [
77,
25
] | python | en | ['en', 'zu', 'en'] | True |
ECCamera.name | (self) | Return the name of the camera. | Return the name of the camera. | def name(self):
"""Return the name of the camera."""
if self.camera_name is not None:
return self.camera_name
return "Environment Canada Radar" | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"camera_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"camera_name",
"return",
"\"Environment Canada Radar\""
] | [
80,
4
] | [
84,
41
] | python | en | ['en', 'en', 'en'] | True |
ECCamera.extra_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def extra_state_attributes(self):
"""Return the state attributes of the device."""
return {ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_UPDATED: self.timestamp} | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"CONF_ATTRIBUTION",
",",
"ATTR_UPDATED",
":",
"self",
".",
"timestamp",
"}"
] | [
87,
4
] | [
89,
81
] | python | en | ['en', 'en', 'en'] | True |
ECCamera.update | (self) | Update radar image. | Update radar image. | def update(self):
"""Update radar image."""
if self.is_loop:
self.image = self.radar_object.get_loop()
else:
self.image = self.radar_object.get_latest_frame()
self.timestamp = self.radar_object.timestamp | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_loop",
":",
"self",
".",
"image",
"=",
"self",
".",
"radar_object",
".",
"get_loop",
"(",
")",
"else",
":",
"self",
".",
"image",
"=",
"self",
".",
"radar_object",
".",
"get_latest_frame",
... | [
92,
4
] | [
98,
52
] | python | en | ['es', 'id', 'en'] | False |
mock_successful_connection | (*args, **kwargs) | Return a successful connection. | Return a successful connection. | async def mock_successful_connection(*args, **kwargs):
"""Return a successful connection."""
return True | [
"async",
"def",
"mock_successful_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"True"
] | [
46,
0
] | [
48,
15
] | python | en | ['en', 'en', 'en'] | True |
mock_failed_connection | (*args, **kwargs) | Return a failed connection. | Return a failed connection. | async def mock_failed_connection(*args, **kwargs):
"""Return a failed connection."""
raise ConnectionError("Connection failed") | [
"async",
"def",
"mock_failed_connection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"ConnectionError",
"(",
"\"Connection failed\"",
")"
] | [
51,
0
] | [
53,
46
] | python | en | ['en', 'ga', 'en'] | True |
test_setup_entry | (hass: HomeAssistant) | Test setting up the entry. | Test setting up the entry. | async def test_setup_entry(hass: HomeAssistant):
"""Test setting up the entry."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "asyn... | [
"async",
"def",
"test_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_USER_INPUT_PLM",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",
"... | [
56,
0
] | [
76,
32
] | python | en | ['en', 'en', 'en'] | True |
test_import_plm | (hass: HomeAssistant) | Test setting up the entry from YAML to a PLM. | Test setting up the entry from YAML to a PLM. | async def test_import_plm(hass: HomeAssistant):
"""Test setting up the entry from YAML to a PLM."""
config = {}
config[DOMAIN] = MOCK_IMPORT_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"), patch.obj... | [
"async",
"def",
"test_import_plm",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",
"=",
... | [
79,
0
] | [
101,
32
] | python | en | ['en', 'en', 'en'] | True |
test_import_hub1 | (hass: HomeAssistant) | Test setting up the entry from YAML to a hub v1. | Test setting up the entry from YAML to a hub v1. | async def test_import_hub1(hass: HomeAssistant):
"""Test setting up the entry from YAML to a hub v1."""
config = {}
config[DOMAIN] = MOCK_IMPORT_MINIMUM_HUB_V1
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"), p... | [
"async",
"def",
"test_import_hub1",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_MINIMUM_HUB_V1",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",
"... | [
104,
0
] | [
128,
36
] | python | en | ['en', 'en', 'en'] | True |
test_import_hub2 | (hass: HomeAssistant) | Test setting up the entry from YAML to a hub v2. | Test setting up the entry from YAML to a hub v2. | async def test_import_hub2(hass: HomeAssistant):
"""Test setting up the entry from YAML to a hub v2."""
config = {}
config[DOMAIN] = MOCK_IMPORT_MINIMUM_HUB_V2
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_connection"), p... | [
"async",
"def",
"test_import_hub2",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_MINIMUM_HUB_V2",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",
"... | [
131,
0
] | [
155,
75
] | python | en | ['en', 'en', 'en'] | True |
test_import_options | (hass: HomeAssistant) | Test setting up the entry from YAML including options. | Test setting up the entry from YAML including options. | async def test_import_options(hass: HomeAssistant):
"""Test setting up the entry from YAML including options."""
config = {}
config[DOMAIN] = MOCK_IMPORT_FULL_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_successful_connection
), patch.object(insteon, "close_insteon_conne... | [
"async",
"def",
"test_import_options",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_FULL_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"new",... | [
158,
0
] | [
188,
75
] | python | en | ['en', 'en', 'en'] | True |
test_import_failed_connection | (hass: HomeAssistant) | Test a failed connection in import does not create a config entry. | Test a failed connection in import does not create a config entry. | async def test_import_failed_connection(hass: HomeAssistant):
"""Test a failed connection in import does not create a config entry."""
config = {}
config[DOMAIN] = MOCK_IMPORT_CONFIG_PLM
with patch.object(
insteon, "async_connect", new=mock_failed_connection
), patch.object(insteon, "async_... | [
"async",
"def",
"test_import_failed_connection",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config",
"=",
"{",
"}",
"config",
"[",
"DOMAIN",
"]",
"=",
"MOCK_IMPORT_CONFIG_PLM",
"with",
"patch",
".",
"object",
"(",
"insteon",
",",
"\"async_connect\"",
",",
"... | [
191,
0
] | [
207,
60
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_failed_connection | (hass: HomeAssistant, caplog) | Test setting up the entry with a failed connection. | Test setting up the entry with a failed connection. | async def test_setup_entry_failed_connection(hass: HomeAssistant, caplog):
"""Test setting up the entry with a failed connection."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
with patch.object(
insteon, "async_connect", new=mock_faile... | [
"async",
"def",
"test_setup_entry_failed_connection",
"(",
"hass",
":",
"HomeAssistant",
",",
"caplog",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"MOCK_USER_INPUT_PLM",
")",
"config_entry",
".",
"add_to_hass",
... | [
210,
0
] | [
223,
66
] | python | en | ['en', 'en', 'en'] | True |
TestEnumTest.testEnumTest | (self) | Test EnumTest | Test EnumTest | def testEnumTest(self):
"""Test EnumTest"""
# FIXME: construct object with mandatory attributes with example values
# model = petstore_api.models.enum_test.EnumTest() # noqa: E501
pass | [
"def",
"testEnumTest",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = petstore_api.models.enum_test.EnumTest() # noqa: E501",
"pass"
] | [
30,
4
] | [
34,
12
] | python | da | ['en', 'da', 'ur'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the ELIQ Online sensor. | Set up the ELIQ Online sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the ELIQ Online sensor."""
access_token = config.get(CONF_ACCESS_TOKEN)
name = config.get(CONF_NAME, DEFAULT_NAME)
channel_id = config.get(CONF_CHANNEL_ID)
session = async_get_clientsession(hass)
ap... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"access_token",
"=",
"config",
".",
"get",
"(",
"CONF_ACCESS_TOKEN",
")",
"name",
"=",
"config",
".",
"get",
"(",
"CO... | [
38,
0
] | [
54,
65
] | python | en | ['en', 'ca', 'en'] | True |
EliqSensor.__init__ | (self, api, channel_id, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api, channel_id, name):
"""Initialize the sensor."""
self._name = name
self._state = None
self._api = api
self._channel_id = channel_id | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"channel_id",
",",
"name",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_channel_id",
"=",
"channel_id"
] | [
62,
4
] | [
67,
37
] | python | en | ['en', 'en', 'en'] | True |
EliqSensor.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"
] | [
70,
4
] | [
72,
25
] | python | en | ['en', 'mi', 'en'] | True |
EliqSensor.icon | (self) | Return icon. | Return icon. | def icon(self):
"""Return icon."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
75,
4
] | [
77,
19
] | python | en | ['en', 'la', 'en'] | False |
EliqSensor.native_unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def native_unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return UNIT_OF_MEASUREMENT | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"return",
"UNIT_OF_MEASUREMENT"
] | [
80,
4
] | [
82,
34
] | python | en | ['en', 'en', 'en'] | True |
EliqSensor.native_value | (self) | Return the state of the device. | Return the state of the device. | def native_value(self):
"""Return the state of the device."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
85,
4
] | [
87,
26
] | python | en | ['en', 'en', 'en'] | True |
EliqSensor.async_update | (self) | Get the latest data. | Get the latest data. | async def async_update(self):
"""Get the latest data."""
try:
response = await self._api.get_data_now(channelid=self._channel_id)
self._state = int(response["power"])
_LOGGER.debug("Updated power from server %d W", self._state)
except KeyError:
_LO... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"response",
"=",
"await",
"self",
".",
"_api",
".",
"get_data_now",
"(",
"channelid",
"=",
"self",
".",
"_channel_id",
")",
"self",
".",
"_state",
"=",
"int",
"(",
"response",
"[",
"\"p... | [
89,
4
] | [
98,
82
] | python | en | ['en', 'en', 'en'] | True |
async_set_away_mode | (hass, away_mode, entity_id=ENTITY_MATCH_ALL) | Turn all or specified water_heater devices away mode on. | Turn all or specified water_heater devices away mode on. | async def async_set_away_mode(hass, away_mode, entity_id=ENTITY_MATCH_ALL):
"""Turn all or specified water_heater devices away mode on."""
data = {ATTR_AWAY_MODE: away_mode}
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(DOMAIN, SERVICE_SET_AWAY_MODE, data, block... | [
"async",
"def",
"async_set_away_mode",
"(",
"hass",
",",
"away_mode",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"ATTR_AWAY_MODE",
":",
"away_mode",
"}",
"if",
"entity_id",
":",
"data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
... | [
17,
0
] | [
24,
86
] | python | en | ['en', 'en', 'en'] | True |
async_set_temperature | (
hass, temperature=None, entity_id=ENTITY_MATCH_ALL, operation_mode=None
) | Set new target temperature. | Set new target temperature. | async def async_set_temperature(
hass, temperature=None, entity_id=ENTITY_MATCH_ALL, operation_mode=None
):
"""Set new target temperature."""
kwargs = {
key: value
for key, value in [
(ATTR_TEMPERATURE, temperature),
(ATTR_ENTITY_ID, entity_id),
(ATTR_OPER... | [
"async",
"def",
"async_set_temperature",
"(",
"hass",
",",
"temperature",
"=",
"None",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
",",
"operation_mode",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"[",
... | [
27,
0
] | [
43,
5
] | python | en | ['en', 'ca', 'en'] | True |
async_set_operation_mode | (hass, operation_mode, entity_id=ENTITY_MATCH_ALL) | Set new target operation mode. | Set new target operation mode. | async def async_set_operation_mode(hass, operation_mode, entity_id=ENTITY_MATCH_ALL):
"""Set new target operation mode."""
data = {ATTR_OPERATION_MODE: operation_mode}
if entity_id is not None:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(
DOMAIN, SERVICE_SET_OPERATI... | [
"async",
"def",
"async_set_operation_mode",
"(",
"hass",
",",
"operation_mode",
",",
"entity_id",
"=",
"ENTITY_MATCH_ALL",
")",
":",
"data",
"=",
"{",
"ATTR_OPERATION_MODE",
":",
"operation_mode",
"}",
"if",
"entity_id",
"is",
"not",
"None",
":",
"data",
"[",
... | [
46,
0
] | [
55,
5
] | python | en | ['nl', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.