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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ndpointer | (dtype=None, ndim=None, shape=None, flags=None) |
Array-checking restype/argtypes.
An ndpointer instance is used to describe an ndarray in restypes
and argtypes specifications. This approach is more flexible than
using, for example, ``POINTER(c_double)``, since several restrictions
can be specified, which are verified upon calling the ctypes fun... |
Array-checking restype/argtypes. | def ndpointer(dtype=None, ndim=None, shape=None, flags=None):
"""
Array-checking restype/argtypes.
An ndpointer instance is used to describe an ndarray in restypes
and argtypes specifications. This approach is more flexible than
using, for example, ``POINTER(c_double)``, since several restrictions... | [
"def",
"ndpointer",
"(",
"dtype",
"=",
"None",
",",
"ndim",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"flags",
"=",
"None",
")",
":",
"# normalize dtype to an Optional[dtype]",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"_dtype",
"(",
"dty... | [
228,
0
] | [
343,
16
] | python | en | ['en', 'error', 'th'] | False |
_concrete_ndptr._check_retval_ | (self) |
This method is called when this class is used as the .restype
attribute for a shared-library function, to automatically wrap the
pointer into an array.
|
This method is called when this class is used as the .restype
attribute for a shared-library function, to automatically wrap the
pointer into an array.
| def _check_retval_(self):
"""
This method is called when this class is used as the .restype
attribute for a shared-library function, to automatically wrap the
pointer into an array.
"""
return self.contents | [
"def",
"_check_retval_",
"(",
"self",
")",
":",
"return",
"self",
".",
"contents"
] | [
204,
4
] | [
210,
28
] | python | en | ['en', 'error', 'th'] | False |
_concrete_ndptr.contents | (self) |
Get an ndarray viewing the data pointed to by this pointer.
This mirrors the `contents` attribute of a normal ctypes pointer
|
Get an ndarray viewing the data pointed to by this pointer. | def contents(self):
"""
Get an ndarray viewing the data pointed to by this pointer.
This mirrors the `contents` attribute of a normal ctypes pointer
"""
full_dtype = _dtype((self._dtype_, self._shape_))
full_ctype = ctypes.c_char * full_dtype.itemsize
buffer = ct... | [
"def",
"contents",
"(",
"self",
")",
":",
"full_dtype",
"=",
"_dtype",
"(",
"(",
"self",
".",
"_dtype_",
",",
"self",
".",
"_shape_",
")",
")",
"full_ctype",
"=",
"ctypes",
".",
"c_char",
"*",
"full_dtype",
".",
"itemsize",
"buffer",
"=",
"ctypes",
"."... | [
213,
4
] | [
222,
67
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) | Set up FireServiceRota sensor based on a config entry. | Set up FireServiceRota sensor based on a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up FireServiceRota sensor based on a config entry."""
client = hass.data[FIRESERVICEROTA_DOMAIN][entry.entry_id][DATA_CLIENT]
async_add_entities([IncidentsSensor(client)]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"client",
"=",
"hass",
".",
"data",
"[",
"FIRESERVICEROTA_DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
... | [
14,
0
] | [
20,
49
] | python | en | ['en', 'da', 'en'] | True |
IncidentsSensor.__init__ | (self, client) | Initialize. | Initialize. | def __init__(self, client):
"""Initialize."""
self._client = client
self._entry_id = self._client.entry_id
self._unique_id = f"{self._client.unique_id}_Incidents"
self._state = None
self._state_attributes = {} | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_entry_id",
"=",
"self",
".",
"_client",
".",
"entry_id",
"self",
".",
"_unique_id",
"=",
"f\"{self._client.unique_id}_Incidents\"",
"self",
".",
"_... | [
26,
4
] | [
32,
35
] | python | en | ['en', 'en', 'it'] | False |
IncidentsSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return "Incidents" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Incidents\""
] | [
35,
4
] | [
37,
26
] | python | en | ['en', 'mi', 'en'] | True |
IncidentsSensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self) -> str:
"""Return the icon to use in the frontend."""
if (
"prio" in self._state_attributes
and self._state_attributes["prio"][0] == "a"
):
return "mdi:ambulance"
return "mdi:fire-truck" | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"if",
"(",
"\"prio\"",
"in",
"self",
".",
"_state_attributes",
"and",
"self",
".",
"_state_attributes",
"[",
"\"prio\"",
"]",
"[",
"0",
"]",
"==",
"\"a\"",
")",
":",
"return",
"\"mdi:ambulance\"",
"retur... | [
40,
4
] | [
48,
31
] | python | en | ['en', 'en', 'en'] | True |
IncidentsSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self) -> str:
"""Return the state of the sensor."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_state"
] | [
51,
4
] | [
53,
26
] | python | en | ['en', 'en', 'en'] | True |
IncidentsSensor.unique_id | (self) | Return the unique ID of the sensor. | Return the unique ID of the sensor. | def unique_id(self) -> str:
"""Return the unique ID of the sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
56,
4
] | [
58,
30
] | python | en | ['en', 'la', 'en'] | True |
IncidentsSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
61,
4
] | [
63,
20
] | python | en | ['en', 'en', 'en'] | True |
IncidentsSensor.extra_state_attributes | (self) | Return available attributes for sensor. | Return available attributes for sensor. | def extra_state_attributes(self) -> object:
"""Return available attributes for sensor."""
attr = {}
data = self._state_attributes
if not data:
return attr
for value in (
"id",
"trigger",
"created_at",
"message_to_speec... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
"->",
"object",
":",
"attr",
"=",
"{",
"}",
"data",
"=",
"self",
".",
"_state_attributes",
"if",
"not",
"data",
":",
"return",
"attr",
"for",
"value",
"in",
"(",
"\"id\"",
",",
"\"trigger\"",
",",
"\"cre... | [
66,
4
] | [
99,
19
] | python | en | ['no', 'en', 'en'] | True |
IncidentsSensor.async_added_to_hass | (self) | Run when about to be added to hass. | Run when about to be added to hass. | async def async_added_to_hass(self) -> None:
"""Run when about to be added to hass."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
self._state = state.state
self._state_attributes = state.attributes
if "id" ... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
":",
"self",
".",
"_state",
... | [
101,
4
] | [
119,
9
] | python | en | ['en', 'en', 'en'] | True |
IncidentsSensor.client_update | (self) | Handle updated data from the data client. | Handle updated data from the data client. | def client_update(self) -> None:
"""Handle updated data from the data client."""
data = self._client.websocket.incident_data
if not data or "body" not in data:
return
self._state = data["body"]
self._state_attributes = data
if "id" in self._state_attributes:
... | [
"def",
"client_update",
"(",
"self",
")",
"->",
"None",
":",
"data",
"=",
"self",
".",
"_client",
".",
"websocket",
".",
"incident_data",
"if",
"not",
"data",
"or",
"\"body\"",
"not",
"in",
"data",
":",
"return",
"self",
".",
"_state",
"=",
"data",
"["... | [
122,
4
] | [
132,
35
] | python | en | ['en', 'en', 'en'] | True |
ecobee_fixture | () | Set up ecobee mock. | Set up ecobee mock. | def ecobee_fixture():
"""Set up ecobee mock."""
vals = {
"name": "Ecobee",
"modelNumber": "athenaSmart",
"program": {
"climates": [
{"name": "Climate1", "climateRef": "c1"},
{"name": "Climate2", "climateRef": "c2"},
],
"... | [
"def",
"ecobee_fixture",
"(",
")",
":",
"vals",
"=",
"{",
"\"name\"",
":",
"\"Ecobee\"",
",",
"\"modelNumber\"",
":",
"\"athenaSmart\"",
",",
"\"program\"",
":",
"{",
"\"climates\"",
":",
"[",
"{",
"\"name\"",
":",
"\"Climate1\"",
",",
"\"climateRef\"",
":",
... | [
11,
0
] | [
54,
22
] | python | en | ['en', 'nl', 'en'] | True |
data_fixture | (ecobee_fixture) | Set up data mock. | Set up data mock. | def data_fixture(ecobee_fixture):
"""Set up data mock."""
data = mock.Mock()
data.ecobee.get_thermostat.return_value = ecobee_fixture
return data | [
"def",
"data_fixture",
"(",
"ecobee_fixture",
")",
":",
"data",
"=",
"mock",
".",
"Mock",
"(",
")",
"data",
".",
"ecobee",
".",
"get_thermostat",
".",
"return_value",
"=",
"ecobee_fixture",
"return",
"data"
] | [
58,
0
] | [
62,
15
] | python | en | ['en', 'da', 'en'] | True |
thermostat_fixture | (data) | Set up ecobee thermostat object. | Set up ecobee thermostat object. | def thermostat_fixture(data):
"""Set up ecobee thermostat object."""
thermostat = data.ecobee.get_thermostat(1)
return ecobee.Thermostat(data, 1, thermostat) | [
"def",
"thermostat_fixture",
"(",
"data",
")",
":",
"thermostat",
"=",
"data",
".",
"ecobee",
".",
"get_thermostat",
"(",
"1",
")",
"return",
"ecobee",
".",
"Thermostat",
"(",
"data",
",",
"1",
",",
"thermostat",
")"
] | [
66,
0
] | [
69,
49
] | python | en | ['en', 'en', 'en'] | True |
test_name | (thermostat) | Test name property. | Test name property. | async def test_name(thermostat):
"""Test name property."""
assert thermostat.name == "Ecobee" | [
"async",
"def",
"test_name",
"(",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"name",
"==",
"\"Ecobee\""
] | [
72,
0
] | [
74,
38
] | python | en | ['en', 'en', 'en'] | True |
test_current_temperature | (ecobee_fixture, thermostat) | Test current temperature. | Test current temperature. | async def test_current_temperature(ecobee_fixture, thermostat):
"""Test current temperature."""
assert thermostat.current_temperature == 30
ecobee_fixture["runtime"]["actualTemperature"] = const.HTTP_NOT_FOUND
assert thermostat.current_temperature == 40.4 | [
"async",
"def",
"test_current_temperature",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"current_temperature",
"==",
"30",
"ecobee_fixture",
"[",
"\"runtime\"",
"]",
"[",
"\"actualTemperature\"",
"]",
"=",
"const",
".",
"HTTP_NOT... | [
77,
0
] | [
81,
49
] | python | en | ['en', 'la', 'en'] | True |
test_target_temperature_low | (ecobee_fixture, thermostat) | Test target low temperature. | Test target low temperature. | async def test_target_temperature_low(ecobee_fixture, thermostat):
"""Test target low temperature."""
assert thermostat.target_temperature_low == 40
ecobee_fixture["runtime"]["desiredHeat"] = 502
assert thermostat.target_temperature_low == 50 | [
"async",
"def",
"test_target_temperature_low",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"target_temperature_low",
"==",
"40",
"ecobee_fixture",
"[",
"\"runtime\"",
"]",
"[",
"\"desiredHeat\"",
"]",
"=",
"502",
"assert",
"therm... | [
84,
0
] | [
88,
50
] | python | en | ['en', 'la', 'en'] | True |
test_target_temperature_high | (ecobee_fixture, thermostat) | Test target high temperature. | Test target high temperature. | async def test_target_temperature_high(ecobee_fixture, thermostat):
"""Test target high temperature."""
assert thermostat.target_temperature_high == 20
ecobee_fixture["runtime"]["desiredCool"] = 679
assert thermostat.target_temperature_high == 68 | [
"async",
"def",
"test_target_temperature_high",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"target_temperature_high",
"==",
"20",
"ecobee_fixture",
"[",
"\"runtime\"",
"]",
"[",
"\"desiredCool\"",
"]",
"=",
"679",
"assert",
"the... | [
91,
0
] | [
95,
51
] | python | en | ['en', 'la', 'en'] | True |
test_target_temperature | (ecobee_fixture, thermostat) | Test target temperature. | Test target temperature. | async def test_target_temperature(ecobee_fixture, thermostat):
"""Test target temperature."""
assert thermostat.target_temperature is None
ecobee_fixture["settings"]["hvacMode"] = "heat"
assert thermostat.target_temperature == 40
ecobee_fixture["settings"]["hvacMode"] = "cool"
assert thermostat.... | [
"async",
"def",
"test_target_temperature",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"target_temperature",
"is",
"None",
"ecobee_fixture",
"[",
"\"settings\"",
"]",
"[",
"\"hvacMode\"",
"]",
"=",
"\"heat\"",
"assert",
"thermost... | [
98,
0
] | [
108,
48
] | python | en | ['en', 'la', 'en'] | True |
test_desired_fan_mode | (ecobee_fixture, thermostat) | Test desired fan mode property. | Test desired fan mode property. | async def test_desired_fan_mode(ecobee_fixture, thermostat):
"""Test desired fan mode property."""
assert thermostat.fan_mode == "on"
ecobee_fixture["runtime"]["desiredFanMode"] = "auto"
assert thermostat.fan_mode == "auto" | [
"async",
"def",
"test_desired_fan_mode",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"fan_mode",
"==",
"\"on\"",
"ecobee_fixture",
"[",
"\"runtime\"",
"]",
"[",
"\"desiredFanMode\"",
"]",
"=",
"\"auto\"",
"assert",
"thermostat",
... | [
111,
0
] | [
115,
40
] | python | en | ['en', 'fy', 'en'] | True |
test_fan | (ecobee_fixture, thermostat) | Test fan property. | Test fan property. | async def test_fan(ecobee_fixture, thermostat):
"""Test fan property."""
assert const.STATE_ON == thermostat.fan
ecobee_fixture["equipmentStatus"] = ""
assert thermostat.fan == STATE_OFF
ecobee_fixture["equipmentStatus"] = "heatPump, heatPump2"
assert thermostat.fan == STATE_OFF | [
"async",
"def",
"test_fan",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"const",
".",
"STATE_ON",
"==",
"thermostat",
".",
"fan",
"ecobee_fixture",
"[",
"\"equipmentStatus\"",
"]",
"=",
"\"\"",
"assert",
"thermostat",
".",
"fan",
"==",
"STATE... | [
118,
0
] | [
124,
38
] | python | en | ['en', 'fy', 'en'] | True |
test_hvac_mode | (ecobee_fixture, thermostat) | Test current operation property. | Test current operation property. | async def test_hvac_mode(ecobee_fixture, thermostat):
"""Test current operation property."""
assert thermostat.hvac_mode == "heat_cool"
ecobee_fixture["settings"]["hvacMode"] = "heat"
assert thermostat.hvac_mode == "heat"
ecobee_fixture["settings"]["hvacMode"] = "cool"
assert thermostat.hvac_mod... | [
"async",
"def",
"test_hvac_mode",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"hvac_mode",
"==",
"\"heat_cool\"",
"ecobee_fixture",
"[",
"\"settings\"",
"]",
"[",
"\"hvacMode\"",
"]",
"=",
"\"heat\"",
"assert",
"thermostat",
".... | [
127,
0
] | [
137,
40
] | python | en | ['nl', 'en', 'en'] | True |
test_hvac_modes | (thermostat) | Test operation list property. | Test operation list property. | async def test_hvac_modes(thermostat):
"""Test operation list property."""
assert ["heat_cool", "heat", "cool", "off"] == thermostat.hvac_modes | [
"async",
"def",
"test_hvac_modes",
"(",
"thermostat",
")",
":",
"assert",
"[",
"\"heat_cool\"",
",",
"\"heat\"",
",",
"\"cool\"",
",",
"\"off\"",
"]",
"==",
"thermostat",
".",
"hvac_modes"
] | [
140,
0
] | [
142,
72
] | python | en | ['nl', 'en', 'en'] | True |
test_hvac_mode2 | (ecobee_fixture, thermostat) | Test operation mode property. | Test operation mode property. | async def test_hvac_mode2(ecobee_fixture, thermostat):
"""Test operation mode property."""
assert thermostat.hvac_mode == "heat_cool"
ecobee_fixture["settings"]["hvacMode"] = "heat"
assert thermostat.hvac_mode == "heat" | [
"async",
"def",
"test_hvac_mode2",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"thermostat",
".",
"hvac_mode",
"==",
"\"heat_cool\"",
"ecobee_fixture",
"[",
"\"settings\"",
"]",
"[",
"\"hvacMode\"",
"]",
"=",
"\"heat\"",
"assert",
"thermostat",
"... | [
145,
0
] | [
149,
41
] | python | en | ['nl', 'en', 'en'] | True |
test_extra_state_attributes | (ecobee_fixture, thermostat) | Test device state attributes property. | Test device state attributes property. | async def test_extra_state_attributes(ecobee_fixture, thermostat):
"""Test device state attributes property."""
ecobee_fixture["equipmentStatus"] = "heatPump2"
assert {
"fan": "off",
"climate_mode": "Climate1",
"fan_min_on_time": 10,
"equipment_running": "heatPump2",
} ==... | [
"async",
"def",
"test_extra_state_attributes",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"ecobee_fixture",
"[",
"\"equipmentStatus\"",
"]",
"=",
"\"heatPump2\"",
"assert",
"{",
"\"fan\"",
":",
"\"off\"",
",",
"\"climate_mode\"",
":",
"\"Climate1\"",
",",
"... | [
152,
0
] | [
199,
42
] | python | en | ['fr', 'en', 'en'] | True |
test_is_aux_heat_on | (ecobee_fixture, thermostat) | Test aux heat property. | Test aux heat property. | async def test_is_aux_heat_on(ecobee_fixture, thermostat):
"""Test aux heat property."""
assert not thermostat.is_aux_heat
ecobee_fixture["equipmentStatus"] = "fan, auxHeat"
assert thermostat.is_aux_heat | [
"async",
"def",
"test_is_aux_heat_on",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"assert",
"not",
"thermostat",
".",
"is_aux_heat",
"ecobee_fixture",
"[",
"\"equipmentStatus\"",
"]",
"=",
"\"fan, auxHeat\"",
"assert",
"thermostat",
".",
"is_aux_heat"
] | [
202,
0
] | [
206,
33
] | python | fr | ['fr', 'fr', 'fr'] | True |
test_set_temperature | (ecobee_fixture, thermostat, data) | Test set temperature. | Test set temperature. | async def test_set_temperature(ecobee_fixture, thermostat, data):
"""Test set temperature."""
# Auto -> Auto
data.reset_mock()
thermostat.set_temperature(target_temp_low=20, target_temp_high=30)
data.ecobee.set_hold_temp.assert_has_calls(
[mock.call(1, 30, 20, "nextTransition", None)]
)
... | [
"async",
"def",
"test_set_temperature",
"(",
"ecobee_fixture",
",",
"thermostat",
",",
"data",
")",
":",
"# Auto -> Auto",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"set_temperature",
"(",
"target_temp_low",
"=",
"20",
",",
"target_temp_high",
"=",
... | [
209,
0
] | [
245,
47
] | python | en | ['en', 'la', 'en'] | True |
test_set_hvac_mode | (thermostat, data) | Test operation mode setter. | Test operation mode setter. | async def test_set_hvac_mode(thermostat, data):
"""Test operation mode setter."""
data.reset_mock()
thermostat.set_hvac_mode("heat_cool")
data.ecobee.set_hvac_mode.assert_has_calls([mock.call(1, "auto")])
data.reset_mock()
thermostat.set_hvac_mode("heat")
data.ecobee.set_hvac_mode.assert_has... | [
"async",
"def",
"test_set_hvac_mode",
"(",
"thermostat",
",",
"data",
")",
":",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"set_hvac_mode",
"(",
"\"heat_cool\"",
")",
"data",
".",
"ecobee",
".",
"set_hvac_mode",
".",
"assert_has_calls",
"(",
"[",
... | [
248,
0
] | [
255,
70
] | python | it | ['nl', 'no', 'it'] | False |
test_set_fan_min_on_time | (thermostat, data) | Test fan min on time setter. | Test fan min on time setter. | async def test_set_fan_min_on_time(thermostat, data):
"""Test fan min on time setter."""
data.reset_mock()
thermostat.set_fan_min_on_time(15)
data.ecobee.set_fan_min_on_time.assert_has_calls([mock.call(1, 15)])
data.reset_mock()
thermostat.set_fan_min_on_time(20)
data.ecobee.set_fan_min_on_t... | [
"async",
"def",
"test_set_fan_min_on_time",
"(",
"thermostat",
",",
"data",
")",
":",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"set_fan_min_on_time",
"(",
"15",
")",
"data",
".",
"ecobee",
".",
"set_fan_min_on_time",
".",
"assert_has_calls",
"(",
... | [
258,
0
] | [
265,
72
] | python | en | ['en', 'fy', 'en'] | True |
test_resume_program | (thermostat, data) | Test resume program. | Test resume program. | async def test_resume_program(thermostat, data):
"""Test resume program."""
# False
data.reset_mock()
thermostat.resume_program(False)
data.ecobee.resume_program.assert_has_calls([mock.call(1, "false")])
data.reset_mock()
thermostat.resume_program(None)
data.ecobee.resume_program.assert_... | [
"async",
"def",
"test_resume_program",
"(",
"thermostat",
",",
"data",
")",
":",
"# False",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"resume_program",
"(",
"False",
")",
"data",
".",
"ecobee",
".",
"resume_program",
".",
"assert_has_calls",
"(",... | [
268,
0
] | [
287,
71
] | python | en | ['en', 'no', 'en'] | True |
test_hold_preference | (ecobee_fixture, thermostat) | Test hold preference. | Test hold preference. | async def test_hold_preference(ecobee_fixture, thermostat):
"""Test hold preference."""
ecobee_fixture["settings"]["holdAction"] = "indefinite"
assert thermostat.hold_preference() == "indefinite"
for action in ["useEndTime2hour", "useEndTime4hour"]:
ecobee_fixture["settings"]["holdAction"] = act... | [
"async",
"def",
"test_hold_preference",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"ecobee_fixture",
"[",
"\"settings\"",
"]",
"[",
"\"holdAction\"",
"]",
"=",
"\"indefinite\"",
"assert",
"thermostat",
".",
"hold_preference",
"(",
")",
"==",
"\"indefinite\"... | [
290,
0
] | [
302,
63
] | python | en | ['en', 'en', 'en'] | True |
test_hold_hours | (ecobee_fixture, thermostat) | Test hold hours preference. | Test hold hours preference. | def test_hold_hours(ecobee_fixture, thermostat):
"""Test hold hours preference."""
ecobee_fixture["settings"]["holdAction"] = "useEndTime2hour"
assert thermostat.hold_hours() == 2
ecobee_fixture["settings"]["holdAction"] = "useEndTime4hour"
assert thermostat.hold_hours() == 4
for action in [
... | [
"def",
"test_hold_hours",
"(",
"ecobee_fixture",
",",
"thermostat",
")",
":",
"ecobee_fixture",
"[",
"\"settings\"",
"]",
"[",
"\"holdAction\"",
"]",
"=",
"\"useEndTime2hour\"",
"assert",
"thermostat",
".",
"hold_hours",
"(",
")",
"==",
"2",
"ecobee_fixture",
"[",... | [
305,
0
] | [
317,
46
] | python | en | ['en', 'en', 'en'] | True |
test_set_fan_mode_on | (thermostat, data) | Test set fan mode to on. | Test set fan mode to on. | async def test_set_fan_mode_on(thermostat, data):
"""Test set fan mode to on."""
data.reset_mock()
thermostat.set_fan_mode("on")
data.ecobee.set_fan_mode.assert_has_calls(
[mock.call(1, "on", "nextTransition", holdHours=None)]
) | [
"async",
"def",
"test_set_fan_mode_on",
"(",
"thermostat",
",",
"data",
")",
":",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"set_fan_mode",
"(",
"\"on\"",
")",
"data",
".",
"ecobee",
".",
"set_fan_mode",
".",
"assert_has_calls",
"(",
"[",
"mock... | [
320,
0
] | [
326,
5
] | python | en | ['en', 'fy', 'en'] | True |
test_set_fan_mode_auto | (thermostat, data) | Test set fan mode to auto. | Test set fan mode to auto. | async def test_set_fan_mode_auto(thermostat, data):
"""Test set fan mode to auto."""
data.reset_mock()
thermostat.set_fan_mode("auto")
data.ecobee.set_fan_mode.assert_has_calls(
[mock.call(1, "auto", "nextTransition", holdHours=None)]
) | [
"async",
"def",
"test_set_fan_mode_auto",
"(",
"thermostat",
",",
"data",
")",
":",
"data",
".",
"reset_mock",
"(",
")",
"thermostat",
".",
"set_fan_mode",
"(",
"\"auto\"",
")",
"data",
".",
"ecobee",
".",
"set_fan_mode",
".",
"assert_has_calls",
"(",
"[",
"... | [
329,
0
] | [
335,
5
] | python | en | ['en', 'fy', 'nl'] | False |
enable | () | Enable the detection of I/O in the event loop. | Enable the detection of I/O in the event loop. | def enable() -> None:
"""Enable the detection of I/O in the event loop."""
# Prevent urllib3 and requests doing I/O in event loop
HTTPConnection.putrequest = protect_loop(HTTPConnection.putrequest) | [
"def",
"enable",
"(",
")",
"->",
"None",
":",
"# Prevent urllib3 and requests doing I/O in event loop",
"HTTPConnection",
".",
"putrequest",
"=",
"protect_loop",
"(",
"HTTPConnection",
".",
"putrequest",
")"
] | [
6,
0
] | [
9,
71
] | python | en | ['en', 'en', 'en'] | True |
embedded_broker_deprecated | (value) | Warn user that embedded MQTT broker is deprecated. | Warn user that embedded MQTT broker is deprecated. | def embedded_broker_deprecated(value):
"""Warn user that embedded MQTT broker is deprecated."""
_LOGGER.warning(
"The embedded MQTT broker has been deprecated and will stop working"
"after June 5th, 2019. Use an external broker instead. For"
"instructions, see https://www.home-assistant.... | [
"def",
"embedded_broker_deprecated",
"(",
"value",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"The embedded MQTT broker has been deprecated and will stop working\"",
"\"after June 5th, 2019. Use an external broker instead. For\"",
"\"instructions, see https://www.home-assistant.io/docs/mqtt... | [
155,
0
] | [
162,
16
] | python | en | ['en', 'fy', 'en'] | True |
_build_publish_data | (topic: Any, qos: int, retain: bool) | Build the arguments for the publish service without the payload. | Build the arguments for the publish service without the payload. | def _build_publish_data(topic: Any, qos: int, retain: bool) -> ServiceDataType:
"""Build the arguments for the publish service without the payload."""
data = {ATTR_TOPIC: topic}
if qos is not None:
data[ATTR_QOS] = qos
if retain is not None:
data[ATTR_RETAIN] = retain
return data | [
"def",
"_build_publish_data",
"(",
"topic",
":",
"Any",
",",
"qos",
":",
"int",
",",
"retain",
":",
"bool",
")",
"->",
"ServiceDataType",
":",
"data",
"=",
"{",
"ATTR_TOPIC",
":",
"topic",
"}",
"if",
"qos",
"is",
"not",
"None",
":",
"data",
"[",
"ATT... | [
249,
0
] | [
256,
15
] | python | en | ['en', 'en', 'en'] | True |
publish | (hass: HomeAssistant, topic, payload, qos=None, retain=None) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def publish(hass: HomeAssistant, topic, payload, qos=None, retain=None) -> None:
"""Publish message to an MQTT topic."""
hass.add_job(async_publish, hass, topic, payload, qos, retain) | [
"def",
"publish",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
",",
"payload",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"hass",
".",
"add_job",
"(",
"async_publish",
",",
"hass",
",",
"topic",
",",
"payload",
"... | [
260,
0
] | [
262,
66
] | python | en | ['en', 'en', 'en'] | True |
async_publish | (
hass: HomeAssistant, topic: Any, payload, qos=None, retain=None
) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def async_publish(
hass: HomeAssistant, topic: Any, payload, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic."""
data = _build_publish_data(topic, qos, retain)
data[ATTR_PAYLOAD] = payload
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_PUBLISH, data)) | [
"def",
"async_publish",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
":",
"Any",
",",
"payload",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"_build_publish_data",
"(",
"topic",
",",
"qos",
",",
"retain... | [
267,
0
] | [
273,
83
] | python | en | ['en', 'en', 'en'] | True |
publish_template | (
hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) | Publish message to an MQTT topic. | Publish message to an MQTT topic. | def publish_template(
hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic."""
hass.add_job(async_publish_template, hass, topic, payload_template, qos, retain) | [
"def",
"publish_template",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
",",
"payload_template",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"hass",
".",
"add_job",
"(",
"async_publish_template",
",",
"hass",
",",
"topi... | [
277,
0
] | [
281,
84
] | python | en | ['en', 'en', 'en'] | True |
async_publish_template | (
hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) | Publish message to an MQTT topic using a template payload. | Publish message to an MQTT topic using a template payload. | def async_publish_template(
hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) -> None:
"""Publish message to an MQTT topic using a template payload."""
data = _build_publish_data(topic, qos, retain)
data[ATTR_PAYLOAD_TEMPLATE] = payload_template
hass.async_create_task(hass.servic... | [
"def",
"async_publish_template",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
",",
"payload_template",
",",
"qos",
"=",
"None",
",",
"retain",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"_build_publish_data",
"(",
"topic",
",",
"qos",
",",
"reta... | [
285,
0
] | [
291,
83
] | python | en | ['en', 'en', 'en'] | True |
wrap_msg_callback | (
msg_callback: AsyncDeprecatedMessageCallbackType | DeprecatedMessageCallbackType,
) | Wrap an MQTT message callback to support deprecated signature. | Wrap an MQTT message callback to support deprecated signature. | def wrap_msg_callback(
msg_callback: AsyncDeprecatedMessageCallbackType | DeprecatedMessageCallbackType,
) -> AsyncMessageCallbackType | MessageCallbackType:
"""Wrap an MQTT message callback to support deprecated signature."""
# Check for partials to properly determine if coroutine function
check_func =... | [
"def",
"wrap_msg_callback",
"(",
"msg_callback",
":",
"AsyncDeprecatedMessageCallbackType",
"|",
"DeprecatedMessageCallbackType",
",",
")",
"->",
"AsyncMessageCallbackType",
"|",
"MessageCallbackType",
":",
"# Check for partials to properly determine if coroutine function",
"check_fu... | [
300,
0
] | [
328,
23
] | python | en | ['en', 'en', 'en'] | True |
async_subscribe | (
hass: HomeAssistant,
topic: str,
msg_callback: AsyncMessageCallbackType
| MessageCallbackType
| DeprecatedMessageCallbackType
| AsyncDeprecatedMessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str | None = "utf-8",
) | Subscribe to an MQTT topic.
Call the return value to unsubscribe.
| Subscribe to an MQTT topic. | async def async_subscribe(
hass: HomeAssistant,
topic: str,
msg_callback: AsyncMessageCallbackType
| MessageCallbackType
| DeprecatedMessageCallbackType
| AsyncDeprecatedMessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str | None = "utf-8",
):
"""Subscribe to an MQTT topic.
... | [
"async",
"def",
"async_subscribe",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"AsyncMessageCallbackType",
"|",
"MessageCallbackType",
"|",
"DeprecatedMessageCallbackType",
"|",
"AsyncDeprecatedMessageCallbackType",
",",
"qos",
... | [
332,
0
] | [
379,
23
] | python | en | ['en', 'en', 'en'] | True |
subscribe | (
hass: HomeAssistant,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str = "utf-8",
) | Subscribe to an MQTT topic. | Subscribe to an MQTT topic. | def subscribe(
hass: HomeAssistant,
topic: str,
msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str = "utf-8",
) -> Callable[[], None]:
"""Subscribe to an MQTT topic."""
async_remove = asyncio.run_coroutine_threadsafe(
async_subscribe(hass, topic, msg_callback, q... | [
"def",
"subscribe",
"(",
"hass",
":",
"HomeAssistant",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"MessageCallbackType",
",",
"qos",
":",
"int",
"=",
"DEFAULT_QOS",
",",
"encoding",
":",
"str",
"=",
"\"utf-8\"",
",",
")",
"->",
"Callable",
"[",
... | [
383,
0
] | [
399,
17
] | python | en | ['en', 'en', 'en'] | True |
_async_setup_discovery | (
hass: HomeAssistant, conf: ConfigType, config_entry
) | Try to start the discovery of MQTT devices.
This method is a coroutine.
| Try to start the discovery of MQTT devices. | async def _async_setup_discovery(
hass: HomeAssistant, conf: ConfigType, config_entry
) -> None:
"""Try to start the discovery of MQTT devices.
This method is a coroutine.
"""
await discovery.async_start(hass, conf[CONF_DISCOVERY_PREFIX], config_entry) | [
"async",
"def",
"_async_setup_discovery",
"(",
"hass",
":",
"HomeAssistant",
",",
"conf",
":",
"ConfigType",
",",
"config_entry",
")",
"->",
"None",
":",
"await",
"discovery",
".",
"async_start",
"(",
"hass",
",",
"conf",
"[",
"CONF_DISCOVERY_PREFIX",
"]",
","... | [
402,
0
] | [
409,
80
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Start the MQTT protocol service. | Start the MQTT protocol service. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Start the MQTT protocol service."""
conf: ConfigType | None = config.get(DOMAIN)
websocket_api.async_register_command(hass, websocket_subscribe)
websocket_api.async_register_command(hass, websocket_remove_device)
websocket_a... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"conf",
":",
"ConfigType",
"|",
"None",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"websocket_api",
".",
"async_register_command",... | [
412,
0
] | [
437,
15
] | python | en | ['en', 'it', 'en'] | True |
_merge_config | (entry, conf) | Merge configuration.yaml config with config entry. | Merge configuration.yaml config with config entry. | def _merge_config(entry, conf):
"""Merge configuration.yaml config with config entry."""
return {**conf, **entry.data} | [
"def",
"_merge_config",
"(",
"entry",
",",
"conf",
")",
":",
"return",
"{",
"*",
"*",
"conf",
",",
"*",
"*",
"entry",
".",
"data",
"}"
] | [
440,
0
] | [
442,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Load a config entry. | Load a config entry. | async def async_setup_entry(hass, entry):
"""Load a config entry."""
conf = hass.data.get(DATA_MQTT_CONFIG)
# Config entry was created because user had configuration.yaml entry
# They removed that, so remove entry.
if conf is None and entry.source == config_entries.SOURCE_IMPORT:
hass.async... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"conf",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_MQTT_CONFIG",
")",
"# Config entry was created because user had configuration.yaml entry",
"# They removed that, so remove entry.",
"if",
"co... | [
445,
0
] | [
550,
15
] | python | en | ['en', 'en', 'en'] | True |
_raise_on_error | (result_code: int | None) | Raise error if error result. | Raise error if error result. | def _raise_on_error(result_code: int | None) -> None:
"""Raise error if error result."""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
if result_code is not None and result_code != 0:
raise HomeAssistantError(
f"Error talking to MQTT: {mqtt.error_string(r... | [
"def",
"_raise_on_error",
"(",
"result_code",
":",
"int",
"|",
"None",
")",
"->",
"None",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"if",
"result_code",
"is",
"not",
"None",
"and",
"result_code"... | [
974,
0
] | [
982,
9
] | python | da | ['da', 'la', 'en'] | False |
websocket_mqtt_info | (hass, connection, msg) | Get MQTT debug info for device. | Get MQTT debug info for device. | async def websocket_mqtt_info(hass, connection, msg):
"""Get MQTT debug info for device."""
device_id = msg["device_id"]
mqtt_info = await debug_info.info_for_device(hass, device_id)
connection.send_result(msg["id"], mqtt_info) | [
"async",
"def",
"websocket_mqtt_info",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"mqtt_info",
"=",
"await",
"debug_info",
".",
"info_for_device",
"(",
"hass",
",",
"device_id",
")",
"connection",
... | [
999,
0
] | [
1004,
48
] | python | en | ['da', 'en', 'en'] | True |
websocket_remove_device | (hass, connection, msg) | Delete device. | Delete device. | async def websocket_remove_device(hass, connection, msg):
"""Delete device."""
device_id = msg["device_id"]
dev_registry = await hass.helpers.device_registry.async_get_registry()
device = dev_registry.async_get(device_id)
if not device:
connection.send_error(
msg["id"], websocke... | [
"async",
"def",
"websocket_remove_device",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"dev_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
"... | [
1011,
0
] | [
1033,
5
] | python | it | ['it', 'it', 'en'] | False |
websocket_subscribe | (hass, connection, msg) | Subscribe to a MQTT topic. | Subscribe to a MQTT topic. | async def websocket_subscribe(hass, connection, msg):
"""Subscribe to a MQTT topic."""
if not connection.user.is_admin:
raise Unauthorized
async def forward_messages(mqttmsg: ReceiveMessage):
"""Forward events to websocket."""
connection.send_message(
websocket_api.event... | [
"async",
"def",
"websocket_subscribe",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"if",
"not",
"connection",
".",
"user",
".",
"is_admin",
":",
"raise",
"Unauthorized",
"async",
"def",
"forward_messages",
"(",
"mqttmsg",
":",
"ReceiveMessage",
")",
... | [
1043,
0
] | [
1066,
68
] | python | en | ['en', 'en', 'en'] | True |
async_subscribe_connection_status | (
hass: HomeAssistant, connection_status_callback: ConnectionStatusCallback
) | Subscribe to MQTT connection changes. | Subscribe to MQTT connection changes. | def async_subscribe_connection_status(
hass: HomeAssistant, connection_status_callback: ConnectionStatusCallback
) -> Callable[[], None]:
"""Subscribe to MQTT connection changes."""
connection_status_callback_job = HassJob(connection_status_callback)
async def connected():
task = hass.async_run... | [
"def",
"async_subscribe_connection_status",
"(",
"hass",
":",
"HomeAssistant",
",",
"connection_status_callback",
":",
"ConnectionStatusCallback",
")",
"->",
"Callable",
"[",
"[",
"]",
",",
"None",
"]",
":",
"connection_status_callback_job",
"=",
"HassJob",
"(",
"conn... | [
1073,
0
] | [
1099,
22
] | python | en | ['en', 'en', 'en'] | True |
is_connected | (hass: HomeAssistant) | Return if MQTT client is connected. | Return if MQTT client is connected. | def is_connected(hass: HomeAssistant) -> bool:
"""Return if MQTT client is connected."""
return hass.data[DATA_MQTT].connected | [
"def",
"is_connected",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"bool",
":",
"return",
"hass",
".",
"data",
"[",
"DATA_MQTT",
"]",
".",
"connected"
] | [
1102,
0
] | [
1104,
41
] | python | en | ['en', 'en', 'en'] | True |
MQTT.__init__ | (
self,
hass: HomeAssistant,
config_entry,
conf,
) | Initialize Home Assistant MQTT client. | Initialize Home Assistant MQTT client. | def __init__(
self,
hass: HomeAssistant,
config_entry,
conf,
) -> None:
"""Initialize Home Assistant MQTT client."""
# We don't import on the top because some integrations
# should be able to optionally rely on MQTT.
import paho.mqtt.client as mqtt # ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
",",
"conf",
",",
")",
"->",
"None",
":",
"# We don't import on the top because some integrations",
"# should be able to optionally rely on MQTT.",
"import",
"paho",
".",
"mqtt",
"."... | [
567,
4
] | [
601,
78
] | python | fr | ['fr', 'fr', 'en'] | True |
MQTT.async_config_entry_updated | (hass, entry) | Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is config entry options changing.
| Handle signals of config entry being updated. | async def async_config_entry_updated(hass, entry) -> None:
"""Handle signals of config entry being updated.
This is a static method because a class method (bound method), can not be used with weak references.
Causes for this is config entry options changing.
"""
self = hass.data... | [
"async",
"def",
"async_config_entry_updated",
"(",
"hass",
",",
"entry",
")",
"->",
"None",
":",
"self",
"=",
"hass",
".",
"data",
"[",
"DATA_MQTT",
"]",
"conf",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_MQTT_CONFIG",
")",
"if",
"conf",
"is",
"N... | [
604,
4
] | [
623,
64
] | python | en | ['en', 'en', 'en'] | True |
MQTT.init_client | (self) | Initialize paho client. | Initialize paho client. | def init_client(self):
"""Initialize paho client."""
# We don't import on the top because some integrations
# should be able to optionally rely on MQTT.
import paho.mqtt.client as mqtt # pylint: disable=import-outside-toplevel
if self.conf[CONF_PROTOCOL] == PROTOCOL_31:
... | [
"def",
"init_client",
"(",
"self",
")",
":",
"# We don't import on the top because some integrations",
"# should be able to optionally rely on MQTT.",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"# pylint: disable=import-outside-toplevel",
"if",
"self",
".",
"... | [
625,
4
] | [
691,
13
] | python | en | ['en', 'fr', 'it'] | False |
MQTT.async_publish | (
self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
) | Publish a MQTT message. | Publish a MQTT message. | async def async_publish(
self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
) -> None:
"""Publish a MQTT message."""
async with self._paho_lock:
msg_info = await self.hass.async_add_executor_job(
self._mqttc.publish, topic, payload, qos, retain
... | [
"async",
"def",
"async_publish",
"(",
"self",
",",
"topic",
":",
"str",
",",
"payload",
":",
"PublishPayloadType",
",",
"qos",
":",
"int",
",",
"retain",
":",
"bool",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"msg_info",
... | [
693,
4
] | [
708,
46
] | python | en | ['en', 'fr', 'en'] | True |
MQTT.async_connect | (self) | Connect to the host. Does not process messages yet. | Connect to the host. Does not process messages yet. | async def async_connect(self) -> None:
"""Connect to the host. Does not process messages yet."""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
result: int | None = None
try:
result = await self.hass.async_add_executor_job(
... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
"->",
"None",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"result",
":",
"int",
"|",
"None",
"=",
"None",
"try",
":",
"result",
"=",
"await",... | [
710,
4
] | [
731,
32
] | python | en | ['en', 'en', 'en'] | True |
MQTT.async_disconnect | (self) | Stop the MQTT client. | Stop the MQTT client. | async def async_disconnect(self):
"""Stop the MQTT client."""
def stop():
"""Stop the MQTT client."""
# Do not disconnect, we want the broker to always publish will
self._mqttc.loop_stop()
await self.hass.async_add_executor_job(stop) | [
"async",
"def",
"async_disconnect",
"(",
"self",
")",
":",
"def",
"stop",
"(",
")",
":",
"\"\"\"Stop the MQTT client.\"\"\"",
"# Do not disconnect, we want the broker to always publish will",
"self",
".",
"_mqttc",
".",
"loop_stop",
"(",
")",
"await",
"self",
".",
"ha... | [
733,
4
] | [
741,
52
] | python | en | ['en', 'fr', 'en'] | True |
MQTT.async_subscribe | (
self,
topic: str,
msg_callback: MessageCallbackType,
qos: int,
encoding: str | None = None,
) | Set up a subscription to a topic with the provided qos.
This method is a coroutine.
| Set up a subscription to a topic with the provided qos. | async def async_subscribe(
self,
topic: str,
msg_callback: MessageCallbackType,
qos: int,
encoding: str | None = None,
) -> Callable[[], None]:
"""Set up a subscription to a topic with the provided qos.
This method is a coroutine.
"""
if not i... | [
"async",
"def",
"async_subscribe",
"(",
"self",
",",
"topic",
":",
"str",
",",
"msg_callback",
":",
"MessageCallbackType",
",",
"qos",
":",
"int",
",",
"encoding",
":",
"str",
"|",
"None",
"=",
"None",
",",
")",
"->",
"Callable",
"[",
"[",
"]",
",",
... | [
743,
4
] | [
784,
27
] | python | en | ['en', 'en', 'en'] | True |
MQTT._async_unsubscribe | (self, topic: str) | Unsubscribe from a topic.
This method is a coroutine.
| Unsubscribe from a topic. | async def _async_unsubscribe(self, topic: str) -> None:
"""Unsubscribe from a topic.
This method is a coroutine.
"""
async with self._paho_lock:
result: int | None = None
result, mid = await self.hass.async_add_executor_job(
self._mqttc.unsubscrib... | [
"async",
"def",
"_async_unsubscribe",
"(",
"self",
",",
"topic",
":",
"str",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"result",
":",
"int",
"|",
"None",
"=",
"None",
"result",
",",
"mid",
"=",
"await",
"self",
".",
"ha... | [
786,
4
] | [
798,
37
] | python | en | ['en', 'en', 'en'] | True |
MQTT._async_perform_subscription | (self, topic: str, qos: int) | Perform a paho-mqtt subscription. | Perform a paho-mqtt subscription. | async def _async_perform_subscription(self, topic: str, qos: int) -> None:
"""Perform a paho-mqtt subscription."""
async with self._paho_lock:
result: int | None = None
result, mid = await self.hass.async_add_executor_job(
self._mqttc.subscribe, topic, qos
... | [
"async",
"def",
"_async_perform_subscription",
"(",
"self",
",",
"topic",
":",
"str",
",",
"qos",
":",
"int",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_paho_lock",
":",
"result",
":",
"int",
"|",
"None",
"=",
"None",
"result",
",",
"mid",... | [
800,
4
] | [
809,
37
] | python | ca | ['hu', 'ca', 'pt'] | False |
MQTT._mqtt_on_connect | (self, _mqttc, _userdata, _flags, result_code: int) | On connect callback.
Resubscribe to all topics we were subscribed to and publish birth
message.
| On connect callback. | def _mqtt_on_connect(self, _mqttc, _userdata, _flags, result_code: int) -> None:
"""On connect callback.
Resubscribe to all topics we were subscribed to and publish birth
message.
"""
# pylint: disable=import-outside-toplevel
import paho.mqtt.client as mqtt
if r... | [
"def",
"_mqtt_on_connect",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"_flags",
",",
"result_code",
":",
"int",
")",
"->",
"None",
":",
"# pylint: disable=import-outside-toplevel",
"import",
"paho",
".",
"mqtt",
".",
"client",
"as",
"mqtt",
"if",
"resu... | [
811,
4
] | [
861,
13
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_message | (self, _mqttc, _userdata, msg) | Message received callback. | Message received callback. | def _mqtt_on_message(self, _mqttc, _userdata, msg) -> None:
"""Message received callback."""
self.hass.add_job(self._mqtt_handle_message, msg) | [
"def",
"_mqtt_on_message",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"msg",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"add_job",
"(",
"self",
".",
"_mqtt_handle_message",
",",
"msg",
")"
] | [
863,
4
] | [
865,
57
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_callback | (self, _mqttc, _userdata, mid, _granted_qos=None) | Publish / Subscribe / Unsubscribe callback. | Publish / Subscribe / Unsubscribe callback. | def _mqtt_on_callback(self, _mqttc, _userdata, mid, _granted_qos=None) -> None:
"""Publish / Subscribe / Unsubscribe callback."""
self.hass.add_job(self._mqtt_handle_mid, mid) | [
"def",
"_mqtt_on_callback",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"mid",
",",
"_granted_qos",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"add_job",
"(",
"self",
".",
"_mqtt_handle_mid",
",",
"mid",
")"
] | [
915,
4
] | [
917,
53
] | python | en | ['en', 'en', 'en'] | True |
MQTT._mqtt_on_disconnect | (self, _mqttc, _userdata, result_code: int) | Disconnected callback. | Disconnected callback. | def _mqtt_on_disconnect(self, _mqttc, _userdata, result_code: int) -> None:
"""Disconnected callback."""
self.connected = False
dispatcher_send(self.hass, MQTT_DISCONNECTED)
_LOGGER.warning(
"Disconnected from MQTT server %s:%s (%s)",
self.conf[CONF_BROKER],
... | [
"def",
"_mqtt_on_disconnect",
"(",
"self",
",",
"_mqttc",
",",
"_userdata",
",",
"result_code",
":",
"int",
")",
"->",
"None",
":",
"self",
".",
"connected",
"=",
"False",
"dispatcher_send",
"(",
"self",
".",
"hass",
",",
"MQTT_DISCONNECTED",
")",
"_LOGGER",... | [
927,
4
] | [
936,
9
] | python | en | ['en', 'en', 'en'] | False |
MQTT._wait_for_mid | (self, mid) | Wait for ACK from broker. | Wait for ACK from broker. | async def _wait_for_mid(self, mid):
"""Wait for ACK from broker."""
# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid
# may be executed first.
if mid not in self._pending_operations:
self._pending_operations[mid] = asyncio.Event()
try:
... | [
"async",
"def",
"_wait_for_mid",
"(",
"self",
",",
"mid",
")",
":",
"# Create the mid event if not created, either _mqtt_handle_mid or _wait_for_mid",
"# may be executed first.",
"if",
"mid",
"not",
"in",
"self",
".",
"_pending_operations",
":",
"self",
".",
"_pending_opera... | [
938,
4
] | [
951,
45
] | python | en | ['en', 'no', 'en'] | True |
mock_default_unifi_requests | (
aioclient_mock,
host,
site_id,
sites=None,
description=None,
clients_response=None,
clients_all_response=None,
devices_response=None,
dpiapp_response=None,
dpigroup_response=None,
wlans_response=None,
) | Mock default UniFi requests responses. | Mock default UniFi requests responses. | def mock_default_unifi_requests(
aioclient_mock,
host,
site_id,
sites=None,
description=None,
clients_response=None,
clients_all_response=None,
devices_response=None,
dpiapp_response=None,
dpigroup_response=None,
wlans_response=None,
):
"""Mock default UniFi requests resp... | [
"def",
"mock_default_unifi_requests",
"(",
"aioclient_mock",
",",
"host",
",",
"site_id",
",",
"sites",
"=",
"None",
",",
"description",
"=",
"None",
",",
"clients_response",
"=",
"None",
",",
"clients_all_response",
"=",
"None",
",",
"devices_response",
"=",
"N... | [
85,
0
] | [
148,
5
] | python | ca | ['fr', 'ca', 'en'] | False |
setup_unifi_integration | (
hass,
aioclient_mock=None,
*,
config=ENTRY_CONFIG,
options=ENTRY_OPTIONS,
sites=SITE,
site_description=DESCRIPTION,
clients_response=None,
clients_all_response=None,
devices_response=None,
dpiapp_response=None,
dpigroup_response=None,
wlans_response=None,
known_... | Create the UniFi controller. | Create the UniFi controller. | async def setup_unifi_integration(
hass,
aioclient_mock=None,
*,
config=ENTRY_CONFIG,
options=ENTRY_OPTIONS,
sites=SITE,
site_description=DESCRIPTION,
clients_response=None,
clients_all_response=None,
devices_response=None,
dpiapp_response=None,
dpigroup_response=None,
... | [
"async",
"def",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
"=",
"None",
",",
"*",
",",
"config",
"=",
"ENTRY_CONFIG",
",",
"options",
"=",
"ENTRY_OPTIONS",
",",
"sites",
"=",
"SITE",
",",
"site_description",
"=",
"DESCRIPTION",
",",
"client... | [
151,
0
] | [
208,
23
] | python | en | ['en', 'ro', 'en'] | True |
test_controller_setup | (hass, aioclient_mock) | Successful setup. | Successful setup. | async def test_controller_setup(hass, aioclient_mock):
"""Successful setup."""
with patch(
"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup",
return_value=True,
) as forward_entry_setup:
config_entry = await setup_unifi_integration(hass, aioclient_mock)
c... | [
"async",
"def",
"test_controller_setup",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup\"",
",",
"return_value",
"=",
"True",
",",
")",
"as",
"forward_entry_setup",
":",
"config_e... | [
211,
0
] | [
246,
73
] | python | en | ['en', 'ro', 'en'] | False |
test_controller_mac | (hass, aioclient_mock) | Test that it is possible to identify controller mac. | Test that it is possible to identify controller mac. | async def test_controller_mac(hass, aioclient_mock):
"""Test that it is possible to identify controller mac."""
config_entry = await setup_unifi_integration(
hass, aioclient_mock, clients_response=[CONTROLLER_HOST]
)
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
assert controll... | [
"async",
"def",
"test_controller_mac",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"config_entry",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"clients_response",
"=",
"[",
"CONTROLLER_HOST",
"]",
")",
"controller",
"=",
"ha... | [
249,
0
] | [
255,
51
] | python | en | ['en', 'en', 'en'] | True |
test_controller_not_accessible | (hass) | Retry to login gets scheduled when connection fails. | Retry to login gets scheduled when connection fails. | async def test_controller_not_accessible(hass):
"""Retry to login gets scheduled when connection fails."""
with patch(
"homeassistant.components.unifi.controller.get_controller",
side_effect=CannotConnect,
):
await setup_unifi_integration(hass)
assert hass.data[UNIFI_DOMAIN] == {... | [
"async",
"def",
"test_controller_not_accessible",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.unifi.controller.get_controller\"",
",",
"side_effect",
"=",
"CannotConnect",
",",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
")",
... | [
258,
0
] | [
265,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controller_trigger_reauth_flow | (hass) | Failed authentication trigger a reauthentication flow. | Failed authentication trigger a reauthentication flow. | async def test_controller_trigger_reauth_flow(hass):
"""Failed authentication trigger a reauthentication flow."""
with patch(
"homeassistant.components.unifi.controller.get_controller",
side_effect=AuthenticationRequired,
), patch.object(hass.config_entries.flow, "async_init") as mock_flow_i... | [
"async",
"def",
"test_controller_trigger_reauth_flow",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.unifi.controller.get_controller\"",
",",
"side_effect",
"=",
"AuthenticationRequired",
",",
")",
",",
"patch",
".",
"object",
"(",
"hass",
"."... | [
268,
0
] | [
276,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controller_unknown_error | (hass) | Unknown errors are handled. | Unknown errors are handled. | async def test_controller_unknown_error(hass):
"""Unknown errors are handled."""
with patch(
"homeassistant.components.unifi.controller.get_controller",
side_effect=Exception,
):
await setup_unifi_integration(hass)
assert hass.data[UNIFI_DOMAIN] == {} | [
"async",
"def",
"test_controller_unknown_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.unifi.controller.get_controller\"",
",",
"side_effect",
"=",
"Exception",
",",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
")",
"asse... | [
279,
0
] | [
286,
40
] | python | en | ['en', 'en', 'en'] | True |
test_config_entry_updated | (hass, aioclient_mock) | Calling reset when the entry has been setup. | Calling reset when the entry has been setup. | async def test_config_entry_updated(hass, aioclient_mock):
"""Calling reset when the entry has been setup."""
config_entry = await setup_unifi_integration(hass, aioclient_mock)
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
event_call = Mock()
unsub = async_dispatcher_connect(hass, con... | [
"async",
"def",
"test_config_entry_updated",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"config_entry",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"controller",
"=",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"[",
"c... | [
289,
0
] | [
307,
11
] | python | en | ['en', 'en', 'en'] | True |
test_reset_after_successful_setup | (hass, aioclient_mock) | Calling reset when the entry has been setup. | Calling reset when the entry has been setup. | async def test_reset_after_successful_setup(hass, aioclient_mock):
"""Calling reset when the entry has been setup."""
config_entry = await setup_unifi_integration(hass, aioclient_mock)
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
result = await controller.async_reset()
await hass.asy... | [
"async",
"def",
"test_reset_after_successful_setup",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"config_entry",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"controller",
"=",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"... | [
310,
0
] | [
318,
25
] | python | en | ['en', 'en', 'en'] | True |
test_reset_fails | (hass, aioclient_mock) | Calling reset when the entry has been setup can return false. | Calling reset when the entry has been setup can return false. | async def test_reset_fails(hass, aioclient_mock):
"""Calling reset when the entry has been setup can return false."""
config_entry = await setup_unifi_integration(hass, aioclient_mock)
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
with patch(
"homeassistant.config_entries.ConfigEn... | [
"async",
"def",
"test_reset_fails",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"config_entry",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"controller",
"=",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"[",
"config_ent... | [
321,
0
] | [
333,
26
] | python | en | ['en', 'en', 'en'] | True |
test_connection_state_signalling | (hass, aioclient_mock, mock_unifi_websocket) | Verify connection statesignalling and connection state are working. | Verify connection statesignalling and connection state are working. | async def test_connection_state_signalling(hass, aioclient_mock, mock_unifi_websocket):
"""Verify connection statesignalling and connection state are working."""
client = {
"hostname": "client",
"ip": "10.0.0.1",
"is_wired": True,
"last_seen": dt_util.as_timestamp(dt_util.utcnow(... | [
"async",
"def",
"test_connection_state_signalling",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_unifi_websocket",
")",
":",
"client",
"=",
"{",
"\"hostname\"",
":",
"\"client\"",
",",
"\"ip\"",
":",
"\"10.0.0.1\"",
",",
"\"is_wired\"",
":",
"True",
",",
"\"last... | [
336,
0
] | [
360,
67
] | python | en | ['en', 'en', 'en'] | True |
test_wireless_client_event_calls_update_wireless_devices | (
hass, aioclient_mock, mock_unifi_websocket
) | Call update_wireless_devices method when receiving wireless client event. | Call update_wireless_devices method when receiving wireless client event. | async def test_wireless_client_event_calls_update_wireless_devices(
hass, aioclient_mock, mock_unifi_websocket
):
"""Call update_wireless_devices method when receiving wireless client event."""
await setup_unifi_integration(hass, aioclient_mock)
with patch(
"homeassistant.components.unifi.contr... | [
"async",
"def",
"test_wireless_client_event_calls_update_wireless_devices",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_unifi_websocket",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"with",
"patch",
"(",
"\"homeassistant.compone... | [
363,
0
] | [
387,
55
] | python | en | ['en', 'en', 'en'] | True |
test_reconnect_mechanism | (hass, aioclient_mock, mock_unifi_websocket) | Verify reconnect prints only on first reconnection try. | Verify reconnect prints only on first reconnection try. | async def test_reconnect_mechanism(hass, aioclient_mock, mock_unifi_websocket):
"""Verify reconnect prints only on first reconnection try."""
await setup_unifi_integration(hass, aioclient_mock)
aioclient_mock.clear_requests()
aioclient_mock.post(f"https://{DEFAULT_HOST}:1234/api/login", status=502)
... | [
"async",
"def",
"test_reconnect_mechanism",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_unifi_websocket",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"aioclient_mock",
".",
"clear_requests",
"(",
")",
"aioclient_mock",
"."... | [
390,
0
] | [
412,
41
] | python | en | ['en', 'en', 'en'] | True |
test_reconnect_mechanism_exceptions | (
hass, aioclient_mock, mock_unifi_websocket, exception
) | Verify async_reconnect calls expected methods. | Verify async_reconnect calls expected methods. | async def test_reconnect_mechanism_exceptions(
hass, aioclient_mock, mock_unifi_websocket, exception
):
"""Verify async_reconnect calls expected methods."""
await setup_unifi_integration(hass, aioclient_mock)
with patch("aiounifi.Controller.login", side_effect=exception), patch(
"homeassistant.... | [
"async",
"def",
"test_reconnect_mechanism_exceptions",
"(",
"hass",
",",
"aioclient_mock",
",",
"mock_unifi_websocket",
",",
"exception",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"with",
"patch",
"(",
"\"aiounifi.Controller.... | [
424,
0
] | [
438,
43
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller | (hass) | Successful call. | Successful call. | async def test_get_controller(hass):
"""Successful call."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", return_value=True
):
assert await get_controller(hass, **CONTROLLER_DATA) | [
"async",
"def",
"test_get_controller",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"return_value",
"=",
"True",
")",
":",
"as... | [
441,
0
] | [
446,
60
] | python | co | ['es', 'co', 'en'] | False |
test_get_controller_verify_ssl_false | (hass) | Successful call with verify ssl set to false. | Successful call with verify ssl set to false. | async def test_get_controller_verify_ssl_false(hass):
"""Successful call with verify ssl set to false."""
controller_data = dict(CONTROLLER_DATA)
controller_data[CONF_VERIFY_SSL] = False
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", retu... | [
"async",
"def",
"test_get_controller_verify_ssl_false",
"(",
"hass",
")",
":",
"controller_data",
"=",
"dict",
"(",
"CONTROLLER_DATA",
")",
"controller_data",
"[",
"CONF_VERIFY_SSL",
"]",
"=",
"False",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",... | [
449,
0
] | [
456,
60
] | python | en | ['en', 'pt', 'en'] | True |
test_get_controller_login_failed | (hass) | Check that get_controller can handle a failed login. | Check that get_controller can handle a failed login. | async def test_get_controller_login_failed(hass):
"""Check that get_controller can handle a failed login."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.Unauthorized
), pytest.raises(AuthenticationRequired):
aw... | [
"async",
"def",
"test_get_controller_login_failed",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",
"aiounifi",
"... | [
459,
0
] | [
464,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller_controller_bad_gateway | (hass) | Check that get_controller can handle controller being unavailable. | Check that get_controller can handle controller being unavailable. | async def test_get_controller_controller_bad_gateway(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.BadGateway
), pytest.raises(CannotConnect... | [
"async",
"def",
"test_get_controller_controller_bad_gateway",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",
"aiou... | [
467,
0
] | [
472,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller_controller_service_unavailable | (hass) | Check that get_controller can handle controller being unavailable. | Check that get_controller can handle controller being unavailable. | async def test_get_controller_controller_service_unavailable(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.ServiceUnavailable
), pytest.rais... | [
"async",
"def",
"test_get_controller_controller_service_unavailable",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",... | [
475,
0
] | [
480,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller_controller_unavailable | (hass) | Check that get_controller can handle controller being unavailable. | Check that get_controller can handle controller being unavailable. | async def test_get_controller_controller_unavailable(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.RequestError
), pytest.raises(CannotConne... | [
"async",
"def",
"test_get_controller_controller_unavailable",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",
"aiou... | [
483,
0
] | [
488,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller_login_required | (hass) | Check that get_controller can handle unknown errors. | Check that get_controller can handle unknown errors. | async def test_get_controller_login_required(hass):
"""Check that get_controller can handle unknown errors."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.LoginRequired
), pytest.raises(AuthenticationRequired):
... | [
"async",
"def",
"test_get_controller_login_required",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",
"aiounifi",
... | [
491,
0
] | [
496,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_controller_unknown_error | (hass) | Check that get_controller can handle unknown errors. | Check that get_controller can handle unknown errors. | async def test_get_controller_unknown_error(hass):
"""Check that get_controller can handle unknown errors."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.AiounifiException
), pytest.raises(AuthenticationRequired):
... | [
"async",
"def",
"test_get_controller_unknown_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"aiounifi.Controller.check_unifi_os\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"aiounifi.Controller.login\"",
",",
"side_effect",
"=",
"aiounifi",
... | [
499,
0
] | [
504,
53
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_no_component_mapping | () | Test that None is returned. | Test that None is returned. | def test_get_device_no_component_mapping():
"""Test that None is returned."""
node = MockNode(manufacturer_id=" ")
value = MockValue(data=0, node=node)
assert workaround.get_device_component_mapping(value) is None | [
"def",
"test_get_device_no_component_mapping",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\" \"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"node",
"=",
"node",
")",
"assert",
"workaround",
".",
"get_device_componen... | [
6,
0
] | [
10,
65
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_component_mapping | () | Test that component is returned. | Test that component is returned. | def test_get_device_component_mapping():
"""Test that component is returned."""
node = MockNode(manufacturer_id="010f", product_type="0b00")
value = MockValue(data=0, node=node, command_class=const.COMMAND_CLASS_SENSOR_ALARM)
assert workaround.get_device_component_mapping(value) == "binary_sensor" | [
"def",
"test_get_device_component_mapping",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"010f\"",
",",
"product_type",
"=",
"\"0b00\"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"node",
"=",
"node",
",",
"command_... | [
13,
0
] | [
17,
76
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_component_mapping_mti | () | Test that component is returned. | Test that component is returned. | def test_get_device_component_mapping_mti():
"""Test that component is returned."""
# GE Fan controller
node = MockNode(manufacturer_id="0063", product_type="4944", product_id="3034")
value = MockValue(
data=0, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
assert worka... | [
"def",
"test_get_device_component_mapping_mti",
"(",
")",
":",
"# GE Fan controller",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"0063\"",
",",
"product_type",
"=",
"\"4944\"",
",",
"product_id",
"=",
"\"3034\"",
")",
"value",
"=",
"MockValue",
"(",
"... | [
20,
0
] | [
34,
65
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_no_mapping | () | Test that no device mapping is returned. | Test that no device mapping is returned. | def test_get_device_no_mapping():
"""Test that no device mapping is returned."""
node = MockNode(manufacturer_id=" ")
value = MockValue(data=0, node=node)
assert workaround.get_device_mapping(value) is None | [
"def",
"test_get_device_no_mapping",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\" \"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"node",
"=",
"node",
")",
"assert",
"workaround",
".",
"get_device_mapping",
"(",
... | [
37,
0
] | [
41,
55
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_mapping_mt | () | Test that device mapping mt is returned. | Test that device mapping mt is returned. | def test_get_device_mapping_mt():
"""Test that device mapping mt is returned."""
node = MockNode(manufacturer_id="0047", product_type="5a52")
value = MockValue(data=0, node=node)
assert workaround.get_device_mapping(value) == "workaround_no_position" | [
"def",
"test_get_device_mapping_mt",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"0047\"",
",",
"product_type",
"=",
"\"5a52\"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"node",
"=",
"node",
")",
"assert",
"wor... | [
44,
0
] | [
48,
75
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_mapping_mtii | () | Test that device mapping mtii is returned. | Test that device mapping mtii is returned. | def test_get_device_mapping_mtii():
"""Test that device mapping mtii is returned."""
node = MockNode(manufacturer_id="013c", product_type="0002", product_id="0002")
value = MockValue(data=0, node=node, index=0)
assert workaround.get_device_mapping(value) == "trigger_no_off_event" | [
"def",
"test_get_device_mapping_mtii",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"013c\"",
",",
"product_type",
"=",
"\"0002\"",
",",
"product_id",
"=",
"\"0002\"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"nod... | [
51,
0
] | [
55,
73
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_mapping_mti_instance | () | Test that device mapping mti_instance is returned. | Test that device mapping mti_instance is returned. | def test_get_device_mapping_mti_instance():
"""Test that device mapping mti_instance is returned."""
node = MockNode(manufacturer_id="013c", product_type="0001", product_id="0005")
value = MockValue(data=0, node=node, instance=1)
assert workaround.get_device_mapping(value) == "refresh_node_on_update"
... | [
"def",
"test_get_device_mapping_mti_instance",
"(",
")",
":",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"013c\"",
",",
"product_type",
"=",
"\"0001\"",
",",
"product_id",
"=",
"\"0005\"",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
","... | [
58,
0
] | [
65,
55
] | python | en | ['en', 'en', 'en'] | True |
stub_blueprint_populate | () | Stub copying the blueprint automations to the config folder. | Stub copying the blueprint automations to the config folder. | def stub_blueprint_populate():
"""Stub copying the blueprint automations to the config folder."""
with patch(
"homeassistant.components.blueprint.models.DomainBlueprints.async_populate"
):
yield | [
"def",
"stub_blueprint_populate",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.blueprint.models.DomainBlueprints.async_populate\"",
")",
":",
"yield"
] | [
8,
0
] | [
13,
13
] | 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.