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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
VenstarThermostat.set_hvac_mode | (self, hvac_mode) | Set new target operation mode. | Set new target operation mode. | def set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
self._set_operation_mode(hvac_mode) | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"self",
".",
"_set_operation_mode",
"(",
"hvac_mode",
")"
] | [
324,
4
] | [
326,
43
] | python | en | ['nl', 'en', 'en'] | True |
VenstarThermostat.set_humidity | (self, humidity) | Set new target humidity. | Set new target humidity. | def set_humidity(self, humidity):
"""Set new target humidity."""
success = self._client.set_hum_setpoint(humidity)
if not success:
_LOGGER.error("Failed to change the target humidity level") | [
"def",
"set_humidity",
"(",
"self",
",",
"humidity",
")",
":",
"success",
"=",
"self",
".",
"_client",
".",
"set_hum_setpoint",
"(",
"humidity",
")",
"if",
"not",
"success",
":",
"_LOGGER",
".",
"error",
"(",
"\"Failed to change the target humidity level\"",
")"... | [
328,
4
] | [
333,
71
] | python | en | ['en', 'en', 'en'] | True |
VenstarThermostat.set_preset_mode | (self, preset_mode) | Set the hold mode. | Set the hold mode. | def set_preset_mode(self, preset_mode):
"""Set the hold mode."""
if preset_mode == PRESET_AWAY:
success = self._client.set_away(self._client.AWAY_AWAY)
elif preset_mode == HOLD_MODE_TEMPERATURE:
success = self._client.set_away(self._client.AWAY_HOME)
success =... | [
"def",
"set_preset_mode",
"(",
"self",
",",
"preset_mode",
")",
":",
"if",
"preset_mode",
"==",
"PRESET_AWAY",
":",
"success",
"=",
"self",
".",
"_client",
".",
"set_away",
"(",
"self",
".",
"_client",
".",
"AWAY_AWAY",
")",
"elif",
"preset_mode",
"==",
"H... | [
335,
4
] | [
350,
69
] | python | en | ['en', 'en', 'en'] | True |
load_dsc_snow_output_annual | (catchment, output_dem, hydro_year_to_take, dsc_snow_output_folder, dsc_snow_dem_folder, run_opt,origin='bottomleft') |
load output from dsc_snow model previously run from linux VM
:param catchment: string giving catchment area to run model on
:param output_dem: string identifying the grid to run model on
:param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001
... |
load output from dsc_snow model previously run from linux VM
:param catchment: string giving catchment area to run model on
:param output_dem: string identifying the grid to run model on
:param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001
... | def load_dsc_snow_output_annual(catchment, output_dem, hydro_year_to_take, dsc_snow_output_folder, dsc_snow_dem_folder, run_opt,origin='bottomleft'):
"""
load output from dsc_snow model previously run from linux VM
:param catchment: string giving catchment area to run model on
:param output_dem: string ... | [
"def",
"load_dsc_snow_output_annual",
"(",
"catchment",
",",
"output_dem",
",",
"hydro_year_to_take",
",",
"dsc_snow_output_folder",
",",
"dsc_snow_dem_folder",
",",
"run_opt",
",",
"origin",
"=",
"'bottomleft'",
")",
":",
"data_id",
"=",
"'{}_{}'",
".",
"format",
"... | [
20,
0
] | [
60,
66
] | python | en | ['en', 'error', 'th'] | False |
load_subset_modis_annual | (catchment, output_dem, year_to_take, modis_folder, dem_folder, modis_dem, mask_folder, catchment_shp_folder) |
load modis data from file and cut to catchment of interest
:param catchment: string giving catchment area to run model on
:param output_dem: string identifying the grid to run model on
:param year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001
:ret... |
load modis data from file and cut to catchment of interest
:param catchment: string giving catchment area to run model on
:param output_dem: string identifying the grid to run model on
:param year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001
:ret... | def load_subset_modis_annual(catchment, output_dem, year_to_take, modis_folder, dem_folder, modis_dem, mask_folder, catchment_shp_folder):
"""
load modis data from file and cut to catchment of interest
:param catchment: string giving catchment area to run model on
:param output_dem: string identifying t... | [
"def",
"load_subset_modis_annual",
"(",
"catchment",
",",
"output_dem",
",",
"year_to_take",
",",
"modis_folder",
",",
"dem_folder",
",",
"modis_dem",
",",
"mask_folder",
",",
"catchment_shp_folder",
")",
":",
"# load a file",
"nc_file",
"=",
"nc",
".",
"Dataset",
... | [
63,
0
] | [
94,
47
] | python | en | ['en', 'error', 'th'] | False |
CustomerTuner.generate_parameters | (self, parameter_id, **kwargs) | Returns a set of trial graph config, as a serializable object.
parameter_id : int
| Returns a set of trial graph config, as a serializable object.
parameter_id : int
| def generate_parameters(self, parameter_id, **kwargs):
"""Returns a set of trial graph config, as a serializable object.
parameter_id : int
"""
if len(self.population) <= 0:
logger.debug("the len of poplution lower than zero.")
raise Exception('The population is e... | [
"def",
"generate_parameters",
"(",
"self",
",",
"parameter_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"self",
".",
"population",
")",
"<=",
"0",
":",
"logger",
".",
"debug",
"(",
"\"the len of poplution lower than zero.\"",
")",
"raise",
"Exce... | [
81,
4
] | [
108,
19
] | python | en | ['en', 'en', 'en'] | True |
CustomerTuner.receive_trial_result | (self, parameter_id, parameters, value, **kwargs) |
Record an observation of the objective function
parameter_id : int
parameters : dict of parameters
value: final metrics of the trial, including reward
|
Record an observation of the objective function
parameter_id : int
parameters : dict of parameters
value: final metrics of the trial, including reward
| def receive_trial_result(self, parameter_id, parameters, value, **kwargs):
'''
Record an observation of the objective function
parameter_id : int
parameters : dict of parameters
value: final metrics of the trial, including reward
'''
reward = extract_scalar_reward... | [
"def",
"receive_trial_result",
"(",
"self",
",",
"parameter_id",
",",
"parameters",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"reward",
"=",
"extract_scalar_reward",
"(",
"value",
")",
"if",
"self",
".",
"optimize_mode",
"is",
"OptimizeMode",
".",
"Mi... | [
111,
4
] | [
128,
14
] | python | en | ['en', 'error', 'th'] | False |
test_setup | (hass) | Test the general setup of the integration. | Test the general setup of the integration. | async def test_setup(hass):
"""Test the general setup of the integration."""
# Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry(
"1234",
"Title 1",
15.5,
(38.0, -3.0),
locality="Locality 1",
attribution="Attribution 1",
... | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"# Set up some mock feed entries for this test.",
"mock_entry_1",
"=",
"_generate_mock_feed_entry",
"(",
"\"1234\"",
",",
"\"Title 1\"",
",",
"15.5",
",",
"(",
"38.0",
",",
"-",
"3.0",
")",
",",
"locality",
"=",... | [
38,
0
] | [
157,
49
] | python | en | ['en', 'en', 'en'] | True |
test_setup_imperial | (hass) | Test the setup of the integration using imperial unit system. | Test the setup of the integration using imperial unit system. | async def test_setup_imperial(hass):
"""Test the setup of the integration using imperial unit system."""
hass.config.units = IMPERIAL_SYSTEM
# Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 15.5, (38.0, -3.0))
# Patching 'utcnow' to gain mor... | [
"async",
"def",
"test_setup_imperial",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"units",
"=",
"IMPERIAL_SYSTEM",
"# Set up some mock feed entries for this test.",
"mock_entry_1",
"=",
"_generate_mock_feed_entry",
"(",
"\"1234\"",
",",
"\"Title 1\"",
",",
"15.5... | [
160,
0
] | [
204,
40
] | python | en | ['en', 'en', 'en'] | True |
register_oauth2_implementations | (
hass: HomeAssistant, client_id: str, client_secret: str
) | Register Toon OAuth2 implementations. | Register Toon OAuth2 implementations. | def register_oauth2_implementations(
hass: HomeAssistant, client_id: str, client_secret: str
) -> None:
"""Register Toon OAuth2 implementations."""
config_flow.ToonFlowHandler.async_register_implementation(
hass,
ToonLocalOAuth2Implementation(
hass,
client_id=client_i... | [
"def",
"register_oauth2_implementations",
"(",
"hass",
":",
"HomeAssistant",
",",
"client_id",
":",
"str",
",",
"client_secret",
":",
"str",
")",
"->",
"None",
":",
"config_flow",
".",
"ToonFlowHandler",
".",
"async_register_implementation",
"(",
"hass",
",",
"Too... | [
10,
0
] | [
44,
5
] | python | en | ['en', 'en', 'en'] | True |
ToonLocalOAuth2Implementation.__init__ | (
self,
hass: HomeAssistant,
client_id: str,
client_secret: str,
name: str,
tenant_id: str,
issuer: Optional[str] = None,
) | Local Toon Oauth Implementation. | Local Toon Oauth Implementation. | def __init__(
self,
hass: HomeAssistant,
client_id: str,
client_secret: str,
name: str,
tenant_id: str,
issuer: Optional[str] = None,
):
"""Local Toon Oauth Implementation."""
self._name = name
self.tenant_id = tenant_id
self.is... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"client_id",
":",
"str",
",",
"client_secret",
":",
"str",
",",
"name",
":",
"str",
",",
"tenant_id",
":",
"str",
",",
"issuer",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",... | [
50,
4
] | [
71,
9
] | python | en | ['en', 'en', 'en'] | True |
ToonLocalOAuth2Implementation.name | (self) | Name of the implementation. | Name of the implementation. | def name(self) -> str:
"""Name of the implementation."""
return f"{self._name} via Configuration.yaml" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._name} via Configuration.yaml\""
] | [
74,
4
] | [
76,
53
] | python | en | ['en', 'en', 'en'] | True |
ToonLocalOAuth2Implementation.extra_authorize_data | (self) | Extra data that needs to be appended to the authorize url. | Extra data that needs to be appended to the authorize url. | def extra_authorize_data(self) -> dict:
"""Extra data that needs to be appended to the authorize url."""
data = {"tenant_id": self.tenant_id}
if self.issuer is not None:
data["issuer"] = self.issuer
return data | [
"def",
"extra_authorize_data",
"(",
"self",
")",
"->",
"dict",
":",
"data",
"=",
"{",
"\"tenant_id\"",
":",
"self",
".",
"tenant_id",
"}",
"if",
"self",
".",
"issuer",
"is",
"not",
"None",
":",
"data",
"[",
"\"issuer\"",
"]",
"=",
"self",
".",
"issuer"... | [
79,
4
] | [
86,
19
] | python | en | ['en', 'en', 'en'] | True |
ToonLocalOAuth2Implementation.async_resolve_external_data | (self, external_data: Any) | Initialize local Toon auth implementation. | Initialize local Toon auth implementation. | async def async_resolve_external_data(self, external_data: Any) -> dict:
"""Initialize local Toon auth implementation."""
data = {
"grant_type": "authorization_code",
"code": external_data,
"redirect_uri": self.redirect_uri,
"tenant_id": self.tenant_id,
... | [
"async",
"def",
"async_resolve_external_data",
"(",
"self",
",",
"external_data",
":",
"Any",
")",
"->",
"dict",
":",
"data",
"=",
"{",
"\"grant_type\"",
":",
"\"authorization_code\"",
",",
"\"code\"",
":",
"external_data",
",",
"\"redirect_uri\"",
":",
"self",
... | [
88,
4
] | [
100,
46
] | python | en | ['en', 'en', 'en'] | True |
ToonLocalOAuth2Implementation._async_refresh_token | (self, token: dict) | Refresh tokens. | Refresh tokens. | async def _async_refresh_token(self, token: dict) -> dict:
"""Refresh tokens."""
data = {
"grant_type": "refresh_token",
"client_id": self.client_id,
"refresh_token": token["refresh_token"],
"tenant_id": self.tenant_id,
}
new_token = await... | [
"async",
"def",
"_async_refresh_token",
"(",
"self",
",",
"token",
":",
"dict",
")",
"->",
"dict",
":",
"data",
"=",
"{",
"\"grant_type\"",
":",
"\"refresh_token\"",
",",
"\"client_id\"",
":",
"self",
".",
"client_id",
",",
"\"refresh_token\"",
":",
"token",
... | [
102,
4
] | [
112,
37
] | python | en | ['en', 'en', 'en'] | False |
ToonLocalOAuth2Implementation._token_request | (self, data: dict) | Make a token request. | Make a token request. | async def _token_request(self, data: dict) -> dict:
"""Make a token request."""
session = async_get_clientsession(self.hass)
headers = {}
data["client_id"] = self.client_id
data["tenant_id"] = self.tenant_id
if self.client_secret is not None:
data["client_se... | [
"async",
"def",
"_token_request",
"(",
"self",
",",
"data",
":",
"dict",
")",
"->",
"dict",
":",
"session",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"headers",
"=",
"{",
"}",
"data",
"[",
"\"client_id\"",
"]",
"=",
"self",
".",
"c... | [
114,
4
] | [
135,
24
] | python | en | ['en', 'de', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up Sensibo devices. | Set up Sensibo devices. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up Sensibo devices."""
client = pysensibo.SensiboClient(
config[CONF_API_KEY], session=async_get_clientsession(hass), timeout=TIMEOUT
)
devices = []
try:
for dev in await client.async_get_de... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"client",
"=",
"pysensibo",
".",
"SensiboClient",
"(",
"config",
"[",
"CONF_API_KEY",
"]",
",",
"session",
"=",
"async_... | [
86,
0
] | [
134,
5
] | python | en | ['eo', 'ht', 'en'] | False |
SensiboClimate.__init__ | (self, client, data, units) | Build SensiboClimate.
client: aiohttp session.
data: initially-fetched data.
| Build SensiboClimate. | def __init__(self, client, data, units):
"""Build SensiboClimate.
client: aiohttp session.
data: initially-fetched data.
"""
self._client = client
self._id = data["id"]
self._external_state = None
self._units = units
self._available = False
... | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"data",
",",
"units",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_id",
"=",
"data",
"[",
"\"id\"",
"]",
"self",
".",
"_external_state",
"=",
"None",
"self",
".",
"_units",
"=",
... | [
140,
4
] | [
151,
29
] | python | en | ['en', 'ro', 'it'] | False |
SensiboClimate.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_features"
] | [
154,
4
] | [
156,
39
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.state | (self) | Return the current state. | Return the current state. | def state(self):
"""Return the current state."""
return self._external_state or super().state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_external_state",
"or",
"super",
"(",
")",
".",
"state"
] | [
188,
4
] | [
190,
52
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {"battery": self.current_battery} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"battery\"",
":",
"self",
".",
"current_battery",
"}"
] | [
193,
4
] | [
195,
48
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.temperature_unit | (self) | Return the unit of measurement which this thermostat uses. | Return the unit of measurement which this thermostat uses. | def temperature_unit(self):
"""Return the unit of measurement which this thermostat uses."""
return self._temperature_unit | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"self",
".",
"_temperature_unit"
] | [
198,
4
] | [
200,
37
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
203,
4
] | [
205,
30
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return self._ac_states.get("targetTemperature") | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ac_states",
".",
"get",
"(",
"\"targetTemperature\"",
")"
] | [
208,
4
] | [
210,
55
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.target_temperature_step | (self) | Return the supported step of target temperature. | Return the supported step of target temperature. | def target_temperature_step(self):
"""Return the supported step of target temperature."""
if self.temperature_unit == self.hass.config.units.temperature_unit:
# We are working in same units as the a/c unit. Use whole degrees
# like the API supports.
return 1
#... | [
"def",
"target_temperature_step",
"(",
"self",
")",
":",
"if",
"self",
".",
"temperature_unit",
"==",
"self",
".",
"hass",
".",
"config",
".",
"units",
".",
"temperature_unit",
":",
"# We are working in same units as the a/c unit. Use whole degrees",
"# like the API suppo... | [
213,
4
] | [
220,
19
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.hvac_mode | (self) | Return current operation ie. heat, cool, idle. | Return current operation ie. heat, cool, idle. | def hvac_mode(self):
"""Return current operation ie. heat, cool, idle."""
if not self._ac_states["on"]:
return HVAC_MODE_OFF
return SENSIBO_TO_HA.get(self._ac_states["mode"]) | [
"def",
"hvac_mode",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_ac_states",
"[",
"\"on\"",
"]",
":",
"return",
"HVAC_MODE_OFF",
"return",
"SENSIBO_TO_HA",
".",
"get",
"(",
"self",
".",
"_ac_states",
"[",
"\"mode\"",
"]",
")"
] | [
223,
4
] | [
227,
57
] | python | en | ['nl', 'en', 'en'] | True |
SensiboClimate.current_humidity | (self) | Return the current humidity. | Return the current humidity. | def current_humidity(self):
"""Return the current humidity."""
return self._measurements["humidity"] | [
"def",
"current_humidity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_measurements",
"[",
"\"humidity\"",
"]"
] | [
230,
4
] | [
232,
45
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.current_battery | (self) | Return the current battery voltage. | Return the current battery voltage. | def current_battery(self):
"""Return the current battery voltage."""
return self._measurements.get("batteryVoltage") | [
"def",
"current_battery",
"(",
"self",
")",
":",
"return",
"self",
".",
"_measurements",
".",
"get",
"(",
"\"batteryVoltage\"",
")"
] | [
235,
4
] | [
237,
55
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self):
"""Return the current temperature."""
# This field is not affected by temperatureUnit.
# It is always in C
return convert_temperature(
self._measurements["temperature"], TEMP_CELSIUS, self.temperature_unit
) | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"# This field is not affected by temperatureUnit.",
"# It is always in C",
"return",
"convert_temperature",
"(",
"self",
".",
"_measurements",
"[",
"\"temperature\"",
"]",
",",
"TEMP_CELSIUS",
",",
"self",
".",
"tempera... | [
240,
4
] | [
246,
9
] | python | en | ['en', 'la', 'en'] | True |
SensiboClimate.hvac_modes | (self) | List of available operation modes. | List of available operation modes. | def hvac_modes(self):
"""List of available operation modes."""
return self._operations | [
"def",
"hvac_modes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_operations"
] | [
249,
4
] | [
251,
31
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.fan_mode | (self) | Return the fan setting. | Return the fan setting. | def fan_mode(self):
"""Return the fan setting."""
return self._ac_states.get("fanLevel") | [
"def",
"fan_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ac_states",
".",
"get",
"(",
"\"fanLevel\"",
")"
] | [
254,
4
] | [
256,
46
] | python | en | ['en', 'fy', 'en'] | True |
SensiboClimate.fan_modes | (self) | List of available fan modes. | List of available fan modes. | def fan_modes(self):
"""List of available fan modes."""
return self._current_capabilities.get("fanLevels") | [
"def",
"fan_modes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_capabilities",
".",
"get",
"(",
"\"fanLevels\"",
")"
] | [
259,
4
] | [
261,
58
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.swing_mode | (self) | Return the fan setting. | Return the fan setting. | def swing_mode(self):
"""Return the fan setting."""
return self._ac_states.get("swing") | [
"def",
"swing_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ac_states",
".",
"get",
"(",
"\"swing\"",
")"
] | [
264,
4
] | [
266,
43
] | python | en | ['en', 'fy', 'en'] | True |
SensiboClimate.swing_modes | (self) | List of available swing modes. | List of available swing modes. | def swing_modes(self):
"""List of available swing modes."""
return self._current_capabilities.get("swing") | [
"def",
"swing_modes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_capabilities",
".",
"get",
"(",
"\"swing\"",
")"
] | [
269,
4
] | [
271,
54
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.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"
] | [
274,
4
] | [
276,
25
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self):
"""Return the minimum temperature."""
return (
self._temperatures_list[0] if self._temperatures_list else super().min_temp
) | [
"def",
"min_temp",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_temperatures_list",
"[",
"0",
"]",
"if",
"self",
".",
"_temperatures_list",
"else",
"super",
"(",
")",
".",
"min_temp",
")"
] | [
279,
4
] | [
283,
9
] | python | en | ['en', 'la', 'en'] | True |
SensiboClimate.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self):
"""Return the maximum temperature."""
return (
self._temperatures_list[-1] if self._temperatures_list else super().max_temp
) | [
"def",
"max_temp",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_temperatures_list",
"[",
"-",
"1",
"]",
"if",
"self",
".",
"_temperatures_list",
"else",
"super",
"(",
")",
".",
"max_temp",
")"
] | [
286,
4
] | [
290,
9
] | python | en | ['en', 'la', 'en'] | True |
SensiboClimate.unique_id | (self) | Return unique ID based on Sensibo ID. | Return unique ID based on Sensibo ID. | def unique_id(self):
"""Return unique ID based on Sensibo ID."""
return self._id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_id"
] | [
293,
4
] | [
295,
23
] | python | en | ['en', 'et', 'en'] | True |
SensiboClimate.async_set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
temperature = int(temperature)
if temperature not in self._temperatures_list:
# Requested temperatu... | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"temperature",
"=",
"int",
"(",
"temperature",
... | [
297,
4
] | [
321,
13
] | python | en | ['en', 'ca', 'en'] | True |
SensiboClimate.async_set_fan_mode | (self, fan_mode) | Set new target fan mode. | Set new target fan mode. | async def async_set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, "fanLevel", fan_mode, self._ac_states
) | [
"async",
"def",
"async_set_fan_mode",
"(",
"self",
",",
"fan_mode",
")",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"await",
"self",
".",
"_client",
".",
"async_set_ac_state_property",
"(",
"self",
".",
"_id",
",",
"\"fanLevel\"",
... | [
323,
4
] | [
328,
13
] | python | en | ['sv', 'fy', 'en'] | False |
SensiboClimate.async_set_hvac_mode | (self, hvac_mode) | Set new target operation mode. | Set new target operation mode. | async def async_set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
if hvac_mode == HVAC_MODE_OFF:
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, "on", False, self._ac_states
... | [
"async",
"def",
"async_set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"if",
"hvac_mode",
"==",
"HVAC_MODE_OFF",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"await",
"self",
".",
"_client",
".",
"async_set_ac_state_property",... | [
330,
4
] | [
349,
13
] | python | en | ['nl', 'en', 'en'] | True |
SensiboClimate.async_set_swing_mode | (self, swing_mode) | Set new target swing operation. | Set new target swing operation. | async def async_set_swing_mode(self, swing_mode):
"""Set new target swing operation."""
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, "swing", swing_mode, self._ac_states
) | [
"async",
"def",
"async_set_swing_mode",
"(",
"self",
",",
"swing_mode",
")",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"await",
"self",
".",
"_client",
".",
"async_set_ac_state_property",
"(",
"self",
".",
"_id",
",",
"\"swing\"",... | [
351,
4
] | [
356,
13
] | python | en | ['en', 'en', 'en'] | True |
SensiboClimate.async_turn_on | (self) | Turn Sensibo unit on. | Turn Sensibo unit on. | async def async_turn_on(self):
"""Turn Sensibo unit on."""
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, "on", True, self._ac_states
) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"await",
"self",
".",
"_client",
".",
"async_set_ac_state_property",
"(",
"self",
".",
"_id",
",",
"\"on\"",
",",
"True",
",",
"self"... | [
358,
4
] | [
363,
13
] | python | en | ['es', 'sq', 'en'] | False |
SensiboClimate.async_turn_off | (self) | Turn Sensibo unit on. | Turn Sensibo unit on. | async def async_turn_off(self):
"""Turn Sensibo unit on."""
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, "on", False, self._ac_states
) | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"await",
"self",
".",
"_client",
".",
"async_set_ac_state_property",
"(",
"self",
".",
"_id",
",",
"\"on\"",
",",
"False",
",",
"sel... | [
365,
4
] | [
370,
13
] | python | en | ['es', 'sq', 'en'] | False |
SensiboClimate.async_assume_state | (self, state) | Set external state. | Set external state. | async def async_assume_state(self, state):
"""Set external state."""
change_needed = (state != HVAC_MODE_OFF and not self._ac_states["on"]) or (
state == HVAC_MODE_OFF and self._ac_states["on"]
)
if change_needed:
with async_timeout.timeout(TIMEOUT):
... | [
"async",
"def",
"async_assume_state",
"(",
"self",
",",
"state",
")",
":",
"change_needed",
"=",
"(",
"state",
"!=",
"HVAC_MODE_OFF",
"and",
"not",
"self",
".",
"_ac_states",
"[",
"\"on\"",
"]",
")",
"or",
"(",
"state",
"==",
"HVAC_MODE_OFF",
"and",
"self"... | [
372,
4
] | [
391,
40
] | python | da | ['da', 'lb', 'en'] | False |
SensiboClimate.async_update | (self) | Retrieve latest state. | Retrieve latest state. | async def async_update(self):
"""Retrieve latest state."""
try:
with async_timeout.timeout(TIMEOUT):
data = await self._client.async_get_device(self._id, _FETCH_FIELDS)
self._do_update(data)
except (aiohttp.client_exceptions.ClientError, pysensibo.Sens... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"TIMEOUT",
")",
":",
"data",
"=",
"await",
"self",
".",
"_client",
".",
"async_get_device",
"(",
"self",
".",
"_id",
",",
"_FETCH_FIELDS",
")... | [
393,
4
] | [
401,
35
] | python | en | ['es', 'sk', 'en'] | False |
SensorManager.__init__ | (self, bridge) | Initialize the sensor manager. | Initialize the sensor manager. | def __init__(self, bridge):
"""Initialize the sensor manager."""
self.bridge = bridge
self._component_add_entities = {}
self.current = {}
self.current_events = {}
self._enabled_platforms = ("binary_sensor", "sensor")
self.coordinator = DataUpdateCoordinator(
... | [
"def",
"__init__",
"(",
"self",
",",
"bridge",
")",
":",
"self",
".",
"bridge",
"=",
"bridge",
"self",
".",
"_component_add_entities",
"=",
"{",
"}",
"self",
".",
"current",
"=",
"{",
"}",
"self",
".",
"current_events",
"=",
"{",
"}",
"self",
".",
"_... | [
37,
4
] | [
54,
9
] | python | en | ['en', 'en', 'en'] | True |
SensorManager.async_update_data | (self) | Update sensor data. | Update sensor data. | async def async_update_data(self):
"""Update sensor data."""
try:
with async_timeout.timeout(4):
return await self.bridge.async_request_call(
self.bridge.api.sensors.update
)
except Unauthorized as err:
await self.bridge... | [
"async",
"def",
"async_update_data",
"(",
"self",
")",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"4",
")",
":",
"return",
"await",
"self",
".",
"bridge",
".",
"async_request_call",
"(",
"self",
".",
"bridge",
".",
"api",
".",
"sensor... | [
56,
4
] | [
67,
60
] | python | en | ['ro', 'no', 'en'] | False |
SensorManager.async_register_component | (self, platform, async_add_entities) | Register async_add_entities methods for components. | Register async_add_entities methods for components. | async def async_register_component(self, platform, async_add_entities):
"""Register async_add_entities methods for components."""
self._component_add_entities[platform] = async_add_entities
if len(self._component_add_entities) < len(self._enabled_platforms):
_LOGGER.debug("Aborting ... | [
"async",
"def",
"async_register_component",
"(",
"self",
",",
"platform",
",",
"async_add_entities",
")",
":",
"self",
".",
"_component_add_entities",
"[",
"platform",
"]",
"=",
"async_add_entities",
"if",
"len",
"(",
"self",
".",
"_component_add_entities",
")",
"... | [
69,
4
] | [
81,
46
] | python | en | ['da', 'en', 'en'] | True |
SensorManager.async_update_items | (self) | Update sensors from the bridge. | Update sensors from the bridge. | def async_update_items(self):
"""Update sensors from the bridge."""
api = self.bridge.api.sensors
if len(self._component_add_entities) < len(self._enabled_platforms):
return
to_add = {}
primary_sensor_devices = {}
current = self.current
# Physical H... | [
"def",
"async_update_items",
"(",
"self",
")",
":",
"api",
"=",
"self",
".",
"bridge",
".",
"api",
".",
"sensors",
"if",
"len",
"(",
"self",
".",
"_component_add_entities",
")",
"<",
"len",
"(",
"self",
".",
"_enabled_platforms",
")",
":",
"return",
"to_... | [
84,
4
] | [
159,
68
] | python | en | ['en', 'sn', 'en'] | True |
GenericHueSensor.available | (self) | Return if sensor is available. | Return if sensor is available. | def available(self):
"""Return if sensor is available."""
return self.bridge.sensor_manager.coordinator.last_update_success and (
self.bridge.allow_unreachable
# remotes like Hue Tap (ZGPSwitchSensor) have no _reachability_
or self.sensor.config.get("reachable", True)... | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"bridge",
".",
"sensor_manager",
".",
"coordinator",
".",
"last_update_success",
"and",
"(",
"self",
".",
"bridge",
".",
"allow_unreachable",
"# remotes like Hue Tap (ZGPSwitchSensor) have no _reachabilit... | [
171,
4
] | [
177,
9
] | python | en | ['en', 'en', 'en'] | True |
GenericHueSensor.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self):
"""When entity is added to hass."""
self.async_on_remove(
self.bridge.sensor_manager.coordinator.async_add_listener(
self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"bridge",
".",
"sensor_manager",
".",
"coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
179,
4
] | [
185,
9
] | python | en | ['en', 'en', 'en'] | True |
GenericHueSensor.async_update | (self) | Update the entity.
Only used by the generic entity update service.
| Update the entity. | async def async_update(self):
"""Update the entity.
Only used by the generic entity update service.
"""
await self.bridge.sensor_manager.coordinator.async_request_refresh() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"bridge",
".",
"sensor_manager",
".",
"coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
187,
4
] | [
192,
76
] | python | en | ['en', 'en', 'en'] | True |
GenericZLLSensor.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
return {"battery_level": self.sensor.battery} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"battery_level\"",
":",
"self",
".",
"sensor",
".",
"battery",
"}"
] | [
199,
4
] | [
201,
53
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Wink platform. | Set up the Wink platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Wink platform."""
for switch in pywink.get_switches():
_id = switch.object_id() + switch.name()
if _id not in hass.data[DOMAIN]["unique_ids"]:
add_entities([WinkToggleDevice(switch, hass)])
for sw... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"for",
"switch",
"in",
"pywink",
".",
"get_switches",
"(",
")",
":",
"_id",
"=",
"switch",
".",
"object_id",
"(",
")",
"+",
"switch",
... | [
8,
0
] | [
26,
58
] | python | en | ['en', 'da', 'en'] | True |
WinkToggleDevice.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
self.hass.data[DOMAIN]["entities"]["switch"].append(self) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"entities\"",
"]",
"[",
"\"switch\"",
"]",
".",
"append",
"(",
"self",
")"
] | [
32,
4
] | [
34,
65
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self.wink.state() | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"wink",
".",
"state",
"(",
")"
] | [
37,
4
] | [
39,
32
] | python | en | ['en', 'fy', 'en'] | True |
WinkToggleDevice.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
self.wink.set_state(True) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"wink",
".",
"set_state",
"(",
"True",
")"
] | [
41,
4
] | [
43,
33
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
self.wink.set_state(False) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"wink",
".",
"set_state",
"(",
"False",
")"
] | [
45,
4
] | [
47,
34
] | python | en | ['en', 'en', 'en'] | True |
WinkToggleDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attributes = super().device_state_attributes
try:
event = self.wink.last_event()
if event is not None:
attributes["last_event"] = event
except AttributeError:
pass
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"try",
":",
"event",
"=",
"self",
".",
"wink",
".",
"last_event",
"(",
")",
"if",
"event",
"is",
"not",
"None",
":",
"attributes"... | [
50,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
community_post | () | Topic JSON with a codeblock marked as auto syntax. | Topic JSON with a codeblock marked as auto syntax. | def community_post():
"""Topic JSON with a codeblock marked as auto syntax."""
return load_fixture("blueprint/community_post.json") | [
"def",
"community_post",
"(",
")",
":",
"return",
"load_fixture",
"(",
"\"blueprint/community_post.json\"",
")"
] | [
13,
0
] | [
15,
56
] | python | en | ['en', 'en', 'en'] | True |
test_get_community_post_import_url | () | Test variations of generating import forum url. | Test variations of generating import forum url. | def test_get_community_post_import_url():
"""Test variations of generating import forum url."""
assert (
importer._get_community_post_import_url(
"https://community.home-assistant.io/t/test-topic/123"
)
== "https://community.home-assistant.io/t/test-topic/123.json"
)
... | [
"def",
"test_get_community_post_import_url",
"(",
")",
":",
"assert",
"(",
"importer",
".",
"_get_community_post_import_url",
"(",
"\"https://community.home-assistant.io/t/test-topic/123\"",
")",
"==",
"\"https://community.home-assistant.io/t/test-topic/123.json\"",
")",
"assert",
... | [
18,
0
] | [
32,
5
] | python | en | ['en', 'la', 'en'] | True |
test_get_github_import_url | () | Test getting github import url. | Test getting github import url. | def test_get_github_import_url():
"""Test getting github import url."""
assert (
importer._get_github_import_url(
"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml"
)
== "https://raw.githubusercontent.com/balloob/home-assistan... | [
"def",
"test_get_github_import_url",
"(",
")",
":",
"assert",
"(",
"importer",
".",
"_get_github_import_url",
"(",
"\"https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\"",
")",
"==",
"\"https://raw.githubusercontent.com/balloob/home-assist... | [
35,
0
] | [
49,
5
] | python | en | ['nl', 'en', 'en'] | True |
test_extract_blueprint_from_community_topic | (community_post) | Test extracting blueprint. | Test extracting blueprint. | def test_extract_blueprint_from_community_topic(community_post):
"""Test extracting blueprint."""
imported_blueprint = importer._extract_blueprint_from_community_topic(
"http://example.com", json.loads(community_post)
)
assert imported_blueprint is not None
assert imported_blueprint.url == "... | [
"def",
"test_extract_blueprint_from_community_topic",
"(",
"community_post",
")",
":",
"imported_blueprint",
"=",
"importer",
".",
"_extract_blueprint_from_community_topic",
"(",
"\"http://example.com\"",
",",
"json",
".",
"loads",
"(",
"community_post",
")",
")",
"assert",... | [
52,
0
] | [
63,
5
] | python | en | ['fr', 'sr', 'en'] | False |
test_extract_blueprint_from_community_topic_invalid_yaml | () | Test extracting blueprint with invalid YAML. | Test extracting blueprint with invalid YAML. | def test_extract_blueprint_from_community_topic_invalid_yaml():
"""Test extracting blueprint with invalid YAML."""
with pytest.raises(HomeAssistantError):
importer._extract_blueprint_from_community_topic(
"http://example.com",
{
"post_stream": {
... | [
"def",
"test_extract_blueprint_from_community_topic_invalid_yaml",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"HomeAssistantError",
")",
":",
"importer",
".",
"_extract_blueprint_from_community_topic",
"(",
"\"http://example.com\"",
",",
"{",
"\"post_stream\"",
":... | [
66,
0
] | [
78,
9
] | python | en | ['en', 'en', 'en'] | True |
test__extract_blueprint_from_community_topic_wrong_lang | () | Test extracting blueprint with invalid YAML. | Test extracting blueprint with invalid YAML. | def test__extract_blueprint_from_community_topic_wrong_lang():
"""Test extracting blueprint with invalid YAML."""
assert (
importer._extract_blueprint_from_community_topic(
"http://example.com",
{
"post_stream": {
"posts": [
... | [
"def",
"test__extract_blueprint_from_community_topic_wrong_lang",
"(",
")",
":",
"assert",
"(",
"importer",
".",
"_extract_blueprint_from_community_topic",
"(",
"\"http://example.com\"",
",",
"{",
"\"post_stream\"",
":",
"{",
"\"posts\"",
":",
"[",
"{",
"\"cooked\"",
":",... | [
81,
0
] | [
95,
5
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_blueprint_from_community_url | (hass, aioclient_mock, community_post) | Test fetching blueprint from url. | Test fetching blueprint from url. | async def test_fetch_blueprint_from_community_url(hass, aioclient_mock, community_post):
"""Test fetching blueprint from url."""
aioclient_mock.get(
"https://community.home-assistant.io/t/test-topic/123.json", text=community_post
)
imported_blueprint = await importer.fetch_blueprint_from_url(
... | [
"async",
"def",
"test_fetch_blueprint_from_community_url",
"(",
"hass",
",",
"aioclient_mock",
",",
"community_post",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"https://community.home-assistant.io/t/test-topic/123.json\"",
",",
"text",
"=",
"community_post",
")",
"impo... | [
98,
0
] | [
111,
5
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_blueprint_from_github_url | (hass, aioclient_mock, url) | Test fetching blueprint from url. | Test fetching blueprint from url. | async def test_fetch_blueprint_from_github_url(hass, aioclient_mock, url):
"""Test fetching blueprint from url."""
aioclient_mock.get(
"https://raw.githubusercontent.com/balloob/home-assistant-config/main/blueprints/automation/motion_light.yaml",
text=Path(
hass.config.path("blueprin... | [
"async",
"def",
"test_fetch_blueprint_from_github_url",
"(",
"hass",
",",
"aioclient_mock",
",",
"url",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"https://raw.githubusercontent.com/balloob/home-assistant-config/main/blueprints/automation/motion_light.yaml\"",
",",
"text",
"=... | [
121,
0
] | [
136,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up the mobile app component. | Set up the mobile app component. | async def async_setup(hass: HomeAssistantType, config: ConfigType):
"""Set up the mobile app component."""
store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
app_config = await store.async_load()
if app_config is None:
app_config = {
DATA_BINARY_SENSOR: {},
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
":",
"store",
"=",
"hass",
".",
"helpers",
".",
"storage",
".",
"Store",
"(",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
")",
"app_config",
"=",
"await",... | [
36,
0
] | [
71,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a mobile_app entry. | Set up a mobile_app entry. | async def async_setup_entry(hass, entry):
"""Set up a mobile_app entry."""
registration = entry.data
webhook_id = registration[CONF_WEBHOOK_ID]
hass.data[DOMAIN][DATA_CONFIG_ENTRIES][webhook_id] = entry
device_registry = await dr.async_get_registry(hass)
device = device_registry.async_get_or... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"registration",
"=",
"entry",
".",
"data",
"webhook_id",
"=",
"registration",
"[",
"CONF_WEBHOOK_ID",
"]",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CONFIG_ENTRIES",
"]",
"["... | [
74,
0
] | [
105,
15
] | python | en | ['en', 'da', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a mobile app entry. | Unload a mobile app entry. | async def async_unload_entry(hass, entry):
"""Unload a mobile app entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
if not unload_ok... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"component",
")",
... | [
108,
0
] | [
127,
15
] | python | en | ['en', 'fr', 'en'] | True |
async_remove_entry | (hass, entry) | Cleanup when entry is removed. | Cleanup when entry is removed. | async def async_remove_entry(hass, entry):
"""Cleanup when entry is removed."""
hass.data[DOMAIN][DATA_DELETED_IDS].append(entry.data[CONF_WEBHOOK_ID])
store = hass.data[DOMAIN][DATA_STORE]
await store.async_save(savable_state(hass))
if CONF_CLOUDHOOK_URL in entry.data:
try:
awa... | [
"async",
"def",
"async_remove_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_DELETED_IDS",
"]",
".",
"append",
"(",
"entry",
".",
"data",
"[",
"CONF_WEBHOOK_ID",
"]",
")",
"store",
"=",
"hass",
".",
"da... | [
130,
0
] | [
140,
16
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Neurio sensor. | Set up the Neurio sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Neurio sensor."""
api_key = config.get(CONF_API_KEY)
api_secret = config.get(CONF_API_SECRET)
sensor_id = config.get(CONF_SENSOR_ID)
data = NeurioData(api_key, api_secret, sensor_id)
@Throttle(MIN_TIME_BETWEEN_D... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"api_key",
"=",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"api_secret",
"=",
"config",
".",
"get",
"(",
"CONF_API_SECRET",
")",
"s... | [
40,
0
] | [
64,
76
] | python | en | ['en', 'pt', 'en'] | True |
NeurioData.__init__ | (self, api_key, api_secret, sensor_id) | Initialize the data. | Initialize the data. | def __init__(self, api_key, api_secret, sensor_id):
"""Initialize the data."""
self.api_key = api_key
self.api_secret = api_secret
self.sensor_id = sensor_id
self._daily_usage = None
self._active_power = None
self._state = None
neurio_tp = neurio.TokenP... | [
"def",
"__init__",
"(",
"self",
",",
"api_key",
",",
"api_secret",
",",
"sensor_id",
")",
":",
"self",
".",
"api_key",
"=",
"api_key",
"self",
".",
"api_secret",
"=",
"api_secret",
"self",
".",
"sensor_id",
"=",
"sensor_id",
"self",
".",
"_daily_usage",
"=... | [
70,
4
] | [
82,
68
] | python | en | ['en', 'en', 'en'] | True |
NeurioData.daily_usage | (self) | Return latest daily usage value. | Return latest daily usage value. | def daily_usage(self):
"""Return latest daily usage value."""
return self._daily_usage | [
"def",
"daily_usage",
"(",
"self",
")",
":",
"return",
"self",
".",
"_daily_usage"
] | [
85,
4
] | [
87,
32
] | python | en | ['en', 'en', 'en'] | True |
NeurioData.active_power | (self) | Return latest active power value. | Return latest active power value. | def active_power(self):
"""Return latest active power value."""
return self._active_power | [
"def",
"active_power",
"(",
"self",
")",
":",
"return",
"self",
".",
"_active_power"
] | [
90,
4
] | [
92,
33
] | python | en | ['en', 'en', 'en'] | True |
NeurioData.get_active_power | (self) | Return current power value. | Return current power value. | def get_active_power(self):
"""Return current power value."""
try:
sample = self.neurio_client.get_samples_live_last(self.sensor_id)
self._active_power = sample["consumptionPower"]
except (requests.exceptions.RequestException, ValueError, KeyError):
_LOGGER.wa... | [
"def",
"get_active_power",
"(",
"self",
")",
":",
"try",
":",
"sample",
"=",
"self",
".",
"neurio_client",
".",
"get_samples_live_last",
"(",
"self",
".",
"sensor_id",
")",
"self",
".",
"_active_power",
"=",
"sample",
"[",
"\"consumptionPower\"",
"]",
"except"... | [
94,
4
] | [
101,
23
] | python | en | ['en', 'la', 'en'] | True |
NeurioData.get_daily_usage | (self) | Return current daily power usage. | Return current daily power usage. | def get_daily_usage(self):
"""Return current daily power usage."""
kwh = 0
start_time = dt_util.start_of_local_day().astimezone(dt_util.UTC).isoformat()
end_time = dt_util.utcnow().isoformat()
_LOGGER.debug("Start: %s, End: %s", start_time, end_time)
try:
hi... | [
"def",
"get_daily_usage",
"(",
"self",
")",
":",
"kwh",
"=",
"0",
"start_time",
"=",
"dt_util",
".",
"start_of_local_day",
"(",
")",
".",
"astimezone",
"(",
"dt_util",
".",
"UTC",
")",
".",
"isoformat",
"(",
")",
"end_time",
"=",
"dt_util",
".",
"utcnow"... | [
103,
4
] | [
122,
41
] | python | en | ['en', 'en', 'en'] | True |
NeurioEnergy.__init__ | (self, data, name, sensor_type, update_call) | Initialize the sensor. | Initialize the sensor. | def __init__(self, data, name, sensor_type, update_call):
"""Initialize the sensor."""
self._name = name
self._data = data
self._sensor_type = sensor_type
self.update_sensor = update_call
self._state = None
if sensor_type == ACTIVE_TYPE:
self._unit_of... | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"name",
",",
"sensor_type",
",",
"update_call",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_sensor_type",
"=",
"sensor_type",
"self",
".",
"update_sensor... | [
128,
4
] | [
139,
61
] | python | en | ['en', 'en', 'en'] | True |
NeurioEnergy.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"
] | [
142,
4
] | [
144,
25
] | python | en | ['en', 'mi', 'en'] | True |
NeurioEnergy.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
147,
4
] | [
149,
26
] | python | en | ['en', 'en', 'en'] | True |
NeurioEnergy.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 unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
152,
4
] | [
154,
40
] | python | en | ['en', 'en', 'en'] | True |
NeurioEnergy.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
157,
4
] | [
159,
19
] | python | en | ['en', 'en', 'en'] | True |
NeurioEnergy.update | (self) | Get the latest data, update state. | Get the latest data, update state. | def update(self):
"""Get the latest data, update state."""
self.update_sensor()
if self._sensor_type == ACTIVE_TYPE:
self._state = self._data.active_power
elif self._sensor_type == DAILY_TYPE:
self._state = self._data.daily_usage | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"update_sensor",
"(",
")",
"if",
"self",
".",
"_sensor_type",
"==",
"ACTIVE_TYPE",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_data",
".",
"active_power",
"elif",
"self",
".",
"_sensor_type",
"==",... | [
161,
4
] | [
168,
48
] | python | en | ['en', 'en', 'en'] | True |
test_service_setup | (hass) | Verify service setup works. | Verify service setup works. | async def test_service_setup(hass):
"""Verify service setup works."""
assert DECONZ_SERVICES not in hass.data
with patch(
"homeassistant.core.ServiceRegistry.async_register", return_value=Mock(True)
) as async_register:
await async_setup_services(hass)
assert hass.data[DECONZ_SER... | [
"async",
"def",
"test_service_setup",
"(",
"hass",
")",
":",
"assert",
"DECONZ_SERVICES",
"not",
"in",
"hass",
".",
"data",
"with",
"patch",
"(",
"\"homeassistant.core.ServiceRegistry.async_register\"",
",",
"return_value",
"=",
"Mock",
"(",
"True",
")",
")",
"as"... | [
75,
0
] | [
83,
45
] | python | en | ['en', 'cs', 'en'] | True |
test_service_setup_already_registered | (hass) | Make sure that services are only registered once. | Make sure that services are only registered once. | async def test_service_setup_already_registered(hass):
"""Make sure that services are only registered once."""
hass.data[DECONZ_SERVICES] = True
with patch(
"homeassistant.core.ServiceRegistry.async_register", return_value=Mock(True)
) as async_register:
await async_setup_services(hass)
... | [
"async",
"def",
"test_service_setup_already_registered",
"(",
"hass",
")",
":",
"hass",
".",
"data",
"[",
"DECONZ_SERVICES",
"]",
"=",
"True",
"with",
"patch",
"(",
"\"homeassistant.core.ServiceRegistry.async_register\"",
",",
"return_value",
"=",
"Mock",
"(",
"True",... | [
86,
0
] | [
93,
42
] | python | en | ['en', 'en', 'en'] | True |
test_service_unload | (hass) | Verify service unload works. | Verify service unload works. | async def test_service_unload(hass):
"""Verify service unload works."""
hass.data[DECONZ_SERVICES] = True
with patch(
"homeassistant.core.ServiceRegistry.async_remove", return_value=Mock(True)
) as async_remove:
await async_unload_services(hass)
assert hass.data[DECONZ_SERVICES] ... | [
"async",
"def",
"test_service_unload",
"(",
"hass",
")",
":",
"hass",
".",
"data",
"[",
"DECONZ_SERVICES",
"]",
"=",
"True",
"with",
"patch",
"(",
"\"homeassistant.core.ServiceRegistry.async_remove\"",
",",
"return_value",
"=",
"Mock",
"(",
"True",
")",
")",
"as... | [
96,
0
] | [
104,
43
] | python | en | ['en', 'fr', 'en'] | True |
test_service_unload_not_registered | (hass) | Make sure that services can only be unloaded once. | Make sure that services can only be unloaded once. | async def test_service_unload_not_registered(hass):
"""Make sure that services can only be unloaded once."""
with patch(
"homeassistant.core.ServiceRegistry.async_remove", return_value=Mock(True)
) as async_remove:
await async_unload_services(hass)
assert DECONZ_SERVICES not in hass.... | [
"async",
"def",
"test_service_unload_not_registered",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.core.ServiceRegistry.async_remove\"",
",",
"return_value",
"=",
"Mock",
"(",
"True",
")",
")",
"as",
"async_remove",
":",
"await",
"async_unload_services"... | [
107,
0
] | [
114,
40
] | python | en | ['en', 'en', 'en'] | True |
test_configure_service_with_field | (hass) | Test that service invokes pydeconz with the correct path and data. | Test that service invokes pydeconz with the correct path and data. | async def test_configure_service_with_field(hass):
"""Test that service invokes pydeconz with the correct path and data."""
await setup_deconz_integration(hass)
data = {
SERVICE_FIELD: "/light/2",
CONF_BRIDGE_ID: BRIDGEID,
SERVICE_DATA: {"on": True, "attr1": 10, "attr2": 20},
}
... | [
"async",
"def",
"test_configure_service_with_field",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"data",
"=",
"{",
"SERVICE_FIELD",
":",
"\"/light/2\"",
",",
"CONF_BRIDGE_ID",
":",
"BRIDGEID",
",",
"SERVICE_DATA",
":",
"{",
"\"on\... | [
117,
0
] | [
134,
9
] | python | en | ['en', 'en', 'en'] | True |
test_configure_service_with_entity | (hass) | Test that service invokes pydeconz with the correct path and data. | Test that service invokes pydeconz with the correct path and data. | async def test_configure_service_with_entity(hass):
"""Test that service invokes pydeconz with the correct path and data."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
gateway.deconz_ids["light.test"] = "/light/1"
data = {
... | [
"async",
"def",
"test_configure_service_with_entity",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"gateway",
".",
"deconz_ids... | [
137,
0
] | [
155,
9
] | python | en | ['en', 'en', 'en'] | True |
test_configure_service_with_entity_and_field | (hass) | Test that service invokes pydeconz with the correct path and data. | Test that service invokes pydeconz with the correct path and data. | async def test_configure_service_with_entity_and_field(hass):
"""Test that service invokes pydeconz with the correct path and data."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
gateway.deconz_ids["light.test"] = "/light/1"
data =... | [
"async",
"def",
"test_configure_service_with_entity_and_field",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"gateway",
".",
"... | [
158,
0
] | [
177,
9
] | python | en | ['en', 'en', 'en'] | True |
test_configure_service_with_faulty_field | (hass) | Test that service invokes pydeconz with the correct path and data. | Test that service invokes pydeconz with the correct path and data. | async def test_configure_service_with_faulty_field(hass):
"""Test that service invokes pydeconz with the correct path and data."""
await setup_deconz_integration(hass)
data = {SERVICE_FIELD: "light/2", SERVICE_DATA: {}}
with pytest.raises(vol.Invalid):
await hass.services.async_call(
... | [
"async",
"def",
"test_configure_service_with_faulty_field",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"data",
"=",
"{",
"SERVICE_FIELD",
":",
"\"light/2\"",
",",
"SERVICE_DATA",
":",
"{",
"}",
"}",
"with",
"pytest",
".",
"rais... | [
180,
0
] | [
190,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configure_service_with_faulty_entity | (hass) | Test that service invokes pydeconz with the correct path and data. | Test that service invokes pydeconz with the correct path and data. | async def test_configure_service_with_faulty_entity(hass):
"""Test that service invokes pydeconz with the correct path and data."""
await setup_deconz_integration(hass)
data = {
SERVICE_ENTITY: "light.nonexisting",
SERVICE_DATA: {},
}
with patch("pydeconz.DeconzSession.request", re... | [
"async",
"def",
"test_configure_service_with_faulty_entity",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"data",
"=",
"{",
"SERVICE_ENTITY",
":",
"\"light.nonexisting\"",
",",
"SERVICE_DATA",
":",
"{",
"}",
",",
"}",
"with",
"patc... | [
193,
0
] | [
207,
37
] | python | en | ['en', 'en', 'en'] | True |
test_service_refresh_devices | (hass) | Test that service can refresh devices. | Test that service can refresh devices. | async def test_service_refresh_devices(hass):
"""Test that service can refresh devices."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
data = {CONF_BRIDGE_ID: BRIDGEID}
with patch(
"pydeconz.DeconzSession.request",
... | [
"async",
"def",
"test_service_refresh_devices",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"data",
"=",
"{",
"CONF_BRIDGE_... | [
210,
0
] | [
231,
5
] | python | en | ['en', 'en', 'en'] | True |
test_remove_orphaned_entries_service | (hass) | Test service works and also don't remove more than expected. | Test service works and also don't remove more than expected. | async def test_remove_orphaned_entries_service(hass):
"""Test service works and also don't remove more than expected."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["lights"] = deepcopy(LIGHT)
data["sensors"] = deepcopy(SWITCH)
config_entry = await setup_deconz_integration(hass, get_state_response=data... | [
"async",
"def",
"test_remove_orphaned_entries_service",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"lights\"",
"]",
"=",
"deepcopy",
"(",
"LIGHT",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"deepcopy",
"(",
... | [
234,
0
] | [
295,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Fritz!Box call monitor sensor platform. | Set up Fritz!Box call monitor sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Fritz!Box call monitor sensor platform."""
name = config[CONF_NAME]
host = config[CONF_HOST]
# Try to resolve a hostname; if it is already an IP, it will be returned as-is
try:
host = socket.gethostbyname(host)
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"# Try to resolve a hostname; if it is already an IP... | [
60,
0
] | [
101,
35
] | python | en | ['en', 'fil', 'en'] | True |
FritzBoxCallSensor.__init__ | (self, name, phonebook) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, phonebook):
"""Initialize the sensor."""
self._state = VALUE_DEFAULT
self._attributes = {}
self._name = name
self.phonebook = phonebook | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"phonebook",
")",
":",
"self",
".",
"_state",
"=",
"VALUE_DEFAULT",
"self",
".",
"_attributes",
"=",
"{",
"}",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"phonebook",
"=",
"phonebook"
] | [
107,
4
] | [
112,
34
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxCallSensor.set_state | (self, state) | Set the state. | Set the state. | def set_state(self, state):
"""Set the state."""
self._state = state | [
"def",
"set_state",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_state",
"=",
"state"
] | [
114,
4
] | [
116,
27
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxCallSensor.set_attributes | (self, attributes) | Set the state attributes. | Set the state attributes. | def set_attributes(self, attributes):
"""Set the state attributes."""
self._attributes = attributes | [
"def",
"set_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"self",
".",
"_attributes",
"=",
"attributes"
] | [
118,
4
] | [
120,
37
] | python | en | ['en', 'en', 'en'] | True |
FritzBoxCallSensor.should_poll | (self) | Only poll to update phonebook, if defined. | Only poll to update phonebook, if defined. | def should_poll(self):
"""Only poll to update phonebook, if defined."""
return self.phonebook is not None | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"self",
".",
"phonebook",
"is",
"not",
"None"
] | [
123,
4
] | [
125,
41
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.