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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AbstractOpenWeatherMapSensor.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._coordinator.last_update_success | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_coordinator",
".",
"last_update_success"
] | [
64,
4
] | [
66,
52
] | python | en | ['en', 'en', 'en'] | True |
AbstractOpenWeatherMapSensor.async_added_to_hass | (self) | Connect to dispatcher listening for entity data notifications. | Connect to dispatcher listening for entity data notifications. | async def async_added_to_hass(self):
"""Connect to dispatcher listening for entity data notifications."""
self.async_on_remove(
self._coordinator.async_add_listener(self.async_write_ha_state)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"_coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
68,
4
] | [
72,
9
] | python | en | ['en', 'en', 'en'] | True |
AbstractOpenWeatherMapSensor.async_update | (self) | Get the latest data from OWM and updates the states. | Get the latest data from OWM and updates the states. | async def async_update(self):
"""Get the latest data from OWM and updates the states."""
await self._coordinator.async_request_refresh() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
74,
4
] | [
76,
55
] | python | en | ['en', 'en', 'en'] | True |
create_dummy_raw | () |
Creates a Raw instance from `create_basic_data`
Returns:
-------
raw : mne.io.Raw
|
Creates a Raw instance from `create_basic_data`
Returns:
-------
raw : mne.io.Raw
| def create_dummy_raw():
"""
Creates a Raw instance from `create_basic_data`
Returns:
-------
raw : mne.io.Raw
"""
data = create_basic_data()
ch_names = DEEP_1010_CHS_LISTING[:8] + [' V-EOG L', 'V-EOG-R'] + ['STI 014']
ch_types = (['eeg'] * 8) + (['eog'] * 2) + ['stim']
info = mn... | [
"def",
"create_dummy_raw",
"(",
")",
":",
"data",
"=",
"create_basic_data",
"(",
")",
"ch_names",
"=",
"DEEP_1010_CHS_LISTING",
"[",
":",
"8",
"]",
"+",
"[",
"' V-EOG L'",
",",
"'V-EOG-R'",
"]",
"+",
"[",
"'STI 014'",
"]",
"ch_types",
"=",
"(",
"[",
"'ee... | [
30,
0
] | [
44,
14
] | python | en | ['en', 'error', 'th'] | False |
ensure_list | (value: Union[T, Sequence[T]]) | Wrap value in list if it is not one. | Wrap value in list if it is not one. | def ensure_list(value: Union[T, Sequence[T]]) -> Sequence[T]:
"""Wrap value in list if it is not one."""
if value is None or (isinstance(value, dict) and not value):
return []
return value if isinstance(value, list) else [value] | [
"def",
"ensure_list",
"(",
"value",
":",
"Union",
"[",
"T",
",",
"Sequence",
"[",
"T",
"]",
"]",
")",
"->",
"Sequence",
"[",
"T",
"]",
":",
"if",
"value",
"is",
"None",
"or",
"(",
"isinstance",
"(",
"value",
",",
"dict",
")",
"and",
"not",
"value... | [
45,
0
] | [
49,
56
] | python | en | ['en', 'en', 'en'] | True |
request_configuration | (hass, config, atv, credentials) | Request configuration steps from the user. | Request configuration steps from the user. | def request_configuration(hass, config, atv, credentials):
"""Request configuration steps from the user."""
configurator = hass.components.configurator
async def configuration_callback(callback_data):
"""Handle the submitted configuration."""
pin = callback_data.get("pin")
try:
... | [
"def",
"request_configuration",
"(",
"hass",
",",
"config",
",",
"atv",
",",
"credentials",
")",
":",
"configurator",
"=",
"hass",
".",
"components",
".",
"configurator",
"async",
"def",
"configuration_callback",
"(",
"callback_data",
")",
":",
"\"\"\"Handle the s... | [
78,
0
] | [
111,
5
] | python | en | ['en', 'en', 'en'] | True |
scan_apple_tvs | (hass) | Scan for devices and present a notification of the ones found. | Scan for devices and present a notification of the ones found. | async def scan_apple_tvs(hass):
"""Scan for devices and present a notification of the ones found."""
atvs = await scan_for_apple_tvs(hass.loop, timeout=3)
devices = []
for atv in atvs:
login_id = atv.login_id
if login_id is None:
login_id = "Home Sharing disabled"
d... | [
"async",
"def",
"scan_apple_tvs",
"(",
"hass",
")",
":",
"atvs",
"=",
"await",
"scan_for_apple_tvs",
"(",
"hass",
".",
"loop",
",",
"timeout",
"=",
"3",
")",
"devices",
"=",
"[",
"]",
"for",
"atv",
"in",
"atvs",
":",
"login_id",
"=",
"atv",
".",
"log... | [
114,
0
] | [
137,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Apple TV component. | Set up the Apple TV component. | async def async_setup(hass, config):
"""Set up the Apple TV component."""
if DATA_APPLE_TV not in hass.data:
hass.data[DATA_APPLE_TV] = {}
async def async_service_handler(service):
"""Handle service calls."""
entity_ids = service.data.get(ATTR_ENTITY_ID)
if service.service ... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DATA_APPLE_TV",
"not",
"in",
"hass",
".",
"data",
":",
"hass",
".",
"data",
"[",
"DATA_APPLE_TV",
"]",
"=",
"{",
"}",
"async",
"def",
"async_service_handler",
"(",
"service",
")"... | [
140,
0
] | [
203,
15
] | python | en | ['en', 'en', 'en'] | True |
_setup_atv | (hass, hass_config, atv_config) | Set up an Apple TV. | Set up an Apple TV. | async def _setup_atv(hass, hass_config, atv_config):
"""Set up an Apple TV."""
name = atv_config.get(CONF_NAME)
host = atv_config.get(CONF_HOST)
login_id = atv_config.get(CONF_LOGIN_ID)
start_off = atv_config.get(CONF_START_OFF)
credentials = atv_config.get(CONF_CREDENTIALS)
if host in has... | [
"async",
"def",
"_setup_atv",
"(",
"hass",
",",
"hass_config",
",",
"atv_config",
")",
":",
"name",
"=",
"atv_config",
".",
"get",
"(",
"CONF_NAME",
")",
"host",
"=",
"atv_config",
".",
"get",
"(",
"CONF_HOST",
")",
"login_id",
"=",
"atv_config",
".",
"g... | [
206,
0
] | [
235,
5
] | python | en | ['en', 'lb', 'en'] | True |
AppleTVPowerManager.__init__ | (self, hass, atv, is_off) | Initialize power manager. | Initialize power manager. | def __init__(self, hass, atv, is_off):
"""Initialize power manager."""
self.hass = hass
self.atv = atv
self.listeners = []
self._is_on = not is_off | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"atv",
",",
"is_off",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"atv",
"=",
"atv",
"self",
".",
"listeners",
"=",
"[",
"]",
"self",
".",
"_is_on",
"=",
"not",
"is_off"
] | [
245,
4
] | [
250,
32
] | python | en | ['en', 'en', 'en'] | True |
AppleTVPowerManager.init | (self) | Initialize power management. | Initialize power management. | def init(self):
"""Initialize power management."""
if self._is_on:
self.atv.push_updater.start() | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_on",
":",
"self",
".",
"atv",
".",
"push_updater",
".",
"start",
"(",
")"
] | [
252,
4
] | [
255,
41
] | python | en | ['en', 'en', 'en'] | True |
AppleTVPowerManager.turned_on | (self) | Return true if device is on or off. | Return true if device is on or off. | def turned_on(self):
"""Return true if device is on or off."""
return self._is_on | [
"def",
"turned_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
258,
4
] | [
260,
26
] | python | en | ['en', 'en', 'en'] | True |
AppleTVPowerManager.set_power_on | (self, value) | Change if a device is on or off. | Change if a device is on or off. | def set_power_on(self, value):
"""Change if a device is on or off."""
if value != self._is_on:
self._is_on = value
if not self._is_on:
self.atv.push_updater.stop()
else:
self.atv.push_updater.start()
for listener in self.li... | [
"def",
"set_power_on",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"_is_on",
":",
"self",
".",
"_is_on",
"=",
"value",
"if",
"not",
"self",
".",
"_is_on",
":",
"self",
".",
"atv",
".",
"push_updater",
".",
"stop",
"(",
")... | [
262,
4
] | [
272,
77
] | python | en | ['en', 'en', 'en'] | True |
draw_box | (
draw: ImageDraw,
box: Tuple[float, float, float, float],
img_width: int,
img_height: int,
text: str = "",
color: Tuple[int, int, int] = (255, 255, 0),
) |
Draw a bounding box on and image.
The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)
where the coordinates are floats in the range [0.0, 1.0] and
relative to the width and height of the image.
For example, if an image is 100 x 200 pixels (height x width) and the bounding
bo... |
Draw a bounding box on and image. | def draw_box(
draw: ImageDraw,
box: Tuple[float, float, float, float],
img_width: int,
img_height: int,
text: str = "",
color: Tuple[int, int, int] = (255, 255, 0),
) -> None:
"""
Draw a bounding box on and image.
The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)... | [
"def",
"draw_box",
"(",
"draw",
":",
"ImageDraw",
",",
"box",
":",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
",",
"float",
"]",
",",
"img_width",
":",
"int",
",",
"img_height",
":",
"int",
",",
"text",
":",
"str",
"=",
"\"\"",
",",
"color"... | [
9,
0
] | [
46,
9
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Old way of setting up the Daikin sensors.
Can only be called when a user accidentally mentions the platform in their
config. But even in that case it would have been ignored.
| Old way of setting up the Daikin sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up the Daikin sensors.
Can only be called when a user accidentally mentions the platform in their
config. But even in that case it would have been ignored.
""" | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":"
] | [
27,
0
] | [
32,
7
] | python | en | ['en', 'fil', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up Daikin climate based on config_entry. | Set up Daikin climate based on config_entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Daikin climate based on config_entry."""
daikin_api = hass.data[DAIKIN_DOMAIN].get(entry.entry_id)
sensors = [ATTR_INSIDE_TEMPERATURE]
if daikin_api.device.support_outside_temperature:
sensors.append(ATTR_OUTSIDE_TEMPERATURE... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"daikin_api",
"=",
"hass",
".",
"data",
"[",
"DAIKIN_DOMAIN",
"]",
".",
"get",
"(",
"entry",
".",
"entry_id",
")",
"sensors",
"=",
"[",
"ATTR_INSIDE_TEMPERAT... | [
35,
0
] | [
48,
88
] | python | en | ['en', 'en', 'en'] | True |
DaikinSensor.factory | (api: DaikinApi, monitored_state: str) | Initialize any DaikinSensor. | Initialize any DaikinSensor. | def factory(api: DaikinApi, monitored_state: str):
"""Initialize any DaikinSensor."""
cls = {
SENSOR_TYPE_TEMPERATURE: DaikinClimateSensor,
SENSOR_TYPE_HUMIDITY: DaikinClimateSensor,
SENSOR_TYPE_POWER: DaikinPowerSensor,
SENSOR_TYPE_ENERGY: DaikinPowerSens... | [
"def",
"factory",
"(",
"api",
":",
"DaikinApi",
",",
"monitored_state",
":",
"str",
")",
":",
"cls",
"=",
"{",
"SENSOR_TYPE_TEMPERATURE",
":",
"DaikinClimateSensor",
",",
"SENSOR_TYPE_HUMIDITY",
":",
"DaikinClimateSensor",
",",
"SENSOR_TYPE_POWER",
":",
"DaikinPower... | [
55,
4
] | [
63,
40
] | python | en | ['mg', 'ny', 'en'] | False |
DaikinSensor.__init__ | (self, api: DaikinApi, monitored_state: str) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api: DaikinApi, monitored_state: str) -> None:
"""Initialize the sensor."""
self._api = api
self._sensor = SENSOR_TYPES[monitored_state]
self._name = f"{api.name} {self._sensor[CONF_NAME]}"
self._device_attribute = monitored_state | [
"def",
"__init__",
"(",
"self",
",",
"api",
":",
"DaikinApi",
",",
"monitored_state",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_sensor",
"=",
"SENSOR_TYPES",
"[",
"monitored_state",
"]",
"self",
".",
"_name",
"... | [
65,
4
] | [
70,
48
] | python | en | ['en', 'en', 'en'] | True |
DaikinSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return f"{self._api.device.mac}-{self._device_attribute}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._api.device.mac}-{self._device_attribute}\""
] | [
73,
4
] | [
75,
65
] | python | ca | ['fr', 'ca', 'en'] | False |
DaikinSensor.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"
] | [
78,
4
] | [
80,
25
] | python | en | ['en', 'mi', 'en'] | True |
DaikinSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
raise NotImplementedError | [
"def",
"state",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
83,
4
] | [
85,
33
] | python | en | ['en', 'en', 'en'] | True |
DaikinSensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self):
"""Return the class of this device."""
return self._sensor.get(CONF_DEVICE_CLASS) | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor",
".",
"get",
"(",
"CONF_DEVICE_CLASS",
")"
] | [
88,
4
] | [
90,
50
] | python | en | ['en', 'en', 'en'] | True |
DaikinSensor.icon | (self) | Return the icon of this device. | Return the icon of this device. | def icon(self):
"""Return the icon of this device."""
return self._sensor.get(CONF_ICON) | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor",
".",
"get",
"(",
"CONF_ICON",
")"
] | [
93,
4
] | [
95,
42
] | python | en | ['en', 'en', 'en'] | True |
DaikinSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._sensor[CONF_UNIT_OF_MEASUREMENT] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor",
"[",
"CONF_UNIT_OF_MEASUREMENT",
"]"
] | [
98,
4
] | [
100,
53
] | python | en | ['en', 'la', 'en'] | True |
DaikinSensor.async_update | (self) | Retrieve latest state. | Retrieve latest state. | async def async_update(self):
"""Retrieve latest state."""
await self._api.async_update() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_api",
".",
"async_update",
"(",
")"
] | [
102,
4
] | [
104,
38
] | python | en | ['es', 'sk', 'en'] | False |
DaikinSensor.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return self._api.device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"device_info"
] | [
107,
4
] | [
109,
36
] | python | en | ['ro', 'fr', 'en'] | False |
DaikinClimateSensor.state | (self) | Return the internal state of the sensor. | Return the internal state of the sensor. | def state(self):
"""Return the internal state of the sensor."""
if self._device_attribute == ATTR_INSIDE_TEMPERATURE:
return self._api.device.inside_temperature
if self._device_attribute == ATTR_OUTSIDE_TEMPERATURE:
return self._api.device.outside_temperature
if ... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_attribute",
"==",
"ATTR_INSIDE_TEMPERATURE",
":",
"return",
"self",
".",
"_api",
".",
"device",
".",
"inside_temperature",
"if",
"self",
".",
"_device_attribute",
"==",
"ATTR_OUTSIDE_TEMPERATURE",
... | [
116,
4
] | [
127,
19
] | python | en | ['en', 'no', 'en'] | True |
DaikinPowerSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self._device_attribute == ATTR_TOTAL_POWER:
return round(self._api.device.current_total_power_consumption, 3)
if self._device_attribute == ATTR_COOL_ENERGY:
return round(self._api.device.last_hour_cool_energy_consu... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_attribute",
"==",
"ATTR_TOTAL_POWER",
":",
"return",
"round",
"(",
"self",
".",
"_api",
".",
"device",
".",
"current_total_power_consumption",
",",
"3",
")",
"if",
"self",
".",
"_device_attri... | [
134,
4
] | [
142,
19
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_no_config | (hass) | Test that we do not discover anything or try to set up a bridge. | Test that we do not discover anything or try to set up a bridge. | async def test_setup_with_no_config(hass):
"""Test that we do not discover anything or try to set up a bridge."""
assert await async_setup_component(hass, UNIFI_DOMAIN, {}) is True
assert UNIFI_DOMAIN not in hass.data | [
"async",
"def",
"test_setup_with_no_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"UNIFI_DOMAIN",
",",
"{",
"}",
")",
"is",
"True",
"assert",
"UNIFI_DOMAIN",
"not",
"in",
"hass",
".",
"data"
] | [
13,
0
] | [
16,
40
] | python | en | ['en', 'en', 'en'] | True |
test_successful_config_entry | (hass) | Test that configured options for a host are loaded via config entry. | Test that configured options for a host are loaded via config entry. | async def test_successful_config_entry(hass):
"""Test that configured options for a host are loaded via config entry."""
await setup_unifi_integration(hass)
assert hass.data[UNIFI_DOMAIN] | [
"async",
"def",
"test_successful_config_entry",
"(",
"hass",
")",
":",
"await",
"setup_unifi_integration",
"(",
"hass",
")",
"assert",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]"
] | [
19,
0
] | [
22,
34
] | python | en | ['en', 'en', 'en'] | True |
test_controller_fail_setup | (hass) | Test that a failed setup still stores controller. | Test that a failed setup still stores controller. | async def test_controller_fail_setup(hass):
"""Test that a failed setup still stores controller."""
with patch("homeassistant.components.unifi.UniFiController") as mock_controller:
mock_controller.return_value.async_setup = AsyncMock(return_value=False)
await setup_unifi_integration(hass)
a... | [
"async",
"def",
"test_controller_fail_setup",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.unifi.UniFiController\"",
")",
"as",
"mock_controller",
":",
"mock_controller",
".",
"return_value",
".",
"async_setup",
"=",
"AsyncMock",
"(",
"return... | [
25,
0
] | [
31,
40
] | python | en | ['en', 'en', 'en'] | True |
test_controller_no_mac | (hass) | Test that configured options for a host are loaded via config entry. | Test that configured options for a host are loaded via config entry. | async def test_controller_no_mac(hass):
"""Test that configured options for a host are loaded via config entry."""
entry = MockConfigEntry(
domain=UNIFI_DOMAIN,
data={
"controller": {
"host": "0.0.0.0",
"username": "user",
"password": "... | [
"async",
"def",
"test_controller_no_mac",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"UNIFI_DOMAIN",
",",
"data",
"=",
"{",
"\"controller\"",
":",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
",",
"\"username\"",
":",
"\"user\"",
",",
... | [
34,
0
] | [
64,
45
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test being able to unload an entry. | Test being able to unload an entry. | async def test_unload_entry(hass):
"""Test being able to unload an entry."""
controller = await setup_unifi_integration(hass)
assert hass.data[UNIFI_DOMAIN]
assert await unifi.async_unload_entry(hass, controller.config_entry)
assert not hass.data[UNIFI_DOMAIN] | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"controller",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
")",
"assert",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"assert",
"await",
"unifi",
".",
"async_unload_entry",
"(",
"hass",
",... | [
67,
0
] | [
73,
38
] | python | en | ['en', 'en', 'en'] | True |
async_register_commands | (hass, async_reg) | Register commands. | Register commands. | def async_register_commands(hass, async_reg):
"""Register commands."""
async_reg(hass, handle_subscribe_events)
async_reg(hass, handle_unsubscribe_events)
async_reg(hass, handle_call_service)
async_reg(hass, handle_get_states)
async_reg(hass, handle_get_services)
async_reg(hass, handle_get_c... | [
"def",
"async_register_commands",
"(",
"hass",
",",
"async_reg",
")",
":",
"async_reg",
"(",
"hass",
",",
"handle_subscribe_events",
")",
"async_reg",
"(",
"hass",
",",
"handle_unsubscribe_events",
")",
"async_reg",
"(",
"hass",
",",
"handle_call_service",
")",
"a... | [
27,
0
] | [
41,
42
] | python | en | ['en', 'da', 'en'] | False |
pong_message | (iden) | Return a pong message. | Return a pong message. | def pong_message(iden):
"""Return a pong message."""
return {"id": iden, "type": "pong"} | [
"def",
"pong_message",
"(",
"iden",
")",
":",
"return",
"{",
"\"id\"",
":",
"iden",
",",
"\"type\"",
":",
"\"pong\"",
"}"
] | [
44,
0
] | [
46,
39
] | python | en | ['en', 'lb', 'en'] | True |
handle_subscribe_events | (hass, connection, msg) | Handle subscribe events command. | Handle subscribe events command. | def handle_subscribe_events(hass, connection, msg):
"""Handle subscribe events command."""
# Circular dep
# pylint: disable=import-outside-toplevel
from .permissions import SUBSCRIBE_WHITELIST
event_type = msg["event_type"]
if event_type not in SUBSCRIBE_WHITELIST and not connection.user.is_ad... | [
"def",
"handle_subscribe_events",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"# Circular dep",
"# pylint: disable=import-outside-toplevel",
"from",
".",
"permissions",
"import",
"SUBSCRIBE_WHITELIST",
"event_type",
"=",
"msg",
"[",
"\"event_type\"",
"]",
"if"... | [
56,
0
] | [
93,
63
] | python | en | ['en', 'en', 'en'] | True |
handle_unsubscribe_events | (hass, connection, msg) | Handle unsubscribe events command. | Handle unsubscribe events command. | def handle_unsubscribe_events(hass, connection, msg):
"""Handle unsubscribe events command."""
subscription = msg["subscription"]
if subscription in connection.subscriptions:
connection.subscriptions.pop(subscription)()
connection.send_message(messages.result_message(msg["id"]))
else:
... | [
"def",
"handle_unsubscribe_events",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"subscription",
"=",
"msg",
"[",
"\"subscription\"",
"]",
"if",
"subscription",
"in",
"connection",
".",
"subscriptions",
":",
"connection",
".",
"subscriptions",
".",
"pop... | [
103,
0
] | [
115,
9
] | python | en | ['en', 'en', 'en'] | True |
handle_call_service | (hass, connection, msg) | Handle call service command. | Handle call service command. | async def handle_call_service(hass, connection, msg):
"""Handle call service command."""
blocking = True
if msg["domain"] == HASS_DOMAIN and msg["service"] in ["restart", "stop"]:
blocking = False
try:
await hass.services.async_call(
msg["domain"],
msg["service"]... | [
"async",
"def",
"handle_call_service",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"blocking",
"=",
"True",
"if",
"msg",
"[",
"\"domain\"",
"]",
"==",
"HASS_DOMAIN",
"and",
"msg",
"[",
"\"service\"",
"]",
"in",
"[",
"\"restart\"",
",",
"\"stop\""... | [
127,
0
] | [
166,
9
] | python | en | ['en', 'en', 'en'] | True |
handle_get_states | (hass, connection, msg) | Handle get states command. | Handle get states command. | def handle_get_states(hass, connection, msg):
"""Handle get states command."""
if connection.user.permissions.access_all_entities("read"):
states = hass.states.async_all()
else:
entity_perm = connection.user.permissions.check_entity
states = [
state
for state ... | [
"def",
"handle_get_states",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"if",
"connection",
".",
"user",
".",
"permissions",
".",
"access_all_entities",
"(",
"\"read\"",
")",
":",
"states",
"=",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
... | [
171,
0
] | [
183,
71
] | python | en | ['nl', 'en', 'en'] | True |
handle_get_services | (hass, connection, msg) | Handle get services command. | Handle get services command. | async def handle_get_services(hass, connection, msg):
"""Handle get services command."""
descriptions = await async_get_all_descriptions(hass)
connection.send_message(messages.result_message(msg["id"], descriptions)) | [
"async",
"def",
"handle_get_services",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"descriptions",
"=",
"await",
"async_get_all_descriptions",
"(",
"hass",
")",
"connection",
".",
"send_message",
"(",
"messages",
".",
"result_message",
"(",
"msg",
"[",... | [
188,
0
] | [
191,
77
] | python | en | ['nl', 'en', 'en'] | True |
handle_get_config | (hass, connection, msg) | Handle get config command. | Handle get config command. | def handle_get_config(hass, connection, msg):
"""Handle get config command."""
connection.send_message(messages.result_message(msg["id"], hass.config.as_dict())) | [
"def",
"handle_get_config",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"connection",
".",
"send_message",
"(",
"messages",
".",
"result_message",
"(",
"msg",
"[",
"\"id\"",
"]",
",",
"hass",
".",
"config",
".",
"as_dict",
"(",
")",
")",
")"
] | [
196,
0
] | [
198,
86
] | python | en | ['nl', 'en', 'en'] | True |
handle_manifest_list | (hass, connection, msg) | Handle integrations command. | Handle integrations command. | async def handle_manifest_list(hass, connection, msg):
"""Handle integrations command."""
integrations = await asyncio.gather(
*[
async_get_integration(hass, domain)
for domain in hass.config.components
# Filter out platforms.
if "." not in domain
... | [
"async",
"def",
"handle_manifest_list",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"integrations",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"async_get_integration",
"(",
"hass",
",",
"domain",
")",
"for",
"domain",
"in",
"hass",
".... | [
203,
0
] | [
215,
5
] | python | ca | ['fr', 'ca', 'en'] | False |
handle_manifest_get | (hass, connection, msg) | Handle integrations command. | Handle integrations command. | async def handle_manifest_get(hass, connection, msg):
"""Handle integrations command."""
try:
integration = await async_get_integration(hass, msg["integration"])
connection.send_result(msg["id"], integration.manifest)
except IntegrationNotFound:
connection.send_error(msg["id"], const... | [
"async",
"def",
"handle_manifest_get",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"try",
":",
"integration",
"=",
"await",
"async_get_integration",
"(",
"hass",
",",
"msg",
"[",
"\"integration\"",
"]",
")",
"connection",
".",
"send_result",
"(",
"... | [
222,
0
] | [
228,
86
] | python | ca | ['fr', 'ca', 'en'] | False |
handle_ping | (hass, connection, msg) | Handle ping command. | Handle ping command. | def handle_ping(hass, connection, msg):
"""Handle ping command."""
connection.send_message(pong_message(msg["id"])) | [
"def",
"handle_ping",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"connection",
".",
"send_message",
"(",
"pong_message",
"(",
"msg",
"[",
"\"id\"",
"]",
")",
")"
] | [
233,
0
] | [
235,
52
] | python | en | ['fr', 'en', 'en'] | True |
handle_render_template | (hass, connection, msg) | Handle render_template command. | Handle render_template command. | async def handle_render_template(hass, connection, msg):
"""Handle render_template command."""
template_str = msg["template"]
template = Template(template_str, hass)
variables = msg.get("variables")
timeout = msg.get("timeout")
info = None
if timeout:
try:
timed_out = aw... | [
"async",
"def",
"handle_render_template",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"template_str",
"=",
"msg",
"[",
"\"template\"",
"]",
"template",
"=",
"Template",
"(",
"template_str",
",",
"hass",
")",
"variables",
"=",
"msg",
".",
"get",
"... | [
248,
0
] | [
301,
54
] | python | en | ['en', 'en', 'en'] | True |
handle_entity_source | (hass, connection, msg) | Handle entity source command. | Handle entity source command. | def handle_entity_source(hass, connection, msg):
"""Handle entity source command."""
raw_sources = entity.entity_sources(hass)
entity_perm = connection.user.permissions.check_entity
if "entity_id" not in msg:
if connection.user.permissions.access_all_entities("read"):
sources = raw_... | [
"def",
"handle_entity_source",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"raw_sources",
"=",
"entity",
".",
"entity_sources",
"(",
"hass",
")",
"entity_perm",
"=",
"connection",
".",
"user",
".",
"permissions",
".",
"check_entity",
"if",
"\"entity_... | [
308,
0
] | [
344,
46
] | python | en | ['en', 'en', 'en'] | True |
handle_subscribe_trigger | (hass, connection, msg) | Handle subscribe trigger command. | Handle subscribe trigger command. | async def handle_subscribe_trigger(hass, connection, msg):
"""Handle subscribe trigger command."""
# Circular dep
# pylint: disable=import-outside-toplevel
from homeassistant.helpers import trigger
trigger_config = await trigger.async_validate_trigger_config(hass, msg["trigger"])
@callback
... | [
"async",
"def",
"handle_subscribe_trigger",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"# Circular dep",
"# pylint: disable=import-outside-toplevel",
"from",
"homeassistant",
".",
"helpers",
"import",
"trigger",
"trigger_config",
"=",
"await",
"trigger",
".",... | [
357,
0
] | [
389,
37
] | python | en | ['en', 'en', 'en'] | True |
handle_test_condition | (hass, connection, msg) | Handle test condition command. | Handle test condition command. | async def handle_test_condition(hass, connection, msg):
"""Handle test condition command."""
# Circular dep
# pylint: disable=import-outside-toplevel
from homeassistant.helpers import condition
check_condition = await condition.async_from_config(hass, msg["condition"])
connection.send_result(
... | [
"async",
"def",
"handle_test_condition",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"# Circular dep",
"# pylint: disable=import-outside-toplevel",
"from",
"homeassistant",
".",
"helpers",
"import",
"condition",
"check_condition",
"=",
"await",
"condition",
".... | [
401,
0
] | [
410,
5
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandSetup.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.config = {rc.DOMAIN: {"test_get": {"url": "http://example.com/"}}} | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"config",
"=",
"{",
"rc",
".",
"DOMAIN",
":",
"{",
"\"test_get\"",
":",
"{",
"\"url\"",
":",
"\"http://example.com/\"",
"}",
"}",
"}... | [
15,
4
] | [
19,
79
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandSetup.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
21,
4
] | [
23,
24
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandSetup.test_setup_component | (self) | Test setup component. | Test setup component. | def test_setup_component(self):
"""Test setup component."""
with assert_setup_component(1):
setup_component(self.hass, rc.DOMAIN, self.config) | [
"def",
"test_setup_component",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")"
] | [
25,
4
] | [
28,
62
] | python | en | ['en', 'da', 'en'] | True |
TestRestCommandSetup.test_setup_component_timeout | (self) | Test setup component timeout. | Test setup component timeout. | def test_setup_component_timeout(self):
"""Test setup component timeout."""
self.config[rc.DOMAIN]["test_get"]["timeout"] = 10
with assert_setup_component(1):
setup_component(self.hass, rc.DOMAIN, self.config) | [
"def",
"test_setup_component_timeout",
"(",
"self",
")",
":",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"test_get\"",
"]",
"[",
"\"timeout\"",
"]",
"=",
"10",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"setup_component",
"(",
... | [
30,
4
] | [
35,
62
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandSetup.test_setup_component_test_service | (self) | Test setup component and check if service exits. | Test setup component and check if service exits. | def test_setup_component_test_service(self):
"""Test setup component and check if service exits."""
with assert_setup_component(1):
setup_component(self.hass, rc.DOMAIN, self.config)
assert self.hass.services.has_service(rc.DOMAIN, "test_get") | [
"def",
"test_setup_component_test_service",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"assert",
"self",
".",
"hass",
... | [
37,
4
] | [
42,
68
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.url = "https://example.com/"
self.config = {
rc.DOMAIN: {
"get_test": {"url": self.url, "method": "get"},
"patch_test": {"url": self.url, "method": "patch"},
... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"url",
"=",
"\"https://example.com/\"",
"self",
".",
"config",
"=",
"{",
"rc",
".",
"DOMAIN",
":",
"{",
"\"get_test\"",
":",
"{",
"\"url\"",
":",
"self",
".",
"url",
",",
"\"method\"",
":",
"\"... | [
48,
4
] | [
61,
45
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
63,
4
] | [
65,
24
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_setup_tests | (self) | Set up test config and test it. | Set up test config and test it. | def test_setup_tests(self):
"""Set up test config and test it."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
assert self.hass.services.has_service(rc.DOMAIN, "get_test")
assert self.hass.services.has_service(rc.DOMAIN, "post_test")
... | [
"def",
"test_setup_tests",
"(",
"self",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"assert",
"self",
".",
"hass",
".",
"services"... | [
67,
4
] | [
75,
71
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_timeout | (self, aioclient_mock) | Call a rest command with timeout. | Call a rest command with timeout. | def test_rest_command_timeout(self, aioclient_mock):
"""Call a rest command with timeout."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.get(self.url, exc=asyncio.TimeoutError())
self.hass.services.call(rc.DOMAIN, "get_t... | [
"def",
"test_rest_command_timeout",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"aioclient_mock",
... | [
77,
4
] | [
87,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_aiohttp_error | (self, aioclient_mock) | Call a rest command with aiohttp exception. | Call a rest command with aiohttp exception. | def test_rest_command_aiohttp_error(self, aioclient_mock):
"""Call a rest command with aiohttp exception."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.get(self.url, exc=aiohttp.ClientError())
self.hass.services.call(rc... | [
"def",
"test_rest_command_aiohttp_error",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"aioclient_moc... | [
89,
4
] | [
99,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_http_error | (self, aioclient_mock) | Call a rest command with status code 400. | Call a rest command with status code 400. | def test_rest_command_http_error(self, aioclient_mock):
"""Call a rest command with status code 400."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.get(self.url, status=400)
self.hass.services.call(rc.DOMAIN, "get_test",... | [
"def",
"test_rest_command_http_error",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"aioclient_mock",... | [
101,
4
] | [
111,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_auth | (self, aioclient_mock) | Call a rest command with auth credential. | Call a rest command with auth credential. | def test_rest_command_auth(self, aioclient_mock):
"""Call a rest command with auth credential."""
data = {"username": "test", "password": "123456"}
self.config[rc.DOMAIN]["get_test"].update(data)
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.conf... | [
"def",
"test_rest_command_auth",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"data",
"=",
"{",
"\"username\"",
":",
"\"test\"",
",",
"\"password\"",
":",
"\"123456\"",
"}",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"get_test\"",
"]",
"... | [
113,
4
] | [
126,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_form_data | (self, aioclient_mock) | Call a rest command with post form data. | Call a rest command with post form data. | def test_rest_command_form_data(self, aioclient_mock):
"""Call a rest command with post form data."""
data = {"payload": "test"}
self.config[rc.DOMAIN]["post_test"].update(data)
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aiocl... | [
"def",
"test_rest_command_form_data",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"data",
"=",
"{",
"\"payload\"",
":",
"\"test\"",
"}",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"post_test\"",
"]",
".",
"update",
"(",
"data",
")",
"... | [
128,
4
] | [
142,
57
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_get | (self, aioclient_mock) | Call a rest command with get. | Call a rest command with get. | def test_rest_command_get(self, aioclient_mock):
"""Call a rest command with get."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.get(self.url, content=b"success")
self.hass.services.call(rc.DOMAIN, "get_test", {})
... | [
"def",
"test_rest_command_get",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"aioclient_mock",
".",... | [
144,
4
] | [
154,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_delete | (self, aioclient_mock) | Call a rest command with delete. | Call a rest command with delete. | def test_rest_command_delete(self, aioclient_mock):
"""Call a rest command with delete."""
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.delete(self.url, content=b"success")
self.hass.services.call(rc.DOMAIN, "delete_test"... | [
"def",
"test_rest_command_delete",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"with",
"assert_setup_component",
"(",
"5",
")",
":",
"setup_component",
"(",
"self",
".",
"hass",
",",
"rc",
".",
"DOMAIN",
",",
"self",
".",
"config",
")",
"aioclient_mock",
"... | [
156,
4
] | [
166,
50
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_patch | (self, aioclient_mock) | Call a rest command with patch. | Call a rest command with patch. | def test_rest_command_patch(self, aioclient_mock):
"""Call a rest command with patch."""
data = {"payload": "data"}
self.config[rc.DOMAIN]["patch_test"].update(data)
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.pa... | [
"def",
"test_rest_command_patch",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"data",
"=",
"{",
"\"payload\"",
":",
"\"data\"",
"}",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"patch_test\"",
"]",
".",
"update",
"(",
"data",
")",
"wit... | [
168,
4
] | [
182,
57
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_post | (self, aioclient_mock) | Call a rest command with post. | Call a rest command with post. | def test_rest_command_post(self, aioclient_mock):
"""Call a rest command with post."""
data = {"payload": "data"}
self.config[rc.DOMAIN]["post_test"].update(data)
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.post(... | [
"def",
"test_rest_command_post",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"data",
"=",
"{",
"\"payload\"",
":",
"\"data\"",
"}",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"post_test\"",
"]",
".",
"update",
"(",
"data",
")",
"with"... | [
184,
4
] | [
198,
57
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_put | (self, aioclient_mock) | Call a rest command with put. | Call a rest command with put. | def test_rest_command_put(self, aioclient_mock):
"""Call a rest command with put."""
data = {"payload": "data"}
self.config[rc.DOMAIN]["put_test"].update(data)
with assert_setup_component(5):
setup_component(self.hass, rc.DOMAIN, self.config)
aioclient_mock.put(self... | [
"def",
"test_rest_command_put",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"data",
"=",
"{",
"\"payload\"",
":",
"\"data\"",
"}",
"self",
".",
"config",
"[",
"rc",
".",
"DOMAIN",
"]",
"[",
"\"put_test\"",
"]",
".",
"update",
"(",
"data",
")",
"with",
... | [
200,
4
] | [
214,
57
] | python | en | ['en', 'en', 'en'] | True |
TestRestCommandComponent.test_rest_command_headers | (self, aioclient_mock) | Call a rest command with custom headers and content types. | Call a rest command with custom headers and content types. | def test_rest_command_headers(self, aioclient_mock):
"""Call a rest command with custom headers and content types."""
header_config_variations = {
rc.DOMAIN: {
"no_headers_test": {},
"content_type_test": {"content_type": CONTENT_TYPE_TEXT_PLAIN},
... | [
"def",
"test_rest_command_headers",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"header_config_variations",
"=",
"{",
"rc",
".",
"DOMAIN",
":",
"{",
"\"no_headers_test\"",
":",
"{",
"}",
",",
"\"content_type_test\"",
":",
"{",
"\"content_type\"",
":",
"CONTENT_T... | [
216,
4
] | [
323,
83
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the light platform for ADS. | Set up the light platform for ADS. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the light platform for ADS."""
ads_hub = hass.data.get(DATA_ADS)
ads_var_enable = config[CONF_ADS_VAR]
ads_var_brightness = config.get(CONF_ADS_VAR_BRIGHTNESS)
name = config[CONF_NAME]
add_entities([AdsLight(ads_hub... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"ads_hub",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_ADS",
")",
"ads_var_enable",
"=",
"config",
"[",
"CONF_ADS_VAR",
"]",
"ads_v... | [
31,
0
] | [
39,
79
] | python | en | ['en', 'da', 'en'] | True |
AdsLight.__init__ | (self, ads_hub, ads_var_enable, ads_var_brightness, name) | Initialize AdsLight entity. | Initialize AdsLight entity. | def __init__(self, ads_hub, ads_var_enable, ads_var_brightness, name):
"""Initialize AdsLight entity."""
super().__init__(ads_hub, name, ads_var_enable)
self._state_dict[STATE_KEY_BRIGHTNESS] = None
self._ads_var_brightness = ads_var_brightness | [
"def",
"__init__",
"(",
"self",
",",
"ads_hub",
",",
"ads_var_enable",
",",
"ads_var_brightness",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"ads_hub",
",",
"name",
",",
"ads_var_enable",
")",
"self",
".",
"_state_dict",
"[",
"STATE_KE... | [
45,
4
] | [
49,
53
] | python | fr | ['fr', 'zu', 'it'] | False |
AdsLight.async_added_to_hass | (self) | Register device notification. | Register device notification. | async def async_added_to_hass(self):
"""Register device notification."""
await self.async_initialize_device(self._ads_var, self._ads_hub.PLCTYPE_BOOL)
if self._ads_var_brightness is not None:
await self.async_initialize_device(
self._ads_var_brightness,
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"async_initialize_device",
"(",
"self",
".",
"_ads_var",
",",
"self",
".",
"_ads_hub",
".",
"PLCTYPE_BOOL",
")",
"if",
"self",
".",
"_ads_var_brightness",
"is",
"not",
"None",
... | [
51,
4
] | [
60,
13
] | python | en | ['da', 'en', 'en'] | True |
AdsLight.brightness | (self) | Return the brightness of the light (0..255). | Return the brightness of the light (0..255). | def brightness(self):
"""Return the brightness of the light (0..255)."""
return self._state_dict[STATE_KEY_BRIGHTNESS] | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state_dict",
"[",
"STATE_KEY_BRIGHTNESS",
"]"
] | [
63,
4
] | [
65,
53
] | python | en | ['en', 'no', 'en'] | True |
AdsLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
if self._ads_var_brightness is not None:
return SUPPORT_BRIGHTNESS
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ads_var_brightness",
"is",
"not",
"None",
":",
"return",
"SUPPORT_BRIGHTNESS",
"return",
"0"
] | [
68,
4
] | [
72,
16
] | python | en | ['da', 'en', 'en'] | True |
AdsLight.is_on | (self) | Return True if the entity is on. | Return True if the entity is on. | def is_on(self):
"""Return True if the entity is on."""
return self._state_dict[STATE_KEY_STATE] | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state_dict",
"[",
"STATE_KEY_STATE",
"]"
] | [
75,
4
] | [
77,
48
] | python | en | ['en', 'en', 'en'] | True |
AdsLight.turn_on | (self, **kwargs) | Turn the light on or set a specific dimmer value. | Turn the light on or set a specific dimmer value. | def turn_on(self, **kwargs):
"""Turn the light on or set a specific dimmer value."""
brightness = kwargs.get(ATTR_BRIGHTNESS)
self._ads_hub.write_by_name(self._ads_var, True, self._ads_hub.PLCTYPE_BOOL)
if self._ads_var_brightness is not None and brightness is not None:
self... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
")",
"self",
".",
"_ads_hub",
".",
"write_by_name",
"(",
"self",
".",
"_ads_var",
",",
"True",
",",
"self",
".",
"_ads_hu... | [
79,
4
] | [
87,
13
] | python | en | ['en', 'en', 'en'] | True |
AdsLight.turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | def turn_off(self, **kwargs):
"""Turn the light off."""
self._ads_hub.write_by_name(self._ads_var, False, self._ads_hub.PLCTYPE_BOOL) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_ads_hub",
".",
"write_by_name",
"(",
"self",
".",
"_ads_var",
",",
"False",
",",
"self",
".",
"_ads_hub",
".",
"PLCTYPE_BOOL",
")"
] | [
89,
4
] | [
91,
85
] | python | en | ['en', 'zh', 'en'] | True |
validate_entity_config | (values) | Validate config entry for CONF_ENTITY. | Validate config entry for CONF_ENTITY. | def validate_entity_config(values):
"""Validate config entry for CONF_ENTITY."""
entity_config_schema = vol.Schema({vol.Optional(CONF_REVERSE): cv.boolean})
if not isinstance(values, dict):
raise vol.Invalid("expected a dictionary")
entities = {}
for entity_id, config in values.items():
... | [
"def",
"validate_entity_config",
"(",
"values",
")",
":",
"entity_config_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Optional",
"(",
"CONF_REVERSE",
")",
":",
"cv",
".",
"boolean",
"}",
")",
"if",
"not",
"isinstance",
"(",
"values",
",",
"... | [
17,
0
] | [
27,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the MyLink platform. | Set up the MyLink platform. | async def async_setup(hass, config):
"""Set up the MyLink platform."""
host = config[DOMAIN][CONF_HOST]
port = config[DOMAIN][CONF_PORT]
system_id = config[DOMAIN][CONF_SYSTEM_ID]
entity_config = config[DOMAIN][CONF_ENTITY_CONFIG]
entity_config[CONF_DEFAULT_REVERSE] = config[DOMAIN][CONF_DEFAUL... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"host",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_HOST",
"]",
"port",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_PORT",
"]",
"system_id",
"=",
"config",
"[",
"DOMAIN",
"]",
"... | [
46,
0
] | [
60,
15
] | python | en | ['en', 'da', 'en'] | True |
build_frame | (station_num: int, snapshots_num: int) | Function to build citi_bike Frame.
Args:
station_num (int): Number of stations.
snapshot_num (int): Number of in-memory snapshots.
Returns:
CitibikeFrame: Frame instance for citi-bike scenario.
| Function to build citi_bike Frame. | def build_frame(station_num: int, snapshots_num: int):
"""Function to build citi_bike Frame.
Args:
station_num (int): Number of stations.
snapshot_num (int): Number of in-memory snapshots.
Returns:
CitibikeFrame: Frame instance for citi-bike scenario.
"""
matrices_cls = gen... | [
"def",
"build_frame",
"(",
"station_num",
":",
"int",
",",
"snapshots_num",
":",
"int",
")",
":",
"matrices_cls",
"=",
"gen_matrices_node_definition",
"(",
"station_num",
")",
"class",
"CitibikeFrame",
"(",
"FrameBase",
")",
":",
"stations",
"=",
"FrameNode",
"(... | [
8,
0
] | [
28,
26
] | python | en | ['en', 'en', 'en'] | True |
build_item_response | (coordinator, payload, get_thumbnail_url=None) | Create response payload for the provided media query. | Create response payload for the provided media query. | def build_item_response(coordinator, payload, get_thumbnail_url=None):
"""Create response payload for the provided media query."""
search_id = payload["search_id"]
search_type = payload["search_type"]
thumbnail = None
title = None
media = None
children_media_class = None
if search_type... | [
"def",
"build_item_response",
"(",
"coordinator",
",",
"payload",
",",
"get_thumbnail_url",
"=",
"None",
")",
":",
"search_id",
"=",
"payload",
"[",
"\"search_id\"",
"]",
"search_type",
"=",
"payload",
"[",
"\"search_type\"",
"]",
"thumbnail",
"=",
"None",
"titl... | [
36,
0
] | [
80,
5
] | python | en | ['en', 'en', 'en'] | True |
item_payload | (item, coordinator, get_thumbnail_url=None) |
Create response payload for a single media item.
Used by async_browse_media.
|
Create response payload for a single media item. | def item_payload(item, coordinator, get_thumbnail_url=None):
"""
Create response payload for a single media item.
Used by async_browse_media.
"""
thumbnail = None
if "app_id" in item:
media_content_type = MEDIA_TYPE_APP
media_content_id = item["app_id"]
if get_thumbnail... | [
"def",
"item_payload",
"(",
"item",
",",
"coordinator",
",",
"get_thumbnail_url",
"=",
"None",
")",
":",
"thumbnail",
"=",
"None",
"if",
"\"app_id\"",
"in",
"item",
":",
"media_content_type",
"=",
"MEDIA_TYPE_APP",
"media_content_id",
"=",
"item",
"[",
"\"app_id... | [
83,
0
] | [
115,
5
] | python | en | ['en', 'error', 'th'] | False |
library_payload | (coordinator, get_thumbnail_url=None) |
Create response payload to describe contents of a specific library.
Used by async_browse_media.
|
Create response payload to describe contents of a specific library. | def library_payload(coordinator, get_thumbnail_url=None):
"""
Create response payload to describe contents of a specific library.
Used by async_browse_media.
"""
library_info = BrowseMedia(
media_class=MEDIA_CLASS_DIRECTORY,
media_content_id="library",
media_content_type="li... | [
"def",
"library_payload",
"(",
"coordinator",
",",
"get_thumbnail_url",
"=",
"None",
")",
":",
"library_info",
"=",
"BrowseMedia",
"(",
"media_class",
"=",
"MEDIA_CLASS_DIRECTORY",
",",
"media_content_id",
"=",
"\"library\"",
",",
"media_content_type",
"=",
"\"library... | [
118,
0
] | [
164,
23
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Digital Ocean droplet switch. | Set up the Digital Ocean droplet switch. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Digital Ocean droplet switch."""
digital = hass.data.get(DATA_DIGITAL_OCEAN)
if not digital:
return False
droplets = config[CONF_DROPLETS]
dev = []
for droplet in droplets:
droplet_id = digital.g... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"digital",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_DIGITAL_OCEAN",
")",
"if",
"not",
"digital",
":",
"return",
"False",
"drople... | [
33,
0
] | [
49,
27
] | python | en | ['en', 'en', 'en'] | True |
DigitalOceanSwitch.__init__ | (self, do, droplet_id) | Initialize a new Digital Ocean sensor. | Initialize a new Digital Ocean sensor. | def __init__(self, do, droplet_id):
"""Initialize a new Digital Ocean sensor."""
self._digital_ocean = do
self._droplet_id = droplet_id
self.data = None
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"do",
",",
"droplet_id",
")",
":",
"self",
".",
"_digital_ocean",
"=",
"do",
"self",
".",
"_droplet_id",
"=",
"droplet_id",
"self",
".",
"data",
"=",
"None",
"self",
".",
"_state",
"=",
"None"
] | [
55,
4
] | [
60,
26
] | python | en | ['en', 'ca', 'en'] | True |
DigitalOceanSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self.data.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
".",
"name"
] | [
63,
4
] | [
65,
29
] | python | en | ['en', 'en', 'en'] | True |
DigitalOceanSwitch.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.status == "active" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
".",
"status",
"==",
"\"active\""
] | [
68,
4
] | [
70,
43
] | python | en | ['en', 'fy', 'en'] | True |
DigitalOceanSwitch.device_state_attributes | (self) | Return the state attributes of the Digital Ocean droplet. | Return the state attributes of the Digital Ocean droplet. | def device_state_attributes(self):
"""Return the state attributes of the Digital Ocean droplet."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_CREATED_AT: self.data.created_at,
ATTR_DROPLET_ID: self.data.id,
ATTR_DROPLET_NAME: self.data.name,
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"ATTR_CREATED_AT",
":",
"self",
".",
"data",
".",
"created_at",
",",
"ATTR_DROPLET_ID",
":",
"self",
".",
"data",
".",
"id",
",",
"ATTR_DROPLET... | [
73,
4
] | [
86,
9
] | python | en | ['en', 'en', 'en'] | True |
DigitalOceanSwitch.turn_on | (self, **kwargs) | Boot-up the droplet. | Boot-up the droplet. | def turn_on(self, **kwargs):
"""Boot-up the droplet."""
if self.data.status != "active":
self.data.power_on() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
".",
"status",
"!=",
"\"active\"",
":",
"self",
".",
"data",
".",
"power_on",
"(",
")"
] | [
88,
4
] | [
91,
32
] | python | en | ['en', 'en', 'en'] | True |
DigitalOceanSwitch.turn_off | (self, **kwargs) | Shutdown the droplet. | Shutdown the droplet. | def turn_off(self, **kwargs):
"""Shutdown the droplet."""
if self.data.status == "active":
self.data.power_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
".",
"status",
"==",
"\"active\"",
":",
"self",
".",
"data",
".",
"power_off",
"(",
")"
] | [
93,
4
] | [
96,
33
] | python | en | ['en', 'ht', 'en'] | True |
DigitalOceanSwitch.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._digital_ocean.update()
for droplet in self._digital_ocean.data:
if droplet.id == self._droplet_id:
self.data = droplet | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_digital_ocean",
".",
"update",
"(",
")",
"for",
"droplet",
"in",
"self",
".",
"_digital_ocean",
".",
"data",
":",
"if",
"droplet",
".",
"id",
"==",
"self",
".",
"_droplet_id",
":",
"self",
".",
"... | [
98,
4
] | [
104,
35
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
if cur_state is None:
_LOGGE... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistantType",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",... | [
22,
0
] | [
55,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce Lock states. | Reproduce Lock states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Lock states."""
await asyncio.gather(
*(
_async_reproduce_state(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
58,
0
] | [
73,
5
] | python | en | ['en', 'en', 'en'] | True |
DotAttention.get_pre_compute | (self, s) |
:param s: [src_sequence, batch_size, src_dim]
:return: [src_sequence, batch_size. hidden_dim]
|
:param s: [src_sequence, batch_size, src_dim]
:return: [src_sequence, batch_size. hidden_dim]
| def get_pre_compute(self, s):
'''
:param s: [src_sequence, batch_size, src_dim]
:return: [src_sequence, batch_size. hidden_dim]
'''
hidden_dim = self.hidden_dim
src_dim = s.get_shape().as_list()[-1]
assert src_dim is not None, 'src dim must be defined'
W =... | [
"def",
"get_pre_compute",
"(",
"self",
",",
"s",
")",
":",
"hidden_dim",
"=",
"self",
".",
"hidden_dim",
"src_dim",
"=",
"s",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"[",
"-",
"1",
"]",
"assert",
"src_dim",
"is",
"not",
"None",
",",
"... | [
93,
4
] | [
103,
49
] | python | en | ['en', 'error', 'th'] | False |
DotAttention.get_prob | (self, src, tgt, mask, pre_compute, return_logits=False) |
:param s: [src_sequence_length, batch_size, src_dim]
:param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim]
:param mask: [src_sequence_length, batch_size]\
or [tgt_sequence_length, src_sequence_length, batch_sizse]
:param pre_compute: [src_sequence_le... |
:param s: [src_sequence_length, batch_size, src_dim]
:param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim]
:param mask: [src_sequence_length, batch_size]\
or [tgt_sequence_length, src_sequence_length, batch_sizse]
:param pre_compute: [src_sequence_le... | def get_prob(self, src, tgt, mask, pre_compute, return_logits=False):
'''
:param s: [src_sequence_length, batch_size, src_dim]
:param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim]
:param mask: [src_sequence_length, batch_size]\
or [tgt_sequence_lengt... | [
"def",
"get_prob",
"(",
"self",
",",
"src",
",",
"tgt",
",",
"mask",
",",
"pre_compute",
",",
"return_logits",
"=",
"False",
")",
":",
"s_shape",
"=",
"src",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"h_shape",
"=",
"tgt",
".",
"get_shape... | [
105,
4
] | [
159,
19
] | python | en | ['en', 'error', 'th'] | False |
DotAttention.get_att | (self, s, prob) |
:param s: [src_sequence_length, batch_size, src_dim]
:param prob: [src_sequence_length, batch_size]\
or [tgt_sequence_length, src_sequence_length, batch_size]
:return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim]
|
:param s: [src_sequence_length, batch_size, src_dim]
:param prob: [src_sequence_length, batch_size]\
or [tgt_sequence_length, src_sequence_length, batch_size]
:return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim]
| def get_att(self, s, prob):
'''
:param s: [src_sequence_length, batch_size, src_dim]
:param prob: [src_sequence_length, batch_size]\
or [tgt_sequence_length, src_sequence_length, batch_size]
:return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim]
... | [
"def",
"get_att",
"(",
"self",
",",
"s",
",",
"prob",
")",
":",
"buf",
"=",
"s",
"*",
"tf",
".",
"expand_dims",
"(",
"prob",
",",
"axis",
"=",
"-",
"1",
")",
"att",
"=",
"tf",
".",
"reduce_sum",
"(",
"buf",
",",
"axis",
"=",
"-",
"3",
")",
... | [
161,
4
] | [
170,
18
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass, config) | Set up the GDACS component. | Set up the GDACS component. | async def async_setup(hass, config):
"""Set up the GDACS component."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
latitude = conf.get(CONF_LATITUDE, hass.config.latitude)
longitude = conf.get(CONF_LONGITUDE, hass.config.longitude)
scan_interval = conf[CONF_SCAN_INTERVAL]... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"latitude",
"=",
"conf",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
... | [
55,
0
] | [
80,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up the GDACS component as config entry. | Set up the GDACS component as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up the GDACS component as config entry."""
hass.data.setdefault(DOMAIN, {})
feeds = hass.data[DOMAIN].setdefault(FEED, {})
radius = config_entry.data[CONF_RADIUS]
if hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL:
radius = METRIC_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"feeds",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"setdefault",
"(",
"FEED",
",",
"{... | [
83,
0
] | [
96,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload an GDACS component config entry. | Unload an GDACS component config entry. | async def async_unload_entry(hass, config_entry):
"""Unload an GDACS component config entry."""
manager = hass.data[DOMAIN][FEED].pop(config_entry.entry_id)
await manager.async_stop()
await asyncio.wait(
[
hass.config_entries.async_forward_entry_unload(config_entry, domain)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"manager",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"FEED",
"]",
".",
"pop",
"(",
"config_entry",
".",
"entry_id",
")",
"await",
"manager",
".",
"async_stop",
"("... | [
99,
0
] | [
109,
15
] | python | en | ['en', 'en', 'en'] | True |
GdacsFeedEntityManager.__init__ | (self, hass, config_entry, radius_in_km) | Initialize the Feed Entity Manager. | Initialize the Feed Entity Manager. | def __init__(self, hass, config_entry, radius_in_km):
"""Initialize the Feed Entity Manager."""
self._hass = hass
self._config_entry = config_entry
coordinates = (
config_entry.data[CONF_LATITUDE],
config_entry.data[CONF_LONGITUDE],
)
categories = ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
",",
"radius_in_km",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_config_entry",
"=",
"config_entry",
"coordinates",
"=",
"(",
"config_entry",
".",
"data",
"[",
"CONF_LATITUDE",... | [
115,
4
] | [
139,
27
] | python | en | ['en', 'en', 'en'] | True |
GdacsFeedEntityManager.async_init | (self) | Schedule initial and regular updates based on configured time interval. | Schedule initial and regular updates based on configured time interval. | async def async_init(self):
"""Schedule initial and regular updates based on configured time interval."""
for domain in PLATFORMS:
self._hass.async_create_task(
self._hass.config_entries.async_forward_entry_setup(
self._config_entry, domain
... | [
"async",
"def",
"async_init",
"(",
"self",
")",
":",
"for",
"domain",
"in",
"PLATFORMS",
":",
"self",
".",
"_hass",
".",
"async_create_task",
"(",
"self",
".",
"_hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"self",
".",
"_config_entry",... | [
141,
4
] | [
160,
56
] | python | en | ['en', 'en', 'en'] | True |
GdacsFeedEntityManager.async_update | (self) | Refresh data. | Refresh data. | async def async_update(self):
"""Refresh data."""
await self._feed_manager.update()
_LOGGER.debug("Feed entity manager updated") | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_feed_manager",
".",
"update",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Feed entity manager updated\"",
")"
] | [
162,
4
] | [
165,
52
] | python | de | ['de', 'sn', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.