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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
parse_args | () |
Helper function parsing the command line options
@retval ArgumentParser
|
Helper function parsing the command line options
| def parse_args():
"""
Helper function parsing the command line options
@retval ArgumentParser
"""
parser = ArgumentParser(description="PyTorch distributed training launch "
"helper utilty that will spawn up "
"multiple d... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"\"PyTorch distributed training launch \"",
"\"helper utilty that will spawn up \"",
"\"multiple distributed processes\"",
")",
"# Optional arguments for the launch helper",
"parser",
".",... | [
107,
0
] | [
152,
30
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the MySensors platform for sensors. | Set up the MySensors platform for sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the MySensors platform for sensors."""
mysensors.setup_mysensors_platform(
hass,
DOMAIN,
discovery_info,
MySensorsSensor,
async_add_entities=async_add_entities,
) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"mysensors",
".",
"setup_mysensors_platform",
"(",
"hass",
",",
"DOMAIN",
",",
"discovery_info",
",",
"MySensorsSensor",
",... | [
56,
0
] | [
64,
5
] | python | en | ['en', 'da', 'en'] | True |
MySensorsSensor.force_update | (self) | Return True if state updates should be forced.
If True, a state change will be triggered anytime the state property is
updated, not just when the value changes.
| Return True if state updates should be forced. | def force_update(self):
"""Return True if state updates should be forced.
If True, a state change will be triggered anytime the state property is
updated, not just when the value changes.
"""
return True | [
"def",
"force_update",
"(",
"self",
")",
":",
"return",
"True"
] | [
71,
4
] | [
77,
19
] | python | en | ['en', 'en', 'en'] | True |
MySensorsSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._values.get(self.value_type) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_values",
".",
"get",
"(",
"self",
".",
"value_type",
")"
] | [
80,
4
] | [
82,
48
] | python | en | ['en', 'en', 'en'] | True |
MySensorsSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
_, icon = self._get_sensor_type()
return icon | [
"def",
"icon",
"(",
"self",
")",
":",
"_",
",",
"icon",
"=",
"self",
".",
"_get_sensor_type",
"(",
")",
"return",
"icon"
] | [
85,
4
] | [
88,
19
] | python | en | ['en', 'en', 'en'] | True |
MySensorsSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity. | Return the unit of measurement of this entity. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity."""
set_req = self.gateway.const.SetReq
if (
float(self.gateway.protocol_version) >= 1.5
and set_req.V_UNIT_PREFIX in self._values
):
return self._values[set_req.V_UNIT_PRE... | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"set_req",
"=",
"self",
".",
"gateway",
".",
"const",
".",
"SetReq",
"if",
"(",
"float",
"(",
"self",
".",
"gateway",
".",
"protocol_version",
")",
">=",
"1.5",
"and",
"set_req",
".",
"V_UNIT_PREFIX",
... | [
91,
4
] | [
100,
19
] | python | en | ['en', 'en', 'en'] | True |
MySensorsSensor._get_sensor_type | (self) | Return list with unit and icon of sensor type. | Return list with unit and icon of sensor type. | def _get_sensor_type(self):
"""Return list with unit and icon of sensor type."""
pres = self.gateway.const.Presentation
set_req = self.gateway.const.SetReq
SENSORS[set_req.V_TEMP.name][0] = (
TEMP_CELSIUS if self.gateway.metric else TEMP_FAHRENHEIT
)
sensor_ty... | [
"def",
"_get_sensor_type",
"(",
"self",
")",
":",
"pres",
"=",
"self",
".",
"gateway",
".",
"const",
".",
"Presentation",
"set_req",
"=",
"self",
".",
"gateway",
".",
"const",
".",
"SetReq",
"SENSORS",
"[",
"set_req",
".",
"V_TEMP",
".",
"name",
"]",
"... | [
102,
4
] | [
112,
26
] | python | en | ['en', 'en', 'en'] | True |
WordnetDict.base64_encode | (cls, i) | Encode a non-negative integer into a dictd compatible base64 string | Encode a non-negative integer into a dictd compatible base64 string | def base64_encode(cls, i):
"""Encode a non-negative integer into a dictd compatible base64 string"""
if (i < 0):
raise ValueError('Value %r for i is negative' % (i,))
r = 63
e = 1
while (r < i):
e += 1
r = 64**e - 1
rv = ''
while (e > 0):
... | [
"def",
"base64_encode",
"(",
"cls",
",",
"i",
")",
":",
"if",
"(",
"i",
"<",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'Value %r for i is negative'",
"%",
"(",
"i",
",",
")",
")",
"r",
"=",
"63",
"e",
"=",
"1",
"while",
"(",
"r",
"<",
"i",
")... | [
216,
3
] | [
232,
15
] | python | en | ['it', 'gl', 'en'] | False |
WordnetDict.dict_entry_write | (cls, file_index, file_data, key, entry, linesep='\n') | Write a single dict entry for <key> to index and data files | Write a single dict entry for <key> to index and data files | def dict_entry_write(cls, file_index, file_data, key, entry, linesep='\n'):
"""Write a single dict entry for <key> to index and data files"""
entry_start = file_data.tell()
file_data.write(entry)
entry_len = len(entry)
file_index.write('%s\t%s\t%s%s' % (key, cls.base64_encode(entry_start),... | [
"def",
"dict_entry_write",
"(",
"cls",
",",
"file_index",
",",
"file_data",
",",
"key",
",",
"entry",
",",
"linesep",
"=",
"'\\n'",
")",
":",
"entry_start",
"=",
"file_data",
".",
"tell",
"(",
")",
"file_data",
".",
"write",
"(",
"entry",
")",
"entry_len... | [
235,
3
] | [
241,
51
] | python | en | ['en', 'en', 'en'] | True |
mxnet_fixgamma_params | (input_param: str, layers: List[str]) |
Replace gamma weights with zeros if fix_gamma is True.
Specific to retinaface_mnet025_v* and genderage_v1 models.
:param input_param: path to MXnet .param file
:param layers: List of nodes names containg fix_gamma = True attribute
|
Replace gamma weights with zeros if fix_gamma is True.
Specific to retinaface_mnet025_v* and genderage_v1 models. | def mxnet_fixgamma_params(input_param: str, layers: List[str]):
'''
Replace gamma weights with zeros if fix_gamma is True.
Specific to retinaface_mnet025_v* and genderage_v1 models.
:param input_param: path to MXnet .param file
:param layers: List of nodes names containg fix_gamma = True attribute... | [
"def",
"mxnet_fixgamma_params",
"(",
"input_param",
":",
"str",
",",
"layers",
":",
"List",
"[",
"str",
"]",
")",
":",
"net_param",
"=",
"mx",
".",
"nd",
".",
"load",
"(",
"input_param",
")",
"for",
"layer",
"in",
"layers",
":",
"name",
"=",
"f'arg:{la... | [
27,
0
] | [
43,
20
] | python | en | ['en', 'error', 'th'] | False |
mxnet_model_fix | (input_symbol_path: str, input_params_path: str, rewrite: bool = True) |
Apply retinaface specific fixes, like renaming SoftmaxActivation and fixing gamma values.
:param input_symbol_path: Path to MXNet .symbol file
:param input_params_path: Path to MXNet .param file
:param rewrite: Write fixed symbol and param at input path
:return:
|
Apply retinaface specific fixes, like renaming SoftmaxActivation and fixing gamma values.
:param input_symbol_path: Path to MXNet .symbol file
:param input_params_path: Path to MXNet .param file
:param rewrite: Write fixed symbol and param at input path
:return:
| def mxnet_model_fix(input_symbol_path: str, input_params_path: str, rewrite: bool = True):
'''
Apply retinaface specific fixes, like renaming SoftmaxActivation and fixing gamma values.
:param input_symbol_path: Path to MXNet .symbol file
:param input_params_path: Path to MXNet .param file
:para... | [
"def",
"mxnet_model_fix",
"(",
"input_symbol_path",
":",
"str",
",",
"input_params_path",
":",
"str",
",",
"rewrite",
":",
"bool",
"=",
"True",
")",
":",
"names",
"=",
"[",
"]",
"fix_gamma_layers",
"=",
"[",
"]",
"with",
"open",
"(",
"input_symbol_path",
"... | [
46,
0
] | [
80,
34
] | python | en | ['en', 'error', 'th'] | False |
arcface_onnx_fixes | (onnx_path: str, rewrite: bool = True) |
Apply fixes specific for InsightFace ArcFace model.
(BatchNormalization spatial, and PRelu reshape)
:param onnx_path: Path to ONNX model produced by MXNet export (str)
:param write: Overwrite input model (bool, default: True)
:return: ONNX model object
|
Apply fixes specific for InsightFace ArcFace model.
(BatchNormalization spatial, and PRelu reshape) | def arcface_onnx_fixes(onnx_path: str, rewrite: bool = True):
'''
Apply fixes specific for InsightFace ArcFace model.
(BatchNormalization spatial, and PRelu reshape)
:param onnx_path: Path to ONNX model produced by MXNet export (str)
:param write: Overwrite input model (bool, default: True)
:re... | [
"def",
"arcface_onnx_fixes",
"(",
"onnx_path",
":",
"str",
",",
"rewrite",
":",
"bool",
"=",
"True",
")",
":",
"model",
"=",
"onnx",
".",
"load",
"(",
"onnx_path",
")",
"onnx_processed_nodes",
"=",
"[",
"]",
"onnx_processed_inputs",
"=",
"[",
"]",
"onnx_pr... | [
83,
0
] | [
153,
21
] | python | en | ['en', 'error', 'th'] | False |
mock_apns_notify_open | () | Mock builtins.open for apns.notfiy. | Mock builtins.open for apns.notfiy. | def mock_apns_notify_open():
"""Mock builtins.open for apns.notfiy."""
with patch("homeassistant.components.apns.notify.open", mock_open(), create=True):
yield | [
"def",
"mock_apns_notify_open",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.apns.notify.open\"",
",",
"mock_open",
"(",
")",
",",
"create",
"=",
"True",
")",
":",
"yield"
] | [
26,
0
] | [
29,
13
] | python | en | ['en', 'lb', 'en'] | True |
test_apns_setup_full | (mock_access, mock_isfile, hass) | Test setup with all data. | Test setup with all data. | async def test_apns_setup_full(mock_access, mock_isfile, hass):
"""Test setup with all data."""
config = {
"notify": {
"platform": "apns",
"name": "test_app",
"sandbox": "True",
"topic": "testapp.appname",
"cert_file": "test_app.pem",
}... | [
"async",
"def",
"test_apns_setup_full",
"(",
"mock_access",
",",
"mock_isfile",
",",
"hass",
")",
":",
"config",
"=",
"{",
"\"notify\"",
":",
"{",
"\"platform\"",
":",
"\"apns\"",
",",
"\"name\"",
":",
"\"test_app\"",
",",
"\"sandbox\"",
":",
"\"True\"",
",",
... | [
44,
0
] | [
58,
39
] | python | en | ['en', 'en', 'en'] | True |
test_apns_setup_missing_name | (hass) | Test setup with missing name. | Test setup with missing name. | async def test_apns_setup_missing_name(hass):
"""Test setup with missing name."""
config = {
"notify": {
"platform": "apns",
"topic": "testapp.appname",
"cert_file": "test_app.pem",
}
}
with assert_setup_component(0) as handle_config:
assert aw... | [
"async",
"def",
"test_apns_setup_missing_name",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"notify\"",
":",
"{",
"\"platform\"",
":",
"\"apns\"",
",",
"\"topic\"",
":",
"\"testapp.appname\"",
",",
"\"cert_file\"",
":",
"\"test_app.pem\"",
",",
"}",
"}",
"with"... | [
61,
0
] | [
72,
43
] | python | en | ['en', 'en', 'en'] | True |
test_apns_setup_missing_certificate | (hass) | Test setup with missing certificate. | Test setup with missing certificate. | async def test_apns_setup_missing_certificate(hass):
"""Test setup with missing certificate."""
config = {
"notify": {
"platform": "apns",
"name": "test_app",
"topic": "testapp.appname",
}
}
with assert_setup_component(0) as handle_config:
asse... | [
"async",
"def",
"test_apns_setup_missing_certificate",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"notify\"",
":",
"{",
"\"platform\"",
":",
"\"apns\"",
",",
"\"name\"",
":",
"\"test_app\"",
",",
"\"topic\"",
":",
"\"testapp.appname\"",
",",
"}",
"}",
"with",
... | [
75,
0
] | [
86,
43
] | python | en | ['en', 'en', 'en'] | True |
test_apns_setup_missing_topic | (hass) | Test setup with missing topic. | Test setup with missing topic. | async def test_apns_setup_missing_topic(hass):
"""Test setup with missing topic."""
config = {
"notify": {
"platform": "apns",
"name": "test_app",
"cert_file": "test_app.pem",
}
}
with assert_setup_component(0) as handle_config:
assert await as... | [
"async",
"def",
"test_apns_setup_missing_topic",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"notify\"",
":",
"{",
"\"platform\"",
":",
"\"apns\"",
",",
"\"name\"",
":",
"\"test_app\"",
",",
"\"cert_file\"",
":",
"\"test_app.pem\"",
",",
"}",
"}",
"with",
"as... | [
89,
0
] | [
100,
43
] | python | en | ['en', 'en', 'en'] | True |
test_register_new_device | (mock_write, hass) | Test registering a new device with a name. | Test registering a new device with a name. | async def test_register_new_device(mock_write, hass):
"""Test registering a new device with a name."""
yaml_file = {5678: {"name": "test device 2"}}
written_devices = []
def fake_write(_out, device):
"""Fake write_device."""
written_devices.append(device)
mock_write.side_effect = ... | [
"async",
"def",
"test_register_new_device",
"(",
"mock_write",
",",
"hass",
")",
":",
"yaml_file",
"=",
"{",
"5678",
":",
"{",
"\"name\"",
":",
"\"test device 2\"",
"}",
"}",
"written_devices",
"=",
"[",
"]",
"def",
"fake_write",
"(",
"_out",
",",
"device",
... | [
104,
0
] | [
130,
51
] | python | en | ['en', 'en', 'en'] | True |
test_register_device_without_name | (mock_write, hass) | Test registering a without a name. | Test registering a without a name. | async def test_register_device_without_name(mock_write, hass):
"""Test registering a without a name."""
yaml_file = {
1234: {"name": "test device 1", "tracking_device_id": "tracking123"},
5678: {"name": "test device 2", "tracking_device_id": "tracking456"},
}
written_devices = []
d... | [
"async",
"def",
"test_register_device_without_name",
"(",
"mock_write",
",",
"hass",
")",
":",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
",",
"\"tracking_device_id\"",
":",
"\"tracking123\"",
"}",
",",
"5678",
":",
"{",
"\"na... | [
134,
0
] | [
164,
35
] | python | en | ['en', 'en', 'en'] | True |
test_update_existing_device | (mock_write, hass) | Test updating an existing device. | Test updating an existing device. | async def test_update_existing_device(mock_write, hass):
"""Test updating an existing device."""
yaml_file = {1234: {"name": "test device 1"}, 5678: {"name": "test device 2"}}
written_devices = []
def fake_write(_out, device):
"""Fake write_device."""
written_devices.append(device)
... | [
"async",
"def",
"test_update_existing_device",
"(",
"mock_write",
",",
"hass",
")",
":",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
"}",
",",
"5678",
":",
"{",
"\"name\"",
":",
"\"test device 2\"",
"}",
"}",
"written_devices... | [
168,
0
] | [
201,
51
] | python | en | ['de', 'en', 'en'] | True |
test_update_existing_device_with_tracking_id | (mock_write, hass) | Test updating an existing device that has a tracking id. | Test updating an existing device that has a tracking id. | async def test_update_existing_device_with_tracking_id(mock_write, hass):
"""Test updating an existing device that has a tracking id."""
yaml_file = {
1234: {"name": "test device 1", "tracking_device_id": "tracking123"},
5678: {"name": "test device 2", "tracking_device_id": "tracking456"},
}... | [
"async",
"def",
"test_update_existing_device_with_tracking_id",
"(",
"mock_write",
",",
"hass",
")",
":",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
",",
"\"tracking_device_id\"",
":",
"\"tracking123\"",
"}",
",",
"5678",
":",
"... | [
205,
0
] | [
242,
60
] | python | en | ['en', 'en', 'en'] | True |
test_send | (mock_client, hass) | Test updating an existing device. | Test updating an existing device. | async def test_send(mock_client, hass):
"""Test updating an existing device."""
send = mock_client.return_value.send_notification
yaml_file = {1234: {"name": "test device 1"}}
with patch(
"homeassistant.components.apns.notify.load_yaml_config_file",
Mock(return_value=yaml_file),
):... | [
"async",
"def",
"test_send",
"(",
"mock_client",
",",
"hass",
")",
":",
"send",
"=",
"mock_client",
".",
"return_value",
".",
"send_notification",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
"}",
"}",
"with",
"patch",
"(",
... | [
246,
0
] | [
278,
40
] | python | en | ['de', 'en', 'en'] | True |
test_send_when_disabled | (mock_client, hass) | Test updating an existing device. | Test updating an existing device. | async def test_send_when_disabled(mock_client, hass):
"""Test updating an existing device."""
send = mock_client.return_value.send_notification
yaml_file = {1234: {"name": "test device 1", "disabled": True}}
with patch(
"homeassistant.components.apns.notify.load_yaml_config_file",
Mock... | [
"async",
"def",
"test_send_when_disabled",
"(",
"mock_client",
",",
"hass",
")",
":",
"send",
"=",
"mock_client",
".",
"return_value",
".",
"send_notification",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
",",
"\"disabled\"",
"... | [
282,
0
] | [
304,
26
] | python | en | ['de', 'en', 'en'] | True |
test_send_with_state | (mock_client, hass) | Test updating an existing device. | Test updating an existing device. | async def test_send_with_state(mock_client, hass):
"""Test updating an existing device."""
send = mock_client.return_value.send_notification
yaml_file = {
1234: {"name": "test device 1", "tracking_device_id": "tracking123"},
5678: {"name": "test device 2", "tracking_device_id": "tracking456... | [
"async",
"def",
"test_send_with_state",
"(",
"mock_client",
",",
"hass",
")",
":",
"send",
"=",
"mock_client",
".",
"return_value",
".",
"send_notification",
"yaml_file",
"=",
"{",
"1234",
":",
"{",
"\"name\"",
":",
"\"test device 1\"",
",",
"\"tracking_device_id\... | [
308,
0
] | [
345,
35
] | python | en | ['de', 'en', 'en'] | True |
test_disable_when_unregistered | (mock_write, mock_client, hass) | Test disabling a device when it is unregistered. | Test disabling a device when it is unregistered. | async def test_disable_when_unregistered(mock_write, mock_client, hass):
"""Test disabling a device when it is unregistered."""
send = mock_client.return_value.send_notification
send.side_effect = Unregistered()
yaml_file = {
1234: {"name": "test device 1", "tracking_device_id": "tracking123"},... | [
"async",
"def",
"test_disable_when_unregistered",
"(",
"mock_write",
",",
"mock_client",
",",
"hass",
")",
":",
"send",
"=",
"mock_client",
".",
"return_value",
".",
"send_notification",
"send",
".",
"side_effect",
"=",
"Unregistered",
"(",
")",
"yaml_file",
"=",
... | [
350,
0
] | [
382,
41
] | python | en | ['en', 'en', 'en'] | True |
test_write_device | () | Test writing device. | Test writing device. | async def test_write_device():
"""Test writing device."""
out = io.StringIO()
device = apns.ApnsDevice("123", "name", "track_id", True)
apns._write_device(out, device)
data = yaml.safe_load(out.getvalue())
assert data == {
123: {"name": "name", "tracking_device_id": "track_id", "disable... | [
"async",
"def",
"test_write_device",
"(",
")",
":",
"out",
"=",
"io",
".",
"StringIO",
"(",
")",
"device",
"=",
"apns",
".",
"ApnsDevice",
"(",
"\"123\"",
",",
"\"name\"",
",",
"\"track_id\"",
",",
"True",
")",
"apns",
".",
"_write_device",
"(",
"out",
... | [
385,
0
] | [
394,
5
] | python | en | ['de', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up switches for UniFi component.
Switches are controlling network access and switch ports with POE.
| Set up switches for UniFi component. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up switches for UniFi component.
Switches are controlling network access and switch ports with POE.
"""
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
controller.entities[DOMAIN] = {
BLOCK_SWITCH: set()... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"controller",
"=",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"controller",
".",
"entities",
"[",
"DOMAIN... | [
31,
0
] | [
88,
40
] | python | en | ['en', 'en', 'en'] | True |
add_block_entities | (controller, async_add_entities, clients) | Add new switch entities from the controller. | Add new switch entities from the controller. | def add_block_entities(controller, async_add_entities, clients):
"""Add new switch entities from the controller."""
switches = []
for mac in controller.option_block_clients:
if mac in controller.entities[DOMAIN][BLOCK_SWITCH] or mac not in clients:
continue
client = controller.... | [
"def",
"add_block_entities",
"(",
"controller",
",",
"async_add_entities",
",",
"clients",
")",
":",
"switches",
"=",
"[",
"]",
"for",
"mac",
"in",
"controller",
".",
"option_block_clients",
":",
"if",
"mac",
"in",
"controller",
".",
"entities",
"[",
"DOMAIN",... | [
92,
0
] | [
104,
36
] | python | en | ['en', 'en', 'en'] | True |
add_poe_entities | (
controller, async_add_entities, clients, previously_known_poe_clients
) | Add new switch entities from the controller. | Add new switch entities from the controller. | def add_poe_entities(
controller, async_add_entities, clients, previously_known_poe_clients
):
"""Add new switch entities from the controller."""
switches = []
devices = controller.api.devices
for mac in clients:
if mac in controller.entities[DOMAIN][POE_SWITCH]:
continue
... | [
"def",
"add_poe_entities",
"(",
"controller",
",",
"async_add_entities",
",",
"clients",
",",
"previously_known_poe_clients",
")",
":",
"switches",
"=",
"[",
"]",
"devices",
"=",
"controller",
".",
"api",
".",
"devices",
"for",
"mac",
"in",
"clients",
":",
"if... | [
108,
0
] | [
154,
36
] | python | en | ['en', 'en', 'en'] | True |
add_dpi_entities | (controller, async_add_entities, dpi_groups) | Add new switch entities from the controller. | Add new switch entities from the controller. | def add_dpi_entities(controller, async_add_entities, dpi_groups):
"""Add new switch entities from the controller."""
switches = []
for group in dpi_groups:
if (
group in controller.entities[DOMAIN][DPI_SWITCH]
or not dpi_groups[group].dpiapp_ids
):
contin... | [
"def",
"add_dpi_entities",
"(",
"controller",
",",
"async_add_entities",
",",
"dpi_groups",
")",
":",
"switches",
"=",
"[",
"]",
"for",
"group",
"in",
"dpi_groups",
":",
"if",
"(",
"group",
"in",
"controller",
".",
"entities",
"[",
"DOMAIN",
"]",
"[",
"DPI... | [
158,
0
] | [
172,
36
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.__init__ | (self, client, controller) | Set up POE switch. | Set up POE switch. | def __init__(self, client, controller):
"""Set up POE switch."""
super().__init__(client, controller)
self.poe_mode = None
if client.sw_port and self.port.poe_mode != "off":
self.poe_mode = self.port.poe_mode | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"controller",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"client",
",",
"controller",
")",
"self",
".",
"poe_mode",
"=",
"None",
"if",
"client",
".",
"sw_port",
"and",
"self",
".",
"port",
"... | [
181,
4
] | [
187,
46
] | python | en | ['en', 'zu', 'en'] | True |
UniFiPOEClientSwitch.async_added_to_hass | (self) | Call when entity about to be added to Home Assistant. | Call when entity about to be added to Home Assistant. | async def async_added_to_hass(self):
"""Call when entity about to be added to Home Assistant."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state is None:
return
if self.poe_mode is None:
self.poe_mode = state.attrib... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
"is",
"None",
":",
"return",
"if",
"self",
... | [
189,
4
] | [
204,
65
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.is_on | (self) | Return true if POE is active. | Return true if POE is active. | def is_on(self):
"""Return true if POE is active."""
return self.port.poe_mode != "off" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"port",
".",
"poe_mode",
"!=",
"\"off\""
] | [
207,
4
] | [
209,
42
] | python | en | ['en', 'nl', 'en'] | True |
UniFiPOEClientSwitch.available | (self) | Return if switch is available.
Poe_mode None means its poe state is unknown.
Sw_mac unavailable means restored client.
| Return if switch is available. | def available(self):
"""Return if switch is available.
Poe_mode None means its poe state is unknown.
Sw_mac unavailable means restored client.
"""
return (
self.poe_mode is None
or self.client.sw_mac
and (
self.controller.avail... | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"poe_mode",
"is",
"None",
"or",
"self",
".",
"client",
".",
"sw_mac",
"and",
"(",
"self",
".",
"controller",
".",
"available",
"and",
"self",
".",
"client",
".",
"sw_mac",
"in",
"... | [
212,
4
] | [
225,
9
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.async_turn_on | (self, **kwargs) | Enable POE for client. | Enable POE for client. | async def async_turn_on(self, **kwargs):
"""Enable POE for client."""
await self.device.async_set_port_poe_mode(self.client.sw_port, self.poe_mode) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"device",
".",
"async_set_port_poe_mode",
"(",
"self",
".",
"client",
".",
"sw_port",
",",
"self",
".",
"poe_mode",
")"
] | [
227,
4
] | [
229,
85
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.async_turn_off | (self, **kwargs) | Disable POE for client. | Disable POE for client. | async def async_turn_off(self, **kwargs):
"""Disable POE for client."""
await self.device.async_set_port_poe_mode(self.client.sw_port, "off") | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"device",
".",
"async_set_port_poe_mode",
"(",
"self",
".",
"client",
".",
"sw_port",
",",
"\"off\"",
")"
] | [
231,
4
] | [
233,
77
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attributes = {
"power": self.port.poe_power,
"switch": self.client.sw_mac,
"port": self.client.sw_port,
"poe_mode": self.poe_mode,
}
return attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"\"power\"",
":",
"self",
".",
"port",
".",
"poe_power",
",",
"\"switch\"",
":",
"self",
".",
"client",
".",
"sw_mac",
",",
"\"port\"",
":",
"self",
".",
"client",
".",
"sw_... | [
236,
4
] | [
244,
25
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.device | (self) | Shortcut to the switch that client is connected to. | Shortcut to the switch that client is connected to. | def device(self):
"""Shortcut to the switch that client is connected to."""
return self.controller.api.devices[self.client.sw_mac] | [
"def",
"device",
"(",
"self",
")",
":",
"return",
"self",
".",
"controller",
".",
"api",
".",
"devices",
"[",
"self",
".",
"client",
".",
"sw_mac",
"]"
] | [
247,
4
] | [
249,
62
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.port | (self) | Shortcut to the switch port that client is connected to. | Shortcut to the switch port that client is connected to. | def port(self):
"""Shortcut to the switch port that client is connected to."""
try:
return self.device.ports[self.client.sw_port]
except (AttributeError, KeyError, TypeError):
_LOGGER.warning(
"Entity %s reports faulty device %s or port %s",
... | [
"def",
"port",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"device",
".",
"ports",
"[",
"self",
".",
"client",
".",
"sw_port",
"]",
"except",
"(",
"AttributeError",
",",
"KeyError",
",",
"TypeError",
")",
":",
"_LOGGER",
".",
"warning",
... | [
252,
4
] | [
262,
13
] | python | en | ['en', 'en', 'en'] | True |
UniFiPOEClientSwitch.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_poe_clients:
await self.remove_item({self.client.mac}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"controller",
".",
"option_poe_clients",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"client",
".",
"mac",
"}",
")"
] | [
264,
4
] | [
267,
53
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.__init__ | (self, client, controller) | Set up block switch. | Set up block switch. | def __init__(self, client, controller):
"""Set up block switch."""
super().__init__(client, controller)
self._is_blocked = client.blocked | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"controller",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"client",
",",
"controller",
")",
"self",
".",
"_is_blocked",
"=",
"client",
".",
"blocked"
] | [
276,
4
] | [
280,
41
] | python | en | ['en', 'zh', 'en'] | True |
UniFiBlockClientSwitch.async_update_callback | (self) | Update the clients state. | Update the clients state. | def async_update_callback(self) -> None:
"""Update the clients state."""
if self.client.last_updated == SOURCE_EVENT:
if self.client.event.event in CLIENT_BLOCKED + CLIENT_UNBLOCKED:
self._is_blocked = self.client.event.event in CLIENT_BLOCKED
super().async_update_c... | [
"def",
"async_update_callback",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"client",
".",
"last_updated",
"==",
"SOURCE_EVENT",
":",
"if",
"self",
".",
"client",
".",
"event",
".",
"event",
"in",
"CLIENT_BLOCKED",
"+",
"CLIENT_UNBLOCKED",
":",
... | [
283,
4
] | [
290,
39
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.is_on | (self) | Return true if client is allowed to connect. | Return true if client is allowed to connect. | def is_on(self):
"""Return true if client is allowed to connect."""
return not self._is_blocked | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"_is_blocked"
] | [
293,
4
] | [
295,
35
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.async_turn_on | (self, **kwargs) | Turn on connectivity for client. | Turn on connectivity for client. | async def async_turn_on(self, **kwargs):
"""Turn on connectivity for client."""
await self.controller.api.clients.async_unblock(self.client.mac) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"controller",
".",
"api",
".",
"clients",
".",
"async_unblock",
"(",
"self",
".",
"client",
".",
"mac",
")"
] | [
297,
4
] | [
299,
72
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.async_turn_off | (self, **kwargs) | Turn off connectivity for client. | Turn off connectivity for client. | async def async_turn_off(self, **kwargs):
"""Turn off connectivity for client."""
await self.controller.api.clients.async_block(self.client.mac) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"controller",
".",
"api",
".",
"clients",
".",
"async_block",
"(",
"self",
".",
"client",
".",
"mac",
")"
] | [
301,
4
] | [
303,
70
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
if self._is_blocked:
return "mdi:network-off"
return "mdi:network" | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_blocked",
":",
"return",
"\"mdi:network-off\"",
"return",
"\"mdi:network\""
] | [
306,
4
] | [
310,
28
] | python | en | ['en', 'en', 'en'] | True |
UniFiBlockClientSwitch.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if self.client.mac not in self.controller.option_block_clients:
await self.remove_item({self.client.mac}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"client",
".",
"mac",
"not",
"in",
"self",
".",
"controller",
".",
"option_block_clients",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"client... | [
312,
4
] | [
315,
53
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.key | (self) | Return item key. | Return item key. | def key(self) -> Any:
"""Return item key."""
return self._item.id | [
"def",
"key",
"(",
"self",
")",
"->",
"Any",
":",
"return",
"self",
".",
"_item",
".",
"id"
] | [
325,
4
] | [
327,
28
] | python | en | ['en', 'hi-Latn', 'en'] | True |
UniFiDPIRestrictionSwitch.unique_id | (self) | Return a unique identifier for this switch. | Return a unique identifier for this switch. | def unique_id(self):
"""Return a unique identifier for this switch."""
return self._item.id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_item",
".",
"id"
] | [
330,
4
] | [
332,
28
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.name | (self) | Return the name of the client. | Return the name of the client. | def name(self) -> str:
"""Return the name of the client."""
return self._item.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_item",
".",
"name"
] | [
335,
4
] | [
337,
30
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
if self._item.enabled:
return "mdi:network"
return "mdi:network-off" | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_item",
".",
"enabled",
":",
"return",
"\"mdi:network\"",
"return",
"\"mdi:network-off\""
] | [
340,
4
] | [
344,
32
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.is_on | (self) | Return true if client is allowed to connect. | Return true if client is allowed to connect. | def is_on(self):
"""Return true if client is allowed to connect."""
return self._item.enabled | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_item",
".",
"enabled"
] | [
347,
4
] | [
349,
33
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.async_turn_on | (self, **kwargs) | Turn on connectivity for client. | Turn on connectivity for client. | async def async_turn_on(self, **kwargs):
"""Turn on connectivity for client."""
await self.controller.api.dpi_groups.async_enable(self._item) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"controller",
".",
"api",
".",
"dpi_groups",
".",
"async_enable",
"(",
"self",
".",
"_item",
")"
] | [
351,
4
] | [
353,
69
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.async_turn_off | (self, **kwargs) | Turn off connectivity for client. | Turn off connectivity for client. | async def async_turn_off(self, **kwargs):
"""Turn off connectivity for client."""
await self.controller.api.dpi_groups.async_disable(self._item) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"controller",
".",
"api",
".",
"dpi_groups",
".",
"async_disable",
"(",
"self",
".",
"_item",
")"
] | [
355,
4
] | [
357,
70
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_dpi_restrictions:
await self.remove_item({self.key}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"controller",
".",
"option_dpi_restrictions",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"key",
"}",
")"
] | [
359,
4
] | [
362,
46
] | python | en | ['en', 'en', 'en'] | True |
UniFiDPIRestrictionSwitch.device_info | (self) | Return a service description for device registry. | Return a service description for device registry. | def device_info(self) -> dict:
"""Return a service description for device registry."""
return {
"identifiers": {(DOMAIN, f"unifi_controller_{self._item.site_id}")},
"name": "UniFi Controller",
"manufacturer": ATTR_MANUFACTURER,
"model": "UniFi Controller",... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"f\"unifi_controller_{self._item.site_id}\"",
")",
"}",
",",
"\"name\"",
":",
"\"UniFi Controller\"",
",",
"\"manufacturer\"",
":",
"ATTR_MAN... | [
365,
4
] | [
373,
9
] | python | en | ['ro', 'fr', 'en'] | False |
test_setup_with_config | (hass) | Test setup component with config. | Test setup component with config. | async def test_setup_with_config(hass):
"""Test setup component with config."""
config = {
SENSOR_DOMAIN: [
{"platform": DOMAIN, CONF_HOST: HOST, CONF_PORT: PORT},
{"platform": DOMAIN, CONF_HOST: HOST, CONF_PORT: 888},
],
}
assert await async_setup_component(hass,... | [
"async",
"def",
"test_setup_with_config",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"SENSOR_DOMAIN",
":",
"[",
"{",
"\"platform\"",
":",
"DOMAIN",
",",
"CONF_HOST",
":",
"HOST",
",",
"CONF_PORT",
":",
"PORT",
"}",
",",
"{",
"\"platform\"",
":",
"DOMAIN",
... | [
17,
0
] | [
40,
62
] | python | en | ['en', 'en', 'en'] | True |
test_update_unique_id | (hass) | Test updating a config entry without a unique_id. | Test updating a config entry without a unique_id. | async def test_update_unique_id(hass):
"""Test updating a config entry without a unique_id."""
entry = MockConfigEntry(domain=DOMAIN, data={CONF_HOST: HOST, CONF_PORT: PORT})
entry.add_to_hass(hass)
config_entries = hass.config_entries.async_entries(DOMAIN)
assert len(config_entries) == 1
asser... | [
"async",
"def",
"test_update_unique_id",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"HOST",
",",
"CONF_PORT",
":",
"PORT",
"}",
")",
"entry",
".",
"add_to_hass",
"(",
"ha... | [
43,
0
] | [
61,
46
] | python | en | ['en', 'en', 'en'] | True |
test_unload_config_entry | (mock_now, hass) | Test unloading a config entry. | Test unloading a config entry. | async def test_unload_config_entry(mock_now, hass):
"""Test unloading a config entry."""
entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: HOST, CONF_PORT: PORT},
unique_id=f"{HOST}:{PORT}",
)
entry.add_to_hass(hass)
config_entries = hass.config_entries.async_entries(... | [
"async",
"def",
"test_unload_config_entry",
"(",
"mock_now",
",",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"HOST",
",",
"CONF_PORT",
":",
"PORT",
"}",
",",
"unique_id",
"=",
... | [
65,
0
] | [
96,
24
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up WeMo lights. | Set up WeMo lights. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up WeMo lights."""
async def _discovered_wemo(device):
"""Handle a discovered Wemo device."""
if device.model_name == "Dimmer":
async_add_entities([WemoDimmer(device)])
else:
await hass.a... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"_discovered_wemo",
"(",
"device",
")",
":",
"\"\"\"Handle a discovered Wemo device.\"\"\"",
"if",
"device",
".",
"model_name",
"==",
"\"Dimmer\... | [
39,
0
] | [
58,
5
] | python | en | ['en', 'da', 'en'] | True |
setup_bridge | (hass, bridge, async_add_entities) | Set up a WeMo link. | Set up a WeMo link. | def setup_bridge(hass, bridge, async_add_entities):
"""Set up a WeMo link."""
lights = {}
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
def update_lights():
"""Update the WeMo led objects with latest info from the bridge."""
bridge.bridge_update()
new_li... | [
"def",
"setup_bridge",
"(",
"hass",
",",
"bridge",
",",
"async_add_entities",
")",
":",
"lights",
"=",
"{",
"}",
"@",
"util",
".",
"Throttle",
"(",
"MIN_TIME_BETWEEN_SCANS",
",",
"MIN_TIME_BETWEEN_FORCED_SCANS",
")",
"def",
"update_lights",
"(",
")",
":",
"\"\... | [
61,
0
] | [
80,
19
] | python | en | ['en', 'da', 'en'] | True |
WemoLight.__init__ | (self, device, update_lights) | Initialize the WeMo light. | Initialize the WeMo light. | def __init__(self, device, update_lights):
"""Initialize the WeMo light."""
self.wemo = device
self._state = None
self._update_lights = update_lights
self._available = True
self._update_lock = None
self._brightness = None
self._hs_color = None
self... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"update_lights",
")",
":",
"self",
".",
"wemo",
"=",
"device",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_update_lights",
"=",
"update_lights",
"self",
".",
"_available",
"=",
"True",
"self",
".... | [
86,
4
] | [
99,
51
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.async_added_to_hass | (self) | Wemo light added to Home Assistant. | Wemo light added to Home Assistant. | async def async_added_to_hass(self):
"""Wemo light added to Home Assistant."""
# Define inside async context so we know our event loop
self._update_lock = asyncio.Lock() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"# Define inside async context so we know our event loop",
"self",
".",
"_update_lock",
"=",
"asyncio",
".",
"Lock",
"(",
")"
] | [
101,
4
] | [
104,
42
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.unique_id | (self) | Return the ID of this light. | Return the ID of this light. | def unique_id(self):
"""Return the ID of this light."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
107,
4
] | [
109,
30
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.name | (self) | Return the name of the light. | Return the name of the light. | def name(self):
"""Return the name of the light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
112,
4
] | [
114,
25
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"name": self._name,
"identifiers": {(WEMO_DOMAIN, self._unique_id)},
"model": self._model_name,
"manufacturer": "Belkin",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"WEMO_DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
",",
"\"model\"",
":",
"self",
".",
"_model_name",
",",
"... | [
117,
4
] | [
124,
9
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self):
"""Return the brightness of this light between 0..255."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
127,
4
] | [
129,
31
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.hs_color | (self) | Return the hs color values of this light. | Return the hs color values of this light. | def hs_color(self):
"""Return the hs color values of this light."""
return self._hs_color | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs_color"
] | [
132,
4
] | [
134,
29
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.color_temp | (self) | Return the color temperature of this light in mireds. | Return the color temperature of this light in mireds. | def color_temp(self):
"""Return the color temperature of this light in mireds."""
return self._color_temp | [
"def",
"color_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_color_temp"
] | [
137,
4
] | [
139,
31
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
142,
4
] | [
144,
26
] | python | en | ['en', 'fy', 'en'] | True |
WemoLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_WEMO | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_WEMO"
] | [
147,
4
] | [
149,
27
] | python | en | ['da', 'en', 'en'] | True |
WemoLight.available | (self) | Return if light is available. | Return if light is available. | def available(self):
"""Return if light is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
152,
4
] | [
154,
30
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | def turn_on(self, **kwargs):
"""Turn the light on."""
xy_color = None
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness or 255)
color_temp = kwargs.get(ATTR_COLOR_TEMP)
hs_color = kwargs.get(ATTR_HS_COLOR)
transition_time = int(kwargs.get(ATTR_TRANSITION, 0))
... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"xy_color",
"=",
"None",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
",",
"self",
".",
"brightness",
"or",
"255",
")",
"color_temp",
"=",
"kwargs",
".",
"get",
"(",
... | [
156,
4
] | [
187,
39
] | python | en | ['en', 'et', 'en'] | True |
WemoLight.turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | def turn_off(self, **kwargs):
"""Turn the light off."""
transition_time = int(kwargs.get(ATTR_TRANSITION, 0))
try:
if self.wemo.turn_off(transition=transition_time):
self._state["onoff"] = WEMO_OFF
except ActionException as err:
_LOGGER.warning("E... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"transition_time",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_TRANSITION",
",",
"0",
")",
")",
"try",
":",
"if",
"self",
".",
"wemo",
".",
"turn_off",
"(",
"transition",
"=",
... | [
189,
4
] | [
200,
39
] | python | en | ['en', 'zh', 'en'] | True |
WemoLight._update | (self, force_update=True) | Synchronize state with bridge. | Synchronize state with bridge. | def _update(self, force_update=True):
"""Synchronize state with bridge."""
try:
self._update_lights(no_throttle=force_update)
self._state = self.wemo.state
except (AttributeError, ActionException) as err:
_LOGGER.warning("Could not update status for %s (%s)", ... | [
"def",
"_update",
"(",
"self",
",",
"force_update",
"=",
"True",
")",
":",
"try",
":",
"self",
".",
"_update_lights",
"(",
"no_throttle",
"=",
"force_update",
")",
"self",
".",
"_state",
"=",
"self",
".",
"wemo",
".",
"state",
"except",
"(",
"AttributeEr... | [
202,
4
] | [
222,
37
] | python | en | ['en', 'en', 'en'] | True |
WemoLight.async_update | (self) | Synchronize state with bridge. | Synchronize state with bridge. | async def async_update(self):
"""Synchronize state with bridge."""
# If an update is in progress, we don't do anything
if self._update_lock.locked():
return
try:
with async_timeout.timeout(5):
await asyncio.shield(self._async_locked_update(True))
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# If an update is in progress, we don't do anything",
"if",
"self",
".",
"_update_lock",
".",
"locked",
"(",
")",
":",
"return",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
")",
":",
"a... | [
224,
4
] | [
235,
35
] | python | en | ['en', 'en', 'en'] | True |
WemoLight._async_locked_update | (self, force_update) | Try updating within an async lock. | Try updating within an async lock. | async def _async_locked_update(self, force_update):
"""Try updating within an async lock."""
async with self._update_lock:
await self.hass.async_add_executor_job(self._update, force_update) | [
"async",
"def",
"_async_locked_update",
"(",
"self",
",",
"force_update",
")",
":",
"async",
"with",
"self",
".",
"_update_lock",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_update",
",",
"force_update",
")"
] | [
237,
4
] | [
240,
78
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.__init__ | (self, device) | Initialize the WeMo dimmer. | Initialize the WeMo dimmer. | def __init__(self, device):
"""Initialize the WeMo dimmer."""
self.wemo = device
self._state = None
self._available = True
self._update_lock = None
self._brightness = None
self._model_name = self.wemo.model_name
self._name = self.wemo.name
self._se... | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"wemo",
"=",
"device",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_available",
"=",
"True",
"self",
".",
"_update_lock",
"=",
"None",
"self",
".",
"_brightness",
"=",
"None",
... | [
246,
4
] | [
255,
51
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer._subscription_callback | (self, _device, _type, _params) | Update the state by the Wemo device. | Update the state by the Wemo device. | def _subscription_callback(self, _device, _type, _params):
"""Update the state by the Wemo device."""
_LOGGER.debug("Subscription update for %s", self.name)
updated = self.wemo.subscription_update(_type, _params)
self.hass.add_job(self._async_locked_subscription_callback(not updated)) | [
"def",
"_subscription_callback",
"(",
"self",
",",
"_device",
",",
"_type",
",",
"_params",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Subscription update for %s\"",
",",
"self",
".",
"name",
")",
"updated",
"=",
"self",
".",
"wemo",
".",
"subscription_update"... | [
257,
4
] | [
261,
80
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer._async_locked_subscription_callback | (self, force_update) | Handle an update from a subscription. | Handle an update from a subscription. | async def _async_locked_subscription_callback(self, force_update):
"""Handle an update from a subscription."""
# If an update is in progress, we don't do anything
if self._update_lock.locked():
return
await self._async_locked_update(force_update)
self.async_write_ha_... | [
"async",
"def",
"_async_locked_subscription_callback",
"(",
"self",
",",
"force_update",
")",
":",
"# If an update is in progress, we don't do anything",
"if",
"self",
".",
"_update_lock",
".",
"locked",
"(",
")",
":",
"return",
"await",
"self",
".",
"_async_locked_upda... | [
263,
4
] | [
270,
35
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.async_added_to_hass | (self) | Wemo dimmer added to Home Assistant. | Wemo dimmer added to Home Assistant. | async def async_added_to_hass(self):
"""Wemo dimmer added to Home Assistant."""
# Define inside async context so we know our event loop
self._update_lock = asyncio.Lock()
registry = self.hass.data[WEMO_DOMAIN]["registry"]
await self.hass.async_add_executor_job(registry.register,... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"# Define inside async context so we know our event loop",
"self",
".",
"_update_lock",
"=",
"asyncio",
".",
"Lock",
"(",
")",
"registry",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"WEMO_DOMAIN",
"]",... | [
272,
4
] | [
279,
65
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.async_update | (self) | Update WeMo state.
Wemo has an aggressive retry logic that sometimes can take over a
minute to return. If we don't get a state after 5 seconds, assume the
Wemo dimmer is unreachable. If update goes through, it will be made
available again.
| Update WeMo state. | async def async_update(self):
"""Update WeMo state.
Wemo has an aggressive retry logic that sometimes can take over a
minute to return. If we don't get a state after 5 seconds, assume the
Wemo dimmer is unreachable. If update goes through, it will be made
available again.
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# If an update is in progress, we don't do anything",
"if",
"self",
".",
"_update_lock",
".",
"locked",
"(",
")",
":",
"return",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
")",
":",
"a... | [
281,
4
] | [
298,
35
] | python | en | ['en', 'sn', 'en'] | True |
WemoDimmer._async_locked_update | (self, force_update) | Try updating within an async lock. | Try updating within an async lock. | async def _async_locked_update(self, force_update):
"""Try updating within an async lock."""
async with self._update_lock:
await self.hass.async_add_executor_job(self._update, force_update) | [
"async",
"def",
"_async_locked_update",
"(",
"self",
",",
"force_update",
")",
":",
"async",
"with",
"self",
".",
"_update_lock",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_update",
",",
"force_update",
")"
] | [
300,
4
] | [
303,
78
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.unique_id | (self) | Return the ID of this WeMo dimmer. | Return the ID of this WeMo dimmer. | def unique_id(self):
"""Return the ID of this WeMo dimmer."""
return self._serialnumber | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_serialnumber"
] | [
306,
4
] | [
308,
33
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.name | (self) | Return the name of the dimmer if any. | Return the name of the dimmer if any. | def name(self):
"""Return the name of the dimmer if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
311,
4
] | [
313,
25
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"name": self._name,
"identifiers": {(WEMO_DOMAIN, self._serialnumber)},
"model": self._model_name,
"manufacturer": "Belkin",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"WEMO_DOMAIN",
",",
"self",
".",
"_serialnumber",
")",
"}",
",",
"\"model\"",
":",
"self",
".",
"_model_name",
",",
... | [
316,
4
] | [
323,
9
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS"
] | [
326,
4
] | [
328,
33
] | python | en | ['da', 'en', 'en'] | True |
WemoDimmer.brightness | (self) | Return the brightness of this light between 1 and 100. | Return the brightness of this light between 1 and 100. | def brightness(self):
"""Return the brightness of this light between 1 and 100."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
331,
4
] | [
333,
31
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.is_on | (self) | Return true if dimmer is on. Standby is on. | Return true if dimmer is on. Standby is on. | def is_on(self):
"""Return true if dimmer is on. Standby is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
336,
4
] | [
338,
26
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer._update | (self, force_update=True) | Update the device state. | Update the device state. | def _update(self, force_update=True):
"""Update the device state."""
try:
self._state = self.wemo.get_state(force_update)
wemobrightness = int(self.wemo.get_brightness(force_update))
self._brightness = int((wemobrightness * 255) / 100)
if not self._avail... | [
"def",
"_update",
"(",
"self",
",",
"force_update",
"=",
"True",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"wemo",
".",
"get_state",
"(",
"force_update",
")",
"wemobrightness",
"=",
"int",
"(",
"self",
".",
"wemo",
".",
"get_bright... | [
340,
4
] | [
354,
45
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.turn_on | (self, **kwargs) | Turn the dimmer on. | Turn the dimmer on. | def turn_on(self, **kwargs):
"""Turn the dimmer on."""
# Wemo dimmer switches use a range of [0, 100] to control
# brightness. Level 255 might mean to set it to previous value
if ATTR_BRIGHTNESS in kwargs:
brightness = kwargs[ATTR_BRIGHTNESS]
brightness = int((bri... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Wemo dimmer switches use a range of [0, 100] to control",
"# brightness. Level 255 might mean to set it to previous value",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"brightness",
"=",
"kwargs",
"[",
"... | [
356,
4
] | [
375,
39
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.turn_off | (self, **kwargs) | Turn the dimmer off. | Turn the dimmer off. | def turn_off(self, **kwargs):
"""Turn the dimmer off."""
try:
if self.wemo.off():
self._state = WEMO_OFF
except ActionException as err:
_LOGGER.warning("Error while turning on device %s (%s)", self.name, err)
self._available = False
se... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"self",
".",
"wemo",
".",
"off",
"(",
")",
":",
"self",
".",
"_state",
"=",
"WEMO_OFF",
"except",
"ActionException",
"as",
"err",
":",
"_LOGGER",
".",
"warning",
"... | [
377,
4
] | [
386,
39
] | python | en | ['en', 'en', 'en'] | True |
WemoDimmer.available | (self) | Return if dimmer is available. | Return if dimmer is available. | def available(self):
"""Return if dimmer is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
389,
4
] | [
391,
30
] | python | en | ['en', 'en', 'en'] | True |
ConceptualCaptionsDataset.__init__ | (self, ann_file, image_set, root_path, data_path, seq_len=64,
with_precomputed_visual_feat=False, mask_raw_pixels=True,
with_rel_task=True, with_mlm_task=True, with_mvrc_task=True,
transform=None, test_mode=False,
zip_mode=False, cache_mode=False, cach... |
Conceptual Captions Dataset
:param ann_file: annotation jsonl file
:param image_set: image folder name, e.g., 'vcr1images'
:param root_path: root path to cache database loaded from annotation file
:param data_path: path to vcr dataset
:param transform: transform
... |
Conceptual Captions Dataset | def __init__(self, ann_file, image_set, root_path, data_path, seq_len=64,
with_precomputed_visual_feat=False, mask_raw_pixels=True,
with_rel_task=True, with_mlm_task=True, with_mvrc_task=True,
transform=None, test_mode=False,
zip_mode=False, cache_mode... | [
"def",
"__init__",
"(",
"self",
",",
"ann_file",
",",
"image_set",
",",
"root_path",
",",
"data_path",
",",
"seq_len",
"=",
"64",
",",
"with_precomputed_visual_feat",
"=",
"False",
",",
"mask_raw_pixels",
"=",
"True",
",",
"with_rel_task",
"=",
"True",
",",
... | [
19,
4
] | [
91,
56
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Ecovacs vacuums. | Set up the Ecovacs vacuums. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Ecovacs vacuums."""
vacuums = []
for device in hass.data[ECOVACS_DEVICES]:
vacuums.append(EcovacsVacuum(device))
_LOGGER.debug("Adding Ecovacs Vacuums to Home Assistant: %s", vacuums)
add_entities(vacuums, Tru... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"vacuums",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"ECOVACS_DEVICES",
"]",
":",
"vacuums",
".",
"append",
"(",... | [
41,
0
] | [
47,
31
] | python | en | ['en', 'en', 'en'] | True |
EcovacsVacuum.__init__ | (self, device) | Initialize the Ecovacs Vacuum. | Initialize the Ecovacs Vacuum. | def __init__(self, device):
"""Initialize the Ecovacs Vacuum."""
self.device = device
self.device.connect_and_wait_until_ready()
if self.device.vacuum.get("nick") is not None:
self._name = str(self.device.vacuum["nick"])
else:
# In case there is no nicknam... | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"device",
"=",
"device",
"self",
".",
"device",
".",
"connect_and_wait_until_ready",
"(",
")",
"if",
"self",
".",
"device",
".",
"vacuum",
".",
"get",
"(",
"\"nick\"",
")",
"is",
"no... | [
53,
4
] | [
65,
58
] | python | en | ['en', 'en', 'en'] | True |
EcovacsVacuum.async_added_to_hass | (self) | Set up the event listeners now that hass is ready. | Set up the event listeners now that hass is ready. | async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
self.device.statusEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.device.batteryEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.device.lifespanEvents.su... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"device",
".",
"statusEvents",
".",
"subscribe",
"(",
"lambda",
"_",
":",
"self",
".",
"schedule_update_ha_state",
"(",
")",
")",
"self",
".",
"device",
".",
"batteryE... | [
67,
4
] | [
72,
56
] | python | en | ['en', 'en', 'en'] | True |
EcovacsVacuum.on_error | (self, error) | Handle an error event from the robot.
This will not change the entity's state. If the error caused the state
to change, that will come through as a separate on_status event
| Handle an error event from the robot. | def on_error(self, error):
"""Handle an error event from the robot.
This will not change the entity's state. If the error caused the state
to change, that will come through as a separate on_status event
"""
if error == "no_error":
self._error = None
else:
... | [
"def",
"on_error",
"(",
"self",
",",
"error",
")",
":",
"if",
"error",
"==",
"\"no_error\"",
":",
"self",
".",
"_error",
"=",
"None",
"else",
":",
"self",
".",
"_error",
"=",
"error",
"self",
".",
"hass",
".",
"bus",
".",
"fire",
"(",
"\"ecovacs_erro... | [
74,
4
] | [
88,
39
] | python | en | ['en', 'en', 'en'] | True |
EcovacsVacuum.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self) -> bool:
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
91,
4
] | [
93,
20
] | python | en | ['en', 'en', 'en'] | True |
EcovacsVacuum.unique_id | (self) | Return an unique ID. | Return an unique ID. | def unique_id(self) -> str:
"""Return an unique ID."""
return self.device.vacuum.get("did") | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"device",
".",
"vacuum",
".",
"get",
"(",
"\"did\"",
")"
] | [
96,
4
] | [
98,
44
] | python | fr | ['fr', 'fr', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.