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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
XiaomiVibration.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_LAST_ACTION: self._last_action}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_LAST_ACTION",
":",
"self",
".",
"_last_action",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
426,
4
] | [
430,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiVibration.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
if value is None:
return False
if value not in ("vibrate", "tilt", "free_fall", "actively"):
_LOGGER.warning("Unsupported movement_type detected: %s", value)
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"value",
"=",
"data",
".",
"get",
"(",
"self",
".",
"_data_key",
")",
"if",
"value",
"is",
"None",
":",
"return",
"False",
"if",
"value",
"not",
"in",
"(",
"\"vibrate\"",
",",
... | [
432,
4
] | [
448,
19
] | python | en | ['en', 'de', 'en'] | True |
XiaomiButton.__init__ | (self, device, name, data_key, hass, xiaomi_hub, config_entry) | Initialize the XiaomiButton. | Initialize the XiaomiButton. | def __init__(self, device, name, data_key, hass, xiaomi_hub, config_entry):
"""Initialize the XiaomiButton."""
self._hass = hass
self._last_action = None
super().__init__(device, name, xiaomi_hub, data_key, None, config_entry) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"name",
",",
"data_key",
",",
"hass",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_last_action",
"=",
"None",
"super",
"(",
")",
".",
"__init__",... | [
454,
4
] | [
458,
80
] | python | en | ['en', 'en', 'en'] | True |
XiaomiButton.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_LAST_ACTION: self._last_action}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_LAST_ACTION",
":",
"self",
".",
"_last_action",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
461,
4
] | [
465,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiButton.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
if value is None:
return False
if value == "long_click_press":
self._state = True
click_type = "long_click_press"
elif value == "long_clic... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"value",
"=",
"data",
".",
"get",
"(",
"self",
".",
"_data_key",
")",
"if",
"value",
"is",
"None",
":",
"return",
"False",
"if",
"value",
"==",
"\"long_click_press\"",
":",
"self... | [
467,
4
] | [
503,
19
] | python | en | ['en', 'de', 'en'] | True |
XiaomiCube.__init__ | (self, device, hass, xiaomi_hub, config_entry) | Initialize the Xiaomi Cube. | Initialize the Xiaomi Cube. | def __init__(self, device, hass, xiaomi_hub, config_entry):
"""Initialize the Xiaomi Cube."""
self._hass = hass
self._last_action = None
self._state = False
if "proto" not in device or int(device["proto"][0:1]) == 1:
data_key = "status"
else:
data_... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"hass",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_last_action",
"=",
"None",
"self",
".",
"_state",
"=",
"False",
"if",
"\"proto\"",
"not",
"i... | [
509,
4
] | [
518,
82
] | python | en | ['en', 'co', 'en'] | True |
XiaomiCube.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_LAST_ACTION: self._last_action}
attrs.update(super().device_state_attributes)
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"ATTR_LAST_ACTION",
":",
"self",
".",
"_last_action",
"}",
"attrs",
".",
"update",
"(",
"super",
"(",
")",
".",
"device_state_attributes",
")",
"return",
"attrs"
] | [
521,
4
] | [
525,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiCube.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if self._data_key in data:
self._hass.bus.fire(
"xiaomi_aqara.cube_action",
{"entity_id": self.entity_id, "action_type": data[self._data_key]},
)
self._last_action ... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"if",
"self",
".",
"_data_key",
"in",
"data",
":",
"self",
".",
"_hass",
".",
"bus",
".",
"fire",
"(",
"\"xiaomi_aqara.cube_action\"",
",",
"{",
"\"entity_id\"",
":",
"self",
".",
... | [
527,
4
] | [
568,
19
] | python | en | ['en', 'de', 'en'] | True |
minify | (src_dir: str, dest_dir: str, n: int) | Write first n lines of each file f in src_dir to dest_dir/f | Write first n lines of each file f in src_dir to dest_dir/f | def minify(src_dir: str, dest_dir: str, n: int):
"""Write first n lines of each file f in src_dir to dest_dir/f """
src_dir = Path(src_dir)
dest_dir = Path(dest_dir)
dest_dir.mkdir(exist_ok=True)
for path in src_dir.iterdir():
new = [x.rstrip() for x in list(path.open().readlines())][:n]
... | [
"def",
"minify",
"(",
"src_dir",
":",
"str",
",",
"dest_dir",
":",
"str",
",",
"n",
":",
"int",
")",
":",
"src_dir",
"=",
"Path",
"(",
"src_dir",
")",
"dest_dir",
"=",
"Path",
"(",
"dest_dir",
")",
"dest_dir",
".",
"mkdir",
"(",
"exist_ok",
"=",
"T... | [
20,
0
] | [
29,
49
] | python | en | ['en', 'en', 'sw'] | True |
async_setup_platform | (
hass, hass_config, async_add_entities, discovery_info=None
) | Set up the LCN light platform. | Set up the LCN light platform. | async def async_setup_platform(
hass, hass_config, async_add_entities, discovery_info=None
):
"""Set up the LCN light platform."""
if discovery_info is None:
return
devices = []
for config in discovery_info:
address, connection_id = config[CONF_ADDRESS]
addr = pypck.lcn_addr... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"hass_config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"devices",
"=",
"[",
"]",
"for",
"config",
"in",
"discovery_i... | [
24,
0
] | [
46,
31
] | python | en | ['en', 'da', 'en'] | True |
LcnOutputLight.__init__ | (self, config, address_connection) | Initialize the LCN light. | Initialize the LCN light. | def __init__(self, config, address_connection):
"""Initialize the LCN light."""
super().__init__(config, address_connection)
self.output = pypck.lcn_defs.OutputPort[config[CONF_OUTPUT]]
self._transition = pypck.lcn_defs.time_to_ramp_value(config[CONF_TRANSITION])
self.dimmable ... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"OutputPort",
"[",
"config",
... | [
52,
4
] | [
63,
40
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputLight.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.output) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"output",
")"
] | [
65,
4
] | [
68,
82
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
if self.dimmable:
return SUPPORT_TRANSITION | SUPPORT_BRIGHTNESS
return SUPPORT_TRANSITION | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"dimmable",
":",
"return",
"SUPPORT_TRANSITION",
"|",
"SUPPORT_BRIGHTNESS",
"return",
"SUPPORT_TRANSITION"
] | [
71,
4
] | [
75,
33
] | python | en | ['da', 'en', 'en'] | True |
LcnOutputLight.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"
] | [
78,
4
] | [
80,
31
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputLight.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self):
"""Return True if entity is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
83,
4
] | [
85,
26
] | python | en | ['en', 'cy', 'en'] | True |
LcnOutputLight.async_turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
self._is_on = True
self._is_dimming_to_zero = False
if ATTR_BRIGHTNESS in kwargs:
percent = int(kwargs[ATTR_BRIGHTNESS] / 255.0 * 100)
else:
percent = 100
if ATTR_TRANSITION in kwar... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"True",
"self",
".",
"_is_dimming_to_zero",
"=",
"False",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"percent",
"=",
"int",
"(",
"kwargs",
"["... | [
87,
4
] | [
103,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputLight.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
self._is_on = False
if ATTR_TRANSITION in kwargs:
transition = pypck.lcn_defs.time_to_ramp_value(
kwargs[ATTR_TRANSITION] * 1000
)
else:
transition = self._transition
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"False",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"transition",
"=",
"pypck",
".",
"lcn_defs",
".",
"time_to_ramp_value",
"(",
"kwargs",
"[",... | [
105,
4
] | [
118,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputLight.input_received | (self, input_obj) | Set light state when LCN input object (command) is received. | Set light state when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set light state when LCN input object (command) is received."""
if (
not isinstance(input_obj, pypck.inputs.ModStatusOutput)
or input_obj.get_output_id() != self.output.value
):
return
self._brightness = int(inp... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusOutput",
")",
"or",
"input_obj",
".",
"get_output_id",
"(",
")",
"!=",
"self",
".",
"output",
... | [
120,
4
] | [
133,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayLight.__init__ | (self, config, address_connection) | Initialize the LCN light. | Initialize the LCN light. | def __init__(self, config, address_connection):
"""Initialize the LCN light."""
super().__init__(config, address_connection)
self.output = pypck.lcn_defs.RelayPort[config[CONF_OUTPUT]]
self._is_on = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"RelayPort",
"[",
"config",
... | [
139,
4
] | [
145,
26
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayLight.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.output) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"output",
")"
] | [
147,
4
] | [
150,
82
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayLight.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self):
"""Return True if entity is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
153,
4
] | [
155,
26
] | python | en | ['en', 'cy', 'en'] | True |
LcnRelayLight.async_turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
self._is_on = True
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.ON
self.address_connection.control_relays(states)
self.async_wri... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"True",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"RelayStateModifier",
".",
"NOCHANGE",
"]",
"*",
"8",
"states",
"[",
"self",
".",
... | [
157,
4
] | [
165,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayLight.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
self._is_on = False
states = [pypck.lcn_defs.RelayStateModifier.NOCHANGE] * 8
states[self.output.value] = pypck.lcn_defs.RelayStateModifier.OFF
self.address_connection.control_relays(states)
self.async... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_on",
"=",
"False",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"RelayStateModifier",
".",
"NOCHANGE",
"]",
"*",
"8",
"states",
"[",
"self",
".",
... | [
167,
4
] | [
175,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayLight.input_received | (self, input_obj) | Set light state when LCN input object (command) is received. | Set light state when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set light state when LCN input object (command) is received."""
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
self._is_on = input_obj.get_state(self.output.value)
self.async_write_ha_state() | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusRelays",
")",
":",
"return",
"self",
".",
"_is_on",
"=",
"input_obj",
".",
"get_state",
"(",
"self",
... | [
177,
4
] | [
183,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Read configuration and create Modbus switches. | Read configuration and create Modbus switches. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Read configuration and create Modbus switches."""
switches = []
if CONF_COILS in config:
for coil in config[CONF_COILS]:
hub: ModbusHub = hass.data[MODBUS_DOMAIN... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"switches",
"=",
"[",
"]",
"if",
"CONF_COILS",
"in",
"config",
":",
"for",... | [
81,
0
] | [
95,
32
] | python | en | ['en', 'en', 'en'] | True |
ModbusBaseSwitch.__init__ | (self, hub: ModbusHub, config: Dict[str, Any]) | Initialize the switch. | Initialize the switch. | def __init__(self, hub: ModbusHub, config: Dict[str, Any]):
"""Initialize the switch."""
self._hub: ModbusHub = hub
self._name = config[CONF_NAME]
self._slave = config.get(CONF_SLAVE)
self._is_on = None
self._available = True | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"self",
".",
"_hub",
":",
"ModbusHub",
"=",
"hub",
"self",
".",
"_name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"self",
... | [
101,
4
] | [
107,
30
] | python | en | ['en', 'en', 'en'] | True |
ModbusBaseSwitch.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._is_on = state.state == STATE_ON | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"not",
"state",
":",
"return",
"self",
".",
"_is_on",
"=",
"state",
".",
"state",
"==",
"STATE_ON"
] | [
109,
4
] | [
114,
45
] | python | en | ['en', 'en', 'en'] | True |
ModbusBaseSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
117,
4
] | [
119,
26
] | python | en | ['en', 'fy', 'en'] | True |
ModbusBaseSwitch.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"
] | [
122,
4
] | [
124,
25
] | python | en | ['en', 'en', 'en'] | True |
ModbusBaseSwitch.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"
] | [
127,
4
] | [
129,
30
] | python | en | ['en', 'en', 'en'] | True |
ModbusCoilSwitch.__init__ | (self, hub: ModbusHub, config: Dict[str, Any]) | Initialize the coil switch. | Initialize the coil switch. | def __init__(self, hub: ModbusHub, config: Dict[str, Any]):
"""Initialize the coil switch."""
super().__init__(hub, config)
self._coil = config[CALL_TYPE_COIL] | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"config",
")",
"self",
".",
"_coil",
"=",
"config",
"[",
"CALL_T... | [
135,
4
] | [
138,
43
] | python | en | ['en', 'en', 'en'] | True |
ModbusCoilSwitch.turn_on | (self, **kwargs) | Set switch on. | Set switch on. | def turn_on(self, **kwargs):
"""Set switch on."""
self._write_coil(self._coil, True)
self._is_on = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_write_coil",
"(",
"self",
".",
"_coil",
",",
"True",
")",
"self",
".",
"_is_on",
"=",
"True"
] | [
140,
4
] | [
143,
26
] | python | en | ['en', 'zh', 'en'] | True |
ModbusCoilSwitch.turn_off | (self, **kwargs) | Set switch off. | Set switch off. | def turn_off(self, **kwargs):
"""Set switch off."""
self._write_coil(self._coil, False)
self._is_on = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_write_coil",
"(",
"self",
".",
"_coil",
",",
"False",
")",
"self",
".",
"_is_on",
"=",
"False"
] | [
145,
4
] | [
148,
27
] | python | en | ['en', 'ja', 'en'] | True |
ModbusCoilSwitch.update | (self) | Update the state of the switch. | Update the state of the switch. | def update(self):
"""Update the state of the switch."""
self._is_on = self._read_coil(self._coil) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_is_on",
"=",
"self",
".",
"_read_coil",
"(",
"self",
".",
"_coil",
")"
] | [
150,
4
] | [
152,
49
] | python | en | ['en', 'en', 'en'] | True |
ModbusCoilSwitch._read_coil | (self, coil) | Read coil using the Modbus hub slave. | Read coil using the Modbus hub slave. | def _read_coil(self, coil) -> bool:
"""Read coil using the Modbus hub slave."""
try:
result = self._hub.read_coils(self._slave, coil, 1)
except ConnectionException:
self._available = False
return False
if isinstance(result, (ModbusException, Exception... | [
"def",
"_read_coil",
"(",
"self",
",",
"coil",
")",
"->",
"bool",
":",
"try",
":",
"result",
"=",
"self",
".",
"_hub",
".",
"read_coils",
"(",
"self",
".",
"_slave",
",",
"coil",
",",
"1",
")",
"except",
"ConnectionException",
":",
"self",
".",
"_ava... | [
154,
4
] | [
170,
39
] | python | en | ['en', 'hmn', 'en'] | True |
ModbusCoilSwitch._write_coil | (self, coil, value) | Write coil using the Modbus hub slave. | Write coil using the Modbus hub slave. | def _write_coil(self, coil, value):
"""Write coil using the Modbus hub slave."""
try:
self._hub.write_coil(self._slave, coil, value)
except ConnectionException:
self._available = False
return
self._available = True | [
"def",
"_write_coil",
"(",
"self",
",",
"coil",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"_hub",
".",
"write_coil",
"(",
"self",
".",
"_slave",
",",
"coil",
",",
"value",
")",
"except",
"ConnectionException",
":",
"self",
".",
"_available",
"="... | [
172,
4
] | [
180,
30
] | python | en | ['en', 'hmn', 'en'] | True |
ModbusRegisterSwitch.__init__ | (self, hub: ModbusHub, config: Dict[str, Any]) | Initialize the register switch. | Initialize the register switch. | def __init__(self, hub: ModbusHub, config: Dict[str, Any]):
"""Initialize the register switch."""
super().__init__(hub, config)
self._register = config[CONF_REGISTER]
self._command_on = config[CONF_COMMAND_ON]
self._command_off = config[CONF_COMMAND_OFF]
self._state_on = ... | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"config",
")",
"self",
".",
"_register",
"=",
"config",
"[",
"CO... | [
186,
4
] | [
198,
26
] | python | en | ['en', 'en', 'en'] | True |
ModbusRegisterSwitch.turn_on | (self, **kwargs) | Set switch on. | Set switch on. | def turn_on(self, **kwargs):
"""Set switch on."""
# Only holding register is writable
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
self._write_register(self._command_on)
if not self._verify_state:
self._is_on = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Only holding register is writable",
"if",
"self",
".",
"_register_type",
"==",
"CALL_TYPE_REGISTER_HOLDING",
":",
"self",
".",
"_write_register",
"(",
"self",
".",
"_command_on",
")",
"if",
"no... | [
200,
4
] | [
207,
34
] | python | en | ['en', 'zh', 'en'] | True |
ModbusRegisterSwitch.turn_off | (self, **kwargs) | Set switch off. | Set switch off. | def turn_off(self, **kwargs):
"""Set switch off."""
# Only holding register is writable
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
self._write_register(self._command_off)
if not self._verify_state:
self._is_on = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Only holding register is writable",
"if",
"self",
".",
"_register_type",
"==",
"CALL_TYPE_REGISTER_HOLDING",
":",
"self",
".",
"_write_register",
"(",
"self",
".",
"_command_off",
")",
"if",
"... | [
209,
4
] | [
216,
35
] | python | en | ['en', 'ja', 'en'] | True |
ModbusRegisterSwitch.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"
] | [
219,
4
] | [
221,
30
] | python | en | ['en', 'en', 'en'] | True |
ModbusRegisterSwitch.update | (self) | Update the state of the switch. | Update the state of the switch. | def update(self):
"""Update the state of the switch."""
if not self._verify_state:
return
value = self._read_register()
if value == self._state_on:
self._is_on = True
elif value == self._state_off:
self._is_on = False
elif value is not... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_verify_state",
":",
"return",
"value",
"=",
"self",
".",
"_read_register",
"(",
")",
"if",
"value",
"==",
"self",
".",
"_state_on",
":",
"self",
".",
"_is_on",
"=",
"True",
"elif",
"... | [
223,
4
] | [
240,
13
] | python | en | ['en', 'en', 'en'] | True |
ModbusRegisterSwitch._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... | [
264,
4
] | [
272,
30
] | python | en | ['en', 'hmn', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
12,
0
] | [
14,
57
] | python | en | ['en', 'en', 'en'] | True |
context_with_user | () | Track calls to a mock service. | Track calls to a mock service. | def context_with_user():
"""Track calls to a mock service."""
return Context(user_id="test_user_id") | [
"def",
"context_with_user",
"(",
")",
":",
"return",
"Context",
"(",
"user_id",
"=",
"\"test_user_id\"",
")"
] | [
18,
0
] | [
20,
42
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass) | Initialize components. | Initialize components. | def setup_comp(hass):
"""Initialize components."""
mock_component(hass, "group") | [
"def",
"setup_comp",
"(",
"hass",
")",
":",
"mock_component",
"(",
"hass",
",",
"\"group\"",
")"
] | [
24,
0
] | [
26,
33
] | python | en | ['de', 'en', 'en'] | False |
test_if_fires_on_event | (hass, calls) | Test the firing of events. | Test the firing of events. | async def test_if_fires_on_event(hass, calls):
"""Test the firing of events."""
context = Context()
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
... | [
"async",
"def",
"test_if_fires_on_event",
"(",
"hass",
",",
"calls",
")",
":",
"context",
"=",
"Context",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
... | [
29,
0
] | [
58,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_multiple_events | (hass, calls) | Test the firing of events. | Test the firing of events. | async def test_if_fires_on_multiple_events(hass, calls):
"""Test the firing of events."""
context = Context()
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "event",
... | [
"async",
"def",
"test_if_fires_on_multiple_events",
"(",
"hass",
",",
"calls",
")",
":",
"context",
"=",
"Context",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",... | [
61,
0
] | [
85,
51
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_event_extra_data | (hass, calls, context_with_user) | Test the firing of events still matches with event data and context. | Test the firing of events still matches with event data and context. | async def test_if_fires_on_event_extra_data(hass, calls, context_with_user):
"""Test the firing of events still matches with event data and context."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": ... | [
"async",
"def",
"test_if_fires_on_event_extra_data",
"(",
"hass",
",",
"calls",
",",
"context_with_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"tri... | [
88,
0
] | [
115,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_event_with_data_and_context | (hass, calls, context_with_user) | Test the firing of events with data and context. | Test the firing of events with data and context. | async def test_if_fires_on_event_with_data_and_context(hass, calls, context_with_user):
"""Test the firing of events with data and context."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
... | [
"async",
"def",
"test_if_fires_on_event_with_data_and_context",
"(",
"hass",
",",
"calls",
",",
"context_with_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{... | [
118,
0
] | [
160,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_event_with_empty_data_and_context_config | (
hass, calls, context_with_user
) | Test the firing of events with empty data and context config.
The frontend automation editor can produce configurations with an
empty dict for event_data instead of no key.
| Test the firing of events with empty data and context config. | async def test_if_fires_on_event_with_empty_data_and_context_config(
hass, calls, context_with_user
):
"""Test the firing of events with empty data and context config.
The frontend automation editor can produce configurations with an
empty dict for event_data instead of no key.
"""
assert await... | [
"async",
"def",
"test_if_fires_on_event_with_empty_data_and_context_config",
"(",
"hass",
",",
"calls",
",",
"context_with_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN"... | [
163,
0
] | [
193,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_event_with_nested_data | (hass, calls) | Test the firing of events with nested data. | Test the firing of events with nested data. | async def test_if_fires_on_event_with_nested_data(hass, calls):
"""Test the firing of events with nested data."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "event",
... | [
"async",
"def",
"test_if_fires_on_event_with_nested_data",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
... | [
196,
0
] | [
217,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_not_fires_if_event_data_not_matches | (hass, calls) | Test firing of event if no data match. | Test firing of event if no data match. | async def test_if_not_fires_if_event_data_not_matches(hass, calls):
"""Test firing of event if no data match."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "event",
... | [
"async",
"def",
"test_if_not_fires_if_event_data_not_matches",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{... | [
220,
0
] | [
239,
26
] | python | en | ['en', 'lb', 'en'] | True |
test_if_not_fires_if_event_context_not_matches | (
hass, calls, context_with_user
) | Test firing of event if no context match. | Test firing of event if no context match. | async def test_if_not_fires_if_event_context_not_matches(
hass, calls, context_with_user
):
"""Test firing of event if no context match."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
... | [
"async",
"def",
"test_if_not_fires_if_event_context_not_matches",
"(",
"hass",
",",
"calls",
",",
"context_with_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
... | [
242,
0
] | [
263,
26
] | python | en | ['en', 'lb', 'en'] | True |
test_if_fires_on_multiple_user_ids | (hass, calls, context_with_user) | Test the firing of event when the trigger has multiple user ids. | Test the firing of event when the trigger has multiple user ids. | async def test_if_fires_on_multiple_user_ids(hass, calls, context_with_user):
"""Test the firing of event when the trigger has multiple user ids."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
... | [
"async",
"def",
"test_if_fires_on_multiple_user_ids",
"(",
"hass",
",",
"calls",
",",
"context_with_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"tr... | [
266,
0
] | [
286,
26
] | python | en | ['en', 'en', 'en'] | True |
test_event_data_with_list | (hass, calls) | Test the (non)firing of event when the data schema has lists. | Test the (non)firing of event when the data schema has lists. | async def test_event_data_with_list(hass, calls):
"""Test the (non)firing of event when the data schema has lists."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "event",
... | [
"async",
"def",
"test_event_data_with_list",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platform\"... | [
289,
0
] | [
319,
26
] | python | en | ['en', 'en', 'en'] | True |
UNetResNetV4.freeze_bn | (self) | Freeze BatchNorm layers. | Freeze BatchNorm layers. | def freeze_bn(self):
'''Freeze BatchNorm layers.'''
for layer in self.modules():
if isinstance(layer, nn.BatchNorm2d):
layer.eval() | [
"def",
"freeze_bn",
"(",
"self",
")",
":",
"for",
"layer",
"in",
"self",
".",
"modules",
"(",
")",
":",
"if",
"isinstance",
"(",
"layer",
",",
"nn",
".",
"BatchNorm2d",
")",
":",
"layer",
".",
"eval",
"(",
")"
] | [
209,
4
] | [
213,
28
] | python | en | ['en', 'ny', 'en'] | True |
async_enable_report_state | (hass: HomeAssistant, google_config: AbstractConfig) | Enable state reporting. | Enable state reporting. | def async_enable_report_state(hass: HomeAssistant, google_config: AbstractConfig):
"""Enable state reporting."""
async def async_entity_state_listener(changed_entity, old_state, new_state):
if not hass.is_running:
return
if not new_state:
return
if not google_c... | [
"def",
"async_enable_report_state",
"(",
"hass",
":",
"HomeAssistant",
",",
"google_config",
":",
"AbstractConfig",
")",
":",
"async",
"def",
"async_entity_state_listener",
"(",
"changed_entity",
",",
"old_state",
",",
"new_state",
")",
":",
"if",
"not",
"hass",
"... | [
19,
0
] | [
84,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the universal media players. | Set up the universal media players. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the universal media players."""
await async_setup_reload_service(hass, "universal", ["media_player"])
player = UniversalMediaPlayer(
hass,
config.get(CONF_NAME),
config.get(CONF_CHILDRE... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"\"universal\"",
",",
"[",
"\"media_player\"",
"]",
")",
"player",... | [
104,
0
] | [
118,
32
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.__init__ | (self, hass, name, children, commands, attributes, state_template=None) | Initialize the Universal media device. | Initialize the Universal media device. | def __init__(self, hass, name, children, commands, attributes, state_template=None):
"""Initialize the Universal media device."""
self.hass = hass
self._name = name
self._children = children
self._cmds = commands
self._attrs = {}
for key, val in attributes.items()... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"children",
",",
"commands",
",",
"attributes",
",",
"state_template",
"=",
"None",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_children",
... | [
124,
4
] | [
138,
45
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.async_added_to_hass | (self) | Subscribe to children and template state changes. | Subscribe to children and template state changes. | async def async_added_to_hass(self):
"""Subscribe to children and template state changes."""
@callback
def _async_on_dependency_update(event):
"""Update ha state when dependencies update."""
self.async_set_context(event.context)
self.async_schedule_update_ha_... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"_async_on_dependency_update",
"(",
"event",
")",
":",
"\"\"\"Update ha state when dependencies update.\"\"\"",
"self",
".",
"async_set_context",
"(",
"event",
".",
"context",
")",
"... | [
140,
4
] | [
184,
9
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer._entity_lkp | (self, entity_id, state_attr=None) | Look up an entity state. | Look up an entity state. | def _entity_lkp(self, entity_id, state_attr=None):
"""Look up an entity state."""
state_obj = self.hass.states.get(entity_id)
if state_obj is None:
return
if state_attr:
return state_obj.attributes.get(state_attr)
return state_obj.state | [
"def",
"_entity_lkp",
"(",
"self",
",",
"entity_id",
",",
"state_attr",
"=",
"None",
")",
":",
"state_obj",
"=",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"entity_id",
")",
"if",
"state_obj",
"is",
"None",
":",
"return",
"if",
"state_attr",
... | [
186,
4
] | [
195,
30
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer._override_or_child_attr | (self, attr_name) | Return either the override or the active child for attr_name. | Return either the override or the active child for attr_name. | def _override_or_child_attr(self, attr_name):
"""Return either the override or the active child for attr_name."""
if attr_name in self._attrs:
return self._entity_lkp(
self._attrs[attr_name][0], self._attrs[attr_name][1]
)
return self._child_attr(attr_nam... | [
"def",
"_override_or_child_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"attr_name",
"in",
"self",
".",
"_attrs",
":",
"return",
"self",
".",
"_entity_lkp",
"(",
"self",
".",
"_attrs",
"[",
"attr_name",
"]",
"[",
"0",
"]",
",",
"self",
".",
"_... | [
197,
4
] | [
204,
42
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer._child_attr | (self, attr_name) | Return the active child's attributes. | Return the active child's attributes. | def _child_attr(self, attr_name):
"""Return the active child's attributes."""
active_child = self._child_state
return active_child.attributes.get(attr_name) if active_child else None | [
"def",
"_child_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"active_child",
"=",
"self",
".",
"_child_state",
"return",
"active_child",
".",
"attributes",
".",
"get",
"(",
"attr_name",
")",
"if",
"active_child",
"else",
"None"
] | [
206,
4
] | [
209,
79
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer._async_call_service | (
self, service_name, service_data=None, allow_override=False
) | Call either a specified or active child's service. | Call either a specified or active child's service. | async def _async_call_service(
self, service_name, service_data=None, allow_override=False
):
"""Call either a specified or active child's service."""
if service_data is None:
service_data = {}
if allow_override and service_name in self._cmds:
await async_cal... | [
"async",
"def",
"_async_call_service",
"(",
"self",
",",
"service_name",
",",
"service_data",
"=",
"None",
",",
"allow_override",
"=",
"False",
")",
":",
"if",
"service_data",
"is",
"None",
":",
"service_data",
"=",
"{",
"}",
"if",
"allow_override",
"and",
"... | [
211,
4
] | [
237,
9
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
240,
4
] | [
242,
20
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.master_state | (self) | Return the master state for entity or None. | Return the master state for entity or None. | def master_state(self):
"""Return the master state for entity or None."""
if self._state_template is not None:
return self._state_template_result
if CONF_STATE in self._attrs:
master_state = self._entity_lkp(
self._attrs[CONF_STATE][0], self._attrs[CONF_ST... | [
"def",
"master_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state_template",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_state_template_result",
"if",
"CONF_STATE",
"in",
"self",
".",
"_attrs",
":",
"master_state",
"=",
"self",
".",
"_entity_lk... | [
245,
4
] | [
255,
19
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.name | (self) | Return the name of universal player. | Return the name of universal player. | def name(self):
"""Return the name of universal player."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
258,
4
] | [
260,
25
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.state | (self) | Return the current state of media player.
Off if master state is off
else Status of first active child
else master state or off
| Return the current state of media player. | def state(self):
"""Return the current state of media player.
Off if master state is off
else Status of first active child
else master state or off
"""
master_state = self.master_state # avoid multiple lookups
if (master_state == STATE_OFF) or (self._state_templ... | [
"def",
"state",
"(",
"self",
")",
":",
"master_state",
"=",
"self",
".",
"master_state",
"# avoid multiple lookups",
"if",
"(",
"master_state",
"==",
"STATE_OFF",
")",
"or",
"(",
"self",
".",
"_state_template",
"is",
"not",
"None",
")",
":",
"return",
"maste... | [
263,
4
] | [
278,
58
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.volume_level | (self) | Volume level of entity specified in attributes or active child. | Volume level of entity specified in attributes or active child. | def volume_level(self):
"""Volume level of entity specified in attributes or active child."""
try:
return float(self._override_or_child_attr(ATTR_MEDIA_VOLUME_LEVEL))
except (TypeError, ValueError):
return None | [
"def",
"volume_level",
"(",
"self",
")",
":",
"try",
":",
"return",
"float",
"(",
"self",
".",
"_override_or_child_attr",
"(",
"ATTR_MEDIA_VOLUME_LEVEL",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"None"
] | [
281,
4
] | [
286,
23
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.is_volume_muted | (self) | Boolean if volume is muted. | Boolean if volume is muted. | def is_volume_muted(self):
"""Boolean if volume is muted."""
return self._override_or_child_attr(ATTR_MEDIA_VOLUME_MUTED) in [True, STATE_ON] | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_override_or_child_attr",
"(",
"ATTR_MEDIA_VOLUME_MUTED",
")",
"in",
"[",
"True",
",",
"STATE_ON",
"]"
] | [
289,
4
] | [
291,
88
] | python | en | ['nl', 'en', 'en'] | True |
UniversalMediaPlayer.media_content_id | (self) | Return the content ID of current playing media. | Return the content ID of current playing media. | def media_content_id(self):
"""Return the content ID of current playing media."""
return self._child_attr(ATTR_MEDIA_CONTENT_ID) | [
"def",
"media_content_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_CONTENT_ID",
")"
] | [
294,
4
] | [
296,
54
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_content_type | (self) | Return the content type of current playing media. | Return the content type of current playing media. | def media_content_type(self):
"""Return the content type of current playing media."""
return self._child_attr(ATTR_MEDIA_CONTENT_TYPE) | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_CONTENT_TYPE",
")"
] | [
299,
4
] | [
301,
56
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_duration | (self) | Return the duration of current playing media in seconds. | Return the duration of current playing media in seconds. | def media_duration(self):
"""Return the duration of current playing media in seconds."""
return self._child_attr(ATTR_MEDIA_DURATION) | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_DURATION",
")"
] | [
304,
4
] | [
306,
52
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_image_url | (self) | Image url of current playing media. | Image url of current playing media. | def media_image_url(self):
"""Image url of current playing media."""
return self._child_attr(ATTR_ENTITY_PICTURE) | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_ENTITY_PICTURE",
")"
] | [
309,
4
] | [
311,
52
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.entity_picture | (self) |
Return image of the media playing.
The universal media player doesn't use the parent class logic, since
the url is coming from child entity pictures which have already been
sent through the API proxy.
|
Return image of the media playing. | def entity_picture(self):
"""
Return image of the media playing.
The universal media player doesn't use the parent class logic, since
the url is coming from child entity pictures which have already been
sent through the API proxy.
"""
return self.media_image_url | [
"def",
"entity_picture",
"(",
"self",
")",
":",
"return",
"self",
".",
"media_image_url"
] | [
314,
4
] | [
322,
35
] | python | en | ['en', 'error', 'th'] | False |
UniversalMediaPlayer.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
return self._child_attr(ATTR_MEDIA_TITLE) | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_TITLE",
")"
] | [
325,
4
] | [
327,
49
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_artist | (self) | Artist of current playing media (Music track only). | Artist of current playing media (Music track only). | def media_artist(self):
"""Artist of current playing media (Music track only)."""
return self._child_attr(ATTR_MEDIA_ARTIST) | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_ARTIST",
")"
] | [
330,
4
] | [
332,
50
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_album_name | (self) | Album name of current playing media (Music track only). | Album name of current playing media (Music track only). | def media_album_name(self):
"""Album name of current playing media (Music track only)."""
return self._child_attr(ATTR_MEDIA_ALBUM_NAME) | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_ALBUM_NAME",
")"
] | [
335,
4
] | [
337,
54
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_album_artist | (self) | Album artist of current playing media (Music track only). | Album artist of current playing media (Music track only). | def media_album_artist(self):
"""Album artist of current playing media (Music track only)."""
return self._child_attr(ATTR_MEDIA_ALBUM_ARTIST) | [
"def",
"media_album_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_ALBUM_ARTIST",
")"
] | [
340,
4
] | [
342,
56
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_track | (self) | Track number of current playing media (Music track only). | Track number of current playing media (Music track only). | def media_track(self):
"""Track number of current playing media (Music track only)."""
return self._child_attr(ATTR_MEDIA_TRACK) | [
"def",
"media_track",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_TRACK",
")"
] | [
345,
4
] | [
347,
49
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_series_title | (self) | Return the title of the series of current playing media (TV). | Return the title of the series of current playing media (TV). | def media_series_title(self):
"""Return the title of the series of current playing media (TV)."""
return self._child_attr(ATTR_MEDIA_SERIES_TITLE) | [
"def",
"media_series_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_SERIES_TITLE",
")"
] | [
350,
4
] | [
352,
56
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_season | (self) | Season of current playing media (TV Show only). | Season of current playing media (TV Show only). | def media_season(self):
"""Season of current playing media (TV Show only)."""
return self._child_attr(ATTR_MEDIA_SEASON) | [
"def",
"media_season",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_SEASON",
")"
] | [
355,
4
] | [
357,
50
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_episode | (self) | Episode of current playing media (TV Show only). | Episode of current playing media (TV Show only). | def media_episode(self):
"""Episode of current playing media (TV Show only)."""
return self._child_attr(ATTR_MEDIA_EPISODE) | [
"def",
"media_episode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_EPISODE",
")"
] | [
360,
4
] | [
362,
51
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_channel | (self) | Channel currently playing. | Channel currently playing. | def media_channel(self):
"""Channel currently playing."""
return self._child_attr(ATTR_MEDIA_CHANNEL) | [
"def",
"media_channel",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_CHANNEL",
")"
] | [
365,
4
] | [
367,
51
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_playlist | (self) | Title of Playlist currently playing. | Title of Playlist currently playing. | def media_playlist(self):
"""Title of Playlist currently playing."""
return self._child_attr(ATTR_MEDIA_PLAYLIST) | [
"def",
"media_playlist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_PLAYLIST",
")"
] | [
370,
4
] | [
372,
52
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.app_id | (self) | ID of the current running app. | ID of the current running app. | def app_id(self):
"""ID of the current running app."""
return self._child_attr(ATTR_APP_ID) | [
"def",
"app_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_APP_ID",
")"
] | [
375,
4
] | [
377,
44
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.app_name | (self) | Name of the current running app. | Name of the current running app. | def app_name(self):
"""Name of the current running app."""
return self._child_attr(ATTR_APP_NAME) | [
"def",
"app_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_APP_NAME",
")"
] | [
380,
4
] | [
382,
46
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.source | (self) | Return the current input source of the device. | Return the current input source of the device. | def source(self):
"""Return the current input source of the device."""
return self._override_or_child_attr(ATTR_INPUT_SOURCE) | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_override_or_child_attr",
"(",
"ATTR_INPUT_SOURCE",
")"
] | [
385,
4
] | [
387,
62
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return self._override_or_child_attr(ATTR_INPUT_SOURCE_LIST) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_override_or_child_attr",
"(",
"ATTR_INPUT_SOURCE_LIST",
")"
] | [
390,
4
] | [
392,
67
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.shuffle | (self) | Boolean if shuffling is enabled. | Boolean if shuffling is enabled. | def shuffle(self):
"""Boolean if shuffling is enabled."""
return self._override_or_child_attr(ATTR_MEDIA_SHUFFLE) | [
"def",
"shuffle",
"(",
"self",
")",
":",
"return",
"self",
".",
"_override_or_child_attr",
"(",
"ATTR_MEDIA_SHUFFLE",
")"
] | [
395,
4
] | [
397,
63
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.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."""
flags = self._child_attr(ATTR_SUPPORTED_FEATURES) or 0
if SERVICE_TURN_ON in self._cmds:
flags |= SUPPORT_TURN_ON
if SERVICE_TURN_OFF in self._cmds:
flags |= SUPPORT_TURN_OFF
... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"flags",
"=",
"self",
".",
"_child_attr",
"(",
"ATTR_SUPPORTED_FEATURES",
")",
"or",
"0",
"if",
"SERVICE_TURN_ON",
"in",
"self",
".",
"_cmds",
":",
"flags",
"|=",
"SUPPORT_TURN_ON",
"if",
"SERVICE_TURN_OFF",
... | [
400,
4
] | [
426,
20
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
active_child = self._child_state
return {ATTR_ACTIVE_CHILD: active_child.entity_id} if active_child else {} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"active_child",
"=",
"self",
".",
"_child_state",
"return",
"{",
"ATTR_ACTIVE_CHILD",
":",
"active_child",
".",
"entity_id",
"}",
"if",
"active_child",
"else",
"{",
"}"
] | [
429,
4
] | [
432,
82
] | python | en | ['fr', 'en', 'en'] | True |
UniversalMediaPlayer.media_position | (self) | Position of current playing media in seconds. | Position of current playing media in seconds. | def media_position(self):
"""Position of current playing media in seconds."""
return self._child_attr(ATTR_MEDIA_POSITION) | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_POSITION",
")"
] | [
435,
4
] | [
437,
52
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.media_position_updated_at | (self) | When was the position of the current playing media valid. | When was the position of the current playing media valid. | def media_position_updated_at(self):
"""When was the position of the current playing media valid."""
return self._child_attr(ATTR_MEDIA_POSITION_UPDATED_AT) | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"return",
"self",
".",
"_child_attr",
"(",
"ATTR_MEDIA_POSITION_UPDATED_AT",
")"
] | [
440,
4
] | [
442,
63
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.async_turn_on | (self) | Turn the media player on. | Turn the media player on. | async def async_turn_on(self):
"""Turn the media player on."""
await self._async_call_service(SERVICE_TURN_ON, allow_override=True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_TURN_ON",
",",
"allow_override",
"=",
"True",
")"
] | [
444,
4
] | [
446,
76
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.async_turn_off | (self) | Turn the media player off. | Turn the media player off. | async def async_turn_off(self):
"""Turn the media player off."""
await self._async_call_service(SERVICE_TURN_OFF, allow_override=True) | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_TURN_OFF",
",",
"allow_override",
"=",
"True",
")"
] | [
448,
4
] | [
450,
77
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.async_mute_volume | (self, mute) | Mute the volume. | Mute the volume. | async def async_mute_volume(self, mute):
"""Mute the volume."""
data = {ATTR_MEDIA_VOLUME_MUTED: mute}
await self._async_call_service(SERVICE_VOLUME_MUTE, data, allow_override=True) | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"data",
"=",
"{",
"ATTR_MEDIA_VOLUME_MUTED",
":",
"mute",
"}",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_VOLUME_MUTE",
",",
"data",
",",
"allow_override",
"=",
"True",
")... | [
452,
4
] | [
455,
86
] | python | en | ['en', 'sn', 'en'] | True |
UniversalMediaPlayer.async_set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | async def async_set_volume_level(self, volume):
"""Set volume level, range 0..1."""
data = {ATTR_MEDIA_VOLUME_LEVEL: volume}
await self._async_call_service(SERVICE_VOLUME_SET, data, allow_override=True) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"data",
"=",
"{",
"ATTR_MEDIA_VOLUME_LEVEL",
":",
"volume",
"}",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_VOLUME_SET",
",",
"data",
",",
"allow_override",
"=",
"Tru... | [
457,
4
] | [
460,
85
] | python | en | ['fr', 'zu', 'en'] | False |
UniversalMediaPlayer.async_media_play | (self) | Send play command. | Send play command. | async def async_media_play(self):
"""Send play command."""
await self._async_call_service(SERVICE_MEDIA_PLAY) | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_MEDIA_PLAY",
")"
] | [
462,
4
] | [
464,
58
] | python | en | ['en', 'en', 'en'] | True |
UniversalMediaPlayer.async_media_pause | (self) | Send pause command. | Send pause command. | async def async_media_pause(self):
"""Send pause command."""
await self._async_call_service(SERVICE_MEDIA_PAUSE) | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"_async_call_service",
"(",
"SERVICE_MEDIA_PAUSE",
")"
] | [
466,
4
] | [
468,
59
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.