Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_connection_failure_on_startup | (
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
) | Test the event listener when it fails to connect to Influx on startup. | Test the event listener when it fails to connect to Influx on startup. | async def test_connection_failure_on_startup(
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
):
"""Test the event listener when it fails to connect to Influx on startup."""
write_api = get_write_api(mock_client)
write_api.side_effect = test_exception
config = {"i... | [
"async",
"def",
"test_connection_failure_on_startup",
"(",
"hass",
",",
"caplog",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"test_exception",
")",
":",
"write_api",
"=",
"get_write_api",
"(",
"mock_client",
")",
"write_a... | [
1481,
0
] | [
1498,
43
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_inputs_error | (
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
) |
Test the event listener when influx returns invalid inputs on write.
The difference in error handling in this case is that we do not sleep
and try again, if an input is invalid it is logged and dropped.
Note that this shouldn't actually occur, if its possible for the current
code to send an inval... |
Test the event listener when influx returns invalid inputs on write. | async def test_invalid_inputs_error(
hass, caplog, mock_client, config_ext, get_write_api, get_mock_call, test_exception
):
"""
Test the event listener when influx returns invalid inputs on write.
The difference in error handling in this case is that we do not sleep
and try again, if an input is in... | [
"async",
"def",
"test_invalid_inputs_error",
"(",
"hass",
",",
"caplog",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"test_exception",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
... | [
1521,
0
] | [
1557,
33
] | python | en | ['en', 'error', 'th'] | False |
test_precision | (
hass, mock_client, config_ext, get_write_api, get_mock_call, precision
) | Test the precision setup. | Test the precision setup. | async def test_precision(
hass, mock_client, config_ext, get_write_api, get_mock_call, precision
):
"""Test the precision setup."""
config = {
"precision": precision,
}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get_write_api)
value = "1.9"
... | [
"async",
"def",
"test_precision",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
",",
"precision",
")",
":",
"config",
"=",
"{",
"\"precision\"",
":",
"precision",
",",
"}",
"config",
".",
"update",
"(",
"conf... | [
1622,
0
] | [
1658,
26
] | python | en | ['en', 'pt', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the HP iLO sensors. | Set up the HP iLO sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the HP iLO sensors."""
hostname = config.get(CONF_HOST)
port = config.get(CONF_PORT)
login = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
monitored_variables = config.get(CONF_MONITORED_VARIABLES)
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"hostname",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"login",
"=",
... | [
70,
0
] | [
99,
31
] | python | en | ['en', 'sq', 'en'] | True |
HpIloSensor.__init__ | (
self,
hass,
hp_ilo_data,
sensor_type,
sensor_name,
sensor_value_template,
unit_of_measurement,
) | Initialize the HP iLO sensor. | Initialize the HP iLO sensor. | def __init__(
self,
hass,
hp_ilo_data,
sensor_type,
sensor_name,
sensor_value_template,
unit_of_measurement,
):
"""Initialize the HP iLO sensor."""
self._hass = hass
self._name = sensor_name
self._unit_of_measurement = unit_of_m... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"hp_ilo_data",
",",
"sensor_type",
",",
"sensor_name",
",",
"sensor_value_template",
",",
"unit_of_measurement",
",",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_name",
"=",
"sensor_name",
"se... | [
105,
4
] | [
128,
55
] | python | en | ['en', 'ro', 'en'] | True |
HpIloSensor.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"
] | [
131,
4
] | [
133,
25
] | python | en | ['en', 'mi', 'en'] | True |
HpIloSensor.unit_of_measurement | (self) | Return the unit of measurement of the sensor. | Return the unit of measurement of the sensor. | def unit_of_measurement(self):
"""Return the unit of measurement of the sensor."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
136,
4
] | [
138,
40
] | python | en | ['en', 'bg', 'en'] | True |
HpIloSensor.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"
] | [
141,
4
] | [
143,
26
] | python | en | ['en', 'en', 'en'] | True |
HpIloSensor.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 self._state_attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state_attributes"
] | [
146,
4
] | [
148,
37
] | python | en | ['en', 'en', 'en'] | True |
HpIloSensor.update | (self) | Get the latest data from HP iLO and updates the states. | Get the latest data from HP iLO and updates the states. | def update(self):
"""Get the latest data from HP iLO and updates the states."""
# Call the API for new data. Each sensor will re-trigger this
# same exact call, but that's fine. Results should be cached for
# a short period of time to prevent hitting API limits.
self.hp_ilo_data.... | [
"def",
"update",
"(",
"self",
")",
":",
"# Call the API for new data. Each sensor will re-trigger this",
"# same exact call, but that's fine. Results should be cached for",
"# a short period of time to prevent hitting API limits.",
"self",
".",
"hp_ilo_data",
".",
"update",
"(",
")",
... | [
150,
4
] | [
163,
30
] | python | en | ['en', 'en', 'en'] | True |
HpIloData.__init__ | (self, host, port, login, password) | Initialize the data object. | Initialize the data object. | def __init__(self, host, port, login, password):
"""Initialize the data object."""
self._host = host
self._port = port
self._login = login
self._password = password
self.data = None
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"port",
",",
"login",
",",
"password",
")",
":",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"_login",
"=",
"login",
"self",
".",
"_password",
"=",
"password",
... | [
169,
4
] | [
178,
21
] | python | en | ['en', 'en', 'en'] | True |
HpIloData.update | (self) | Get the latest data from HP iLO. | Get the latest data from HP iLO. | def update(self):
"""Get the latest data from HP iLO."""
try:
self.data = hpilo.Ilo(
hostname=self._host,
login=self._login,
password=self._password,
port=self._port,
)
except (
hpilo.IloError,
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"data",
"=",
"hpilo",
".",
"Ilo",
"(",
"hostname",
"=",
"self",
".",
"_host",
",",
"login",
"=",
"self",
".",
"_login",
",",
"password",
"=",
"self",
".",
"_password",
",",
"port",
... | [
181,
4
] | [
195,
74
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Twilio SMS notification service. | Get the Twilio SMS notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Twilio SMS notification service."""
return TwilioSMSNotificationService(
hass.data[DATA_TWILIO], config[CONF_FROM_NUMBER]
) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"TwilioSMSNotificationService",
"(",
"hass",
".",
"data",
"[",
"DATA_TWILIO",
"]",
",",
"config",
"[",
"CONF_FROM_NUMBER",
"]",
")"
] | [
34,
0
] | [
38,
5
] | python | en | ['en', 'en', 'en'] | True |
TwilioSMSNotificationService.__init__ | (self, twilio_client, from_number) | Initialize the service. | Initialize the service. | def __init__(self, twilio_client, from_number):
"""Initialize the service."""
self.client = twilio_client
self.from_number = from_number | [
"def",
"__init__",
"(",
"self",
",",
"twilio_client",
",",
"from_number",
")",
":",
"self",
".",
"client",
"=",
"twilio_client",
"self",
".",
"from_number",
"=",
"from_number"
] | [
44,
4
] | [
47,
38
] | python | en | ['en', 'en', 'en'] | True |
TwilioSMSNotificationService.send_message | (self, message="", **kwargs) | Send SMS to specified target user cell. | Send SMS to specified target user cell. | def send_message(self, message="", **kwargs):
"""Send SMS to specified target user cell."""
targets = kwargs.get(ATTR_TARGET)
data = kwargs.get(ATTR_DATA) or {}
twilio_args = {"body": message, "from_": self.from_number}
if ATTR_MEDIAURL in data:
twilio_args[ATTR_MEDI... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"targets",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET",
")",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"or",
"{",
"}",
"twilio_args"... | [
49,
4
] | [
63,
65
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up an InComfort/Intouch water_heater device. | Set up an InComfort/Intouch water_heater device. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up an InComfort/Intouch water_heater device."""
if discovery_info is None:
return
client = hass.data[DOMAIN]["client"]
heaters = hass.data[DOMAIN]["heaters"]
async_add_entities([IncomfortWaterHeat... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"... | [
21,
0
] | [
29,
74
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.__init__ | (self, client, heater) | Initialize the water_heater device. | Initialize the water_heater device. | def __init__(self, client, heater) -> None:
"""Initialize the water_heater device."""
super().__init__()
self._unique_id = f"{heater.serial_no}"
self.entity_id = f"{WATER_HEATER_DOMAIN}.{DOMAIN}"
self._name = "Boiler"
self._client = client
self._heater = heater | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"heater",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_unique_id",
"=",
"f\"{heater.serial_no}\"",
"self",
".",
"entity_id",
"=",
"f\"{WATER_HEATER_DOMAIN}.{DOMAIN}\"",... | [
35,
4
] | [
44,
29
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.icon | (self) | Return the icon of the water_heater device. | Return the icon of the water_heater device. | def icon(self) -> str:
"""Return the icon of the water_heater device."""
return "mdi:thermometer-lines" | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mdi:thermometer-lines\""
] | [
47,
4
] | [
49,
38
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self) -> Dict[str, Any]:
"""Return the device state attributes."""
return {k: v for k, v in self._heater.status.items() if k in HEATER_ATTRS} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_heater",
".",
"status",
".",
"items",
"(",
")",
"if",
"k",
"in",
"HEATER_... | [
52,
4
] | [
54,
82
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self) -> float:
"""Return the current temperature."""
if self._heater.is_tapping:
return self._heater.tap_temp
if self._heater.is_pumping:
return self._heater.heater_temp
return max(self._heater.heater_temp, self._heater.tap_temp) | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"float",
":",
"if",
"self",
".",
"_heater",
".",
"is_tapping",
":",
"return",
"self",
".",
"_heater",
".",
"tap_temp",
"if",
"self",
".",
"_heater",
".",
"is_pumping",
":",
"return",
"self",
".",
"_he... | [
57,
4
] | [
63,
67
] | python | en | ['en', 'la', 'en'] | True |
IncomfortWaterHeater.min_temp | (self) | Return max valid temperature that can be set. | Return max valid temperature that can be set. | def min_temp(self) -> float:
"""Return max valid temperature that can be set."""
return 80.0 | [
"def",
"min_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"80.0"
] | [
66,
4
] | [
68,
19
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.max_temp | (self) | Return max valid temperature that can be set. | Return max valid temperature that can be set. | def max_temp(self) -> float:
"""Return max valid temperature that can be set."""
return 30.0 | [
"def",
"max_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"30.0"
] | [
71,
4
] | [
73,
19
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.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"
] | [
76,
4
] | [
78,
27
] | python | en | ['en', 'la', 'en'] | True |
IncomfortWaterHeater.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"0"
] | [
81,
4
] | [
83,
16
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.current_operation | (self) | Return the current operation mode. | Return the current operation mode. | def current_operation(self) -> str:
"""Return the current operation mode."""
if self._heater.is_failed:
return f"Fault code: {self._heater.fault_code}"
return self._heater.display_text | [
"def",
"current_operation",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_heater",
".",
"is_failed",
":",
"return",
"f\"Fault code: {self._heater.fault_code}\"",
"return",
"self",
".",
"_heater",
".",
"display_text"
] | [
86,
4
] | [
91,
40
] | python | en | ['en', 'en', 'en'] | True |
IncomfortWaterHeater.async_update | (self) | Get the latest state data from the gateway. | Get the latest state data from the gateway. | async def async_update(self) -> None:
"""Get the latest state data from the gateway."""
try:
await self._heater.update()
except (ClientResponseError, asyncio.TimeoutError) as err:
_LOGGER.warning("Update failed, message is: %s", err)
else:
async_disp... | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"await",
"self",
".",
"_heater",
".",
"update",
"(",
")",
"except",
"(",
"ClientResponseError",
",",
"asyncio",
".",
"TimeoutError",
")",
"as",
"err",
":",
"_LOGGER",
".",
... | [
93,
4
] | [
102,
52
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Discover cameras on a Unifi NVR. | Discover cameras on a Unifi NVR. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Discover cameras on a Unifi NVR."""
addr = config[CONF_NVR]
key = config[CONF_KEY]
password = config[CONF_PASSWORD]
port = config[CONF_PORT]
ssl = config[CONF_SSL]
try:
# Exceptions may be raised in all method c... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"addr",
"=",
"config",
"[",
"CONF_NVR",
"]",
"key",
"=",
"config",
"[",
"CONF_KEY",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD"... | [
34,
0
] | [
72,
15
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.__init__ | (self, camera, uuid, name, password) | Initialize an Unifi camera. | Initialize an Unifi camera. | def __init__(self, camera, uuid, name, password):
"""Initialize an Unifi camera."""
super().__init__()
self._nvr = camera
self._uuid = uuid
self._name = name
self._password = password
self.is_streaming = False
self._connect_addr = None
self._camera... | [
"def",
"__init__",
"(",
"self",
",",
"camera",
",",
"uuid",
",",
"name",
",",
"password",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_nvr",
"=",
"camera",
"self",
".",
"_uuid",
"=",
"uuid",
"self",
".",
"_name",
"=",
"n... | [
78,
4
] | [
89,
28
] | python | co | ['ro', 'co', 'it'] | False |
UnifiVideoCamera.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
92,
4
] | [
94,
25
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.should_poll | (self) | If this entity should be polled. | If this entity should be polled. | def should_poll(self):
"""If this entity should be polled."""
return True | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"True"
] | [
97,
4
] | [
99,
19
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
channels = self._caminfo["channels"]
for channel in channels:
if channel["isRtspEnabled"]:
return SUPPORT_STREAM
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
":",
"channels",
"=",
"self",
".",
"_caminfo",
"[",
"\"channels\"",
"]",
"for",
"channel",
"in",
"channels",
":",
"if",
"channel",
"[",
"\"isRtspEnabled\"",
"]",
":",
"return",
"SUPPORT_STREAM",
"return",
"0"
] | [
102,
4
] | [
109,
16
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.is_recording | (self) | Return true if the camera is recording. | Return true if the camera is recording. | def is_recording(self):
"""Return true if the camera is recording."""
return self._caminfo["recordingSettings"]["fullTimeRecordEnabled"] | [
"def",
"is_recording",
"(",
"self",
")",
":",
"return",
"self",
".",
"_caminfo",
"[",
"\"recordingSettings\"",
"]",
"[",
"\"fullTimeRecordEnabled\"",
"]"
] | [
112,
4
] | [
114,
74
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.motion_detection_enabled | (self) | Camera Motion Detection Status. | Camera Motion Detection Status. | def motion_detection_enabled(self):
"""Camera Motion Detection Status."""
return self._caminfo["recordingSettings"]["motionRecordEnabled"] | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"_caminfo",
"[",
"\"recordingSettings\"",
"]",
"[",
"\"motionRecordEnabled\"",
"]"
] | [
117,
4
] | [
119,
72
] | python | en | ['sv', 'ja', 'en'] | False |
UnifiVideoCamera.brand | (self) | Return the brand of this camera. | Return the brand of this camera. | def brand(self):
"""Return the brand of this camera."""
return "Ubiquiti" | [
"def",
"brand",
"(",
"self",
")",
":",
"return",
"\"Ubiquiti\""
] | [
122,
4
] | [
124,
25
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.model | (self) | Return the model of this camera. | Return the model of this camera. | def model(self):
"""Return the model of this camera."""
return self._caminfo["model"] | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"_caminfo",
"[",
"\"model\"",
"]"
] | [
127,
4
] | [
129,
37
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera._login | (self) | Login to the camera. | Login to the camera. | def _login(self):
"""Login to the camera."""
caminfo = self._caminfo
if self._connect_addr:
addrs = [self._connect_addr]
else:
addrs = [caminfo["host"], caminfo["internalHost"]]
if self._nvr.server_version >= (3, 2, 0):
client_cls = uvc_camera... | [
"def",
"_login",
"(",
"self",
")",
":",
"caminfo",
"=",
"self",
".",
"_caminfo",
"if",
"self",
".",
"_connect_addr",
":",
"addrs",
"=",
"[",
"self",
".",
"_connect_addr",
"]",
"else",
":",
"addrs",
"=",
"[",
"caminfo",
"[",
"\"host\"",
"]",
",",
"cam... | [
131,
4
] | [
170,
19
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.camera_image | (self) | Return the image of this camera. | Return the image of this camera. | def camera_image(self):
"""Return the image of this camera."""
if not self._camera:
if not self._login():
return
def _get_image(retry=True):
try:
return self._camera.get_snapshot()
except uvc_camera.CameraConnectError:
... | [
"def",
"camera_image",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_camera",
":",
"if",
"not",
"self",
".",
"_login",
"(",
")",
":",
"return",
"def",
"_get_image",
"(",
"retry",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"_came... | [
172,
4
] | [
191,
27
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.set_motion_detection | (self, mode) | Set motion detection on or off. | Set motion detection on or off. | def set_motion_detection(self, mode):
"""Set motion detection on or off."""
set_mode = "motion" if mode is True else "none"
try:
self._nvr.set_recordmode(self._uuid, set_mode)
self._motion_status = mode
except nvr.NvrError as err:
_LOGGER.error("Unabl... | [
"def",
"set_motion_detection",
"(",
"self",
",",
"mode",
")",
":",
"set_mode",
"=",
"\"motion\"",
"if",
"mode",
"is",
"True",
"else",
"\"none\"",
"try",
":",
"self",
".",
"_nvr",
".",
"set_recordmode",
"(",
"self",
".",
"_uuid",
",",
"set_mode",
")",
"se... | [
193,
4
] | [
202,
30
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.enable_motion_detection | (self) | Enable motion detection in camera. | Enable motion detection in camera. | def enable_motion_detection(self):
"""Enable motion detection in camera."""
self.set_motion_detection(True) | [
"def",
"enable_motion_detection",
"(",
"self",
")",
":",
"self",
".",
"set_motion_detection",
"(",
"True",
")"
] | [
204,
4
] | [
206,
39
] | python | en | ['it', 'en', 'en'] | True |
UnifiVideoCamera.disable_motion_detection | (self) | Disable motion detection in camera. | Disable motion detection in camera. | def disable_motion_detection(self):
"""Disable motion detection in camera."""
self.set_motion_detection(False) | [
"def",
"disable_motion_detection",
"(",
"self",
")",
":",
"self",
".",
"set_motion_detection",
"(",
"False",
")"
] | [
208,
4
] | [
210,
40
] | python | en | ['it', 'en', 'en'] | True |
UnifiVideoCamera.stream_source | (self) | Return the source of the stream. | Return the source of the stream. | async def stream_source(self):
"""Return the source of the stream."""
for channel in self._caminfo["channels"]:
if channel["isRtspEnabled"]:
uri = next(
(
uri
for i, uri in enumerate(channel["rtspUris"])
... | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"for",
"channel",
"in",
"self",
".",
"_caminfo",
"[",
"\"channels\"",
"]",
":",
"if",
"channel",
"[",
"\"isRtspEnabled\"",
"]",
":",
"uri",
"=",
"next",
"(",
"(",
"uri",
"for",
"i",
",",
"uri",
... | [
212,
4
] | [
227,
19
] | python | en | ['en', 'en', 'en'] | True |
UnifiVideoCamera.update | (self) | Update the info. | Update the info. | def update(self):
"""Update the info."""
self._caminfo = self._nvr.get_camera(self._uuid) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_caminfo",
"=",
"self",
".",
"_nvr",
".",
"get_camera",
"(",
"self",
".",
"_uuid",
")"
] | [
229,
4
] | [
231,
56
] | python | en | ['en', 'co', 'en'] | True |
mock_cloud | (hass, config=None) | Mock cloud. | Mock cloud. | async def mock_cloud(hass, config=None):
"""Mock cloud."""
assert await async_setup_component(hass, cloud.DOMAIN, {"cloud": config or {}})
cloud_inst = hass.data["cloud"]
with patch("hass_nabucasa.Cloud.run_executor", AsyncMock(return_value=None)):
await cloud_inst.start() | [
"async",
"def",
"mock_cloud",
"(",
"hass",
",",
"config",
"=",
"None",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"cloud",
".",
"DOMAIN",
",",
"{",
"\"cloud\"",
":",
"config",
"or",
"{",
"}",
"}",
")",
"cloud_inst",
"=",
"h... | [
9,
0
] | [
14,
32
] | python | en | ['en', 'fy', 'en'] | False |
mock_cloud_prefs | (hass, prefs={}) | Fixture for cloud component. | Fixture for cloud component. | def mock_cloud_prefs(hass, prefs={}):
"""Fixture for cloud component."""
prefs_to_set = {
const.PREF_ENABLE_ALEXA: True,
const.PREF_ENABLE_GOOGLE: True,
const.PREF_GOOGLE_SECURE_DEVICES_PIN: None,
}
prefs_to_set.update(prefs)
hass.data[cloud.DOMAIN].client._prefs._prefs = pre... | [
"def",
"mock_cloud_prefs",
"(",
"hass",
",",
"prefs",
"=",
"{",
"}",
")",
":",
"prefs_to_set",
"=",
"{",
"const",
".",
"PREF_ENABLE_ALEXA",
":",
"True",
",",
"const",
".",
"PREF_ENABLE_GOOGLE",
":",
"True",
",",
"const",
".",
"PREF_GOOGLE_SECURE_DEVICES_PIN",
... | [
17,
0
] | [
26,
48
] | python | en | ['en', 'en', 'en'] | True |
check_node_schema | (node, schema) | Check if node matches the passed node schema. | Check if node matches the passed node schema. | def check_node_schema(node, schema):
"""Check if node matches the passed node schema."""
if const.DISC_NODE_ID in schema and node.node_id not in schema[const.DISC_NODE_ID]:
_LOGGER.debug(
"node.node_id %s not in node_id %s",
node.node_id,
schema[const.DISC_NODE_ID],
... | [
"def",
"check_node_schema",
"(",
"node",
",",
"schema",
")",
":",
"if",
"const",
".",
"DISC_NODE_ID",
"in",
"schema",
"and",
"node",
".",
"node_id",
"not",
"in",
"schema",
"[",
"const",
".",
"DISC_NODE_ID",
"]",
":",
"_LOGGER",
".",
"debug",
"(",
"\"node... | [
11,
0
] | [
40,
15
] | python | en | ['en', 'en', 'en'] | True |
check_value_schema | (value, schema) | Check if the value matches the passed value schema. | Check if the value matches the passed value schema. | def check_value_schema(value, schema):
"""Check if the value matches the passed value schema."""
if (
const.DISC_COMMAND_CLASS in schema
and value.command_class not in schema[const.DISC_COMMAND_CLASS]
):
_LOGGER.debug(
"value.command_class %s not in command_class %s",
... | [
"def",
"check_value_schema",
"(",
"value",
",",
"schema",
")",
":",
"if",
"(",
"const",
".",
"DISC_COMMAND_CLASS",
"in",
"schema",
"and",
"value",
".",
"command_class",
"not",
"in",
"schema",
"[",
"const",
".",
"DISC_COMMAND_CLASS",
"]",
")",
":",
"_LOGGER",... | [
43,
0
] | [
87,
15
] | python | en | ['en', 'en', 'en'] | True |
node_name | (node) | Return the name of the node. | Return the name of the node. | def node_name(node):
"""Return the name of the node."""
if is_node_parsed(node):
return node.name or f"{node.manufacturer_name} {node.product_name}"
return f"Unknown Node {node.node_id}" | [
"def",
"node_name",
"(",
"node",
")",
":",
"if",
"is_node_parsed",
"(",
"node",
")",
":",
"return",
"node",
".",
"name",
"or",
"f\"{node.manufacturer_name} {node.product_name}\"",
"return",
"f\"Unknown Node {node.node_id}\""
] | [
90,
0
] | [
94,
41
] | python | en | ['en', 'en', 'en'] | True |
node_device_id_and_name | (node, instance=1) | Return the name and device ID for the value with the given index. | Return the name and device ID for the value with the given index. | def node_device_id_and_name(node, instance=1):
"""Return the name and device ID for the value with the given index."""
name = node_name(node)
if instance == 1:
return ((const.DOMAIN, node.node_id), name)
name = f"{name} ({instance})"
return ((const.DOMAIN, node.node_id, instance), name) | [
"def",
"node_device_id_and_name",
"(",
"node",
",",
"instance",
"=",
"1",
")",
":",
"name",
"=",
"node_name",
"(",
"node",
")",
"if",
"instance",
"==",
"1",
":",
"return",
"(",
"(",
"const",
".",
"DOMAIN",
",",
"node",
".",
"node_id",
")",
",",
"name... | [
97,
0
] | [
103,
57
] | python | en | ['en', 'en', 'en'] | True |
check_has_unique_id | (entity, ready_callback, timeout_callback) | Wait for entity to have unique_id. | Wait for entity to have unique_id. | async def check_has_unique_id(entity, ready_callback, timeout_callback):
"""Wait for entity to have unique_id."""
start_time = dt_util.utcnow()
while True:
waited = int((dt_util.utcnow() - start_time).total_seconds())
if entity.unique_id:
ready_callback(waited)
return... | [
"async",
"def",
"check_has_unique_id",
"(",
"entity",
",",
"ready_callback",
",",
"timeout_callback",
")",
":",
"start_time",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"while",
"True",
":",
"waited",
"=",
"int",
"(",
"(",
"dt_util",
".",
"utcnow",
"(",
")",... | [
106,
0
] | [
118,
30
] | python | en | ['en', 'en', 'en'] | True |
is_node_parsed | (node) | Check whether the node has been parsed or still waiting to be parsed. | Check whether the node has been parsed or still waiting to be parsed. | def is_node_parsed(node):
"""Check whether the node has been parsed or still waiting to be parsed."""
return bool((node.manufacturer_name and node.product_name) or node.name) | [
"def",
"is_node_parsed",
"(",
"node",
")",
":",
"return",
"bool",
"(",
"(",
"node",
".",
"manufacturer_name",
"and",
"node",
".",
"product_name",
")",
"or",
"node",
".",
"name",
")"
] | [
121,
0
] | [
123,
76
] | python | en | ['en', 'en', 'en'] | True |
get_api | (hass: HomeAssistantType, host: str) | Get the Freebox API. | Get the Freebox API. | async def get_api(hass: HomeAssistantType, host: str) -> Freepybox:
"""Get the Freebox API."""
freebox_path = Path(hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY).path)
freebox_path.mkdir(exist_ok=True)
token_file = Path(f"{freebox_path}/{slugify(host)}.conf")
return Freepybox(APP_DESC, t... | [
"async",
"def",
"get_api",
"(",
"hass",
":",
"HomeAssistantType",
",",
"host",
":",
"str",
")",
"->",
"Freepybox",
":",
"freebox_path",
"=",
"Path",
"(",
"hass",
".",
"helpers",
".",
"storage",
".",
"Store",
"(",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
")",... | [
192,
0
] | [
199,
55
] | python | en | ['en', 'pt', 'en'] | True |
FreeboxRouter.__init__ | (self, hass: HomeAssistantType, entry: ConfigEntry) | Initialize a Freebox router. | Initialize a Freebox router. | def __init__(self, hass: HomeAssistantType, entry: ConfigEntry) -> None:
"""Initialize a Freebox router."""
self.hass = hass
self._entry = entry
self._host = entry.data[CONF_HOST]
self._port = entry.data[CONF_PORT]
self._api: Freepybox = None
self._name = None
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_entry",
"=",
"entry",
"self",
".",
"_host",
"=",
"entry",
".",
"data",
"... | [
36,
4
] | [
55,
27
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.setup | (self) | Set up a Freebox router. | Set up a Freebox router. | async def setup(self) -> None:
"""Set up a Freebox router."""
self._api = await get_api(self.hass, self._host)
try:
await self._api.open(self._host, self._port)
except HttpRequestError:
_LOGGER.exception("Failed to connect to Freebox")
return ConfigEn... | [
"async",
"def",
"setup",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_api",
"=",
"await",
"get_api",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_host",
")",
"try",
":",
"await",
"self",
".",
"_api",
".",
"open",
"(",
"self",
".",
"_host"... | [
57,
4
] | [
77,
9
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.update_all | (self, now: Optional[datetime] = None) | Update all Freebox platforms. | Update all Freebox platforms. | async def update_all(self, now: Optional[datetime] = None) -> None:
"""Update all Freebox platforms."""
await self.update_sensors()
await self.update_devices() | [
"async",
"def",
"update_all",
"(",
"self",
",",
"now",
":",
"Optional",
"[",
"datetime",
"]",
"=",
"None",
")",
"->",
"None",
":",
"await",
"self",
".",
"update_sensors",
"(",
")",
"await",
"self",
".",
"update_devices",
"(",
")"
] | [
79,
4
] | [
82,
35
] | python | en | ['en', 'de', 'en'] | True |
FreeboxRouter.update_devices | (self) | Update Freebox devices. | Update Freebox devices. | async def update_devices(self) -> None:
"""Update Freebox devices."""
new_device = False
fbx_devices: Dict[str, Any] = await self._api.lan.get_hosts_list()
# Adds the Freebox itself
fbx_devices.append(
{
"primary_name": self._name,
"l2... | [
"async",
"def",
"update_devices",
"(",
"self",
")",
"->",
"None",
":",
"new_device",
"=",
"False",
"fbx_devices",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"await",
"self",
".",
"_api",
".",
"lan",
".",
"get_hosts_list",
"(",
")",
"# Adds the Freebo... | [
84,
4
] | [
112,
68
] | python | en | ['es', 'en', 'en'] | True |
FreeboxRouter.update_sensors | (self) | Update Freebox sensors. | Update Freebox sensors. | async def update_sensors(self) -> None:
"""Update Freebox sensors."""
# System sensors
syst_datas: Dict[str, Any] = await self._api.system.get_config()
# According to the doc `syst_datas["sensors"]` is temperature sensors in celsius degree.
# Name and id of sensors may vary unde... | [
"async",
"def",
"update_sensors",
"(",
"self",
")",
"->",
"None",
":",
"# System sensors",
"syst_datas",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"await",
"self",
".",
"_api",
".",
"system",
".",
"get_config",
"(",
")",
"# According to the doc `syst_da... | [
114,
4
] | [
142,
67
] | python | en | ['en', 'bg', 'en'] | True |
FreeboxRouter.reboot | (self) | Reboot the Freebox. | Reboot the Freebox. | async def reboot(self) -> None:
"""Reboot the Freebox."""
await self._api.system.reboot() | [
"async",
"def",
"reboot",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_api",
".",
"system",
".",
"reboot",
"(",
")"
] | [
144,
4
] | [
146,
39
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.close | (self) | Close the connection. | Close the connection. | async def close(self) -> None:
"""Close the connection."""
if self._api is not None:
await self._api.close()
self._unsub_dispatcher()
self._api = None | [
"async",
"def",
"close",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_api",
"is",
"not",
"None",
":",
"await",
"self",
".",
"_api",
".",
"close",
"(",
")",
"self",
".",
"_unsub_dispatcher",
"(",
")",
"self",
".",
"_api",
"=",
"None"
] | [
148,
4
] | [
153,
24
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> Dict[str, Any]:
"""Return the device information."""
return {
"connections": {(CONNECTION_NETWORK_MAC, self.mac)},
"identifiers": {(DOMAIN, self.mac)},
"name": self._name,
"manufacturer": "Freebox SAS",
"sw_version": se... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"mac",
")",
"}",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
... | [
156,
4
] | [
164,
9
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.signal_device_new | (self) | Event specific per Freebox entry to signal new device. | Event specific per Freebox entry to signal new device. | def signal_device_new(self) -> str:
"""Event specific per Freebox entry to signal new device."""
return f"{DOMAIN}-{self._host}-device-new" | [
"def",
"signal_device_new",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{DOMAIN}-{self._host}-device-new\""
] | [
167,
4
] | [
169,
50
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.signal_device_update | (self) | Event specific per Freebox entry to signal updates in devices. | Event specific per Freebox entry to signal updates in devices. | def signal_device_update(self) -> str:
"""Event specific per Freebox entry to signal updates in devices."""
return f"{DOMAIN}-{self._host}-device-update" | [
"def",
"signal_device_update",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{DOMAIN}-{self._host}-device-update\""
] | [
172,
4
] | [
174,
53
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.signal_sensor_update | (self) | Event specific per Freebox entry to signal updates in sensors. | Event specific per Freebox entry to signal updates in sensors. | def signal_sensor_update(self) -> str:
"""Event specific per Freebox entry to signal updates in sensors."""
return f"{DOMAIN}-{self._host}-sensor-update" | [
"def",
"signal_sensor_update",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{DOMAIN}-{self._host}-sensor-update\""
] | [
177,
4
] | [
179,
53
] | python | en | ['en', 'en', 'en'] | True |
FreeboxRouter.sensors | (self) | Return sensors. | Return sensors. | def sensors(self) -> Dict[str, Any]:
"""Return sensors."""
return {**self.sensors_temperature, **self.sensors_connection} | [
"def",
"sensors",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"*",
"*",
"self",
".",
"sensors_temperature",
",",
"*",
"*",
"self",
".",
"sensors_connection",
"}"
] | [
182,
4
] | [
184,
70
] | python | en | ['en', 'bg', 'en'] | False |
FreeboxRouter.wifi | (self) | Return the wifi. | Return the wifi. | def wifi(self) -> Wifi:
"""Return the wifi."""
return self._api.wifi | [
"def",
"wifi",
"(",
"self",
")",
"->",
"Wifi",
":",
"return",
"self",
".",
"_api",
".",
"wifi"
] | [
187,
4
] | [
189,
29
] | python | en | ['en', 'ig', 'en'] | True |
WebsocketAPIView.get | (self, request: web.Request) | Handle an incoming websocket connection. | Handle an incoming websocket connection. | async def get(self, request: web.Request) -> web.WebSocketResponse:
"""Handle an incoming websocket connection."""
return await WebSocketHandler(request.app["hass"], request).async_handle() | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
")",
"->",
"web",
".",
"WebSocketResponse",
":",
"return",
"await",
"WebSocketHandler",
"(",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
",",
"request",
")",
".",
"async_han... | [
39,
4
] | [
41,
82
] | python | en | ['en', 'en', 'en'] | True |
WebSocketAdapter.process | (self, msg, kwargs) | Add connid to websocket log messages. | Add connid to websocket log messages. | def process(self, msg, kwargs):
"""Add connid to websocket log messages."""
return f'[{self.extra["connid"]}] {msg}', kwargs | [
"def",
"process",
"(",
"self",
",",
"msg",
",",
"kwargs",
")",
":",
"return",
"f'[{self.extra[\"connid\"]}] {msg}'",
",",
"kwargs"
] | [
47,
4
] | [
49,
56
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler.__init__ | (self, hass, request) | Initialize an active connection. | Initialize an active connection. | def __init__(self, hass, request):
"""Initialize an active connection."""
self.hass = hass
self.request = request
self.wsock: Optional[web.WebSocketResponse] = None
self._to_write: asyncio.Queue = asyncio.Queue(maxsize=MAX_PENDING_MSG)
self._handle_task = None
sel... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"request",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"request",
"=",
"request",
"self",
".",
"wsock",
":",
"Optional",
"[",
"web",
".",
"WebSocketResponse",
"]",
"=",
"None",
"self",
".... | [
55,
4
] | [
64,
39
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler._writer | (self) | Write outgoing messages. | Write outgoing messages. | async def _writer(self):
"""Write outgoing messages."""
# Exceptions if Socket disconnected or cancelled by connection handler
with suppress(RuntimeError, ConnectionResetError, *CANCELLATION_ERRORS):
while not self.wsock.closed:
message = await self._to_write.get()
... | [
"async",
"def",
"_writer",
"(",
"self",
")",
":",
"# Exceptions if Socket disconnected or cancelled by connection handler",
"with",
"suppress",
"(",
"RuntimeError",
",",
"ConnectionResetError",
",",
"*",
"CANCELLATION_ERRORS",
")",
":",
"while",
"not",
"self",
".",
"wso... | [
66,
4
] | [
85,
43
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler._send_message | (self, message) | Send a message to the client.
Closes connection if the client is not reading the messages.
Async friendly.
| Send a message to the client. | def _send_message(self, message):
"""Send a message to the client.
Closes connection if the client is not reading the messages.
Async friendly.
"""
try:
self._to_write.put_nowait(message)
except asyncio.QueueFull:
self._logger.error(
... | [
"def",
"_send_message",
"(",
"self",
",",
"message",
")",
":",
"try",
":",
"self",
".",
"_to_write",
".",
"put_nowait",
"(",
"message",
")",
"except",
"asyncio",
".",
"QueueFull",
":",
"self",
".",
"_logger",
".",
"error",
"(",
"\"Client exceeded max pending... | [
88,
4
] | [
113,
13
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler._check_write_peak | (self, _) | Check that we are no longer above the write peak. | Check that we are no longer above the write peak. | def _check_write_peak(self, _):
"""Check that we are no longer above the write peak."""
self._peak_checker_unsub = None
if self._to_write.qsize() < PENDING_MSG_PEAK:
return
self._logger.error(
"Client unable to keep up with pending messages. Stayed over %s for %... | [
"def",
"_check_write_peak",
"(",
"self",
",",
"_",
")",
":",
"self",
".",
"_peak_checker_unsub",
"=",
"None",
"if",
"self",
".",
"_to_write",
".",
"qsize",
"(",
")",
"<",
"PENDING_MSG_PEAK",
":",
"return",
"self",
".",
"_logger",
".",
"error",
"(",
"\"Cl... | [
116,
4
] | [
128,
22
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler._cancel | (self) | Cancel the connection. | Cancel the connection. | def _cancel(self):
"""Cancel the connection."""
self._handle_task.cancel()
self._writer_task.cancel() | [
"def",
"_cancel",
"(",
"self",
")",
":",
"self",
".",
"_handle_task",
".",
"cancel",
"(",
")",
"self",
".",
"_writer_task",
".",
"cancel",
"(",
")"
] | [
131,
4
] | [
134,
34
] | python | en | ['en', 'en', 'en'] | True |
WebSocketHandler.async_handle | (self) | Handle a websocket response. | Handle a websocket response. | async def async_handle(self) -> web.WebSocketResponse:
"""Handle a websocket response."""
request = self.request
wsock = self.wsock = web.WebSocketResponse(heartbeat=55)
await wsock.prepare(request)
self._logger.debug("Connected from %s", request.remote)
self._handle_task... | [
"async",
"def",
"async_handle",
"(",
"self",
")",
"->",
"web",
".",
"WebSocketResponse",
":",
"request",
"=",
"self",
".",
"request",
"wsock",
"=",
"self",
".",
"wsock",
"=",
"web",
".",
"WebSocketResponse",
"(",
"heartbeat",
"=",
"55",
")",
"await",
"ws... | [
136,
4
] | [
249,
20
] | python | en | ['en', 'hu', 'en'] | True |
test_show_user_form | (hass: HomeAssistant) | Test that the setup form is served. | Test that the setup form is served. | async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the setup form is served."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id... | [
"async",
"def",
"test_show_user_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entri... | [
22,
0
] | [
29,
38
] | python | en | ['en', 'en', 'en'] | True |
test_authorization_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps authorization error. | Test we show user form on Azure DevOps authorization error. | async def test_authorization_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps authorization error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
return_value=False,
):
result = await hass.config_entries.flow.as... | [
"async",
"def",
"test_authorization_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
"return_value",
"=",
"False",
",",
")",
":",
"result",
"=",
... | [
32,
0
] | [
53,
60
] | python | en | ['en', 'de', 'en'] | True |
test_reauth_authorization_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps authorization error. | Test we show user form on Azure DevOps authorization error. | async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps authorization error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
return_value=False,
):
result = await hass.config_entries.... | [
"async",
"def",
"test_reauth_authorization_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
"return_value",
"=",
"False",
",",
")",
":",
"result",
... | [
56,
0
] | [
77,
60
] | python | en | ['en', 'de', 'en'] | True |
test_connection_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps connection error. | Test we show user form on Azure DevOps connection error. | async def test_connection_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps connection error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
side_effect=aiohttp.ClientError,
):
result = await hass.config_entries.... | [
"async",
"def",
"test_connection_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
"side_effect",
"=",
"aiohttp",
".",
"ClientError",
",",
")",
":... | [
80,
0
] | [
101,
62
] | python | en | ['en', 'da', 'en'] | True |
test_reauth_connection_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps connection error. | Test we show user form on Azure DevOps connection error. | async def test_reauth_connection_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps connection error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
side_effect=aiohttp.ClientError,
):
result = await hass.config_e... | [
"async",
"def",
"test_reauth_connection_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
"side_effect",
"=",
"aiohttp",
".",
"ClientError",
",",
")... | [
104,
0
] | [
125,
62
] | python | en | ['en', 'da', 'en'] | True |
test_project_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps connection error. | Test we show user form on Azure DevOps connection error. | async def test_project_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps connection error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorized",
return_value=True,
), patch(
"homeassistant.components.azure_devops.confi... | [
"async",
"def",
"test_project_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorized\"",
",",
"return_value",
"=",
"True",
",",
")",
",",
"patch",
"(",
"\"ho... | [
128,
0
] | [
154,
61
] | python | en | ['en', 'da', 'en'] | True |
test_reauth_project_error | (hass: HomeAssistant) | Test we show user form on Azure DevOps project error. | Test we show user form on Azure DevOps project error. | async def test_reauth_project_error(hass: HomeAssistant) -> None:
"""Test we show user form on Azure DevOps project error."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
), patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.auth... | [
"async",
"def",
"test_reauth_project_error",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.azure_devops.... | [
157,
0
] | [
183,
61
] | python | da | ['de', 'da', 'en'] | False |
test_reauth_flow | (hass: HomeAssistant) | Test reauth works. | Test reauth works. | async def test_reauth_flow(hass: HomeAssistant) -> None:
"""Test reauth works."""
with patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize",
return_value=False,
):
mock_config = MockConfigEntry(
domain=DOMAIN, unique_id=UNIQUE_ID, data=FIXTURE... | [
"async",
"def",
"test_reauth_flow",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorize\"",
",",
"return_value",
"=",
"False",
",",
")",
":",
"mock_config",
"=",
"... | [
186,
0
] | [
223,
55
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow_implementation | (hass: HomeAssistant) | Test registering an integration and finishing flow works. | Test registering an integration and finishing flow works. | async def test_full_flow_implementation(hass: HomeAssistant) -> None:
"""Test registering an integration and finishing flow works."""
with patch(
"homeassistant.components.azure_devops.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.azure_devops.async_setup_... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"with",
"patch",
"(",
"\"homeassistant.components.azure_devops.async_setup\"",
",",
"return_value",
"=",
"True",
")",
"as",
"mock_setup",
",",
"patch",
"(",
"... | [
226,
0
] | [
265,
80
] | python | en | ['en', 'en', 'en'] | True |
test_ws_get_notifications | (hass, hass_ws_client) | Test websocket endpoint for retrieving persistent notifications. | Test websocket endpoint for retrieving persistent notifications. | async def test_ws_get_notifications(hass, hass_ws_client):
"""Test websocket endpoint for retrieving persistent notifications."""
await async_setup_component(hass, pn.DOMAIN, {})
client = await hass_ws_client(hass)
await client.send_json({"id": 5, "type": "persistent_notification/get"})
msg = awai... | [
"async",
"def",
"test_ws_get_notifications",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"pn",
".",
"DOMAIN",
",",
"{",
"}",
")",
"client",
"=",
"await",
"hass_ws_client",
"(",
"hass",
")",
"await",
"clie... | [
141,
0
] | [
188,
34
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.setup_method | (self, method) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self, method):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
setup_component(self.hass, pn.DOMAIN, {}) | [
"def",
"setup_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"setup_component",
"(",
"self",
".",
"hass",
",",
"pn",
".",
"DOMAIN",
",",
"{",
"}",
")"
] | [
11,
4
] | [
14,
49
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.teardown_method | (self, method) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self, method):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
16,
4
] | [
18,
24
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create | (self) | Test creating notification without title or notification id. | Test creating notification without title or notification id. | def test_create(self):
"""Test creating notification without title or notification id."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "Hello World {{ 1 + 1 ... | [
"def",
"test_create",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
"(",
"pn",
... | [
20,
4
] | [
43,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create_notification_id | (self) | Ensure overwrites existing notification with same id. | Ensure overwrites existing notification with same id. | def test_create_notification_id(self):
"""Ensure overwrites existing notification with same id."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "test", notif... | [
"def",
"test_create_notification_id",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
45,
4
] | [
75,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_create_template_error | (self) | Ensure we output templates if contain error. | Ensure we output templates if contain error. | def test_create_template_error(self):
"""Ensure we output templates if contain error."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "{{ message + 1 }}", "{... | [
"def",
"test_create_template_error",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
77,
4
] | [
97,
29
] | python | en | ['eu', 'en', 'en'] | True |
TestPersistentNotification.test_dismiss_notification | (self) | Ensure removal of specific notification. | Ensure removal of specific notification. | def test_dismiss_notification(self):
"""Ensure removal of specific notification."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(self.hass.states.entity_ids(pn.DOMAIN)) == 0
assert len(notifications) == 0
pn.create(self.hass, "test", notification_id="Bee... | [
"def",
"test_dismiss_notification",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"self",
".",
"hass",
".",
"states",
".",
"entity_ids",
... | [
99,
4
] | [
115,
29
] | python | en | ['en', 'en', 'en'] | True |
TestPersistentNotification.test_mark_read | (self) | Ensure notification is marked as Read. | Ensure notification is marked as Read. | def test_mark_read(self):
"""Ensure notification is marked as Read."""
notifications = self.hass.data[pn.DOMAIN]["notifications"]
assert len(notifications) == 0
pn.create(self.hass, "test", notification_id="Beer 2")
self.hass.block_till_done()
entity_id = "persistent_no... | [
"def",
"test_mark_read",
"(",
"self",
")",
":",
"notifications",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"pn",
".",
"DOMAIN",
"]",
"[",
"\"notifications\"",
"]",
"assert",
"len",
"(",
"notifications",
")",
"==",
"0",
"pn",
".",
"create",
"(",
"self... | [
117,
4
] | [
138,
29
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up an APCUPSd Online Status binary sensor. | Set up an APCUPSd Online Status binary sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up an APCUPSd Online Status binary sensor."""
apcups_data = hass.data[DOMAIN]
add_entities([OnlineStatus(config, apcups_data)], True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"apcups_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"add_entities",
"(",
"[",
"OnlineStatus",
"(",
"config",
",",
"apcups_data",
... | [
15,
0
] | [
19,
59
] | python | en | ['en', 'su', 'en'] | True |
OnlineStatus.__init__ | (self, config, data) | Initialize the APCUPSd binary device. | Initialize the APCUPSd binary device. | def __init__(self, config, data):
"""Initialize the APCUPSd binary device."""
self._config = config
self._data = data
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"data",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_state",
"=",
"None"
] | [
25,
4
] | [
29,
26
] | python | en | ['en', 'en', 'en'] | True |
OnlineStatus.name | (self) | Return the name of the UPS online status sensor. | Return the name of the UPS online status sensor. | def name(self):
"""Return the name of the UPS online status sensor."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
32,
4
] | [
34,
38
] | python | en | ['en', 'id', 'en'] | True |
OnlineStatus.is_on | (self) | Return true if the UPS is online, else false. | Return true if the UPS is online, else false. | def is_on(self):
"""Return true if the UPS is online, else false."""
return self._state & VALUE_ONLINE > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"&",
"VALUE_ONLINE",
">",
"0"
] | [
37,
4
] | [
39,
45
] | python | en | ['en', 'da', 'en'] | True |
OnlineStatus.update | (self) | Get the status report from APCUPSd and set this entity's state. | Get the status report from APCUPSd and set this entity's state. | def update(self):
"""Get the status report from APCUPSd and set this entity's state."""
self._state = int(self._data.status[KEY_STATUS], 16) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"int",
"(",
"self",
".",
"_data",
".",
"status",
"[",
"KEY_STATUS",
"]",
",",
"16",
")"
] | [
41,
4
] | [
43,
60
] | python | en | ['en', 'en', 'en'] | True |
test_smoke_test_setup_component | (hass) | Smoke test for successfully set-up with default config. | Smoke test for successfully set-up with default config. | async def test_smoke_test_setup_component(hass):
"""Smoke test for successfully set-up with default config."""
assert await async_setup_component(hass, weather.DOMAIN, BASE_CONFIG)
await hass.async_block_till_done()
state = hass.states.get("weather.volkel")
assert state.state == "unknown" | [
"async",
"def",
"test_smoke_test_setup_component",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"weather",
".",
"DOMAIN",
",",
"BASE_CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"state",
"=",
"has... | [
18,
0
] | [
24,
35
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate_error | (hass, ping_client) | Test that errors are shown when duplicate entries are added. | Test that errors are shown when duplicate entries are added. | async def test_duplicate_error(hass, ping_client):
"""Test that errors are shown when duplicate entries are added."""
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PORT: 7777}
MockConfigEntry(domain=DOMAIN, unique_id="guardian_3456", data=conf).add_to_hass(
hass
)
result = await hass.conf... | [
"async",
"def",
"test_duplicate_error",
"(",
"hass",
",",
"ping_client",
")",
":",
"conf",
"=",
"{",
"CONF_IP_ADDRESS",
":",
"\"192.168.1.100\"",
",",
"CONF_PORT",
":",
"7777",
"}",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"gua... | [
16,
0
] | [
29,
51
] | python | en | ['en', 'en', 'en'] | True |
test_connect_error | (hass) | Test that the config entry errors out if the device cannot connect. | Test that the config entry errors out if the device cannot connect. | async def test_connect_error(hass):
"""Test that the config entry errors out if the device cannot connect."""
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PORT: 7777}
with patch(
"aioguardian.client.Client.connect",
side_effect=GuardianError,
):
result = await hass.config_entr... | [
"async",
"def",
"test_connect_error",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_IP_ADDRESS",
":",
"\"192.168.1.100\"",
",",
"CONF_PORT",
":",
"7777",
"}",
"with",
"patch",
"(",
"\"aioguardian.client.Client.connect\"",
",",
"side_effect",
"=",
"GuardianError",
... | [
32,
0
] | [
44,
70
] | python | en | ['en', 'en', 'en'] | True |
test_get_pin_from_discovery_hostname | () | Test getting a device PIN from the zeroconf-discovered hostname. | Test getting a device PIN from the zeroconf-discovered hostname. | async def test_get_pin_from_discovery_hostname():
"""Test getting a device PIN from the zeroconf-discovered hostname."""
pin = async_get_pin_from_discovery_hostname("GVC1-3456.local.")
assert pin == "3456" | [
"async",
"def",
"test_get_pin_from_discovery_hostname",
"(",
")",
":",
"pin",
"=",
"async_get_pin_from_discovery_hostname",
"(",
"\"GVC1-3456.local.\"",
")",
"assert",
"pin",
"==",
"\"3456\""
] | [
47,
0
] | [
50,
24
] | python | en | ['en', 'en', 'en'] | True |
test_get_pin_from_uid | () | Test getting a device PIN from its UID. | Test getting a device PIN from its UID. | async def test_get_pin_from_uid():
"""Test getting a device PIN from its UID."""
pin = async_get_pin_from_uid("ABCDEF123456")
assert pin == "3456" | [
"async",
"def",
"test_get_pin_from_uid",
"(",
")",
":",
"pin",
"=",
"async_get_pin_from_uid",
"(",
"\"ABCDEF123456\"",
")",
"assert",
"pin",
"==",
"\"3456\""
] | [
53,
0
] | [
56,
24
] | python | en | ['en', 'en', 'en'] | True |
test_step_user | (hass, ping_client) | Test the user step. | Test the user step. | async def test_step_user(hass, ping_client):
"""Test the user step."""
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PORT: 7777}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
asser... | [
"async",
"def",
"test_step_user",
"(",
"hass",
",",
"ping_client",
")",
":",
"conf",
"=",
"{",
"CONF_IP_ADDRESS",
":",
"\"192.168.1.100\"",
",",
"CONF_PORT",
":",
"7777",
"}",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_in... | [
59,
0
] | [
78,
5
] | 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.