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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_setup_platform | (
hass: HomeAssistantType,
config: ConfigType,
async_add_entities,
discovery_info: Optional[DiscoveryInfoType] = None,
) | Read configuration and create Modbus cover. | Read configuration and create Modbus cover. | async def async_setup_platform(
hass: HomeAssistantType,
config: ConfigType,
async_add_entities,
discovery_info: Optional[DiscoveryInfoType] = None,
):
"""Read configuration and create Modbus cover."""
if discovery_info is None:
return
covers = []
for cover in discovery_info[CON... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
":",
"Optional",
"[",
"DiscoveryInfoType",
"]",
"=",
"None",
",",
")",
":",
"if",
"discovery_info",
... | [
39,
0
] | [
54,
30
] | python | en | ['en', 'it', 'en'] | True |
ModbusCover.__init__ | (
self,
hub: ModbusHub,
config: Dict[str, Any],
) | Initialize the modbus cover. | Initialize the modbus cover. | def __init__(
self,
hub: ModbusHub,
config: Dict[str, Any],
):
"""Initialize the modbus cover."""
self._hub: ModbusHub = hub
self._coil = config.get(CALL_TYPE_COIL)
self._device_class = config.get(CONF_DEVICE_CLASS)
self._name = config[CONF_NAME]
... | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
")",
":",
"self",
".",
"_hub",
":",
"ModbusHub",
"=",
"hub",
"self",
".",
"_coil",
"=",
"config",
".",
"get",
"(",
"CALL_T... | [
60,
4
] | [
96,
67
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
state = await self.async_get_last_state()
if not state:
return
self._value = state.state
async_track_time_interval(
self.hass, lambda arg: self._update(), self._scan_interval
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"not",
"state",
":",
"return",
"self",
".",
"_value",
"=",
"state",
".",
"state",
"async_track_time_interval",
"(",
"sel... | [
98,
4
] | [
107,
9
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> Optional[str]:
"""Return the device class of the sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_device_class"
] | [
110,
4
] | [
112,
33
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.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._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
115,
4
] | [
117,
25
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_OPEN | SUPPORT_CLOSE | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE"
] | [
120,
4
] | [
122,
43
] | python | en | ['da', 'en', 'en'] | True |
ModbusCover.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
125,
4
] | [
127,
30
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return self._value == self._state_opening | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value",
"==",
"self",
".",
"_state_opening"
] | [
130,
4
] | [
132,
49
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return self._value == self._state_closing | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value",
"==",
"self",
".",
"_state_closing"
] | [
135,
4
] | [
137,
49
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.is_closed | (self) | Return if the cover is closed or not. | Return if the cover is closed or not. | def is_closed(self):
"""Return if the cover is closed or not."""
return self._value == self._state_closed | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value",
"==",
"self",
".",
"_state_closed"
] | [
140,
4
] | [
142,
48
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.should_poll | (self) | Return True if entity has to be polled for state.
False if entity pushes its state to HA.
| Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state.
False if entity pushes its state to HA.
"""
# Handle polling directly in this entity
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"# Handle polling directly in this entity",
"return",
"False"
] | [
145,
4
] | [
152,
20
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover.open_cover | (self, **kwargs: Any) | Open cover. | Open cover. | def open_cover(self, **kwargs: Any) -> None:
"""Open cover."""
if self._coil is not None:
self._write_coil(True)
else:
self._write_register(self._state_open)
self._update() | [
"def",
"open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"_coil",
"is",
"not",
"None",
":",
"self",
".",
"_write_coil",
"(",
"True",
")",
"else",
":",
"self",
".",
"_write_register",
"(",
"se... | [
154,
4
] | [
161,
22
] | python | en | ['es', 'en', 'en'] | False |
ModbusCover.close_cover | (self, **kwargs: Any) | Close cover. | Close cover. | def close_cover(self, **kwargs: Any) -> None:
"""Close cover."""
if self._coil is not None:
self._write_coil(False)
else:
self._write_register(self._state_closed)
self._update() | [
"def",
"close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"_coil",
"is",
"not",
"None",
":",
"self",
".",
"_write_coil",
"(",
"False",
")",
"else",
":",
"self",
".",
"_write_register",
"(",
"... | [
163,
4
] | [
170,
22
] | python | en | ['en', 'la', 'en'] | False |
ModbusCover._update | (self) | Update the state of the cover. | Update the state of the cover. | def _update(self):
"""Update the state of the cover."""
if self._coil is not None and self._status_register is None:
self._value = self._read_coil()
else:
self._value = self._read_status_register()
self.schedule_update_ha_state() | [
"def",
"_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_coil",
"is",
"not",
"None",
"and",
"self",
".",
"_status_register",
"is",
"None",
":",
"self",
".",
"_value",
"=",
"self",
".",
"_read_coil",
"(",
")",
"else",
":",
"self",
".",
"_value",
... | [
172,
4
] | [
179,
39
] | python | en | ['en', 'en', 'en'] | True |
ModbusCover._read_status_register | (self) | Read status register using the Modbus hub slave. | Read status register using the Modbus hub slave. | def _read_status_register(self) -> Optional[int]:
"""Read status register using the Modbus hub slave."""
try:
if self._status_register_type == CALL_TYPE_REGISTER_INPUT:
result = self._hub.read_input_registers(
self._slave, self._status_register, 1
... | [
"def",
"_read_status_register",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"try",
":",
"if",
"self",
".",
"_status_register_type",
"==",
"CALL_TYPE_REGISTER_INPUT",
":",
"result",
"=",
"self",
".",
"_hub",
".",
"read_input_registers",
"(",
"self... | [
181,
4
] | [
203,
20
] | python | en | ['en', 'hmn', 'en'] | True |
ModbusCover._write_register | (self, value) | Write holding register using the Modbus hub slave. | Write holding register using the Modbus hub slave. | def _write_register(self, value):
"""Write holding register using the Modbus hub slave."""
try:
self._hub.write_register(self._slave, self._register, value)
except ConnectionException:
self._available = False
return
self._available = True | [
"def",
"_write_register",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"_hub",
".",
"write_register",
"(",
"self",
".",
"_slave",
",",
"self",
".",
"_register",
",",
"value",
")",
"except",
"ConnectionException",
":",
"self",
".",
"_avai... | [
205,
4
] | [
213,
30
] | python | en | ['en', 'hmn', 'en'] | True |
ModbusCover._read_coil | (self) | Read coil using the Modbus hub slave. | Read coil using the Modbus hub slave. | def _read_coil(self) -> Optional[bool]:
"""Read coil using the Modbus hub slave."""
try:
result = self._hub.read_coils(self._slave, self._coil, 1)
except ConnectionException:
self._available = False
return
if isinstance(result, (ModbusException, Excep... | [
"def",
"_read_coil",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"try",
":",
"result",
"=",
"self",
".",
"_hub",
".",
"read_coils",
"(",
"self",
".",
"_slave",
",",
"self",
".",
"_coil",
",",
"1",
")",
"except",
"ConnectionException",
... | [
215,
4
] | [
230,
20
] | python | en | ['en', 'hmn', 'en'] | True |
ModbusCover._write_coil | (self, value) | Write coil using the Modbus hub slave. | Write coil using the Modbus hub slave. | def _write_coil(self, value):
"""Write coil using the Modbus hub slave."""
try:
self._hub.write_coil(self._slave, self._coil, value)
except ConnectionException:
self._available = False
return
self._available = True | [
"def",
"_write_coil",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"_hub",
".",
"write_coil",
"(",
"self",
".",
"_slave",
",",
"self",
".",
"_coil",
",",
"value",
")",
"except",
"ConnectionException",
":",
"self",
".",
"_available",
"=... | [
232,
4
] | [
240,
30
] | python | en | ['en', 'hmn', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Tank Utility sensor. | Set up the Tank Utility sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tank Utility sensor."""
email = config.get(CONF_EMAIL)
password = config.get(CONF_PASSWORD)
devices = config.get(CONF_DEVICES)
try:
token = auth.get_token(email, password)
except requests.exceptions.HTTP... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"email",
"=",
"config",
".",
"get",
"(",
"CONF_EMAIL",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"devices",... | [
40,
0
] | [
61,
35
] | python | en | ['en', 'sq', 'en'] | True |
TankUtilitySensor.__init__ | (self, email, password, token, device) | Initialize the sensor. | Initialize the sensor. | def __init__(self, email, password, token, device):
"""Initialize the sensor."""
self._email = email
self._password = password
self._token = token
self._device = device
self._state = None
self._name = f"Tank Utility {self.device}"
self._unit_of_measurement... | [
"def",
"__init__",
"(",
"self",
",",
"email",
",",
"password",
",",
"token",
",",
"device",
")",
":",
"self",
".",
"_email",
"=",
"email",
"self",
".",
"_password",
"=",
"password",
"self",
".",
"_token",
"=",
"token",
"self",
".",
"_device",
"=",
"d... | [
67,
4
] | [
76,
29
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.device | (self) | Return the device identifier. | Return the device identifier. | def device(self):
"""Return the device identifier."""
return self._device | [
"def",
"device",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device"
] | [
79,
4
] | [
81,
27
] | python | en | ['en', 'fy', 'en'] | True |
TankUtilitySensor.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._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
84,
4
] | [
86,
26
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
89,
4
] | [
91,
25
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.unit_of_measurement | (self) | Return the unit of measurement of the device. | Return the unit of measurement of the device. | def unit_of_measurement(self):
"""Return the unit of measurement of the device."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
94,
4
] | [
96,
40
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.device_state_attributes | (self) | Return the attributes of the device. | Return the attributes of the device. | def device_state_attributes(self):
"""Return the attributes of the device."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
99,
4
] | [
101,
31
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.get_data | (self) | Get data from the device.
Flatten dictionary to map device to map of device data.
| Get data from the device. | def get_data(self):
"""Get data from the device.
Flatten dictionary to map device to map of device data.
"""
data = {}
try:
data = tank_monitor.get_device_data(self._token, self.device)
except requests.exceptions.HTTPError as http_error:
if (
... | [
"def",
"get_data",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"try",
":",
"data",
"=",
"tank_monitor",
".",
"get_device_data",
"(",
"self",
".",
"_token",
",",
"self",
".",
"device",
")",
"except",
"requests",
".",
"exceptions",
".",
"HTTPError",
"a... | [
103,
4
] | [
127,
19
] | python | en | ['en', 'en', 'en'] | True |
TankUtilitySensor.update | (self) | Set the device state and attributes. | Set the device state and attributes. | def update(self):
"""Set the device state and attributes."""
data = self.get_data()
self._state = round(data[SENSOR_TYPE], SENSOR_ROUNDING_PRECISION)
self._attributes = {k: v for k, v in data.items() if k in SENSOR_ATTRS} | [
"def",
"update",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"get_data",
"(",
")",
"self",
".",
"_state",
"=",
"round",
"(",
"data",
"[",
"SENSOR_TYPE",
"]",
",",
"SENSOR_ROUNDING_PRECISION",
")",
"self",
".",
"_attributes",
"=",
"{",
"k",
":",
... | [
129,
4
] | [
133,
79
] | python | en | ['en', 'en', 'en'] | True |
MXNetGraph.register | (op_name) | Register operators | Register operators | def register(op_name):
"""Register operators"""
def wrapper(func):
"""Helper function to map functions"""
try:
import onnx as _
MXNetGraph.registry_[op_name] = func
except ImportError:
pass
return func
... | [
"def",
"register",
"(",
"op_name",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"\"\"\"Helper function to map functions\"\"\"",
"try",
":",
"import",
"onnx",
"as",
"_",
"MXNetGraph",
".",
"registry_",
"[",
"op_name",
"]",
"=",
"func",
"except",
"ImportEr... | [
67,
4
] | [
78,
22
] | python | en | ['en', 'la', 'en'] | False |
MXNetGraph.convert_layer | (node, **kwargs) | Convert MXNet layer to ONNX | Convert MXNet layer to ONNX | def convert_layer(node, **kwargs):
"""Convert MXNet layer to ONNX"""
op = str(node["op"])
if op not in MXNetGraph.registry_:
raise AttributeError("No conversion function registered for op type %s yet." % op)
convert_func = MXNetGraph.registry_[op]
return convert_func(... | [
"def",
"convert_layer",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"op",
"=",
"str",
"(",
"node",
"[",
"\"op\"",
"]",
")",
"if",
"op",
"not",
"in",
"MXNetGraph",
".",
"registry_",
":",
"raise",
"AttributeError",
"(",
"\"No conversion function register... | [
81,
4
] | [
87,
43
] | python | en | ['en', 'lb', 'en'] | True |
MXNetGraph.split_params | (sym, params) | Helper function to split params dictionary into args and aux params
Parameters
----------
sym : :class:`~mxnet.symbol.Symbol`
MXNet symbol object
params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray`
Dict of converted parameters stored in ``mxnet.ndarray.ND... | Helper function to split params dictionary into args and aux params | def split_params(sym, params):
"""Helper function to split params dictionary into args and aux params
Parameters
----------
sym : :class:`~mxnet.symbol.Symbol`
MXNet symbol object
params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray`
Dict of convert... | [
"def",
"split_params",
"(",
"sym",
",",
"params",
")",
":",
"arg_params",
"=",
"{",
"}",
"aux_params",
"=",
"{",
"}",
"for",
"args",
"in",
"sym",
".",
"list_arguments",
"(",
")",
":",
"if",
"args",
"in",
"params",
":",
"arg_params",
".",
"update",
"(... | [
90,
4
] | [
115,
37
] | python | en | ['en', 'en', 'en'] | True |
MXNetGraph.get_outputs | (sym, params, in_shape, in_label, verbose=True) | Infer output shapes and return dictionary of output name to shape
:param :class:`~mxnet.symbol.Symbol` sym: symbol to perform infer shape on
:param dic of (str, nd.NDArray) params:
:param list of tuple(int, ...) in_shape: list of all input shapes
:param in_label: name of label typical... | Infer output shapes and return dictionary of output name to shape | def get_outputs(sym, params, in_shape, in_label, verbose=True):
""" Infer output shapes and return dictionary of output name to shape
:param :class:`~mxnet.symbol.Symbol` sym: symbol to perform infer shape on
:param dic of (str, nd.NDArray) params:
:param list of tuple(int, ...) in_shap... | [
"def",
"get_outputs",
"(",
"sym",
",",
"params",
",",
"in_shape",
",",
"in_label",
",",
"verbose",
"=",
"True",
")",
":",
"# remove any input listed in params from sym.list_inputs() and bind them to the input shapes provided",
"# by user. Also remove in_label, which is the name of ... | [
118,
4
] | [
153,
28
] | python | en | ['en', 'en', 'en'] | True |
MXNetGraph.convert_weights_to_numpy | (weights_dict) | Convert weights to numpy | Convert weights to numpy | def convert_weights_to_numpy(weights_dict):
"""Convert weights to numpy"""
return dict([(k.replace("arg:", "").replace("aux:", ""), v.asnumpy())
for k, v in weights_dict.items()]) | [
"def",
"convert_weights_to_numpy",
"(",
"weights_dict",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"k",
".",
"replace",
"(",
"\"arg:\"",
",",
"\"\"",
")",
".",
"replace",
"(",
"\"aux:\"",
",",
"\"\"",
")",
",",
"v",
".",
"asnumpy",
"(",
")",
")",
"fo... | [
156,
4
] | [
159,
55
] | python | en | ['en', 'en', 'en'] | True |
MXNetGraph.create_onnx_graph_proto | (self, sym, params, in_shape, in_type, verbose=False) | Convert MXNet graph to ONNX graph
Parameters
----------
sym : :class:`~mxnet.symbol.Symbol`
MXNet symbol object
params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray`
Dict of converted parameters stored in ``mxnet.ndarray.NDArray`` format
in_shape : ... | Convert MXNet graph to ONNX graph | def create_onnx_graph_proto(self, sym, params, in_shape, in_type, verbose=False):
"""Convert MXNet graph to ONNX graph
Parameters
----------
sym : :class:`~mxnet.symbol.Symbol`
MXNet symbol object
params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray`
... | [
"def",
"create_onnx_graph_proto",
"(",
"self",
",",
"sym",
",",
"params",
",",
"in_shape",
",",
"in_type",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"from",
"onnx",
"import",
"(",
"checker",
",",
"helper",
",",
"NodeProto",
",",
"ValueInfoProto",... | [
161,
4
] | [
313,
20
] | python | en | ['en', 'lb', 'en'] | True |
ONVIFBaseEntity.__init__ | (self, device: ONVIFDevice, profile: Profile = None) | Initialize the ONVIF entity. | Initialize the ONVIF entity. | def __init__(self, device: ONVIFDevice, profile: Profile = None) -> None:
"""Initialize the ONVIF entity."""
self.device: ONVIFDevice = device
self.profile: Profile = profile | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"ONVIFDevice",
",",
"profile",
":",
"Profile",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"device",
":",
"ONVIFDevice",
"=",
"device",
"self",
".",
"profile",
":",
"Profile",
"=",
"profile"
] | [
12,
4
] | [
15,
39
] | python | en | ['en', 'en', 'en'] | True |
ONVIFBaseEntity.available | (self) | Return True if device is available. | Return True if device is available. | def available(self):
"""Return True if device is available."""
return self.device.available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"available"
] | [
18,
4
] | [
20,
36
] | python | en | ['en', 'en', 'en'] | True |
ONVIFBaseEntity.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."""
device_info = {
"manufacturer": self.device.info.manufacturer,
"model": self.device.info.model,
"name": self.device.name,
"sw_version": self.device.info.fw_version,
"... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"\"manufacturer\"",
":",
"self",
".",
"device",
".",
"info",
".",
"manufacturer",
",",
"\"model\"",
":",
"self",
".",
"device",
".",
"info",
".",
"model",
",",
"\"name\"",
":",
"self",... | [
23,
4
] | [
46,
26
] | python | en | ['ro', 'fr', 'en'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Snapcast platform. | Set up the Snapcast platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Snapcast platform."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT, CONTROL_PORT)
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(SERVICE_SNAPSH... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
",",... | [
54,
0
] | [
88,
31
] | python | en | ['en', 'cs', 'en'] | True |
handle_async_join | (entity, service_call) | Handle the entity service join. | Handle the entity service join. | async def handle_async_join(entity, service_call):
"""Handle the entity service join."""
if not isinstance(entity, SnapcastClientDevice):
raise ValueError("Entity is not a client. Can only join clients.")
await entity.async_join(service_call.data[ATTR_MASTER]) | [
"async",
"def",
"handle_async_join",
"(",
"entity",
",",
"service_call",
")",
":",
"if",
"not",
"isinstance",
"(",
"entity",
",",
"SnapcastClientDevice",
")",
":",
"raise",
"ValueError",
"(",
"\"Entity is not a client. Can only join clients.\"",
")",
"await",
"entity"... | [
91,
0
] | [
95,
59
] | python | en | ['en', 'en', 'en'] | True |
handle_async_unjoin | (entity, service_call) | Handle the entity service unjoin. | Handle the entity service unjoin. | async def handle_async_unjoin(entity, service_call):
"""Handle the entity service unjoin."""
if not isinstance(entity, SnapcastClientDevice):
raise ValueError("Entity is not a client. Can only unjoin clients.")
await entity.async_unjoin() | [
"async",
"def",
"handle_async_unjoin",
"(",
"entity",
",",
"service_call",
")",
":",
"if",
"not",
"isinstance",
"(",
"entity",
",",
"SnapcastClientDevice",
")",
":",
"raise",
"ValueError",
"(",
"\"Entity is not a client. Can only unjoin clients.\"",
")",
"await",
"ent... | [
98,
0
] | [
102,
31
] | python | en | ['en', 'en', 'en'] | True |
handle_set_latency | (entity, service_call) | Handle the entity service set_latency. | Handle the entity service set_latency. | async def handle_set_latency(entity, service_call):
"""Handle the entity service set_latency."""
if not isinstance(entity, SnapcastClientDevice):
raise ValueError("Latency can only be set for a Snapcast client.")
await entity.async_set_latency(service_call.data[ATTR_LATENCY]) | [
"async",
"def",
"handle_set_latency",
"(",
"entity",
",",
"service_call",
")",
":",
"if",
"not",
"isinstance",
"(",
"entity",
",",
"SnapcastClientDevice",
")",
":",
"raise",
"ValueError",
"(",
"\"Latency can only be set for a Snapcast client.\"",
")",
"await",
"entity... | [
105,
0
] | [
109,
67
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.__init__ | (self, group, uid_part) | Initialize the Snapcast group device. | Initialize the Snapcast group device. | def __init__(self, group, uid_part):
"""Initialize the Snapcast group device."""
group.set_callback(self.schedule_update_ha_state)
self._group = group
self._uid = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}" | [
"def",
"__init__",
"(",
"self",
",",
"group",
",",
"uid_part",
")",
":",
"group",
".",
"set_callback",
"(",
"self",
".",
"schedule_update_ha_state",
")",
"self",
".",
"_group",
"=",
"group",
"self",
".",
"_uid",
"=",
"f\"{GROUP_PREFIX}{uid_part}_{self._group.ide... | [
115,
4
] | [
119,
72
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.state | (self) | Return the state of the player. | Return the state of the player. | def state(self):
"""Return the state of the player."""
return {
"idle": STATE_IDLE,
"playing": STATE_PLAYING,
"unknown": STATE_UNKNOWN,
}.get(self._group.stream_status, STATE_UNKNOWN) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"{",
"\"idle\"",
":",
"STATE_IDLE",
",",
"\"playing\"",
":",
"STATE_PLAYING",
",",
"\"unknown\"",
":",
"STATE_UNKNOWN",
",",
"}",
".",
"get",
"(",
"self",
".",
"_group",
".",
"stream_status",
",",
"STATE_UNK... | [
122,
4
] | [
128,
55
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.unique_id | (self) | Return the ID of snapcast group. | Return the ID of snapcast group. | def unique_id(self):
"""Return the ID of snapcast group."""
return self._uid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_uid"
] | [
131,
4
] | [
133,
24
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return f"{GROUP_PREFIX}{self._group.identifier}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{GROUP_PREFIX}{self._group.identifier}\""
] | [
136,
4
] | [
138,
56
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.source | (self) | Return the current input source. | Return the current input source. | def source(self):
"""Return the current input source."""
return self._group.stream | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_group",
".",
"stream"
] | [
141,
4
] | [
143,
33
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.volume_level | (self) | Return the volume level. | Return the volume level. | def volume_level(self):
"""Return the volume level."""
return self._group.volume / 100 | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_group",
".",
"volume",
"/",
"100"
] | [
146,
4
] | [
148,
39
] | python | en | ['en', 'no', 'en'] | True |
SnapcastGroupDevice.is_volume_muted | (self) | Volume muted. | Volume muted. | def is_volume_muted(self):
"""Volume muted."""
return self._group.muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_group",
".",
"muted"
] | [
151,
4
] | [
153,
32
] | python | en | ['en', 'de', 'en'] | False |
SnapcastGroupDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_SNAPCAST_GROUP | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_SNAPCAST_GROUP"
] | [
156,
4
] | [
158,
37
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return list(self._group.streams_by_name().keys()) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"_group",
".",
"streams_by_name",
"(",
")",
".",
"keys",
"(",
")",
")"
] | [
161,
4
] | [
163,
57
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
name = f"{self._group.friendly_name} {GROUP_SUFFIX}"
return {"friendly_name": name} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"name",
"=",
"f\"{self._group.friendly_name} {GROUP_SUFFIX}\"",
"return",
"{",
"\"friendly_name\"",
":",
"name",
"}"
] | [
166,
4
] | [
169,
38
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.should_poll | (self) | Do not poll for state. | Do not poll for state. | def should_poll(self):
"""Do not poll for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
172,
4
] | [
174,
20
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.async_select_source | (self, source) | Set input source. | Set input source. | async def async_select_source(self, source):
"""Set input source."""
streams = self._group.streams_by_name()
if source in streams:
await self._group.set_stream(streams[source].identifier)
self.async_write_ha_state() | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
")",
":",
"streams",
"=",
"self",
".",
"_group",
".",
"streams_by_name",
"(",
")",
"if",
"source",
"in",
"streams",
":",
"await",
"self",
".",
"_group",
".",
"set_stream",
"(",
"streams",
... | [
176,
4
] | [
181,
39
] | python | en | ['fr', 'su', 'en'] | False |
SnapcastGroupDevice.async_mute_volume | (self, mute) | Send the mute command. | Send the mute command. | async def async_mute_volume(self, mute):
"""Send the mute command."""
await self._group.set_muted(mute)
self.async_write_ha_state() | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"await",
"self",
".",
"_group",
".",
"set_muted",
"(",
"mute",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
183,
4
] | [
186,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.async_set_volume_level | (self, volume) | Set the volume level. | Set the volume level. | async def async_set_volume_level(self, volume):
"""Set the volume level."""
await self._group.set_volume(round(volume * 100))
self.async_write_ha_state() | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_group",
".",
"set_volume",
"(",
"round",
"(",
"volume",
"*",
"100",
")",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
188,
4
] | [
191,
35
] | python | en | ['en', 'sr', 'en'] | True |
SnapcastGroupDevice.snapshot | (self) | Snapshot the group state. | Snapshot the group state. | def snapshot(self):
"""Snapshot the group state."""
self._group.snapshot() | [
"def",
"snapshot",
"(",
"self",
")",
":",
"self",
".",
"_group",
".",
"snapshot",
"(",
")"
] | [
193,
4
] | [
195,
30
] | python | en | ['en', 'en', 'en'] | True |
SnapcastGroupDevice.async_restore | (self) | Restore the group state. | Restore the group state. | async def async_restore(self):
"""Restore the group state."""
await self._group.restore() | [
"async",
"def",
"async_restore",
"(",
"self",
")",
":",
"await",
"self",
".",
"_group",
".",
"restore",
"(",
")"
] | [
197,
4
] | [
199,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.__init__ | (self, client, uid_part) | Initialize the Snapcast client device. | Initialize the Snapcast client device. | def __init__(self, client, uid_part):
"""Initialize the Snapcast client device."""
client.set_callback(self.schedule_update_ha_state)
self._client = client
self._uid = f"{CLIENT_PREFIX}{uid_part}_{self._client.identifier}" | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"uid_part",
")",
":",
"client",
".",
"set_callback",
"(",
"self",
".",
"schedule_update_ha_state",
")",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_uid",
"=",
"f\"{CLIENT_PREFIX}{uid_part}_{self._clie... | [
205,
4
] | [
209,
74
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.unique_id | (self) |
Return the ID of this snapcast client.
Note: Host part is needed, when using multiple snapservers
|
Return the ID of this snapcast client. | def unique_id(self):
"""
Return the ID of this snapcast client.
Note: Host part is needed, when using multiple snapservers
"""
return self._uid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_uid"
] | [
212,
4
] | [
218,
24
] | python | en | ['en', 'error', 'th'] | False |
SnapcastClientDevice.identifier | (self) | Return the snapcast identifier. | Return the snapcast identifier. | def identifier(self):
"""Return the snapcast identifier."""
return self._client.identifier | [
"def",
"identifier",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"identifier"
] | [
221,
4
] | [
223,
38
] | python | en | ['en', 'no', 'en'] | True |
SnapcastClientDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return f"{CLIENT_PREFIX}{self._client.identifier}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{CLIENT_PREFIX}{self._client.identifier}\""
] | [
226,
4
] | [
228,
58
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.source | (self) | Return the current input source. | Return the current input source. | def source(self):
"""Return the current input source."""
return self._client.group.stream | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"group",
".",
"stream"
] | [
231,
4
] | [
233,
40
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.volume_level | (self) | Return the volume level. | Return the volume level. | def volume_level(self):
"""Return the volume level."""
return self._client.volume / 100 | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"volume",
"/",
"100"
] | [
236,
4
] | [
238,
40
] | python | en | ['en', 'no', 'en'] | True |
SnapcastClientDevice.is_volume_muted | (self) | Volume muted. | Volume muted. | def is_volume_muted(self):
"""Volume muted."""
return self._client.muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"muted"
] | [
241,
4
] | [
243,
33
] | python | en | ['en', 'de', 'en'] | False |
SnapcastClientDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_SNAPCAST_CLIENT | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_SNAPCAST_CLIENT"
] | [
246,
4
] | [
248,
38
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return list(self._client.group.streams_by_name().keys()) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"_client",
".",
"group",
".",
"streams_by_name",
"(",
")",
".",
"keys",
"(",
")",
")"
] | [
251,
4
] | [
253,
64
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.state | (self) | Return the state of the player. | Return the state of the player. | def state(self):
"""Return the state of the player."""
if self._client.connected:
return STATE_ON
return STATE_OFF | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
".",
"connected",
":",
"return",
"STATE_ON",
"return",
"STATE_OFF"
] | [
256,
4
] | [
260,
24
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
state_attrs = {}
if self.latency is not None:
state_attrs["latency"] = self.latency
name = f"{self._client.friendly_name} {CLIENT_SUFFIX}"
state_attrs["friendly_name"] = name
return state_at... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"state_attrs",
"=",
"{",
"}",
"if",
"self",
".",
"latency",
"is",
"not",
"None",
":",
"state_attrs",
"[",
"\"latency\"",
"]",
"=",
"self",
".",
"latency",
"name",
"=",
"f\"{self._client.friendly_name} {C... | [
263,
4
] | [
270,
26
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.should_poll | (self) | Do not poll for state. | Do not poll for state. | def should_poll(self):
"""Do not poll for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
273,
4
] | [
275,
20
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.latency | (self) | Latency for Client. | Latency for Client. | def latency(self):
"""Latency for Client."""
return self._client.latency | [
"def",
"latency",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"latency"
] | [
278,
4
] | [
280,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.async_select_source | (self, source) | Set input source. | Set input source. | async def async_select_source(self, source):
"""Set input source."""
streams = self._client.group.streams_by_name()
if source in streams:
await self._client.group.set_stream(streams[source].identifier)
self.async_write_ha_state() | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
")",
":",
"streams",
"=",
"self",
".",
"_client",
".",
"group",
".",
"streams_by_name",
"(",
")",
"if",
"source",
"in",
"streams",
":",
"await",
"self",
".",
"_client",
".",
"group",
".",... | [
282,
4
] | [
287,
39
] | python | en | ['fr', 'su', 'en'] | False |
SnapcastClientDevice.async_mute_volume | (self, mute) | Send the mute command. | Send the mute command. | async def async_mute_volume(self, mute):
"""Send the mute command."""
await self._client.set_muted(mute)
self.async_write_ha_state() | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"await",
"self",
".",
"_client",
".",
"set_muted",
"(",
"mute",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
289,
4
] | [
292,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.async_set_volume_level | (self, volume) | Set the volume level. | Set the volume level. | async def async_set_volume_level(self, volume):
"""Set the volume level."""
await self._client.set_volume(round(volume * 100))
self.async_write_ha_state() | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_client",
".",
"set_volume",
"(",
"round",
"(",
"volume",
"*",
"100",
")",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
294,
4
] | [
297,
35
] | python | en | ['en', 'sr', 'en'] | True |
SnapcastClientDevice.async_join | (self, master) | Join the group of the master player. | Join the group of the master player. | async def async_join(self, master):
"""Join the group of the master player."""
master_entity = next(
entity for entity in self.hass.data[DATA_KEY] if entity.entity_id == master
)
if not isinstance(master_entity, SnapcastClientDevice):
raise ValueError("Master is ... | [
"async",
"def",
"async_join",
"(",
"self",
",",
"master",
")",
":",
"master_entity",
"=",
"next",
"(",
"entity",
"for",
"entity",
"in",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_KEY",
"]",
"if",
"entity",
".",
"entity_id",
"==",
"master",
")",
"if",... | [
299,
4
] | [
314,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.async_unjoin | (self) | Unjoin the group the player is currently in. | Unjoin the group the player is currently in. | async def async_unjoin(self):
"""Unjoin the group the player is currently in."""
await self._client.group.remove_client(self._client.identifier)
self.async_write_ha_state() | [
"async",
"def",
"async_unjoin",
"(",
"self",
")",
":",
"await",
"self",
".",
"_client",
".",
"group",
".",
"remove_client",
"(",
"self",
".",
"_client",
".",
"identifier",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
316,
4
] | [
319,
35
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.snapshot | (self) | Snapshot the client state. | Snapshot the client state. | def snapshot(self):
"""Snapshot the client state."""
self._client.snapshot() | [
"def",
"snapshot",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"snapshot",
"(",
")"
] | [
321,
4
] | [
323,
31
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.async_restore | (self) | Restore the client state. | Restore the client state. | async def async_restore(self):
"""Restore the client state."""
await self._client.restore() | [
"async",
"def",
"async_restore",
"(",
"self",
")",
":",
"await",
"self",
".",
"_client",
".",
"restore",
"(",
")"
] | [
325,
4
] | [
327,
36
] | python | en | ['en', 'en', 'en'] | True |
SnapcastClientDevice.async_set_latency | (self, latency) | Set the latency of the client. | Set the latency of the client. | async def async_set_latency(self, latency):
"""Set the latency of the client."""
await self._client.set_latency(latency)
self.async_write_ha_state() | [
"async",
"def",
"async_set_latency",
"(",
"self",
",",
"latency",
")",
":",
"await",
"self",
".",
"_client",
".",
"set_latency",
"(",
"latency",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
329,
4
] | [
332,
35
] | python | en | ['en', 'en', 'en'] | True |
singleton | (data_key: str) | Decorate a function that should be called once per instance.
Result will be cached and simultaneous calls will be handled.
| Decorate a function that should be called once per instance. | def singleton(data_key: str) -> Callable[[FUNC], FUNC]:
"""Decorate a function that should be called once per instance.
Result will be cached and simultaneous calls will be handled.
"""
def wrapper(func: FUNC) -> FUNC:
"""Wrap a function with caching logic."""
if not asyncio.iscoroutin... | [
"def",
"singleton",
"(",
"data_key",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"FUNC",
"]",
",",
"FUNC",
"]",
":",
"def",
"wrapper",
"(",
"func",
":",
"FUNC",
")",
"->",
"FUNC",
":",
"\"\"\"Wrap a function with caching logic.\"\"\"",
"if",
"not",
"async... | [
13,
0
] | [
56,
18
] | python | en | ['en', 'en', 'en'] | True |
DeconzBase.__init__ | (self, device, gateway) | Set up device and add update callback to get data from websocket. | Set up device and add update callback to get data from websocket. | def __init__(self, device, gateway):
"""Set up device and add update callback to get data from websocket."""
self._device = device
self.gateway = gateway | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"gateway",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"gateway",
"=",
"gateway"
] | [
12,
4
] | [
15,
30
] | python | en | ['en', 'en', 'en'] | True |
DeconzBase.unique_id | (self) | Return a unique identifier for this device. | Return a unique identifier for this device. | def unique_id(self):
"""Return a unique identifier for this device."""
return self._device.uniqueid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"uniqueid"
] | [
18,
4
] | [
20,
36
] | python | en | ['en', 'en', 'en'] | True |
DeconzBase.serial | (self) | Return a serial number for this device. | Return a serial number for this device. | def serial(self):
"""Return a serial number for this device."""
if self._device.uniqueid is None or self._device.uniqueid.count(":") != 7:
return None
return self._device.uniqueid.split("-", 1)[0] | [
"def",
"serial",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"uniqueid",
"is",
"None",
"or",
"self",
".",
"_device",
".",
"uniqueid",
".",
"count",
"(",
"\":\"",
")",
"!=",
"7",
":",
"return",
"None",
"return",
"self",
".",
"_device",
... | [
23,
4
] | [
28,
53
] | python | en | ['en', 'en', 'en'] | True |
DeconzBase.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."""
if self.serial is None:
return None
bridgeid = self.gateway.api.config.bridgeid
return {
"connections": {(CONNECTION_ZIGBEE, self.serial)},
"identifiers": {(DECONZ_DOMAIN, ... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"serial",
"is",
"None",
":",
"return",
"None",
"bridgeid",
"=",
"self",
".",
"gateway",
".",
"api",
".",
"config",
".",
"bridgeid",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNEC... | [
31,
4
] | [
46,
9
] | python | en | ['ro', 'fr', 'en'] | False |
DeconzDevice.__init__ | (self, device, gateway) | Set up device and add update callback to get data from websocket. | Set up device and add update callback to get data from websocket. | def __init__(self, device, gateway):
"""Set up device and add update callback to get data from websocket."""
super().__init__(device, gateway)
self.gateway.entities[self.TYPE].add(self.unique_id) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"gateway",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"gateway",
")",
"self",
".",
"gateway",
".",
"entities",
"[",
"self",
".",
"TYPE",
"]",
".",
"add",
"(",
"self",
".",
... | [
54,
4
] | [
57,
60
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry.
Daylight is a virtual sensor from deCONZ that should never be enabled by default.
| Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self):
"""Return if the entity should be enabled when first added to the entity registry.
Daylight is a virtual sensor from deCONZ that should never be enabled by default.
"""
if self._device.type == "Daylight":
return False
retur... | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"type",
"==",
"\"Daylight\"",
":",
"return",
"False",
"return",
"True"
] | [
60,
4
] | [
68,
19
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.async_added_to_hass | (self) | Subscribe to device events. | Subscribe to device events. | async def async_added_to_hass(self):
"""Subscribe to device events."""
self._device.register_callback(self.async_update_callback)
self.gateway.deconz_ids[self.entity_id] = self._device.deconz_id
self.async_on_remove(
async_dispatcher_connect(
self.hass, self.g... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"register_callback",
"(",
"self",
".",
"async_update_callback",
")",
"self",
".",
"gateway",
".",
"deconz_ids",
"[",
"self",
".",
"entity_id",
"]",
"=",
"self",
".",
... | [
70,
4
] | [
78,
9
] | python | en | ['it', 'en', 'en'] | True |
DeconzDevice.async_will_remove_from_hass | (self) | Disconnect device object when removed. | Disconnect device object when removed. | async def async_will_remove_from_hass(self) -> None:
"""Disconnect device object when removed."""
self._device.remove_callback(self.async_update_callback)
del self.gateway.deconz_ids[self.entity_id]
self.gateway.entities[self.TYPE].remove(self.unique_id) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_device",
".",
"remove_callback",
"(",
"self",
".",
"async_update_callback",
")",
"del",
"self",
".",
"gateway",
".",
"deconz_ids",
"[",
"self",
".",
"entity_id",... | [
80,
4
] | [
84,
63
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.async_update_callback | (self, force_update=False) | Update the device's state. | Update the device's state. | def async_update_callback(self, force_update=False):
"""Update the device's state."""
if not force_update and self.gateway.ignore_state_updates:
return
self.async_write_ha_state() | [
"def",
"async_update_callback",
"(",
"self",
",",
"force_update",
"=",
"False",
")",
":",
"if",
"not",
"force_update",
"and",
"self",
".",
"gateway",
".",
"ignore_state_updates",
":",
"return",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
87,
4
] | [
92,
35
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.available | (self) | Return True if device is available. | Return True if device is available. | def available(self):
"""Return True if device is available."""
return self.gateway.available and self._device.reachable | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"gateway",
".",
"available",
"and",
"self",
".",
"_device",
".",
"reachable"
] | [
95,
4
] | [
97,
64
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
100,
4
] | [
102,
32
] | python | en | ['en', 'en', 'en'] | True |
DeconzDevice.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
105,
4
] | [
107,
20
] | python | en | ['en', 'en', 'en'] | True |
async_get_service | (hass, config, discovery_info=None) | Get the Tibber notification service. | Get the Tibber notification service. | async def async_get_service(hass, config, discovery_info=None):
"""Get the Tibber notification service."""
tibber_connection = hass.data[TIBBER_DOMAIN]
return TibberNotificationService(tibber_connection.send_notification) | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"tibber_connection",
"=",
"hass",
".",
"data",
"[",
"TIBBER_DOMAIN",
"]",
"return",
"TibberNotificationService",
"(",
"tibber_connection",
".",
"send_not... | [
15,
0
] | [
18,
73
] | python | en | ['en', 'en', 'en'] | True |
TibberNotificationService.__init__ | (self, notify) | Initialize the service. | Initialize the service. | def __init__(self, notify):
"""Initialize the service."""
self._notify = notify | [
"def",
"__init__",
"(",
"self",
",",
"notify",
")",
":",
"self",
".",
"_notify",
"=",
"notify"
] | [
24,
4
] | [
26,
29
] | python | en | ['en', 'en', 'en'] | True |
TibberNotificationService.async_send_message | (self, message=None, **kwargs) | Send a message to Tibber devices. | Send a message to Tibber devices. | async def async_send_message(self, message=None, **kwargs):
"""Send a message to Tibber devices."""
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
try:
await self._notify(title=title, message=message)
except asyncio.TimeoutError:
_LOGGER.error("Timeout sending... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
",",
"ATTR_TITLE_DEFAULT",
")",
"try",
":",
"await",
"self",
".",
"_notify",
"(",
... | [
28,
4
] | [
34,
64
] | python | en | ['en', 'en', 'en'] | True |
ResNetVLBERTForAttentionVis._collect_obj_reps | (self, span_tags, object_reps) |
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
|
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
| def _collect_obj_reps(self, span_tags, object_reps):
"""
Collect span-level object representations
:param span_tags: [batch_size, ..leading_dims.., L]
:param object_reps: [batch_size, max_num_objs_per_batch, obj_dim]
:return:
"""
span_tags_fixed = torch.clamp(spa... | [
"def",
"_collect_obj_reps",
"(",
"self",
",",
"span_tags",
",",
"object_reps",
")",
":",
"span_tags_fixed",
"=",
"torch",
".",
"clamp",
"(",
"span_tags",
",",
"min",
"=",
"0",
")",
"# In case there were masked values here",
"row_id",
"=",
"span_tags_fixed",
".",
... | [
72,
4
] | [
89,
102
] | python | en | ['en', 'error', 'th'] | False |
GLUETransformer.prepare_data | (self) | Called to initialize data. Use the call to construct features | Called to initialize data. Use the call to construct features | def prepare_data(self):
"Called to initialize data. Use the call to construct features"
args = self.hparams
processor = processors[args.task]()
self.labels = processor.get_labels()
for mode in ["train", "dev"]:
cached_features_file = self._feature_file(mode)
... | [
"def",
"prepare_data",
"(",
"self",
")",
":",
"args",
"=",
"self",
".",
"hparams",
"processor",
"=",
"processors",
"[",
"args",
".",
"task",
"]",
"(",
")",
"self",
".",
"labels",
"=",
"processor",
".",
"get_labels",
"(",
")",
"for",
"mode",
"in",
"["... | [
50,
4
] | [
75,
58
] | python | en | ['en', 'en', 'en'] | True |
GLUETransformer.get_dataloader | (self, mode: str, batch_size: int, shuffle: bool = False) | Load datasets. Called after prepare data. | Load datasets. Called after prepare data. | def get_dataloader(self, mode: str, batch_size: int, shuffle: bool = False) -> DataLoader:
"Load datasets. Called after prepare data."
# We test on dev set to compare to benchmarks without having to submit to GLUE server
mode = "dev" if mode == "test" else mode
cached_features_file = s... | [
"def",
"get_dataloader",
"(",
"self",
",",
"mode",
":",
"str",
",",
"batch_size",
":",
"int",
",",
"shuffle",
":",
"bool",
"=",
"False",
")",
"->",
"DataLoader",
":",
"# We test on dev set to compare to benchmarks without having to submit to GLUE server",
"mode",
"=",... | [
77,
4
] | [
98,
9
] | python | en | ['en', 'en', 'en'] | True |
test_template_state_text | (hass) | Test the state text of a template. | Test the state text of a template. | async def test_template_state_text(hass):
"""Test the state text of a template."""
await setup.async_setup_component(
hass,
"alarm_control_panel",
{
"alarm_control_panel": {
"platform": "template",
"panels": {
"test_template... | [
"async",
"def",
"test_template_state_text",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"alarm_control_panel\"",
",",
"{",
"\"alarm_control_panel\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"panels\"",
":"... | [
16,
0
] | [
103,
35
] | python | en | ['en', 'en', 'en'] | True |
test_optimistic_states | (hass) | Test the optimistic state. | Test the optimistic state. | async def test_optimistic_states(hass):
"""Test the optimistic state."""
await setup.async_setup_component(
hass,
"alarm_control_panel",
{
"alarm_control_panel": {
"platform": "template",
"panels": {
"test_template_panel": {... | [
"async",
"def",
"test_optimistic_states",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"alarm_control_panel\"",
",",
"{",
"\"alarm_control_panel\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"panels\"",
":",
... | [
106,
0
] | [
177,
46
] | python | en | ['en', 'en', 'en'] | True |
test_no_action_scripts | (hass) | Test no action scripts per state. | Test no action scripts per state. | async def test_no_action_scripts(hass):
"""Test no action scripts per state."""
await setup.async_setup_component(
hass,
"alarm_control_panel",
{
"alarm_control_panel": {
"platform": "template",
"panels": {
"test_template_pa... | [
"async",
"def",
"test_no_action_scripts",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"alarm_control_panel\"",
",",
"{",
"\"alarm_control_panel\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"panels\"",
":",
... | [
180,
0
] | [
234,
48
] | python | ca | ['ca', 'en', 'it'] | False |
test_template_syntax_error | (hass, caplog) | Test templating syntax error. | Test templating syntax error. | async def test_template_syntax_error(hass, caplog):
"""Test templating syntax error."""
await setup.async_setup_component(
hass,
"alarm_control_panel",
{
"alarm_control_panel": {
"platform": "template",
"panels": {
"test_tem... | [
"async",
"def",
"test_template_syntax_error",
"(",
"hass",
",",
"caplog",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"alarm_control_panel\"",
",",
"{",
"\"alarm_control_panel\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
... | [
237,
0
] | [
279,
46
] | python | ca | ['ca', 'de', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.