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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ElecPriceSensor.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
self._pvpc_data.state = state.state
# Update 'state' value in hour changes
self._hourly_track... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
":",
"self",
".",
"_pvpc_data",
".",
"state... | [
65,
4
] | [
91,
51
] | python | en | ['en', 'en', 'en'] | True |
ElecPriceSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_unique_id"
] | [
94,
4
] | [
96,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
ElecPriceSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
99,
4
] | [
101,
25
] | python | en | ['en', 'mi', 'en'] | True |
ElecPriceSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._pvpc_data.state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pvpc_data",
".",
"state"
] | [
104,
4
] | [
106,
36
] | python | en | ['en', 'en', 'en'] | True |
ElecPriceSensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._pvpc_data.state_available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_pvpc_data",
".",
"state_available"
] | [
109,
4
] | [
111,
46
] | python | en | ['en', 'en', 'en'] | True |
ElecPriceSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._pvpc_data.attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pvpc_data",
".",
"attributes"
] | [
114,
4
] | [
116,
41
] | python | en | ['en', 'en', 'en'] | True |
ElecPriceSensor.update_current_price | (self, now) | Update the sensor state, by selecting the current price for this hour. | Update the sensor state, by selecting the current price for this hour. | def update_current_price(self, now):
"""Update the sensor state, by selecting the current price for this hour."""
self._pvpc_data.process_state_and_attributes(now)
self.async_write_ha_state() | [
"def",
"update_current_price",
"(",
"self",
",",
"now",
")",
":",
"self",
".",
"_pvpc_data",
".",
"process_state_and_attributes",
"(",
"now",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
119,
4
] | [
122,
35
] | python | en | ['en', 'en', 'en'] | True |
ElecPriceSensor.async_update_prices | (self, now) | Update electricity prices from the ESIOS API. | Update electricity prices from the ESIOS API. | async def async_update_prices(self, now):
"""Update electricity prices from the ESIOS API."""
prices = await self._pvpc_data.async_update_prices(now)
if not prices and self._pvpc_data.source_available:
self._num_retries += 1
if self._num_retries > 2:
_LOGG... | [
"async",
"def",
"async_update_prices",
"(",
"self",
",",
"now",
")",
":",
"prices",
"=",
"await",
"self",
".",
"_pvpc_data",
".",
"async_update_prices",
"(",
"now",
")",
"if",
"not",
"prices",
"and",
"self",
".",
"_pvpc_data",
".",
"source_available",
":",
... | [
124,
4
] | [
155,
42
] | python | en | ['en', 'en', 'en'] | True |
max_pool2d | (A, kernel_size=3, stride=1, padding=1) | 2D Max Pooling
Parameters:
A: input 2D array
kernel_size: int, the size of the window
stride: int, the stride of the window
padding: int, implicit zero paddings on both sides of the input
| 2D Max Pooling
Parameters:
A: input 2D array
kernel_size: int, the size of the window
stride: int, the stride of the window
padding: int, implicit zero paddings on both sides of the input
| def max_pool2d(A, kernel_size=3, stride=1, padding=1):
"""2D Max Pooling
Parameters:
A: input 2D array
kernel_size: int, the size of the window
stride: int, the stride of the window
padding: int, implicit zero paddings on both sides of the input
"""
A = np.pad(A, padding,... | [
"def",
"max_pool2d",
"(",
"A",
",",
"kernel_size",
"=",
"3",
",",
"stride",
"=",
"1",
",",
"padding",
"=",
"1",
")",
":",
"A",
"=",
"np",
".",
"pad",
"(",
"A",
",",
"padding",
",",
"mode",
"=",
"'constant'",
")",
"output_shape",
"=",
"(",
"(",
... | [
33,
0
] | [
48,
53
] | python | en | ['en', 'bg', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Vultr subscription switch. | Set up the Vultr subscription switch. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Vultr subscription switch."""
vultr = hass.data[DATA_VULTR]
subscription = config.get(CONF_SUBSCRIPTION)
name = config.get(CONF_NAME)
if subscription not in vultr.data:
_LOGGER.error("Subscription %s not fou... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"vultr",
"=",
"hass",
".",
"data",
"[",
"DATA_VULTR",
"]",
"subscription",
"=",
"config",
".",
"get",
"(",
"CONF_SUBSCRIPTION",
")",
"na... | [
38,
0
] | [
49,
64
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.__init__ | (self, vultr, subscription, name) | Initialize a new Vultr switch. | Initialize a new Vultr switch. | def __init__(self, vultr, subscription, name):
"""Initialize a new Vultr switch."""
self._vultr = vultr
self._name = name
self.subscription = subscription
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"vultr",
",",
"subscription",
",",
"name",
")",
":",
"self",
".",
"_vultr",
"=",
"vultr",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"subscription",
"=",
"subscription",
"self",
".",
"data",
"=",
"None"
] | [
55,
4
] | [
61,
24
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
try:
return self._name.format(self.data["label"])
except (TypeError, KeyError):
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_name",
".",
"format",
"(",
"self",
".",
"data",
"[",
"\"label\"",
"]",
")",
"except",
"(",
"TypeError",
",",
"KeyError",
")",
":",
"return",
"self",
".",
"_name"
] | [
64,
4
] | [
69,
29
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self.data["power_status"] == "running" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"==",
"\"running\""
] | [
72,
4
] | [
74,
53
] | python | en | ['en', 'fy', 'en'] | True |
VultrSwitch.icon | (self) | Return the icon of this server. | Return the icon of this server. | def icon(self):
"""Return the icon of this server."""
return "mdi:server" if self.is_on else "mdi:server-off" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:server\"",
"if",
"self",
".",
"is_on",
"else",
"\"mdi:server-off\""
] | [
77,
4
] | [
79,
63
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.device_state_attributes | (self) | Return the state attributes of the Vultr subscription. | Return the state attributes of the Vultr subscription. | def device_state_attributes(self):
"""Return the state attributes of the Vultr subscription."""
return {
ATTR_ALLOWED_BANDWIDTH: self.data.get("allowed_bandwidth_gb"),
ATTR_AUTO_BACKUPS: self.data.get("auto_backups"),
ATTR_COST_PER_MONTH: self.data.get("cost_per_month... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ALLOWED_BANDWIDTH",
":",
"self",
".",
"data",
".",
"get",
"(",
"\"allowed_bandwidth_gb\"",
")",
",",
"ATTR_AUTO_BACKUPS",
":",
"self",
".",
"data",
".",
"get",
"(",
"\"auto_backups\"",... | [
82,
4
] | [
98,
9
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.turn_on | (self, **kwargs) | Boot-up the subscription. | Boot-up the subscription. | def turn_on(self, **kwargs):
"""Boot-up the subscription."""
if self.data["power_status"] != "running":
self._vultr.start(self.subscription) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"!=",
"\"running\"",
":",
"self",
".",
"_vultr",
".",
"start",
"(",
"self",
".",
"subscription",
")"
] | [
100,
4
] | [
103,
48
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.turn_off | (self, **kwargs) | Halt the subscription. | Halt the subscription. | def turn_off(self, **kwargs):
"""Halt the subscription."""
if self.data["power_status"] == "running":
self._vultr.halt(self.subscription) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"==",
"\"running\"",
":",
"self",
".",
"_vultr",
".",
"halt",
"(",
"self",
".",
"subscription",
")"
] | [
105,
4
] | [
108,
47
] | python | en | ['en', 'ga', 'en'] | True |
VultrSwitch.update | (self) | Get the latest data from the device and update the data. | Get the latest data from the device and update the data. | def update(self):
"""Get the latest data from the device and update the data."""
self._vultr.update()
self.data = self._vultr.data[self.subscription] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_vultr",
".",
"update",
"(",
")",
"self",
".",
"data",
"=",
"self",
".",
"_vultr",
".",
"data",
"[",
"self",
".",
"subscription",
"]"
] | [
110,
4
] | [
113,
55
] | python | en | ['en', 'en', 'en'] | True |
async_init_integration | (hass: HomeAssistant) | Set up the homekit integration in Home Assistant. | Set up the homekit integration in Home Assistant. | async def async_init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the homekit integration in Home Assistant."""
with patch(f"{PATH_HOMEKIT}.HomeKit.async_start"):
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
entr... | [
"async",
"def",
"async_init_integration",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"MockConfigEntry",
":",
"with",
"patch",
"(",
"f\"{PATH_HOMEKIT}.HomeKit.async_start\"",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"... | [
12,
0
] | [
22,
20
] | python | en | ['en', 'en', 'en'] | True |
async_init_entry | (hass: HomeAssistant, entry: MockConfigEntry) | Set up the homekit integration in Home Assistant. | Set up the homekit integration in Home Assistant. | async def async_init_entry(hass: HomeAssistant, entry: MockConfigEntry):
"""Set up the homekit integration in Home Assistant."""
with patch(f"{PATH_HOMEKIT}.HomeKit.async_start"):
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block... | [
"async",
"def",
"async_init_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"MockConfigEntry",
")",
":",
"with",
"patch",
"(",
"f\"{PATH_HOMEKIT}.HomeKit.async_start\"",
")",
":",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"await",
"h... | [
25,
0
] | [
32,
20
] | python | en | ['en', 'en', 'en'] | True |
test_setup_minimum | (hass, requests_mock) | Test setup with minimum configuration. | Test setup with minimum configuration. | async def test_setup_minimum(hass, requests_mock):
"""Test setup with minimum configuration."""
resource = f"http://{google_wifi.DEFAULT_HOST}{google_wifi.ENDPOINT}"
requests_mock.get(resource, status_code=200)
assert await async_setup_component(
hass,
"sensor",
{"sensor": {"plat... | [
"async",
"def",
"test_setup_minimum",
"(",
"hass",
",",
"requests_mock",
")",
":",
"resource",
"=",
"f\"http://{google_wifi.DEFAULT_HOST}{google_wifi.ENDPOINT}\"",
"requests_mock",
".",
"get",
"(",
"resource",
",",
"status_code",
"=",
"200",
")",
"assert",
"await",
"a... | [
32,
0
] | [
41,
39
] | python | en | ['en', 'zu', 'en'] | True |
test_setup_get | (hass, requests_mock) | Test setup with full configuration. | Test setup with full configuration. | async def test_setup_get(hass, requests_mock):
"""Test setup with full configuration."""
resource = f"http://localhost{google_wifi.ENDPOINT}"
requests_mock.get(resource, status_code=200)
assert await async_setup_component(
hass,
"sensor",
{
"sensor": {
... | [
"async",
"def",
"test_setup_get",
"(",
"hass",
",",
"requests_mock",
")",
":",
"resource",
"=",
"f\"http://localhost{google_wifi.ENDPOINT}\"",
"requests_mock",
".",
"get",
"(",
"resource",
",",
"status_code",
"=",
"200",
")",
"assert",
"await",
"async_setup_component"... | [
44,
0
] | [
67,
39
] | python | en | ['en', 'en', 'en'] | True |
setup_api | (data, requests_mock) | Set up API with fake data. | Set up API with fake data. | def setup_api(data, requests_mock):
"""Set up API with fake data."""
resource = f"http://localhost{google_wifi.ENDPOINT}"
now = datetime(1970, month=1, day=1)
sensor_dict = {}
with patch("homeassistant.util.dt.now", return_value=now):
requests_mock.get(resource, text=data, status_code=200)
... | [
"def",
"setup_api",
"(",
"data",
",",
"requests_mock",
")",
":",
"resource",
"=",
"f\"http://localhost{google_wifi.ENDPOINT}\"",
"now",
"=",
"datetime",
"(",
"1970",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
")",
"sensor_dict",
"=",
"{",
"}",
"with",
"... | [
70,
0
] | [
86,
27
] | python | en | ['en', 'zu', 'en'] | True |
fake_delay | (hass, ha_delay) | Fake delay to prevent update throttle. | Fake delay to prevent update throttle. | def fake_delay(hass, ha_delay):
"""Fake delay to prevent update throttle."""
hass_now = dt_util.utcnow()
shifted_time = hass_now + timedelta(seconds=ha_delay)
async_fire_time_changed(hass, shifted_time) | [
"def",
"fake_delay",
"(",
"hass",
",",
"ha_delay",
")",
":",
"hass_now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"shifted_time",
"=",
"hass_now",
"+",
"timedelta",
"(",
"seconds",
"=",
"ha_delay",
")",
"async_fire_time_changed",
"(",
"hass",
",",
"shifted_t... | [
89,
0
] | [
93,
47
] | python | en | ['en', 'en', 'en'] | True |
test_name | (requests_mock) | Test the name. | Test the name. | def test_name(requests_mock):
"""Test the name."""
api, sensor_dict = setup_api(MOCK_DATA, requests_mock)
for name in sensor_dict:
sensor = sensor_dict[name]["sensor"]
test_name = sensor_dict[name]["name"]
assert test_name == sensor.name | [
"def",
"test_name",
"(",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA",
",",
"requests_mock",
")",
"for",
"name",
"in",
"sensor_dict",
":",
"sensor",
"=",
"sensor_dict",
"[",
"name",
"]",
"[",
"\"sensor\"",
"]",
"... | [
96,
0
] | [
102,
39
] | python | en | ['en', 'en', 'en'] | True |
test_unit_of_measurement | (requests_mock) | Test the unit of measurement. | Test the unit of measurement. | def test_unit_of_measurement(requests_mock):
"""Test the unit of measurement."""
api, sensor_dict = setup_api(MOCK_DATA, requests_mock)
for name in sensor_dict:
sensor = sensor_dict[name]["sensor"]
assert sensor_dict[name]["units"] == sensor.unit_of_measurement | [
"def",
"test_unit_of_measurement",
"(",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA",
",",
"requests_mock",
")",
"for",
"name",
"in",
"sensor_dict",
":",
"sensor",
"=",
"sensor_dict",
"[",
"name",
"]",
"[",
"\"sensor... | [
105,
0
] | [
110,
71
] | python | en | ['en', 'fr', 'en'] | True |
test_icon | (requests_mock) | Test the icon. | Test the icon. | def test_icon(requests_mock):
"""Test the icon."""
api, sensor_dict = setup_api(MOCK_DATA, requests_mock)
for name in sensor_dict:
sensor = sensor_dict[name]["sensor"]
assert sensor_dict[name]["icon"] == sensor.icon | [
"def",
"test_icon",
"(",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA",
",",
"requests_mock",
")",
"for",
"name",
"in",
"sensor_dict",
":",
"sensor",
"=",
"sensor_dict",
"[",
"name",
"]",
"[",
"\"sensor\"",
"]",
"... | [
113,
0
] | [
118,
55
] | python | en | ['en', 'en', 'en'] | True |
test_state | (hass, requests_mock) | Test the initial state. | Test the initial state. | def test_state(hass, requests_mock):
"""Test the initial state."""
api, sensor_dict = setup_api(MOCK_DATA, requests_mock)
now = datetime(1970, month=1, day=1)
with patch("homeassistant.util.dt.now", return_value=now):
for name in sensor_dict:
sensor = sensor_dict[name]["sensor"]
... | [
"def",
"test_state",
"(",
"hass",
",",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA",
",",
"requests_mock",
")",
"now",
"=",
"datetime",
"(",
"1970",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
")",
"with",
... | [
121,
0
] | [
137,
48
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_value_is_none | (hass, requests_mock) | Test state gets updated to unknown when sensor returns no data. | Test state gets updated to unknown when sensor returns no data. | def test_update_when_value_is_none(hass, requests_mock):
"""Test state gets updated to unknown when sensor returns no data."""
api, sensor_dict = setup_api(None, requests_mock)
for name in sensor_dict:
sensor = sensor_dict[name]["sensor"]
fake_delay(hass, 2)
sensor.update()
a... | [
"def",
"test_update_when_value_is_none",
"(",
"hass",
",",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"None",
",",
"requests_mock",
")",
"for",
"name",
"in",
"sensor_dict",
":",
"sensor",
"=",
"sensor_dict",
"[",
"name",
"]",
... | [
140,
0
] | [
147,
35
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_value_changed | (hass, requests_mock) | Test state gets updated when sensor returns a new status. | Test state gets updated when sensor returns a new status. | def test_update_when_value_changed(hass, requests_mock):
"""Test state gets updated when sensor returns a new status."""
api, sensor_dict = setup_api(MOCK_DATA_NEXT, requests_mock)
now = datetime(1970, month=1, day=1)
with patch("homeassistant.util.dt.now", return_value=now):
for name in sensor_... | [
"def",
"test_update_when_value_changed",
"(",
"hass",
",",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA_NEXT",
",",
"requests_mock",
")",
"now",
"=",
"datetime",
"(",
"1970",
",",
"month",
"=",
"1",
",",
"day",
"=",... | [
150,
0
] | [
170,
45
] | python | en | ['en', 'en', 'en'] | True |
test_when_api_data_missing | (hass, requests_mock) | Test state logs an error when data is missing. | Test state logs an error when data is missing. | def test_when_api_data_missing(hass, requests_mock):
"""Test state logs an error when data is missing."""
api, sensor_dict = setup_api(MOCK_DATA_MISSING, requests_mock)
now = datetime(1970, month=1, day=1)
with patch("homeassistant.util.dt.now", return_value=now):
for name in sensor_dict:
... | [
"def",
"test_when_api_data_missing",
"(",
"hass",
",",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA_MISSING",
",",
"requests_mock",
")",
"now",
"=",
"datetime",
"(",
"1970",
",",
"month",
"=",
"1",
",",
"day",
"=",
... | [
173,
0
] | [
182,
48
] | python | en | ['en', 'en', 'en'] | True |
test_update_when_unavailable | (requests_mock) | Test state updates when Google Wifi unavailable. | Test state updates when Google Wifi unavailable. | def test_update_when_unavailable(requests_mock):
"""Test state updates when Google Wifi unavailable."""
api, sensor_dict = setup_api(None, requests_mock)
api.update = Mock(
"google_wifi.GoogleWifiAPI.update",
side_effect=update_side_effect(requests_mock),
)
for name in sensor_dict:
... | [
"def",
"test_update_when_unavailable",
"(",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"None",
",",
"requests_mock",
")",
"api",
".",
"update",
"=",
"Mock",
"(",
"\"google_wifi.GoogleWifiAPI.update\"",
",",
"side_effect",
"=",
"up... | [
185,
0
] | [
195,
35
] | python | en | ['en', 'en', 'en'] | True |
update_side_effect | (requests_mock) | Mock representation of update function. | Mock representation of update function. | def update_side_effect(requests_mock):
"""Mock representation of update function."""
api, sensor_dict = setup_api(MOCK_DATA, requests_mock)
api.data = None
api.available = False | [
"def",
"update_side_effect",
"(",
"requests_mock",
")",
":",
"api",
",",
"sensor_dict",
"=",
"setup_api",
"(",
"MOCK_DATA",
",",
"requests_mock",
")",
"api",
".",
"data",
"=",
"None",
"api",
".",
"available",
"=",
"False"
] | [
198,
0
] | [
202,
25
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the UpCloud server switch. | Set up the UpCloud server switch. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the UpCloud server switch."""
coordinator = hass.data[DATA_UPCLOUD].coordinators[config_entry.data[CONF_USERNAME]]
entities = [UpCloudSwitch(coordinator, uuid) for uuid in coordinator.data]
async_add_entities(entities, True) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DATA_UPCLOUD",
"]",
".",
"coordinators",
"[",
"config_entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
"]"... | [
16,
0
] | [
20,
38
] | python | en | ['en', 'en', 'en'] | True |
UpCloudSwitch.turn_on | (self, **kwargs) | Start the server. | Start the server. | def turn_on(self, **kwargs):
"""Start the server."""
if self.state == STATE_OFF:
self._server.start()
dispatcher_send(self.hass, SIGNAL_UPDATE_UPCLOUD) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_OFF",
":",
"self",
".",
"_server",
".",
"start",
"(",
")",
"dispatcher_send",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_UPCLOUD",
")"
] | [
26,
4
] | [
30,
61
] | python | en | ['en', 'no', 'en'] | True |
UpCloudSwitch.turn_off | (self, **kwargs) | Stop the server. | Stop the server. | def turn_off(self, **kwargs):
"""Stop the server."""
if self.is_on:
self._server.stop() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_on",
":",
"self",
".",
"_server",
".",
"stop",
"(",
")"
] | [
32,
4
] | [
35,
31
] | python | en | ['en', 'en', 'en'] | True |
test_entity_and_device_attributes | (hass, scene) | Test the attributes of the entity are correct. | Test the attributes of the entity are correct. | async def test_entity_and_device_attributes(hass, scene):
"""Test the attributes of the entity are correct."""
# Arrange
entity_registry = await hass.helpers.entity_registry.async_get_registry()
# Act
await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
# Assert
entry = entity_registry.a... | [
"async",
"def",
"test_entity_and_device_attributes",
"(",
"hass",
",",
"scene",
")",
":",
"# Arrange",
"entity_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"# Act",
"await",
"setup_platform",
"(",
"h... | [
12,
0
] | [
21,
44
] | python | en | ['en', 'en', 'en'] | True |
test_scene_activate | (hass, scene) | Test the scene is activated. | Test the scene is activated. | async def test_scene_activate(hass, scene):
"""Test the scene is activated."""
await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
await hass.services.async_call(
SCENE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "scene.test_scene"},
blocking=True,
)
state = hass.s... | [
"async",
"def",
"test_scene_activate",
"(",
"hass",
",",
"scene",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SCENE_DOMAIN",
",",
"scenes",
"=",
"[",
"scene",
"]",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"SCENE_DOMAIN",
"... | [
24,
0
] | [
38,
40
] | python | en | ['en', 'en', 'en'] | True |
test_unload_config_entry | (hass, scene) | Test the scene is removed when the config entry is unloaded. | Test the scene is removed when the config entry is unloaded. | async def test_unload_config_entry(hass, scene):
"""Test the scene is removed when the config entry is unloaded."""
# Arrange
config_entry = await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
# Act
await hass.config_entries.async_forward_entry_unload(config_entry, SCENE_DOMAIN)
# Assert
... | [
"async",
"def",
"test_unload_config_entry",
"(",
"hass",
",",
"scene",
")",
":",
"# Arrange",
"config_entry",
"=",
"await",
"setup_platform",
"(",
"hass",
",",
"SCENE_DOMAIN",
",",
"scenes",
"=",
"[",
"scene",
"]",
")",
"# Act",
"await",
"hass",
".",
"config... | [
41,
0
] | [
48,
50
] | python | en | ['en', 'en', 'en'] | True |
test_failed_config | (
hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None]
) | Test failed configuration. | Test failed configuration. | async def test_failed_config(
hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None]
) -> None:
"""Test failed configuration."""
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) is False | [
"async",
"def",
"test_failed_config",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_failed_bridge",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
")",
"->",
"None",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",... | [
46,
0
] | [
50,
86
] | python | en | ['en', 'sm', 'en'] | True |
test_minimal_config | (
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) | Test setup with configuration minimal entries. | Test setup with configuration minimal entries. | async def test_minimal_config(
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) -> None:
"""Test setup with configuration minimal entries."""
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) | [
"async",
"def",
"test_minimal_config",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_bridge",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
")",
"->",
"None",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
","... | [
53,
0
] | [
57,
77
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_data_bucket | (
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) | Test the event send with the updated device. | Test the event send with the updated device. | async def test_discovery_data_bucket(
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) -> None:
"""Test the event send with the updated device."""
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
await hass.async_block_till_done()
device = hass.data[DOMAI... | [
"async",
"def",
"test_discovery_data_bucket",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_bridge",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
")",
"->",
"None",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN"... | [
60,
0
] | [
78,
44
] | python | en | ['en', 'en', 'en'] | True |
test_set_auto_off_service | (
hass: HomeAssistantType,
mock_bridge: Generator[None, Any, None],
mock_api: Generator[None, Any, None],
hass_owner_user: "MockUser",
hass_read_only_user: "MockUser",
) | Test the set_auto_off service. | Test the set_auto_off service. | async def test_set_auto_off_service(
hass: HomeAssistantType,
mock_bridge: Generator[None, Any, None],
mock_api: Generator[None, Any, None],
hass_owner_user: "MockUser",
hass_read_only_user: "MockUser",
) -> None:
"""Test the set_auto_off service."""
assert await async_setup_component(hass, ... | [
"async",
"def",
"test_set_auto_off_service",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_bridge",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
",",
"mock_api",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
",",
"hass_ow... | [
81,
0
] | [
152,
86
] | python | en | ['en', 'fr', 'en'] | True |
test_signal_dispatcher | (
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) | Test signal dispatcher dispatching device updates every 4 seconds. | Test signal dispatcher dispatching device updates every 4 seconds. | async def test_signal_dispatcher(
hass: HomeAssistantType, mock_bridge: Generator[None, Any, None]
) -> None:
"""Test signal dispatcher dispatching device updates every 4 seconds."""
assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION)
await hass.async_block_till_done()
@callb... | [
"async",
"def",
"test_signal_dispatcher",
"(",
"hass",
":",
"HomeAssistantType",
",",
"mock_bridge",
":",
"Generator",
"[",
"None",
",",
"Any",
",",
"None",
"]",
")",
"->",
"None",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
... | [
155,
0
] | [
170,
69
] | python | en | ['id', 'en', 'en'] | True |
ReLUConvBN.forward | (self, x) |
Parameters
---
x: torch.Tensor
input tensor
|
Parameters
---
x: torch.Tensor
input tensor
| def forward(self, x):
"""
Parameters
---
x: torch.Tensor
input tensor
"""
return self.op(x) | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"return",
"self",
".",
"op",
"(",
"x",
")"
] | [
36,
4
] | [
43,
25
] | python | en | ['en', 'error', 'th'] | False |
Pooling.forward | (self, x) |
Parameters
---
x: torch.Tensor
input tensor
|
Parameters
---
x: torch.Tensor
input tensor
| def forward(self, x):
"""
Parameters
---
x: torch.Tensor
input tensor
"""
if self.preprocess:
x = self.preprocess(x)
return self.op(x) | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"preprocess",
":",
"x",
"=",
"self",
".",
"preprocess",
"(",
"x",
")",
"return",
"self",
".",
"op",
"(",
"x",
")"
] | [
72,
4
] | [
81,
25
] | python | en | ['en', 'error', 'th'] | False |
Zero.forward | (self, x) |
Parameters
---
x: torch.Tensor
input tensor
|
Parameters
---
x: torch.Tensor
input tensor
| def forward(self, x):
"""
Parameters
---
x: torch.Tensor
input tensor
"""
if self.C_in == self.C_out:
if self.stride == 1:
return x.mul(0.)
else:
return x[:, :, ::self.stride, ::self.stride].mul(0.)
... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"C_in",
"==",
"self",
".",
"C_out",
":",
"if",
"self",
".",
"stride",
"==",
"1",
":",
"return",
"x",
".",
"mul",
"(",
"0.",
")",
"else",
":",
"return",
"x",
"[",
":",
",",
... | [
102,
4
] | [
118,
24
] | python | en | ['en', 'error', 'th'] | False |
_assert_tensors_equal | (a, b, atol=1e-12, prefix="") | If tensors not close, or a and b arent both tensors, raise a nice Assertion error. | If tensors not close, or a and b arent both tensors, raise a nice Assertion error. | def _assert_tensors_equal(a, b, atol=1e-12, prefix=""):
"""If tensors not close, or a and b arent both tensors, raise a nice Assertion error."""
if a is None and b is None:
return True
try:
if tf.debugging.assert_near(a, b, atol=atol):
return True
raise
except Excepti... | [
"def",
"_assert_tensors_equal",
"(",
"a",
",",
"b",
",",
"atol",
"=",
"1e-12",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
":",
"return",
"True",
"try",
":",
"if",
"tf",
".",
"debugging",
".",
"assert_ne... | [
280,
0
] | [
292,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the EBox sensor. | Set up the EBox sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the EBox sensor."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
httpsession = hass.helpers.aiohttp_client.async_get_clientsession()
ebox_data = EBoxData(username, password,... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_P... | [
69,
0
] | [
89,
37
] | python | en | ['en', 'ca', 'en'] | True |
EBoxSensor.__init__ | (self, ebox_data, sensor_type, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, ebox_data, sensor_type, name):
"""Initialize the sensor."""
self.client_name = name
self.type = sensor_type
self._name = SENSOR_TYPES[sensor_type][0]
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._icon = SENSOR_TYPES[sensor_type][2]
... | [
"def",
"__init__",
"(",
"self",
",",
"ebox_data",
",",
"sensor_type",
",",
"name",
")",
":",
"self",
".",
"client_name",
"=",
"name",
"self",
".",
"type",
"=",
"sensor_type",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
"sensor_type",
"]",
"[",
"0",
... | [
95,
4
] | [
103,
26
] | python | en | ['en', 'en', 'en'] | True |
EBoxSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
106,
4
] | [
108,
49
] | python | en | ['en', 'mi', 'en'] | True |
EBoxSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
111,
4
] | [
113,
26
] | python | en | ['en', 'en', 'en'] | True |
EBoxSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
116,
4
] | [
118,
40
] | python | en | ['en', 'en', 'en'] | True |
EBoxSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
121,
4
] | [
123,
25
] | python | en | ['en', 'en', 'en'] | True |
EBoxSensor.async_update | (self) | Get the latest data from EBox and update the state. | Get the latest data from EBox and update the state. | async def async_update(self):
"""Get the latest data from EBox and update the state."""
await self.ebox_data.async_update()
if self.type in self.ebox_data.data:
self._state = round(self.ebox_data.data[self.type], 2) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"ebox_data",
".",
"async_update",
"(",
")",
"if",
"self",
".",
"type",
"in",
"self",
".",
"ebox_data",
".",
"data",
":",
"self",
".",
"_state",
"=",
"round",
"(",
"self",
".... | [
125,
4
] | [
129,
66
] | python | en | ['en', 'en', 'en'] | True |
EBoxData.__init__ | (self, username, password, httpsession) | Initialize the data object. | Initialize the data object. | def __init__(self, username, password, httpsession):
"""Initialize the data object."""
self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession)
self.data = {} | [
"def",
"__init__",
"(",
"self",
",",
"username",
",",
"password",
",",
"httpsession",
")",
":",
"self",
".",
"client",
"=",
"EboxClient",
"(",
"username",
",",
"password",
",",
"REQUESTS_TIMEOUT",
",",
"httpsession",
")",
"self",
".",
"data",
"=",
"{",
"... | [
135,
4
] | [
138,
22
] | python | en | ['en', 'en', 'en'] | True |
EBoxData.async_update | (self) | Get the latest data from Ebox. | Get the latest data from Ebox. | async def async_update(self):
"""Get the latest data from Ebox."""
try:
await self.client.fetch_data()
except PyEboxError as exp:
_LOGGER.error("Error on receive last EBox data: %s", exp)
return
# Update data
self.data = self.client.get_data() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"await",
"self",
".",
"client",
".",
"fetch_data",
"(",
")",
"except",
"PyEboxError",
"as",
"exp",
":",
"_LOGGER",
".",
"error",
"(",
"\"Error on receive last EBox data: %s\"",
",",
"exp",
")... | [
141,
4
] | [
149,
42
] | python | en | ['en', 'en', 'en'] | True |
mocked_exception | (*args, **kwargs) | Mock exception thrown by requests.get. | Mock exception thrown by requests.get. | def mocked_exception(*args, **kwargs):
"""Mock exception thrown by requests.get."""
raise OSError | [
"def",
"mocked_exception",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"OSError"
] | [
9,
0
] | [
11,
17
] | python | en | ['en', 'en', 'en'] | True |
mocked_requests_get | (*args, **kwargs) | Mock requests.get invocations. | Mock requests.get invocations. | def mocked_requests_get(*args, **kwargs):
"""Mock requests.get invocations."""
class MockResponse:
"""Class to represent a mocked response."""
def __init__(self, json_data, status_code):
"""Initialize the mock response class."""
self.json_data = json_data
se... | [
"def",
"mocked_requests_get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"class",
"MockResponse",
":",
"\"\"\"Class to represent a mocked response.\"\"\"",
"def",
"__init__",
"(",
"self",
",",
"json_data",
",",
"status_code",
")",
":",
"\"\"\"Initialize th... | [
14,
0
] | [
188,
55
] | python | en | ['en', 'nl', 'en'] | True |
test_diskspace_no_paths | (hass) | Test getting all disk space. | Test getting all disk space. | async def test_diskspace_no_paths(hass):
"""Test getting all disk space."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": [],
"monitored_conditions": ["diskspace... | [
"async",
"def",
"test_diskspace_no_paths",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"... | [
191,
0
] | [
217,
71
] | python | en | ['sv', 'en', 'en'] | True |
test_diskspace_paths | (hass) | Test getting diskspace for included paths. | Test getting diskspace for included paths. | async def test_diskspace_paths(hass):
"""Test getting diskspace for included paths."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_condit... | [
"async",
"def",
"test_diskspace_paths",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"i... | [
220,
0
] | [
246,
71
] | python | en | ['en', 'en', 'en'] | True |
test_commands | (hass) | Test getting running commands. | Test getting running commands. | async def test_commands(hass):
"""Test getting running commands."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_conditions": ["commands"]... | [
"async",
"def",
"test_commands",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"include_... | [
249,
0
] | [
275,
60
] | python | en | ['nl', 'en', 'en'] | True |
test_movies | (hass) | Test getting the number of movies. | Test getting the number of movies. | async def test_movies(hass):
"""Test getting the number of movies."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_conditions": ["movies"]... | [
"async",
"def",
"test_movies",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"include_pa... | [
278,
0
] | [
304,
70
] | python | en | ['en', 'en', 'en'] | True |
test_upcoming_multiple_days | (hass) | Test the upcoming movies for multiple days. | Test the upcoming movies for multiple days. | async def test_upcoming_multiple_days(hass):
"""Test the upcoming movies for multiple days."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitore... | [
"async",
"def",
"test_upcoming_multiple_days",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",... | [
307,
0
] | [
333,
82
] | python | en | ['en', 'en', 'en'] | True |
test_upcoming_today | (hass) | Test filtering for a single day.
Radarr needs to respond with at least 2 days.
| Test filtering for a single day. | async def test_upcoming_today(hass):
"""Test filtering for a single day.
Radarr needs to respond with at least 2 days.
"""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "1",
"unit": DATA_GIGABYTES,
"include_pat... | [
"async",
"def",
"test_upcoming_today",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"1\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"in... | [
337,
0
] | [
363,
82
] | python | en | ['en', 'en', 'en'] | True |
test_system_status | (hass) | Test the getting of the system status. | Test the getting of the system status. | async def test_system_status(hass):
"""Test the getting of the system status."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "2",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_conditions":... | [
"async",
"def",
"test_system_status",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"2\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"inc... | [
366,
0
] | [
389,
59
] | python | en | ['en', 'en', 'en'] | True |
test_ssl | (hass) | Test SSL being enabled. | Test SSL being enabled. | async def test_ssl(hass):
"""Test SSL being enabled."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "1",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_conditions": ["upcoming"],
... | [
"async",
"def",
"test_ssl",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"1\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"\"include_paths... | [
392,
0
] | [
417,
82
] | python | en | ['de', 'en', 'en'] | True |
test_exception_handling | (hass) | Test exception being handled. | Test exception being handled. | async def test_exception_handling(hass):
"""Test exception being handled."""
config = {
"sensor": {
"platform": "radarr",
"api_key": "foo",
"days": "1",
"unit": DATA_GIGABYTES,
"include_paths": ["/data"],
"monitored_conditions": ["u... | [
"async",
"def",
"test_exception_handling",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"radarr\"",
",",
"\"api_key\"",
":",
"\"foo\"",
",",
"\"days\"",
":",
"\"1\"",
",",
"\"unit\"",
":",
"DATA_GIGABYTES",
",",
"... | [
420,
0
] | [
440,
44
] | python | en | ['de', 'en', 'en'] | True |
setup_demo_climate | (hass) | Initialize setup demo climate. | Initialize setup demo climate. | async def setup_demo_climate(hass):
"""Initialize setup demo climate."""
hass.config.units = METRIC_SYSTEM
assert await async_setup_component(hass, DOMAIN, {"climate": {"platform": "demo"}})
await hass.async_block_till_done() | [
"async",
"def",
"setup_demo_climate",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"units",
"=",
"METRIC_SYSTEM",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"\"climate\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
... | [
54,
0
] | [
58,
38
] | python | en | ['en', 'pt', 'en'] | True |
test_setup_params | (hass) | Test the initial parameters. | Test the initial parameters. | def test_setup_params(hass):
"""Test the initial parameters."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.state == HVAC_MODE_COOL
assert state.attributes.get(ATTR_TEMPERATURE) == 21
assert state.attributes.get(ATTR_CURRENT_TEMPERATURE) == 22
assert state.attributes.get(ATTR_FAN_MODE) ... | [
"def",
"test_setup_params",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_COOL",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE"... | [
61,
0
] | [
79,
5
] | python | en | ['en', 'en', 'en'] | True |
test_default_setup_params | (hass) | Test the setup with default parameters. | Test the setup with default parameters. | def test_default_setup_params(hass):
"""Test the setup with default parameters."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_MIN_TEMP) == 7
assert state.attributes.get(ATTR_MAX_TEMP) == 35
assert state.attributes.get(ATTR_MIN_HUMIDITY) == 30
assert state.attributes... | [
"def",
"test_default_setup_params",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_MIN_TEMP",
")",
"==",
"7",
"assert",
"state",
".",
"attribu... | [
82,
0
] | [
88,
56
] | python | en | ['en', 'en', 'en'] | True |
test_set_only_target_temp_bad_attr | (hass) | Test setting the target temperature without required attribute. | Test setting the target temperature without required attribute. | async def test_set_only_target_temp_bad_attr(hass):
"""Test setting the target temperature without required attribute."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_TEMPERATURE) == 21
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMA... | [
"async",
"def",
"test_set_only_target_temp_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"==",
"21",
"with",
"pyt... | [
91,
0
] | [
105,
55
] | python | en | ['en', 'en', 'en'] | True |
test_set_only_target_temp | (hass) | Test the setting of the target temperature. | Test the setting of the target temperature. | async def test_set_only_target_temp(hass):
"""Test the setting of the target temperature."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_TEMPERATURE) == 21
await hass.services.async_call(
DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: ENTITY_CLIMA... | [
"async",
"def",
"test_set_only_target_temp",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"==",
"21",
"await",
"hass",
".... | [
108,
0
] | [
121,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_only_target_temp_with_convert | (hass) | Test the setting of the target temperature. | Test the setting of the target temperature. | async def test_set_only_target_temp_with_convert(hass):
"""Test the setting of the target temperature."""
state = hass.states.get(ENTITY_HEATPUMP)
assert state.attributes.get(ATTR_TEMPERATURE) == 20
await hass.services.async_call(
DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID... | [
"async",
"def",
"test_set_only_target_temp_with_convert",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_HEATPUMP",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"==",
"20",
"await",
... | [
124,
0
] | [
137,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_temp_range | (hass) | Test the setting of the target temperature with range. | Test the setting of the target temperature with range. | async def test_set_target_temp_range(hass):
"""Test the setting of the target temperature with range."""
state = hass.states.get(ENTITY_ECOBEE)
assert state.attributes.get(ATTR_TEMPERATURE) is None
assert state.attributes.get(ATTR_TARGET_TEMP_LOW) == 21.0
assert state.attributes.get(ATTR_TARGET_TEMP... | [
"async",
"def",
"test_set_target_temp_range",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_ECOBEE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"is",
"None",
"assert",
"state",
... | [
140,
0
] | [
161,
62
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_temp_range_bad_attr | (hass) | Test setting the target temperature range without attribute. | Test setting the target temperature range without attribute. | async def test_set_target_temp_range_bad_attr(hass):
"""Test setting the target temperature range without attribute."""
state = hass.states.get(ENTITY_ECOBEE)
assert state.attributes.get(ATTR_TEMPERATURE) is None
assert state.attributes.get(ATTR_TARGET_TEMP_LOW) == 21.0
assert state.attributes.get(A... | [
"async",
"def",
"test_set_target_temp_range_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_ECOBEE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"is",
"None",
"assert",
... | [
164,
0
] | [
186,
62
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_humidity_bad_attr | (hass) | Test setting the target humidity without required attribute. | Test setting the target humidity without required attribute. | async def test_set_target_humidity_bad_attr(hass):
"""Test setting the target humidity without required attribute."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_HUMIDITY) == 67
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMAIN,
... | [
"async",
"def",
"test_set_target_humidity_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HUMIDITY",
")",
"==",
"67",
"with",
"pytest"... | [
189,
0
] | [
203,
52
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_humidity | (hass) | Test the setting of the target humidity. | Test the setting of the target humidity. | async def test_set_target_humidity(hass):
"""Test the setting of the target humidity."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_HUMIDITY) == 67
await hass.services.async_call(
DOMAIN,
SERVICE_SET_HUMIDITY,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_H... | [
"async",
"def",
"test_set_target_humidity",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HUMIDITY",
")",
"==",
"67",
"await",
"hass",
".",
... | [
206,
0
] | [
219,
54
] | python | en | ['en', 'en', 'en'] | True |
test_set_fan_mode_bad_attr | (hass) | Test setting fan mode without required attribute. | Test setting fan mode without required attribute. | async def test_set_fan_mode_bad_attr(hass):
"""Test setting fan mode without required attribute."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_FAN_MODE) == "On High"
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMAIN,
SE... | [
"async",
"def",
"test_set_fan_mode_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_FAN_MODE",
")",
"==",
"\"On High\"",
"with",
"pytes... | [
222,
0
] | [
236,
59
] | python | en | ['en', 'en', 'en'] | True |
test_set_fan_mode | (hass) | Test setting of new fan mode. | Test setting of new fan mode. | async def test_set_fan_mode(hass):
"""Test setting of new fan mode."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_FAN_MODE) == "On High"
await hass.services.async_call(
DOMAIN,
SERVICE_SET_FAN_MODE,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_FAN_MODE: "O... | [
"async",
"def",
"test_set_fan_mode",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_FAN_MODE",
")",
"==",
"\"On High\"",
"await",
"hass",
".",... | [
239,
0
] | [
252,
58
] | python | en | ['en', 'fy', 'en'] | True |
test_set_swing_mode_bad_attr | (hass) | Test setting swing mode without required attribute. | Test setting swing mode without required attribute. | async def test_set_swing_mode_bad_attr(hass):
"""Test setting swing mode without required attribute."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_SWING_MODE) == "Off"
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMAIN,
... | [
"async",
"def",
"test_set_swing_mode_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SWING_MODE",
")",
"==",
"\"Off\"",
"with",
"pytes... | [
255,
0
] | [
269,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_swing | (hass) | Test setting of new swing mode. | Test setting of new swing mode. | async def test_set_swing(hass):
"""Test setting of new swing mode."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_SWING_MODE) == "Off"
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SWING_MODE,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_SWING_MODE: "... | [
"async",
"def",
"test_set_swing",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SWING_MODE",
")",
"==",
"\"Off\"",
"await",
"hass",
".",
"s... | [
272,
0
] | [
285,
58
] | python | en | ['en', 'en', 'en'] | True |
test_set_hvac_bad_attr_and_state | (hass) | Test setting hvac mode without required attribute.
Also check the state.
| Test setting hvac mode without required attribute. | async def test_set_hvac_bad_attr_and_state(hass):
"""Test setting hvac mode without required attribute.
Also check the state.
"""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_COOL
assert state.state == HVAC_MODE_COOL
with pytest.rais... | [
"async",
"def",
"test_set_hvac_bad_attr_and_state",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HVAC_ACTION",
")",
"==",
"CURRENT_HVAC_COOL",
"... | [
288,
0
] | [
307,
40
] | python | en | ['en', 'en', 'en'] | True |
test_set_hvac | (hass) | Test setting of new hvac mode. | Test setting of new hvac mode. | async def test_set_hvac(hass):
"""Test setting of new hvac mode."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.state == HVAC_MODE_COOL
await hass.services.async_call(
DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVAC_MODE_HEAT},
... | [
"async",
"def",
"test_set_hvac",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"state",
"==",
"HVAC_MODE_COOL",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN"... | [
310,
0
] | [
323,
40
] | python | en | ['en', 'bg', 'en'] | True |
test_set_hold_mode_away | (hass) | Test setting the hold mode away. | Test setting the hold mode away. | async def test_set_hold_mode_away(hass):
"""Test setting the hold mode away."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: ENTITY_ECOBEE, ATTR_PRESET_MODE: PRESET_AWAY},
blocking=True,
)
state = hass.states.get(ENTITY_ECOBEE)
as... | [
"async",
"def",
"test_set_hold_mode_away",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_PRESET_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_ECOBEE",
",",
"ATTR_PRESET_MODE",
":",
"PRESET_AWAY",
"}"... | [
326,
0
] | [
336,
64
] | python | en | ['en', 'en', 'en'] | True |
test_set_hold_mode_eco | (hass) | Test setting the hold mode eco. | Test setting the hold mode eco. | async def test_set_hold_mode_eco(hass):
"""Test setting the hold mode eco."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: ENTITY_ECOBEE, ATTR_PRESET_MODE: PRESET_ECO},
blocking=True,
)
state = hass.states.get(ENTITY_ECOBEE)
asser... | [
"async",
"def",
"test_set_hold_mode_eco",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_PRESET_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_ECOBEE",
",",
"ATTR_PRESET_MODE",
":",
"PRESET_ECO",
"}",
... | [
339,
0
] | [
349,
63
] | python | en | ['en', 'en', 'en'] | True |
test_set_aux_heat_bad_attr | (hass) | Test setting the auxiliary heater without required attribute. | Test setting the auxiliary heater without required attribute. | async def test_set_aux_heat_bad_attr(hass):
"""Test setting the auxiliary heater without required attribute."""
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_AUX_HEAT) == STATE_OFF
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMAIN,
... | [
"async",
"def",
"test_set_aux_heat_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_CLIMATE",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_AUX_HEAT",
")",
"==",
"STATE_OFF",
"with",
"pytest"... | [
352,
0
] | [
366,
59
] | python | en | ['en', 'en', 'en'] | True |
test_set_aux_heat_on | (hass) | Test setting the axillary heater on/true. | Test setting the axillary heater on/true. | async def test_set_aux_heat_on(hass):
"""Test setting the axillary heater on/true."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_AUX_HEAT,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_AUX_HEAT: True},
blocking=True,
)
state = hass.states.get(ENTITY_CLIMATE)
assert ... | [
"async",
"def",
"test_set_aux_heat_on",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_AUX_HEAT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_CLIMATE",
",",
"ATTR_AUX_HEAT",
":",
"True",
"}",
",",
"blo... | [
369,
0
] | [
379,
58
] | python | en | ['en', 'fi', 'en'] | True |
test_set_aux_heat_off | (hass) | Test setting the auxiliary heater off/false. | Test setting the auxiliary heater off/false. | async def test_set_aux_heat_off(hass):
"""Test setting the auxiliary heater off/false."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_AUX_HEAT,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_AUX_HEAT: False},
blocking=True,
)
state = hass.states.get(ENTITY_CLIMATE)
as... | [
"async",
"def",
"test_set_aux_heat_off",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_AUX_HEAT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_CLIMATE",
",",
"ATTR_AUX_HEAT",
":",
"False",
"}",
",",
"b... | [
382,
0
] | [
392,
59
] | python | en | ['en', 'sm', 'en'] | True |
test_turn_on | (hass) | Test turn on device. | Test turn on device. | async def test_turn_on(hass):
"""Test turn on device."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVAC_MODE_OFF},
blocking=True,
)
state = hass.states.get(ENTITY_CLIMATE)
assert state.state == HVA... | [
"async",
"def",
"test_turn_on",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_HVAC_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_CLIMATE",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_OFF",
"}",
",",
"... | [
395,
0
] | [
411,
40
] | python | en | ['fr', 'en', 'en'] | True |
test_turn_off | (hass) | Test turn on device. | Test turn on device. | async def test_turn_off(hass):
"""Test turn on device."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVAC_MODE_HEAT},
blocking=True,
)
state = hass.states.get(ENTITY_CLIMATE)
assert state.state == H... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_HVAC_MODE",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_CLIMATE",
",",
"ATTR_HVAC_MODE",
":",
"HVAC_MODE_HEAT",
"}",
",",
... | [
414,
0
] | [
430,
39
] | python | en | ['fr', 'en', 'en'] | True |
RedisController.lock | (self, name: str) | Get a new lock with redis.
Use 'with lock(name):' paradigm to do the locking.
Args:
name (str): name of the lock.
Returns:
redis.lock.Lock: lock from the redis.
| Get a new lock with redis. | def lock(self, name: str) -> Lock:
""" Get a new lock with redis.
Use 'with lock(name):' paradigm to do the locking.
Args:
name (str): name of the lock.
Returns:
redis.lock.Lock: lock from the redis.
"""
return self._redis.lock(name=name) | [
"def",
"lock",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Lock",
":",
"return",
"self",
".",
"_redis",
".",
"lock",
"(",
"name",
"=",
"name",
")"
] | [
347,
4
] | [
359,
42
] | python | en | ['en', 'en', 'en'] | True |
DeploymentValidator.validate_and_fill_dict | (template_dict: dict, actual_dict: dict, optional_key_to_value: dict) | Validate incoming actual_dict with template_dict, and fill optional keys to the template.
We use deepDiff to find missing keys in the actual_dict, see
https://deepdiff.readthedocs.io/en/latest/diff.html#deepdiff-reference for reference.
Args:
template_dict (dict): template dict, we... | Validate incoming actual_dict with template_dict, and fill optional keys to the template. | def validate_and_fill_dict(template_dict: dict, actual_dict: dict, optional_key_to_value: dict) -> None:
"""Validate incoming actual_dict with template_dict, and fill optional keys to the template.
We use deepDiff to find missing keys in the actual_dict, see
https://deepdiff.readthedocs.io/en/l... | [
"def",
"validate_and_fill_dict",
"(",
"template_dict",
":",
"dict",
",",
"actual_dict",
":",
"dict",
",",
"optional_key_to_value",
":",
"dict",
")",
"->",
"None",
":",
"deep_diff",
"=",
"deepdiff",
".",
"DeepDiff",
"(",
"template_dict",
",",
"actual_dict",
")",
... | [
364,
4
] | [
389,
17
] | python | en | ['en', 'en', 'en'] | True |
DeploymentValidator._set_value | (original_dict: dict, key_list: list, value) | Set the value to the original dict based on the key_list.
Args:
original_dict (dict): original dict that needs to be modified.
key_list (list): the parent to child path of keys, which describes that position of the value.
value: the value needs to be set.
Returns:
... | Set the value to the original dict based on the key_list. | def _set_value(original_dict: dict, key_list: list, value) -> None:
"""Set the value to the original dict based on the key_list.
Args:
original_dict (dict): original dict that needs to be modified.
key_list (list): the parent to child path of keys, which describes that position ... | [
"def",
"_set_value",
"(",
"original_dict",
":",
"dict",
",",
"key_list",
":",
"list",
",",
"value",
")",
"->",
"None",
":",
"DeploymentValidator",
".",
"_get_sub_structure_of_dict",
"(",
"original_dict",
",",
"key_list",
"[",
":",
"-",
"1",
"]",
")",
"[",
... | [
392,
4
] | [
403,
106
] | python | en | ['en', 'en', 'en'] | True |
DeploymentValidator._get_parent_to_child_key_list | (deep_diff_str: str) | Get parent to child key list by parsing the deep_diff_str.
Args:
deep_diff_str (str): a specially defined string that indicate the position of the key.
e.g. "root['a']['b']" -> {"a": {"b": value}}.
Returns:
list: the parent to child path of keys.
| Get parent to child key list by parsing the deep_diff_str. | def _get_parent_to_child_key_list(deep_diff_str: str) -> list:
"""Get parent to child key list by parsing the deep_diff_str.
Args:
deep_diff_str (str): a specially defined string that indicate the position of the key.
e.g. "root['a']['b']" -> {"a": {"b": value}}.
Re... | [
"def",
"_get_parent_to_child_key_list",
"(",
"deep_diff_str",
":",
"str",
")",
"->",
"list",
":",
"deep_diff_str",
"=",
"deep_diff_str",
".",
"strip",
"(",
"\"root['\"",
")",
"deep_diff_str",
"=",
"deep_diff_str",
".",
"strip",
"(",
"\"']\"",
")",
"return",
"dee... | [
406,
4
] | [
419,
42
] | python | en | ['en', 'en', 'en'] | True |
DeploymentValidator._get_sub_structure_of_dict | (original_dict: dict, key_list: list) | Get sub structure of dict from original_dict and key_list using reduce.
Args:
original_dict (dict): original dict that needs to be modified.
key_list (list): the parent to child path of keys, which describes that position of the value.
Returns:
dict: sub structure o... | Get sub structure of dict from original_dict and key_list using reduce. | def _get_sub_structure_of_dict(original_dict: dict, key_list: list) -> dict:
"""Get sub structure of dict from original_dict and key_list using reduce.
Args:
original_dict (dict): original dict that needs to be modified.
key_list (list): the parent to child path of keys, which d... | [
"def",
"_get_sub_structure_of_dict",
"(",
"original_dict",
":",
"dict",
",",
"key_list",
":",
"list",
")",
"->",
"dict",
":",
"return",
"functools",
".",
"reduce",
"(",
"operator",
".",
"getitem",
",",
"key_list",
",",
"original_dict",
")"
] | [
422,
4
] | [
433,
74
] | python | en | ['en', 'en', 'en'] | True |
Subprocess.run | (command: str, timeout: int = None) | Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
| Run one-time command with subprocess.run(). | def run(command: str, timeout: int = None) -> None:
"""Run one-time command with subprocess.run().
Args:
command (str): command to be executed.
timeout (int): timeout in seconds.
Returns:
str: return stdout of the command.
"""
# TODO: Windows... | [
"def",
"run",
"(",
"command",
":",
"str",
",",
"timeout",
":",
"int",
"=",
"None",
")",
"->",
"None",
":",
"# TODO: Windows node",
"completed_process",
"=",
"subprocess",
".",
"run",
"(",
"command",
",",
"shell",
"=",
"True",
",",
"executable",
"=",
"\"/... | [
438,
4
] | [
460,
50
] | python | en | ['en', 'en', 'en'] | True |
Subprocess.interactive_run | (command: str) | Run one-time command with subprocess.popen() and write stdout output interactively.
Args:
command (str): command to be executed.
Returns:
None.
| Run one-time command with subprocess.popen() and write stdout output interactively. | def interactive_run(command: str) -> None:
"""Run one-time command with subprocess.popen() and write stdout output interactively.
Args:
command (str): command to be executed.
Returns:
None.
"""
# TODO: Windows master
process = subprocess.Popen(
... | [
"def",
"interactive_run",
"(",
"command",
":",
"str",
")",
"->",
"None",
":",
"# TODO: Windows master",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"executable",
"=",
"\"/bin/bash\"",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subpr... | [
463,
4
] | [
489,
36
] | python | en | ['en', 'en', 'en'] | True |
async_call_action_from_config | (
hass: HomeAssistant,
config: ConfigType,
variables: TemplateVarsType,
context: Context,
) | Change state based on configuration. | Change state based on configuration. | async def async_call_action_from_config(
hass: HomeAssistant,
config: ConfigType,
variables: TemplateVarsType,
context: Context,
) -> None:
"""Change state based on configuration."""
await toggle_entity.async_call_action_from_config(
hass, config, variables, context, DOMAIN
) | [
"async",
"def",
"async_call_action_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"variables",
":",
"TemplateVarsType",
",",
"context",
":",
"Context",
",",
")",
"->",
"None",
":",
"await",
"toggle_entity",
".",
"async_ca... | [
15,
0
] | [
24,
5
] | python | en | ['en', 'en', 'en'] | True |
async_get_actions | (hass: HomeAssistant, device_id: str) | List device actions. | List device actions. | async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device actions."""
return await toggle_entity.async_get_actions(hass, device_id, DOMAIN) | [
"async",
"def",
"async_get_actions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"await",
"toggle_entity",
".",
"async_get_actions",
"(",
"hass",
",",
"device_id",
",",
"DOMAIN",
")"
] | [
27,
0
] | [
29,
73
] | python | en | ['fr', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.