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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WaqiSensor.available | (self) | Return sensor availability. | Return sensor availability. | def available(self):
"""Return sensor availability."""
return self._data is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
"is",
"not",
"None"
] | [
138,
4
] | [
140,
37
] | python | en | ['fr', 'ga', 'en'] | False |
WaqiSensor.unique_id | (self) | Return unique ID. | Return unique ID. | def unique_id(self):
"""Return unique ID."""
return self.uid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"uid"
] | [
143,
4
] | [
145,
23
] | python | en | ['fr', 'la', 'en'] | False |
WaqiSensor.native_unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def native_unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return "AQI" | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"return",
"\"AQI\""
] | [
148,
4
] | [
150,
20
] | python | en | ['en', 'en', 'en'] | True |
WaqiSensor.extra_state_attributes | (self) | Return the state attributes of the last update. | Return the state attributes of the last update. | def extra_state_attributes(self):
"""Return the state attributes of the last update."""
attrs = {}
if self._data is not None:
try:
attrs[ATTR_ATTRIBUTION] = " and ".join(
[ATTRIBUTION]
+ [v["name"] for v in self._data.get("attr... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
":",
"try",
":",
"attrs",
"[",
"ATTR_ATTRIBUTION",
"]",
"=",
"\" and \"",
".",
"join",
"(",
"[",
"ATTRIBUTION",
"]",
"+",
... | [
153,
4
] | [
175,
54
] | python | en | ['en', 'en', 'en'] | True |
WaqiSensor.async_update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | async def async_update(self):
"""Get the latest data and updates the states."""
if self.uid:
result = await self._client.get_station_by_number(self.uid)
elif self.url:
result = await self._client.get_station_by_name(self.url)
else:
result = None
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"uid",
":",
"result",
"=",
"await",
"self",
".",
"_client",
".",
"get_station_by_number",
"(",
"self",
".",
"uid",
")",
"elif",
"self",
".",
"url",
":",
"result",
"=",
"await",
... | [
177,
4
] | [
185,
27
] | python | en | ['en', 'en', 'en'] | True |
test_sensor | (hass, create_registrations, webhook_client) | Test that sensors can be registered and updated. | Test that sensors can be registered and updated. | async def test_sensor(hass, create_registrations, webhook_client):
"""Test that sensors can be registered and updated."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
webhook_url,
json={
"... | [
"async",
"def",
"test_sensor",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_resp",
"=",
"aw... | [
5,
0
] | [
84,
66
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_must_register | (hass, create_registrations, webhook_client) | Test that sensors must be registered before updating. | Test that sensors must be registered before updating. | async def test_sensor_must_register(hass, create_registrations, webhook_client):
"""Test that sensors must be registered before updating."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
resp = await webhook_client.post(
webhook_url,
json={... | [
"async",
"def",
"test_sensor_must_register",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"resp",
... | [
87,
0
] | [
103,
69
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_id_no_dupes | (hass, create_registrations, webhook_client, caplog) | Test that a duplicate unique ID in registration updates the sensor. | Test that a duplicate unique ID in registration updates the sensor. | async def test_sensor_id_no_dupes(hass, create_registrations, webhook_client, caplog):
"""Test that a duplicate unique ID in registration updates the sensor."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
payload = {
"type": "register_sensor",
... | [
"async",
"def",
"test_sensor_id_no_dupes",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
",",
"caplog",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}... | [
106,
0
] | [
165,
31
] | python | en | ['en', 'en', 'en'] | True |
test_register_sensor_no_state | (hass, create_registrations, webhook_client) | Test that sensors can be registered, when there is no (unknown) state. | Test that sensors can be registered, when there is no (unknown) state. | async def test_register_sensor_no_state(hass, create_registrations, webhook_client):
"""Test that sensors can be registered, when there is no (unknown) state."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
w... | [
"async",
"def",
"test_register_sensor_no_state",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_r... | [
168,
0
] | [
222,
40
] | python | en | ['en', 'en', 'en'] | True |
test_update_sensor_no_state | (hass, create_registrations, webhook_client) | Test that sensors can be updated, when there is no (unknown) state. | Test that sensors can be updated, when there is no (unknown) state. | async def test_update_sensor_no_state(hass, create_registrations, webhook_client):
"""Test that sensors can be updated, when there is no (unknown) state."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
webhoo... | [
"async",
"def",
"test_update_sensor_no_state",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_res... | [
225,
0
] | [
267,
48
] | python | en | ['en', 'en', 'en'] | True |
Marker.evaluate | (self, environment=None) | Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
The environment is determined from the current Python process.
| Evaluate a marker. | def evaluate(self, environment=None):
# type: (Optional[Dict[str, str]]) -> bool
"""Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
... | [
"def",
"evaluate",
"(",
"self",
",",
"environment",
"=",
"None",
")",
":",
"# type: (Optional[Dict[str, str]]) -> bool",
"current_environment",
"=",
"default_environment",
"(",
")",
"if",
"environment",
"is",
"not",
"None",
":",
"current_environment",
".",
"update",
... | [
313,
4
] | [
327,
68
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the MiTempBt sensor. | Set up the MiTempBt sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MiTempBt sensor."""
backend = BACKEND
_LOGGER.debug("MiTempBt is using %s backend", backend.__name__)
cache = config[CONF_CACHE]
poller = mitemp_bt_poller.MiTempBtPoller(
config[CONF_MAC],
cache_timeo... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"backend",
"=",
"BACKEND",
"_LOGGER",
".",
"debug",
"(",
"\"MiTempBt is using %s backend\"",
",",
"backend",
".",
"__name__",
")",
"cache",
... | [
93,
0
] | [
118,
26
] | python | en | ['en', 'ca', 'en'] | True |
MiTempBtSensor.__init__ | (
self, poller, prefix, force_update, median, description: SensorEntityDescription
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, poller, prefix, force_update, median, description: SensorEntityDescription
):
"""Initialize the sensor."""
self.entity_description = description
self.poller = poller
self.data: list[Any] = []
self._attr_name = f"{prefix} {description.name}"
... | [
"def",
"__init__",
"(",
"self",
",",
"poller",
",",
"prefix",
",",
"force_update",
",",
"median",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"poller",
"=",
"poller",
"self",... | [
124,
4
] | [
136,
34
] | python | en | ['en', 'en', 'en'] | True |
MiTempBtSensor.update | (self) |
Update current conditions.
This uses a rolling median over 3 values to filter out outliers.
|
Update current conditions. | def update(self):
"""
Update current conditions.
This uses a rolling median over 3 values to filter out outliers.
"""
try:
_LOGGER.debug("Polling data for %s", self.name)
data = self.poller.parameter_value(self.entity_description.key)
except OSErr... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Polling data for %s\"",
",",
"self",
".",
"name",
")",
"data",
"=",
"self",
".",
"poller",
".",
"parameter_value",
"(",
"self",
".",
"entity_description",
".",
"key",
")... | [
138,
4
] | [
177,
71
] | python | en | ['en', 'error', 'th'] | False |
RedisCache.clear | (self) | Helper for clearing all the keys in a database. Use with
caution! | Helper for clearing all the keys in a database. Use with
caution! | def clear(self):
"""Helper for clearing all the keys in a database. Use with
caution!"""
for key in self.conn.keys():
self.conn.delete(key) | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"conn",
".",
"keys",
"(",
")",
":",
"self",
".",
"conn",
".",
"delete",
"(",
"key",
")"
] | [
24,
4
] | [
28,
33
] | python | en | ['en', 'en', 'en'] | True |
RedisCache.close | (self) | Redis uses connection pooling, no need to close the connection. | Redis uses connection pooling, no need to close the connection. | def close(self):
"""Redis uses connection pooling, no need to close the connection."""
pass | [
"def",
"close",
"(",
"self",
")",
":",
"pass"
] | [
30,
4
] | [
32,
12
] | python | en | ['en', 'en', 'en'] | True |
PlaneTracker.add_target | (self, image, rect, data=None) | Add a new tracking target. | Add a new tracking target. | def add_target(self, image, rect, data=None):
'''Add a new tracking target.'''
x0, y0, x1, y1 = rect
raw_points, raw_descrs = self.detect_features(image)
points, descs = [], []
for kp, desc in zip(raw_points, raw_descrs):
x, y = kp.pt
if x0 <= x <= x1 and ... | [
"def",
"add_target",
"(",
"self",
",",
"image",
",",
"rect",
",",
"data",
"=",
"None",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"rect",
"raw_points",
",",
"raw_descrs",
"=",
"self",
".",
"detect_features",
"(",
"image",
")",
"points",
... | [
77,
4
] | [
90,
35
] | python | en | ['en', 'en', 'en'] | True |
PlaneTracker.clear | (self) | Remove all targets | Remove all targets | def clear(self):
'''Remove all targets'''
self.targets = []
self.matcher.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"targets",
"=",
"[",
"]",
"self",
".",
"matcher",
".",
"clear",
"(",
")"
] | [
92,
4
] | [
95,
28
] | python | en | ['en', 'en', 'en'] | True |
PlaneTracker.track | (self, frame) | Returns a list of detected TrackedTarget objects | Returns a list of detected TrackedTarget objects | def track(self, frame):
'''Returns a list of detected TrackedTarget objects'''
self.frame_points, frame_descrs = self.detect_features(frame)
if len(self.frame_points) < MIN_MATCH_COUNT:
return []
matches = self.matcher.knnMatch(frame_descrs, k = 2)
matches = [m[0] for... | [
"def",
"track",
"(",
"self",
",",
"frame",
")",
":",
"self",
".",
"frame_points",
",",
"frame_descrs",
"=",
"self",
".",
"detect_features",
"(",
"frame",
")",
"if",
"len",
"(",
"self",
".",
"frame_points",
")",
"<",
"MIN_MATCH_COUNT",
":",
"return",
"[",... | [
97,
4
] | [
130,
22
] | python | en | ['en', 'en', 'en'] | True |
PlaneTracker.detect_features | (self, frame) | detect_features(self, frame) -> keypoints, descrs | detect_features(self, frame) -> keypoints, descrs | def detect_features(self, frame):
'''detect_features(self, frame) -> keypoints, descrs'''
keypoints, descrs = self.detector.detectAndCompute(frame, None)
if descrs is None: # detectAndCompute returns descs=None if not keypoints found
descrs = []
return keypoints, descrs | [
"def",
"detect_features",
"(",
"self",
",",
"frame",
")",
":",
"keypoints",
",",
"descrs",
"=",
"self",
".",
"detector",
".",
"detectAndCompute",
"(",
"frame",
",",
"None",
")",
"if",
"descrs",
"is",
"None",
":",
"# detectAndCompute returns descs=None if not key... | [
132,
4
] | [
137,
32
] | python | en | ['fr', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up AirNow sensor entities based on a config entry. | Set up AirNow sensor entities based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up AirNow sensor entities based on a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
entities = [AirNowSensor(coordinator, description) for description in SENSOR_TYPES]
async_add_entities(entities, Fals... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"AirNowSensor",
"(",
"co... | [
49,
0
] | [
55,
39
] | python | en | ['en', 'en', 'en'] | True |
AirNowSensor.__init__ | (
self,
coordinator: AirNowDataUpdateCoordinator,
description: SensorEntityDescription,
) | Initialize. | Initialize. | def __init__(
self,
coordinator: AirNowDataUpdateCoordinator,
description: SensorEntityDescription,
) -> None:
"""Initialize."""
super().__init__(coordinator)
self.entity_description = description
self._state = None
self._attrs = {ATTR_ATTRIBUTION: ATT... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"AirNowDataUpdateCoordinator",
",",
"description",
":",
"SensorEntityDescription",
",",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"entity_description... | [
63,
4
] | [
76,
9
] | python | en | ['en', 'en', 'it'] | False |
AirNowSensor.native_value | (self) | Return the state. | Return the state. | def native_value(self):
"""Return the state."""
self._state = self.coordinator.data[self.entity_description.key]
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"entity_description",
".",
"key",
"]",
"return",
"self",
".",
"_state"
] | [
79,
4
] | [
82,
26
] | python | en | ['en', 'en', 'en'] | True |
AirNowSensor.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
if self.entity_description.key == ATTR_API_AQI:
self._attrs[SENSOR_AQI_ATTR_DESCR] = self.coordinator.data[
ATTR_API_AQI_DESCRIPTION
]
self._attrs[SENSOR_AQI_ATTR_LEVEL] = self.coordi... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"entity_description",
".",
"key",
"==",
"ATTR_API_AQI",
":",
"self",
".",
"_attrs",
"[",
"SENSOR_AQI_ATTR_DESCR",
"]",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"ATTR_API_AQI_D... | [
85,
4
] | [
95,
26
] | python | en | ['en', 'en', 'en'] | True |
async_get_triggers | (
hass: HomeAssistant, device_id: str
) | List device triggers for Arcam FMJ Receiver control devices. | List device triggers for Arcam FMJ Receiver control devices. | async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Arcam FMJ Receiver control devices."""
registry = await entity_registry.async_get_registry(hass)
triggers = []
# Get all the integrations entities for this device
for entry i... | [
"async",
"def",
"async_get_triggers",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass... | [
35,
0
] | [
55,
19
] | python | en | ['da', 'en', 'en'] | True |
async_attach_trigger | (
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) | Attach a trigger. | Attach a trigger. | async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) -> CALLBACK_TYPE:
"""Attach a trigger."""
trigger_data = automation_info["trigger_data"]
job = HassJob(action)
if config[CONF_TYPE] == "turn_o... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"action",
":",
"AutomationActionType",
",",
"automation_info",
":",
"AutomationTriggerInfo",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"trigger_data",
"=",
... | [
58,
0
] | [
88,
23
] | python | en | ['en', 'lb', 'en'] | True |
handle_error | (func) | Handle tradfri api call error. | Handle tradfri api call error. | def handle_error(func):
"""Handle tradfri api call error."""
@wraps(func)
async def wrapper(command):
"""Decorate api call."""
try:
await func(command)
except PytradfriError as err:
_LOGGER.error("Unable to execute command %s: %s", command, err)
return w... | [
"def",
"handle_error",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"command",
")",
":",
"\"\"\"Decorate api call.\"\"\"",
"try",
":",
"await",
"func",
"(",
"command",
")",
"except",
"PytradfriError",
"as",
"err",
... | [
14,
0
] | [
25,
18
] | python | cy | ['cy', 'pt', 'en'] | False |
TradfriBaseClass.__init__ | (self, device, api, gateway_id) | Initialize a device. | Initialize a device. | def __init__(self, device, api, gateway_id):
"""Initialize a device."""
self._api = handle_error(api)
self._device = None
self._device_control = None
self._device_data = None
self._gateway_id = gateway_id
self._refresh(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"api",
",",
"gateway_id",
")",
":",
"self",
".",
"_api",
"=",
"handle_error",
"(",
"api",
")",
"self",
".",
"_device",
"=",
"None",
"self",
".",
"_device_control",
"=",
"None",
"self",
".",
"_device_d... | [
36,
4
] | [
43,
29
] | python | en | ['es', 'en', 'en'] | True |
TradfriBaseClass._async_start_observe | (self, exc=None) | Start observation of device. | Start observation of device. | def _async_start_observe(self, exc=None):
"""Start observation of device."""
if exc:
self.async_write_ha_state()
_LOGGER.warning("Observation failed for %s", self._attr_name, exc_info=exc)
try:
cmd = self._device.observe(
callback=self._observ... | [
"def",
"_async_start_observe",
"(",
"self",
",",
"exc",
"=",
"None",
")",
":",
"if",
"exc",
":",
"self",
".",
"async_write_ha_state",
"(",
")",
"_LOGGER",
".",
"warning",
"(",
"\"Observation failed for %s\"",
",",
"self",
".",
"_attr_name",
",",
"exc_info",
... | [
46,
4
] | [
61,
39
] | python | en | ['en', 'da', 'en'] | True |
TradfriBaseClass.async_added_to_hass | (self) | Start thread when added to hass. | Start thread when added to hass. | async def async_added_to_hass(self):
"""Start thread when added to hass."""
self._async_start_observe() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_async_start_observe",
"(",
")"
] | [
63,
4
] | [
65,
35
] | python | en | ['en', 'en', 'en'] | True |
TradfriBaseClass._observe_update | (self, device) | Receive new state data for this device. | Receive new state data for this device. | def _observe_update(self, device):
"""Receive new state data for this device."""
self._refresh(device)
self.async_write_ha_state() | [
"def",
"_observe_update",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"_refresh",
"(",
"device",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
68,
4
] | [
71,
35
] | python | en | ['en', 'en', 'en'] | True |
TradfriBaseClass._refresh | (self, device) | Refresh the device data. | Refresh the device data. | def _refresh(self, device):
"""Refresh the device data."""
self._device = device
self._attr_name = device.name | [
"def",
"_refresh",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_attr_name",
"=",
"device",
".",
"name"
] | [
73,
4
] | [
76,
37
] | python | en | ['en', 'en', 'en'] | True |
TradfriBaseDevice.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
info = self._device.device_info
return {
"identifiers": {(DOMAIN, self._device.id)},
"manufacturer": info.manufacturer,
"model": info.model_number,
"name": self._attr_name,
"sw_versi... | [
"def",
"device_info",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_device",
".",
"device_info",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"id",
")",
"}",
",",
"\"manufacturer\"",
":",
"info",
"."... | [
86,
4
] | [
97,
9
] | python | en | ['en', 'en', 'en'] | True |
TradfriBaseDevice._refresh | (self, device) | Refresh the device data. | Refresh the device data. | def _refresh(self, device):
"""Refresh the device data."""
super()._refresh(device)
self._attr_available = device.reachable | [
"def",
"_refresh",
"(",
"self",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"_refresh",
"(",
"device",
")",
"self",
".",
"_attr_available",
"=",
"device",
".",
"reachable"
] | [
99,
4
] | [
102,
47
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
13,
0
] | [
38,
48
] | python | en | ['en', 'en', 'en'] | True |
test_already_configured | (hass) | Test config flow when Omnilogic component is already setup. | Test config flow when Omnilogic component is already setup. | async def test_already_configured(hass):
"""Test config flow when Omnilogic component is already setup."""
MockConfigEntry(domain="omnilogic", data=DATA).add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_already_configured",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"omnilogic\"",
",",
"data",
"=",
"DATA",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"... | [
41,
0
] | [
51,
56
] | python | en | ['en', 'en', 'en'] | True |
test_with_invalid_credentials | (hass) | Test with invalid credentials. | Test with invalid credentials. | async def test_with_invalid_credentials(hass):
"""Test with invalid credentials."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homea... | [
"async",
"def",
"test_with_invalid_credentials",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
54,
0
] | [
73,
55
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test if invalid response or no connection returned from Hayward. | Test if invalid response or no connection returned from Hayward. | async def test_form_cannot_connect(hass):
"""Test if invalid response or no connection returned from Hayward."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"as... | [
76,
0
] | [
95,
57
] | python | en | ['en', 'en', 'en'] | True |
test_with_unknown_error | (hass) | Test with unknown error response from Hayward. | Test with unknown error response from Hayward. | async def test_with_unknown_error(hass):
"""Test with unknown error response from Hayward."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
... | [
"async",
"def",
"test_with_unknown_error",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"asy... | [
98,
0
] | [
116,
50
] | python | en | ['en', 'en', 'en'] | True |
test_option_flow | (hass) | Test option flow. | Test option flow. | async def test_option_flow(hass):
"""Test option flow."""
entry = MockConfigEntry(domain=DOMAIN, data=DATA)
entry.add_to_hass(hass)
assert not entry.options
with patch(
"homeassistant.components.omnilogic.async_setup_entry", return_value=True
):
result = await hass.config_entri... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"DATA",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"entry",
".",
"options",
"with",
"pat... | [
119,
0
] | [
144,
50
] | python | da | ['nl', 'da', 'en'] | False |
build_py.get_data_files | (self) | Generate list of '(package,src_dir,build_dir,filenames)' tuples | Generate list of '(package,src_dir,build_dir,filenames)' tuples | def get_data_files(self):
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
data = []
if not self.packages:
return data
for package in self.packages:
# Locate package source directory
src_dir = self.get_package_dir(package)
... | [
"def",
"get_data_files",
"(",
"self",
")",
":",
"data",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"packages",
":",
"return",
"data",
"for",
"package",
"in",
"self",
".",
"packages",
":",
"# Locate package source directory",
"src_dir",
"=",
"self",
".",
"get... | [
96,
4
] | [
118,
19
] | python | en | ['en', 'af', 'en'] | True |
build_py.find_data_files | (self, package, src_dir) | Return filenames for package's data files in 'src_dir | Return filenames for package's data files in 'src_dir | def find_data_files(self, package, src_dir):
"""Return filenames for package's data files in 'src_dir'"""
globs = (self.package_data.get('', [])
+ self.package_data.get(package, []))
files = []
for pattern in globs:
# Each pattern has to be converted to a pla... | [
"def",
"find_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
")",
":",
"globs",
"=",
"(",
"self",
".",
"package_data",
".",
"get",
"(",
"''",
",",
"[",
"]",
")",
"+",
"self",
".",
"package_data",
".",
"get",
"(",
"package",
",",
"[",
"]",... | [
120,
4
] | [
131,
20
] | python | en | ['en', 'no', 'en'] | True |
build_py.build_package_data | (self) | Copy data files into build directory | Copy data files into build directory | def build_package_data(self):
"""Copy data files into build directory"""
lastdir = None
for package, src_dir, build_dir, filenames in self.data_files:
for filename in filenames:
target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(tar... | [
"def",
"build_package_data",
"(",
"self",
")",
":",
"lastdir",
"=",
"None",
"for",
"package",
",",
"src_dir",
",",
"build_dir",
",",
"filenames",
"in",
"self",
".",
"data_files",
":",
"for",
"filename",
"in",
"filenames",
":",
"target",
"=",
"os",
".",
"... | [
133,
4
] | [
141,
51
] | python | en | ['en', 'en', 'en'] | True |
build_py.get_package_dir | (self, package) | Return the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any). | Return the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any). | def get_package_dir(self, package):
"""Return the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any)."""
path = package.split('.')
if not self.package_dir:
... | [
"def",
"get_package_dir",
"(",
"self",
",",
"package",
")",
":",
"path",
"=",
"package",
".",
"split",
"(",
"'.'",
")",
"if",
"not",
"self",
".",
"package_dir",
":",
"if",
"path",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"*",
"path",
")"... | [
143,
4
] | [
180,
29
] | python | en | ['en', 'en', 'en'] | True |
build_py.find_modules | (self) | Finds individually-specified Python modules, ie. those listed by
module name in 'self.py_modules'. Returns a list of tuples (package,
module_base, filename): 'package' is a tuple of the path through
package-space to the module; 'module_base' is the bare (no
packages, no dots) module nam... | Finds individually-specified Python modules, ie. those listed by
module name in 'self.py_modules'. Returns a list of tuples (package,
module_base, filename): 'package' is a tuple of the path through
package-space to the module; 'module_base' is the bare (no
packages, no dots) module nam... | def find_modules(self):
"""Finds individually-specified Python modules, ie. those listed by
module name in 'self.py_modules'. Returns a list of tuples (package,
module_base, filename): 'package' is a tuple of the path through
package-space to the module; 'module_base' is the bare (no
... | [
"def",
"find_modules",
"(",
"self",
")",
":",
"# Map package names to tuples of useful info about the package:",
"# (package_dir, checked)",
"# package_dir - the directory where we'll find source files for",
"# this package",
"# checked - true if we have checked that the package directory",... | [
231,
4
] | [
281,
22
] | python | en | ['en', 'en', 'en'] | True |
build_py.find_all_modules | (self) | Compute the list of all modules that will be built, whether
they are specified one-module-at-a-time ('self.py_modules') or
by whole packages ('self.packages'). Return a list of tuples
(package, module, module_file), just like 'find_modules()' and
'find_package_modules()' do. | Compute the list of all modules that will be built, whether
they are specified one-module-at-a-time ('self.py_modules') or
by whole packages ('self.packages'). Return a list of tuples
(package, module, module_file), just like 'find_modules()' and
'find_package_modules()' do. | def find_all_modules(self):
"""Compute the list of all modules that will be built, whether
they are specified one-module-at-a-time ('self.py_modules') or
by whole packages ('self.packages'). Return a list of tuples
(package, module, module_file), just like 'find_modules()' and
'... | [
"def",
"find_all_modules",
"(",
"self",
")",
":",
"modules",
"=",
"[",
"]",
"if",
"self",
".",
"py_modules",
":",
"modules",
".",
"extend",
"(",
"self",
".",
"find_modules",
"(",
")",
")",
"if",
"self",
".",
"packages",
":",
"for",
"package",
"in",
"... | [
283,
4
] | [
297,
22
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Lutron Caseta fan platform.
Adds fan controllers from the Caseta bridge associated with the config_entry
as fan entities.
| Set up the Lutron Caseta fan platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Lutron Caseta fan platform.
Adds fan controllers from the Caseta bridge associated with the config_entry
as fan entities.
"""
entities = []
data = hass.data[CASETA_DOMAIN][config_entry.entry_id]
bridge = data... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"data",
"=",
"hass",
".",
"data",
"[",
"CASETA_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"bridge",
"=",
"d... | [
22,
0
] | [
38,
38
] | python | en | ['en', 'fr', 'en'] | True |
LutronCasetaFan.percentage | (self) | Return the current speed percentage. | Return the current speed percentage. | def percentage(self) -> int | None:
"""Return the current speed percentage."""
if self._device["fan_speed"] is None:
return None
if self._device["fan_speed"] == FAN_OFF:
return 0
return ordered_list_item_to_percentage(
ORDERED_NAMED_FAN_SPEEDS, self._d... | [
"def",
"percentage",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"if",
"self",
".",
"_device",
"[",
"\"fan_speed\"",
"]",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_device",
"[",
"\"fan_speed\"",
"]",
"==",
"FAN_OFF",
":",
"return",... | [
45,
4
] | [
53,
9
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaFan.speed_count | (self) | Return the number of speeds the fan supports. | Return the number of speeds the fan supports. | def speed_count(self) -> int:
"""Return the number of speeds the fan supports."""
return len(ORDERED_NAMED_FAN_SPEEDS) | [
"def",
"speed_count",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"ORDERED_NAMED_FAN_SPEEDS",
")"
] | [
56,
4
] | [
58,
44
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaFan.supported_features | (self) | Flag supported features. Speed Only. | Flag supported features. Speed Only. | def supported_features(self) -> int:
"""Flag supported features. Speed Only."""
return SUPPORT_SET_SPEED | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_SET_SPEED"
] | [
61,
4
] | [
63,
32
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaFan.async_turn_on | (
self,
speed: str = None,
percentage: int = None,
preset_mode: str = None,
**kwargs,
) | Turn the fan on. | Turn the fan on. | async def async_turn_on(
self,
speed: str = None,
percentage: int = None,
preset_mode: str = None,
**kwargs,
):
"""Turn the fan on."""
if percentage is None:
percentage = DEFAULT_ON_PERCENTAGE
await self.async_set_percentage(percentage) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
",",
"percentage",
":",
"int",
"=",
"None",
",",
"preset_mode",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"if",
"percentage",
"is",
"None",
... | [
65,
4
] | [
76,
51
] | python | en | ['en', 'fy', 'en'] | True |
LutronCasetaFan.async_turn_off | (self, **kwargs) | Turn the fan off. | Turn the fan off. | async def async_turn_off(self, **kwargs):
"""Turn the fan off."""
await self.async_set_percentage(0) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"async_set_percentage",
"(",
"0",
")"
] | [
78,
4
] | [
80,
42
] | python | en | ['en', 'fy', 'en'] | True |
LutronCasetaFan.async_set_percentage | (self, percentage: int) | Set the speed of the fan. | Set the speed of the fan. | async def async_set_percentage(self, percentage: int) -> None:
"""Set the speed of the fan."""
if percentage == 0:
named_speed = FAN_OFF
else:
named_speed = percentage_to_ordered_list_item(
ORDERED_NAMED_FAN_SPEEDS, percentage
)
await ... | [
"async",
"def",
"async_set_percentage",
"(",
"self",
",",
"percentage",
":",
"int",
")",
"->",
"None",
":",
"if",
"percentage",
"==",
"0",
":",
"named_speed",
"=",
"FAN_OFF",
"else",
":",
"named_speed",
"=",
"percentage_to_ordered_list_item",
"(",
"ORDERED_NAMED... | [
82,
4
] | [
91,
68
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaFan.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self.percentage and self.percentage > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"percentage",
"and",
"self",
".",
"percentage",
">",
"0"
] | [
94,
4
] | [
96,
54
] | python | en | ['en', 'fy', 'en'] | True |
LutronCasetaFan.async_update | (self) | Update when forcing a refresh of the device. | Update when forcing a refresh of the device. | async def async_update(self):
"""Update when forcing a refresh of the device."""
self._device = self._smartbridge.get_device_by_id(self.device_id)
_LOGGER.debug("State of this lutron fan device is %s", self._device) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"self",
".",
"_device",
"=",
"self",
".",
"_smartbridge",
".",
"get_device_by_id",
"(",
"self",
".",
"device_id",
")",
"_LOGGER",
".",
"debug",
"(",
"\"State of this lutron fan device is %s\"",
",",
"self",
... | [
98,
4
] | [
101,
76
] | python | en | ['en', 'en', 'en'] | True |
test_entity_registry | (hass) | Tests that the devices are registered in the entity registry. | Tests that the devices are registered in the entity registry. | async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, COVER_DOMAIN)
entity_registry = er.async_get(hass)
entry = entity_registry.async_get(DEVICE_ID)
assert entry.unique_id == "61cbz3b542d2o33ed2fz02721bda3324" | [
"async",
"def",
"test_entity_registry",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"COVER_DOMAIN",
")",
"entity_registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"entry",
"=",
"entity_registry",
".",
"async_get",
"(",
"DEVICE_I... | [
19,
0
] | [
25,
64
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass) | Test the cover attributes are correct. | Test the cover attributes are correct. | async def test_attributes(hass):
"""Test the cover attributes are correct."""
await setup_platform(hass, COVER_DOMAIN)
state = hass.states.get(DEVICE_ID)
assert state.state == STATE_CLOSED
assert state.attributes.get(ATTR_DEVICE_ID) == "ZW:00000007"
assert not state.attributes.get("battery_low"... | [
"async",
"def",
"test_attributes",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"COVER_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"DEVICE_ID",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_CLOSED",
"asse... | [
28,
0
] | [
38,
68
] | python | en | ['en', 'en', 'en'] | True |
test_open | (hass) | Test the cover can be opened. | Test the cover can be opened. | async def test_open(hass):
"""Test the cover can be opened."""
await setup_platform(hass, COVER_DOMAIN)
with patch("abodepy.AbodeCover.open_cover") as mock_open:
await hass.services.async_call(
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DEVICE_ID}, blocking=True
)
... | [
"async",
"def",
"test_open",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"COVER_DOMAIN",
")",
"with",
"patch",
"(",
"\"abodepy.AbodeCover.open_cover\"",
")",
"as",
"mock_open",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"... | [
41,
0
] | [
50,
38
] | python | en | ['en', 'en', 'en'] | True |
test_close | (hass) | Test the cover can be closed. | Test the cover can be closed. | async def test_close(hass):
"""Test the cover can be closed."""
await setup_platform(hass, COVER_DOMAIN)
with patch("abodepy.AbodeCover.close_cover") as mock_close:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: DEVICE_ID},
... | [
"async",
"def",
"test_close",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"COVER_DOMAIN",
")",
"with",
"patch",
"(",
"\"abodepy.AbodeCover.close_cover\"",
")",
"as",
"mock_close",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
... | [
53,
0
] | [
65,
39
] | python | en | ['en', 'en', 'en'] | True |
get_kodi_connection | (
host, port, ws_port, username, password, ssl=False, timeout=5, session=None
) | Get Kodi connection. | Get Kodi connection. | def get_kodi_connection(
host, port, ws_port, username, password, ssl=False, timeout=5, session=None
):
"""Get Kodi connection."""
if ws_port is None:
return MockConnection()
else:
return MockWSConnection() | [
"def",
"get_kodi_connection",
"(",
"host",
",",
"port",
",",
"ws_port",
",",
"username",
",",
"password",
",",
"ssl",
"=",
"False",
",",
"timeout",
"=",
"5",
",",
"session",
"=",
"None",
")",
":",
"if",
"ws_port",
"is",
"None",
":",
"return",
"MockConn... | [
48,
0
] | [
55,
33
] | python | en | ['it', 'en', 'en'] | True |
MockConnection.__init__ | (self, connected=True) | Mock the Kodi connection. | Mock the Kodi connection. | def __init__(self, connected=True):
"""Mock the Kodi connection."""
self._connected = connected | [
"def",
"__init__",
"(",
"self",
",",
"connected",
"=",
"True",
")",
":",
"self",
".",
"_connected",
"=",
"connected"
] | [
61,
4
] | [
63,
35
] | python | en | ['en', 'xh', 'en'] | True |
MockConnection.connect | (self) | Mock connect. | Mock connect. | async def connect(self):
"""Mock connect."""
pass | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"pass"
] | [
65,
4
] | [
67,
12
] | python | en | ['en', 'en', 'en'] | False |
MockConnection.connected | (self) | Mock connected. | Mock connected. | def connected(self):
"""Mock connected."""
return self._connected | [
"def",
"connected",
"(",
"self",
")",
":",
"return",
"self",
".",
"_connected"
] | [
70,
4
] | [
72,
30
] | python | en | ['en', 'en', 'en'] | False |
MockConnection.can_subscribe | (self) | Mock can_subscribe. | Mock can_subscribe. | def can_subscribe(self):
"""Mock can_subscribe."""
return False | [
"def",
"can_subscribe",
"(",
"self",
")",
":",
"return",
"False"
] | [
75,
4
] | [
77,
20
] | python | en | ['en', 'en', 'en'] | False |
MockConnection.close | (self) | Mock close. | Mock close. | async def close(self):
"""Mock close."""
pass | [
"async",
"def",
"close",
"(",
"self",
")",
":",
"pass"
] | [
79,
4
] | [
81,
12
] | python | en | ['en', 'ca', 'en'] | False |
MockConnection.server | (self) | Mock server. | Mock server. | def server(self):
"""Mock server."""
return None | [
"def",
"server",
"(",
"self",
")",
":",
"return",
"None"
] | [
84,
4
] | [
86,
19
] | python | en | ['en', 'da', 'en'] | False |
MockWSConnection.__init__ | (self, connected=True) | Mock the websocket connection. | Mock the websocket connection. | def __init__(self, connected=True):
"""Mock the websocket connection."""
self._connected = connected | [
"def",
"__init__",
"(",
"self",
",",
"connected",
"=",
"True",
")",
":",
"self",
".",
"_connected",
"=",
"connected"
] | [
92,
4
] | [
94,
35
] | python | en | ['en', 'da', 'en'] | True |
MockWSConnection.connect | (self) | Mock connect. | Mock connect. | async def connect(self):
"""Mock connect."""
pass | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"pass"
] | [
96,
4
] | [
98,
12
] | python | en | ['en', 'en', 'en'] | False |
MockWSConnection.connected | (self) | Mock connected. | Mock connected. | def connected(self):
"""Mock connected."""
return self._connected | [
"def",
"connected",
"(",
"self",
")",
":",
"return",
"self",
".",
"_connected"
] | [
101,
4
] | [
103,
30
] | python | en | ['en', 'en', 'en'] | False |
MockWSConnection.can_subscribe | (self) | Mock can_subscribe. | Mock can_subscribe. | def can_subscribe(self):
"""Mock can_subscribe."""
return False | [
"def",
"can_subscribe",
"(",
"self",
")",
":",
"return",
"False"
] | [
106,
4
] | [
108,
20
] | python | en | ['en', 'en', 'en'] | False |
MockWSConnection.close | (self) | Mock close. | Mock close. | async def close(self):
"""Mock close."""
pass | [
"async",
"def",
"close",
"(",
"self",
")",
":",
"pass"
] | [
110,
4
] | [
112,
12
] | python | en | ['en', 'ca', 'en'] | False |
MockWSConnection.server | (self) | Mock server. | Mock server. | def server(self):
"""Mock server."""
return None | [
"def",
"server",
"(",
"self",
")",
":",
"return",
"None"
] | [
115,
4
] | [
117,
19
] | python | en | ['en', 'da', 'en'] | False |
validate_input | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
rachio = Rachio(data[CONF_API_KEY])
username = None
try:
data = await hass.async_add_executor_job(rachio.pe... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"rachio",
"=",
"Rachio",
"(",
"data",
"[",
"CONF_API_KEY",
"]",
")",
"username",
"=",
"None",
"try",
":",
"data",
"=",
"await",
"hass",
".",
"async... | [
25,
0
] | [
50,
30
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
await self.async_set_unique_id(user_input[CONF_API_KEY])
self._abort_if_unique_id_configured()
try:
info = await validate_in... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"CONF_API_KEY",
"]",
")",
... | [
58,
4
] | [
77,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_homekit | (self, discovery_info) | Handle HomeKit discovery. | Handle HomeKit discovery. | async def async_step_homekit(self, discovery_info):
"""Handle HomeKit discovery."""
self._async_abort_entries_match()
properties = {
key.lower(): value for (key, value) in discovery_info["properties"].items()
}
await self.async_set_unique_id(properties["id"])
... | [
"async",
"def",
"async_step_homekit",
"(",
"self",
",",
"discovery_info",
")",
":",
"self",
".",
"_async_abort_entries_match",
"(",
")",
"properties",
"=",
"{",
"key",
".",
"lower",
"(",
")",
":",
"value",
"for",
"(",
"key",
",",
"value",
")",
"in",
"dis... | [
79,
4
] | [
86,
43
] | python | en | ['fr', 'xh', 'en'] | False |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
90,
4
] | [
92,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
98,
4
] | [
100,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
data_schema = vol.Schema(
{
vol.Optional(
CONF_MANUAL_RUN_MINS,
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"user_input",
")",
"data_schem... | [
102,
4
] | [
117,
76
] | python | en | ['en', 'nl', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the generic hygrostat platform. | Set up the generic hygrostat platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the generic hygrostat platform."""
if discovery_info:
config = discovery_info
name = config[CONF_NAME]
switch_entity_id = config[CONF_HUMIDIFIER]
sensor_entity_id = config[CONF_SENSOR]
min_hu... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
":",
"config",
"=",
"discovery_info",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"switch_entit... | [
58,
0
] | [
98,
5
] | python | en | ['en', 'da', 'en'] | True |
GenericHygrostat.__init__ | (
self,
name,
switch_entity_id,
sensor_entity_id,
min_humidity,
max_humidity,
target_humidity,
device_class,
min_cycle_duration,
dry_tolerance,
wet_tolerance,
keep_alive,
initial_state,
away_humidity,
... | Initialize the hygrostat. | Initialize the hygrostat. | def __init__(
self,
name,
switch_entity_id,
sensor_entity_id,
min_humidity,
max_humidity,
target_humidity,
device_class,
min_cycle_duration,
dry_tolerance,
wet_tolerance,
keep_alive,
initial_state,
away_humid... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"switch_entity_id",
",",
"sensor_entity_id",
",",
"min_humidity",
",",
"max_humidity",
",",
"target_humidity",
",",
"device_class",
",",
"min_cycle_duration",
",",
"dry_tolerance",
",",
"wet_tolerance",
",",
"keep_al... | [
104,
4
] | [
148,
56
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.async_added_to_hass | (self) | Run when entity about to be added. | Run when entity about to be added. | async def async_added_to_hass(self):
"""Run when entity about to be added."""
await super().async_added_to_hass()
# Add listener
async_track_state_change(
self.hass, self._sensor_entity_id, self._async_sensor_changed
)
async_track_state_change(
se... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"# Add listener",
"async_track_state_change",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sensor_entity_id",
",",
"self",
".",
"_a... | [
150,
4
] | [
198,
34
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._active | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_active"
] | [
201,
4
] | [
203,
27
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.state_attributes | (self) | Return the optional state attributes. | Return the optional state attributes. | def state_attributes(self):
"""Return the optional state attributes."""
data = super().state_attributes
if self._saved_target_humidity:
data[ATTR_SAVED_HUMIDITY] = self._saved_target_humidity
return data | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"super",
"(",
")",
".",
"state_attributes",
"if",
"self",
".",
"_saved_target_humidity",
":",
"data",
"[",
"ATTR_SAVED_HUMIDITY",
"]",
"=",
"self",
".",
"_saved_target_humidity",
"return",
"data"
] | [
206,
4
] | [
213,
19
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
216,
4
] | [
218,
20
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.name | (self) | Return the name of the hygrostat. | Return the name of the hygrostat. | def name(self):
"""Return the name of the hygrostat."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
221,
4
] | [
223,
25
] | python | en | ['en', 'no', 'en'] | True |
GenericHygrostat.is_on | (self) | Return true if the hygrostat is on. | Return true if the hygrostat is on. | def is_on(self):
"""Return true if the hygrostat is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
226,
4
] | [
228,
26
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.target_humidity | (self) | Return the humidity we try to reach. | Return the humidity we try to reach. | def target_humidity(self):
"""Return the humidity we try to reach."""
return self._target_humidity | [
"def",
"target_humidity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_target_humidity"
] | [
231,
4
] | [
233,
36
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.mode | (self) | Return the current mode. | Return the current mode. | def mode(self):
"""Return the current mode."""
if self._away_humidity is None:
return None
if self._is_away:
return MODE_AWAY
return MODE_NORMAL | [
"def",
"mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_away_humidity",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_is_away",
":",
"return",
"MODE_AWAY",
"return",
"MODE_NORMAL"
] | [
236,
4
] | [
242,
26
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.available_modes | (self) | Return a list of available modes. | Return a list of available modes. | def available_modes(self):
"""Return a list of available modes."""
if self._away_humidity:
return [MODE_NORMAL, MODE_AWAY]
return None | [
"def",
"available_modes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_away_humidity",
":",
"return",
"[",
"MODE_NORMAL",
",",
"MODE_AWAY",
"]",
"return",
"None"
] | [
245,
4
] | [
249,
19
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.device_class | (self) | Return the device class of the humidifier. | Return the device class of the humidifier. | def device_class(self):
"""Return the device class of the humidifier."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
252,
4
] | [
254,
33
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.async_turn_on | (self, **kwargs) | Turn hygrostat on. | Turn hygrostat on. | async def async_turn_on(self, **kwargs):
"""Turn hygrostat on."""
if not self._active:
return
self._state = True
await self._async_operate(force=True)
await self.async_update_ha_state() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_active",
":",
"return",
"self",
".",
"_state",
"=",
"True",
"await",
"self",
".",
"_async_operate",
"(",
"force",
"=",
"True",
")",
"await",
... | [
256,
4
] | [
262,
42
] | python | en | ['fi', 'ru-Latn', 'en'] | False |
GenericHygrostat.async_turn_off | (self, **kwargs) | Turn hygrostat off. | Turn hygrostat off. | async def async_turn_off(self, **kwargs):
"""Turn hygrostat off."""
if not self._active:
return
self._state = False
if self._is_device_active:
await self._async_device_turn_off()
await self.async_update_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_active",
":",
"return",
"self",
".",
"_state",
"=",
"False",
"if",
"self",
".",
"_is_device_active",
":",
"await",
"self",
".",
"_async_device_t... | [
264,
4
] | [
271,
42
] | python | en | ['en', 'ru-Latn', 'en'] | True |
GenericHygrostat.async_set_humidity | (self, humidity: int) | Set new target humidity. | Set new target humidity. | async def async_set_humidity(self, humidity: int):
"""Set new target humidity."""
if humidity is None:
return
if self._is_away and self._away_fixed:
self._saved_target_humidity = humidity
await self.async_update_ha_state()
return
self._ta... | [
"async",
"def",
"async_set_humidity",
"(",
"self",
",",
"humidity",
":",
"int",
")",
":",
"if",
"humidity",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_is_away",
"and",
"self",
".",
"_away_fixed",
":",
"self",
".",
"_saved_target_humidity",
"=",
"hum... | [
273,
4
] | [
285,
42
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat.min_humidity | (self) | Return the minimum humidity. | Return the minimum humidity. | def min_humidity(self):
"""Return the minimum humidity."""
if self._min_humidity:
return self._min_humidity
# get default humidity from super class
return super().min_humidity | [
"def",
"min_humidity",
"(",
"self",
")",
":",
"if",
"self",
".",
"_min_humidity",
":",
"return",
"self",
".",
"_min_humidity",
"# get default humidity from super class",
"return",
"super",
"(",
")",
".",
"min_humidity"
] | [
288,
4
] | [
294,
35
] | python | en | ['en', 'et', 'en'] | True |
GenericHygrostat.max_humidity | (self) | Return the maximum humidity. | Return the maximum humidity. | def max_humidity(self):
"""Return the maximum humidity."""
if self._max_humidity:
return self._max_humidity
# Get default humidity from super class
return super().max_humidity | [
"def",
"max_humidity",
"(",
"self",
")",
":",
"if",
"self",
".",
"_max_humidity",
":",
"return",
"self",
".",
"_max_humidity",
"# Get default humidity from super class",
"return",
"super",
"(",
")",
".",
"max_humidity"
] | [
297,
4
] | [
303,
35
] | python | en | ['en', 'la', 'en'] | True |
GenericHygrostat._async_sensor_changed | (self, entity_id, old_state, new_state) | Handle ambient humidity changes. | Handle ambient humidity changes. | async def _async_sensor_changed(self, entity_id, old_state, new_state):
"""Handle ambient humidity changes."""
if new_state is None:
return
if self._sensor_stale_duration:
if self._remove_stale_tracking:
self._remove_stale_tracking()
self._rem... | [
"async",
"def",
"_async_sensor_changed",
"(",
"self",
",",
"entity_id",
",",
"old_state",
",",
"new_state",
")",
":",
"if",
"new_state",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_sensor_stale_duration",
":",
"if",
"self",
".",
"_remove_stale_tracking",
... | [
306,
4
] | [
322,
42
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat._async_sensor_not_responding | (self, now=None) | Handle sensor stale event. | Handle sensor stale event. | async def _async_sensor_not_responding(self, now=None):
"""Handle sensor stale event."""
_LOGGER.debug(
"Sensor has not been updated for %s",
now - self.hass.states.get(self._sensor_entity_id).last_updated,
)
_LOGGER.warning("Sensor is stalled, call the emergency... | [
"async",
"def",
"_async_sensor_not_responding",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Sensor has not been updated for %s\"",
",",
"now",
"-",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"self",
".",
"_senso... | [
325,
4
] | [
333,
52
] | python | bs | ['it', 'bs', 'en'] | False |
GenericHygrostat._async_switch_changed | (self, entity_id, old_state, new_state) | Handle humidifier switch state changes. | Handle humidifier switch state changes. | def _async_switch_changed(self, entity_id, old_state, new_state):
"""Handle humidifier switch state changes."""
if new_state is None:
return
self.async_schedule_update_ha_state() | [
"def",
"_async_switch_changed",
"(",
"self",
",",
"entity_id",
",",
"old_state",
",",
"new_state",
")",
":",
"if",
"new_state",
"is",
"None",
":",
"return",
"self",
".",
"async_schedule_update_ha_state",
"(",
")"
] | [
336,
4
] | [
340,
45
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat._async_update_humidity | (self, humidity) | Update hygrostat with latest state from sensor. | Update hygrostat with latest state from sensor. | async def _async_update_humidity(self, humidity):
"""Update hygrostat with latest state from sensor."""
try:
self._cur_humidity = float(humidity)
except ValueError as ex:
_LOGGER.warning("Unable to update from sensor: %s", ex)
self._cur_humidity = None
... | [
"async",
"def",
"_async_update_humidity",
"(",
"self",
",",
"humidity",
")",
":",
"try",
":",
"self",
".",
"_cur_humidity",
"=",
"float",
"(",
"humidity",
")",
"except",
"ValueError",
"as",
"ex",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Unable to update from se... | [
342,
4
] | [
351,
51
] | python | en | ['en', 'en', 'en'] | True |
GenericHygrostat._async_operate | (self, time=None, force=False) | Check if we need to turn humidifying on or off. | Check if we need to turn humidifying on or off. | async def _async_operate(self, time=None, force=False):
"""Check if we need to turn humidifying on or off."""
async with self._humidity_lock:
if not self._active and None not in (
self._cur_humidity,
self._target_humidity,
):
self._... | [
"async",
"def",
"_async_operate",
"(",
"self",
",",
"time",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"async",
"with",
"self",
".",
"_humidity_lock",
":",
"if",
"not",
"self",
".",
"_active",
"and",
"None",
"not",
"in",
"(",
"self",
".",
"_c... | [
353,
4
] | [
418,
55
] | 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.