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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FuelPriceSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
101,
4
] | [
103,
25
] | python | en | ['en', 'mi', 'en'] | True |
FuelPriceSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
106,
4
] | [
108,
19
] | python | en | ['en', 'en', 'en'] | True |
FuelPriceSensor.unit_of_measurement | (self) | Return unit of measurement. | Return unit of measurement. | def unit_of_measurement(self):
"""Return unit of measurement."""
return CURRENCY_EURO | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"CURRENCY_EURO"
] | [
111,
4
] | [
113,
28
] | python | en | ['en', 'la', 'en'] | True |
FuelPriceSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
# key Fuel_type is not available when the fuel station is closed, use "get" instead of "[]" to avoid exceptions
return self.coordinator.data[self._station_id].get(self._fuel_type) | [
"def",
"state",
"(",
"self",
")",
":",
"# key Fuel_type is not available when the fuel station is closed, use \"get\" instead of \"[]\" to avoid exceptions",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_station_id",
"]",
".",
"get",
"(",
"self",
... | [
116,
4
] | [
119,
75
] | python | en | ['en', 'en', 'en'] | True |
FuelPriceSensor.unique_id | (self) | Return a unique identifier for this entity. | Return a unique identifier for this entity. | def unique_id(self) -> str:
"""Return a unique identifier for this entity."""
return f"{self._station_id}_{self._fuel_type}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._station_id}_{self._fuel_type}\""
] | [
122,
4
] | [
124,
54
] | python | en | ['en', 'fr', 'en'] | True |
FuelPriceSensor.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."""
data = self.coordinator.data[self._station_id]
attrs = {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_BRAND: self._station["brand"],
ATTR_FUEL_TYPE: self._fuel_type,
ATTR_STATION... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"_station_id",
"]",
"attrs",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"ATTR_BRAND",
":",
"self",
".",
"_station",
... | [
127,
4
] | [
148,
20
] | python | en | ['en', 'en', 'en'] | True |
get_api | (project_id, debug=False) | Get Lokalise API. | Get Lokalise API. | def get_api(project_id, debug=False) -> "Lokalise":
"""Get Lokalise API."""
return Lokalise(project_id, get_lokalise_token(), debug) | [
"def",
"get_api",
"(",
"project_id",
",",
"debug",
"=",
"False",
")",
"->",
"\"Lokalise\"",
":",
"return",
"Lokalise",
"(",
"project_id",
",",
"get_lokalise_token",
"(",
")",
",",
"debug",
")"
] | [
8,
0
] | [
10,
60
] | python | en | ['et', 'haw', 'en'] | False |
Lokalise.__init__ | (self, project_id, token, debug) | Initialize Lokalise API. | Initialize Lokalise API. | def __init__(self, project_id, token, debug):
"""Initialize Lokalise API."""
self.project_id = project_id
self.token = token
self.debug = debug | [
"def",
"__init__",
"(",
"self",
",",
"project_id",
",",
"token",
",",
"debug",
")",
":",
"self",
".",
"project_id",
"=",
"project_id",
"self",
".",
"token",
"=",
"token",
"self",
".",
"debug",
"=",
"debug"
] | [
16,
4
] | [
20,
26
] | python | et | ['et', 'zu', 'it'] | False |
Lokalise.request | (self, method, path, data) | Make a request to the Lokalise API. | Make a request to the Lokalise API. | def request(self, method, path, data):
"""Make a request to the Lokalise API."""
method = method.upper()
kwargs = {"headers": {"x-api-token": self.token}}
if method == "GET":
kwargs["params"] = data
else:
kwargs["json"] = data
if self.debug:
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
")",
":",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"kwargs",
"=",
"{",
"\"headers\"",
":",
"{",
"\"x-api-token\"",
":",
"self",
".",
"token",
"}",
"}",
"if",
"method",
... | [
22,
4
] | [
45,
25
] | python | en | ['en', 'en', 'en'] | True |
Lokalise.keys_list | (self, params={}) | List keys.
https://app.lokalise.com/api2docs/curl/#transition-list-all-keys-get
| List keys. | def keys_list(self, params={}):
"""List keys.
https://app.lokalise.com/api2docs/curl/#transition-list-all-keys-get
"""
return self.request("GET", "keys", params)["keys"] | [
"def",
"keys_list",
"(",
"self",
",",
"params",
"=",
"{",
"}",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"GET\"",
",",
"\"keys\"",
",",
"params",
")",
"[",
"\"keys\"",
"]"
] | [
47,
4
] | [
52,
58
] | python | et | ['et', 'et', 'en'] | False |
Lokalise.keys_create | (self, keys) | Create keys.
https://app.lokalise.com/api2docs/curl/#transition-create-keys-post
| Create keys. | def keys_create(self, keys):
"""Create keys.
https://app.lokalise.com/api2docs/curl/#transition-create-keys-post
"""
return self.request("POST", "keys", {"keys": keys})["keys"] | [
"def",
"keys_create",
"(",
"self",
",",
"keys",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"POST\"",
",",
"\"keys\"",
",",
"{",
"\"keys\"",
":",
"keys",
"}",
")",
"[",
"\"keys\"",
"]"
] | [
54,
4
] | [
59,
67
] | python | en | ['en', 'et', 'en'] | False |
Lokalise.keys_delete_multiple | (self, key_ids) | Delete multiple keys.
https://app.lokalise.com/api2docs/curl/#transition-delete-multiple-keys-delete
| Delete multiple keys. | def keys_delete_multiple(self, key_ids):
"""Delete multiple keys.
https://app.lokalise.com/api2docs/curl/#transition-delete-multiple-keys-delete
"""
return self.request("DELETE", "keys", {"keys": key_ids}) | [
"def",
"keys_delete_multiple",
"(",
"self",
",",
"key_ids",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"DELETE\"",
",",
"\"keys\"",
",",
"{",
"\"keys\"",
":",
"key_ids",
"}",
")"
] | [
61,
4
] | [
66,
64
] | python | en | ['en', 'no', 'en'] | True |
Lokalise.keys_bulk_update | (self, updates) | Update multiple keys.
https://app.lokalise.com/api2docs/curl/#transition-bulk-update-put
| Update multiple keys. | def keys_bulk_update(self, updates):
"""Update multiple keys.
https://app.lokalise.com/api2docs/curl/#transition-bulk-update-put
"""
return self.request("PUT", "keys", {"keys": updates})["keys"] | [
"def",
"keys_bulk_update",
"(",
"self",
",",
"updates",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"PUT\"",
",",
"\"keys\"",
",",
"{",
"\"keys\"",
":",
"updates",
"}",
")",
"[",
"\"keys\"",
"]"
] | [
68,
4
] | [
73,
69
] | python | en | ['en', 'no', 'en'] | True |
Lokalise.translations_list | (self, params={}) | List translations.
https://app.lokalise.com/api2docs/curl/#transition-list-all-translations-get
| List translations. | def translations_list(self, params={}):
"""List translations.
https://app.lokalise.com/api2docs/curl/#transition-list-all-translations-get
"""
return self.request("GET", "translations", params)["translations"] | [
"def",
"translations_list",
"(",
"self",
",",
"params",
"=",
"{",
"}",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"GET\"",
",",
"\"translations\"",
",",
"params",
")",
"[",
"\"translations\"",
"]"
] | [
75,
4
] | [
80,
74
] | python | en | ['en', 'bg', 'en'] | False |
Lokalise.languages_list | (self, params={}) | List languages.
https://app.lokalise.com/api2docs/curl/#transition-list-project-languages-get
| List languages. | def languages_list(self, params={}):
"""List languages.
https://app.lokalise.com/api2docs/curl/#transition-list-project-languages-get
"""
return self.request("GET", "languages", params)["languages"] | [
"def",
"languages_list",
"(",
"self",
",",
"params",
"=",
"{",
"}",
")",
":",
"return",
"self",
".",
"request",
"(",
"\"GET\"",
",",
"\"languages\"",
",",
"params",
")",
"[",
"\"languages\"",
"]"
] | [
82,
4
] | [
87,
68
] | python | en | ['en', 'fr', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the sensor platform. | Set up the sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the sensor platform."""
sensors = []
for entry in discovery_info["entries"]:
port = entry[CONF_PORT]
for node in entry[CONF_NODES]:
for virtual_machine in node[CONF_VMS]:
sensors.app... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"entry",
"in",
"discovery_info",
"[",
"\"entries\"",
"]",
":",
"port",
"=",
"entry",
"[",
"CONF_PORT",
... | [
12,
0
] | [
41,
31
] | python | en | ['en', 'da', 'en'] | True |
ProxmoxBinarySensor.__init__ | (self, proxmox_client, item_node, item_type, item_id) | Initialize the binary sensor. | Initialize the binary sensor. | def __init__(self, proxmox_client, item_node, item_type, item_id):
"""Initialize the binary sensor."""
self._proxmox_client = proxmox_client
self._item_node = item_node
self._item_type = item_type
self._item_id = item_id
self._vmname = None
self._name = None
... | [
"def",
"__init__",
"(",
"self",
",",
"proxmox_client",
",",
"item_node",
",",
"item_type",
",",
"item_id",
")",
":",
"self",
".",
"_proxmox_client",
"=",
"proxmox_client",
"self",
".",
"_item_node",
"=",
"item_node",
"self",
".",
"_item_type",
"=",
"item_type"... | [
47,
4
] | [
57,
26
] | python | en | ['en', 'haw', 'en'] | True |
ProxmoxBinarySensor.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
60,
4
] | [
62,
25
] | python | en | ['en', 'en', 'en'] | True |
ProxmoxBinarySensor.is_on | (self) | Return true if VM/container is running. | Return true if VM/container is running. | def is_on(self):
"""Return true if VM/container is running."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
65,
4
] | [
67,
26
] | python | en | ['en', 'en', 'en'] | True |
ProxmoxBinarySensor.device_state_attributes | (self) | Return device attributes of the entity. | Return device attributes of the entity. | def device_state_attributes(self):
"""Return device attributes of the entity."""
return {
"node": self._item_node,
"vmid": self._item_id,
"vmname": self._vmname,
"type": self._item_type.name,
ATTR_ATTRIBUTION: ATTRIBUTION,
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"node\"",
":",
"self",
".",
"_item_node",
",",
"\"vmid\"",
":",
"self",
".",
"_item_id",
",",
"\"vmname\"",
":",
"self",
".",
"_vmname",
",",
"\"type\"",
":",
"self",
".",
"_item_typ... | [
70,
4
] | [
78,
9
] | python | en | ['en', 'en', 'en'] | True |
ProxmoxBinarySensor.update | (self) | Check if the VM/Container is running. | Check if the VM/Container is running. | def update(self):
"""Check if the VM/Container is running."""
item = self.poll_item()
if item is None:
_LOGGER.warning("Failed to poll VM/container %s", self._item_id)
return
self._state = item["status"] == "running" | [
"def",
"update",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"poll_item",
"(",
")",
"if",
"item",
"is",
"None",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Failed to poll VM/container %s\"",
",",
"self",
".",
"_item_id",
")",
"return",
"self",
".",
"_st... | [
80,
4
] | [
88,
49
] | python | en | ['en', 'en', 'en'] | True |
ProxmoxBinarySensor.poll_item | (self) | Find the VM/Container with the set item_id. | Find the VM/Container with the set item_id. | def poll_item(self):
"""Find the VM/Container with the set item_id."""
items = (
self._proxmox_client.get_api_client()
.nodes(self._item_node)
.get(self._item_type.name)
)
item = next(
(item for item in items if item["vmid"] == str(self._it... | [
"def",
"poll_item",
"(",
"self",
")",
":",
"items",
"=",
"(",
"self",
".",
"_proxmox_client",
".",
"get_api_client",
"(",
")",
".",
"nodes",
"(",
"self",
".",
"_item_node",
")",
".",
"get",
"(",
"self",
".",
"_item_type",
".",
"name",
")",
")",
"item... | [
90,
4
] | [
111,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up IPP sensor based on a config entry. | Set up IPP sensor based on a config entry. | async def async_setup_entry(
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up IPP sensor based on a config entry."""
coordinator: IPPDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
# config flow sets this to ei... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":... | [
26,
0
] | [
50,
37
] | python | en | ['en', 'da', 'en'] | True |
IPPSensor.__init__ | (
self,
*,
coordinator: IPPDataUpdateCoordinator,
enabled_default: bool = True,
entry_id: str,
unique_id: str,
icon: str,
key: str,
name: str,
unit_of_measurement: Optional[str] = None,
) | Initialize IPP sensor. | Initialize IPP sensor. | def __init__(
self,
*,
coordinator: IPPDataUpdateCoordinator,
enabled_default: bool = True,
entry_id: str,
unique_id: str,
icon: str,
key: str,
name: str,
unit_of_measurement: Optional[str] = None,
) -> None:
"""Initialize IPP s... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
",",
"enabled_default",
":",
"bool",
"=",
"True",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"icon",
":",
"str",
",",
"key",
":",
"str",
... | [
56,
4
] | [
83,
9
] | python | en | ['en', 'ro', 'it'] | False |
IPPSensor.unique_id | (self) | Return the unique ID for this sensor. | Return the unique ID for this sensor. | def unique_id(self) -> str:
"""Return the unique ID for this sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
86,
4
] | [
88,
30
] | python | en | ['en', 'la', 'en'] | True |
IPPSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self) -> str:
"""Return the unit this state is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
91,
4
] | [
93,
40
] | python | en | ['en', 'en', 'en'] | True |
IPPMarkerSensor.__init__ | (
self,
entry_id: str,
unique_id: str,
coordinator: IPPDataUpdateCoordinator,
marker_index: int,
) | Initialize IPP marker sensor. | Initialize IPP marker sensor. | def __init__(
self,
entry_id: str,
unique_id: str,
coordinator: IPPDataUpdateCoordinator,
marker_index: int,
) -> None:
"""Initialize IPP marker sensor."""
self.marker_index = marker_index
super().__init__(
coordinator=coordinator,
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
",",
"marker_index",
":",
"int",
",",
")",
"->",
"None",
":",
"self",
".",
"marker_index",
"=",
"marker_index",
... | [
99,
4
] | [
117,
9
] | python | en | ['en', 'fy', 'it'] | False |
IPPMarkerSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
return {
ATTR_MARKER_HIGH_LEVEL: self.coordinator.data.markers[
self.marker_index
].high_level,
ATTR_MARKER_LOW_LEVEL: self.coordinator.data... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"ATTR_MARKER_HIGH_LEVEL",
":",
"self",
".",
"coordinator",
".",
"data",
".",
"markers",
"[",
"self",
".",
"marker_index... | [
120,
4
] | [
132,
9
] | python | en | ['en', 'en', 'en'] | True |
IPPMarkerSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> Optional[int]:
"""Return the state of the sensor."""
level = self.coordinator.data.markers[self.marker_index].level
if level >= 0:
return level
return None | [
"def",
"state",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"level",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"markers",
"[",
"self",
".",
"marker_index",
"]",
".",
"level",
"if",
"level",
">=",
"0",
":",
"return",
"level",
... | [
135,
4
] | [
142,
19
] | python | en | ['en', 'en', 'en'] | True |
IPPPrinterSensor.__init__ | (
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) | Initialize IPP printer sensor. | Initialize IPP printer sensor. | def __init__(
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) -> None:
"""Initialize IPP printer sensor."""
super().__init__(
coordinator=coordinator,
entry_id=entry_id,
unique_id=unique_id,
icon="mdi:printer",
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordinator",
",",
"entry_... | [
148,
4
] | [
160,
9
] | python | en | ['en', 'pt', 'it'] | False |
IPPPrinterSensor.device_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""
return {
ATTR_INFO: self.coordinator.data.info.printer_info,
ATTR_SERIAL: self.coordinator.data.info.serial,
ATTR_LOCATION: self.coordinator.data.info.locat... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"ATTR_INFO",
":",
"self",
".",
"coordinator",
".",
"data",
".",
"info",
".",
"printer_info",
",",
"ATTR_SERIAL",
":",... | [
163,
4
] | [
173,
9
] | python | en | ['en', 'en', 'en'] | True |
IPPPrinterSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> str:
"""Return the state of the sensor."""
return self.coordinator.data.state.printer_state | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"state",
".",
"printer_state"
] | [
176,
4
] | [
178,
56
] | python | en | ['en', 'en', 'en'] | True |
IPPUptimeSensor.__init__ | (
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) | Initialize IPP uptime sensor. | Initialize IPP uptime sensor. | def __init__(
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) -> None:
"""Initialize IPP uptime sensor."""
super().__init__(
coordinator=coordinator,
enabled_default=False,
entry_id=entry_id,
unique_id=unique_id,
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordinator",
",",
"enable... | [
184,
4
] | [
196,
9
] | python | en | ['en', 'ro', 'en'] | True |
IPPUptimeSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> str:
"""Return the state of the sensor."""
uptime = utcnow() - timedelta(seconds=self.coordinator.data.info.uptime)
return uptime.replace(microsecond=0).isoformat() | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"uptime",
"=",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"info",
".",
"uptime",
")",
"return",
"uptime",
".",
"replace",
"(",
"microsec... | [
199,
4
] | [
202,
56
] | python | en | ['en', 'en', 'en'] | True |
IPPUptimeSensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self) -> Optional[str]:
"""Return the class of this sensor."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
205,
4
] | [
207,
37
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry, async_add_entities) | Configure a dispatcher connection based on a config entry. | Configure a dispatcher connection based on a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry, async_add_entities):
"""Configure a dispatcher connection based on a config entry."""
@callback
def _receive_data(device, gps, battery, accuracy, attrs):
"""Receive set location."""
if device in hass.data[GPL_DOMAIN]["devices"]:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
",",
"async_add_entities",
")",
":",
"@",
"callback",
"def",
"_receive_data",
"(",
"device",
",",
"gps",
",",
"battery",
",",
"accuracy",
",",
"attrs",
")",
":",
"\"\"\... | [
25,
0
] | [
59,
32
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.__init__ | (self, device, location, battery, accuracy, attributes) | Set up Geofency entity. | Set up Geofency entity. | def __init__(self, device, location, battery, accuracy, attributes):
"""Set up Geofency entity."""
self._accuracy = accuracy
self._attributes = attributes
self._name = device
self._battery = battery
self._location = location
self._unsub_dispatcher = None
s... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"location",
",",
"battery",
",",
"accuracy",
",",
"attributes",
")",
":",
"self",
".",
"_accuracy",
"=",
"accuracy",
"self",
".",
"_attributes",
"=",
"attributes",
"self",
".",
"_name",
"=",
"device",
"... | [
65,
4
] | [
73,
32
] | python | en | ['en', 'pl', 'en'] | True |
GPSLoggerEntity.battery_level | (self) | Return battery value of the device. | Return battery value of the device. | def battery_level(self):
"""Return battery value of the device."""
return self._battery | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_battery"
] | [
76,
4
] | [
78,
28
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.device_state_attributes | (self) | Return device specific attributes. | Return device specific attributes. | def device_state_attributes(self):
"""Return device specific attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
81,
4
] | [
83,
31
] | python | en | ['fr', 'it', 'en'] | False |
GPSLoggerEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
return self._location[0] | [
"def",
"latitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_location",
"[",
"0",
"]"
] | [
86,
4
] | [
88,
32
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
return self._location[1] | [
"def",
"longitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_location",
"[",
"1",
"]"
] | [
91,
4
] | [
93,
32
] | python | en | ['en', 'zu', 'en'] | True |
GPSLoggerEntity.location_accuracy | (self) | Return the gps accuracy of the device. | Return the gps accuracy of the device. | def location_accuracy(self):
"""Return the gps accuracy of the device."""
return self._accuracy | [
"def",
"location_accuracy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_accuracy"
] | [
96,
4
] | [
98,
29
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.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"
] | [
101,
4
] | [
103,
25
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.unique_id | (self) | Return the unique ID. | Return the unique ID. | def unique_id(self):
"""Return the unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
106,
4
] | [
108,
30
] | python | en | ['en', 'la', 'en'] | True |
GPSLoggerEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {"name": self._name, "identifiers": {(GPL_DOMAIN, self._unique_id)}} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"GPL_DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
"}"
] | [
111,
4
] | [
113,
83
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_GPS | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_GPS"
] | [
116,
4
] | [
118,
30
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
await super().async_added_to_hass()
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, TRACKER_UPDATE, self._async_receive_data
)
# don't restore if we got created with data
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_unsub_dispatcher",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"TRACKER_UPDATE",
",",
"self",
"."... | [
120,
4
] | [
155,
52
] | python | en | ['en', 'co', 'en'] | True |
GPSLoggerEntity.async_will_remove_from_hass | (self) | Clean up after entity before removal. | Clean up after entity before removal. | async def async_will_remove_from_hass(self):
"""Clean up after entity before removal."""
await super().async_will_remove_from_hass()
self._unsub_dispatcher() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"self",
".",
"_unsub_dispatcher",
"(",
")"
] | [
157,
4
] | [
160,
32
] | python | en | ['en', 'en', 'en'] | True |
GPSLoggerEntity._async_receive_data | (self, device, location, battery, accuracy, attributes) | Mark the device as seen. | Mark the device as seen. | def _async_receive_data(self, device, location, battery, accuracy, attributes):
"""Mark the device as seen."""
if device != self.name:
return
self._location = location
self._battery = battery
self._accuracy = accuracy
self._attributes.update(attributes)
... | [
"def",
"_async_receive_data",
"(",
"self",
",",
"device",
",",
"location",
",",
"battery",
",",
"accuracy",
",",
"attributes",
")",
":",
"if",
"device",
"!=",
"self",
".",
"name",
":",
"return",
"self",
".",
"_location",
"=",
"location",
"self",
".",
"_b... | [
163,
4
] | [
172,
35
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Aurora ABB PowerOne device. | Set up the Aurora ABB PowerOne device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Aurora ABB PowerOne device."""
devices = []
comport = config[CONF_DEVICE]
address = config[CONF_ADDRESS]
name = config[CONF_NAME]
_LOGGER.debug("Intitialising com port=%s address=%s", comport, address)
client... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"[",
"]",
"comport",
"=",
"config",
"[",
"CONF_DEVICE",
"]",
"address",
"=",
"config",
"[",
"CONF_ADDRESS",
"]",
"name",... | [
32,
0
] | [
43,
31
] | python | en | ['en', 'zh', 'en'] | True |
AuroraABBSolarPVMonitorSensor.__init__ | (self, client, name, typename) | Initialize the sensor. | Initialize the sensor. | def __init__(self, client, name, typename):
"""Initialize the sensor."""
self._name = f"{name} {typename}"
self.client = client
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"name",
",",
"typename",
")",
":",
"self",
".",
"_name",
"=",
"f\"{name} {typename}\"",
"self",
".",
"client",
"=",
"client",
"self",
".",
"_state",
"=",
"None"
] | [
49,
4
] | [
53,
26
] | python | en | ['en', 'en', 'en'] | True |
AuroraABBSolarPVMonitorSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
56,
4
] | [
58,
25
] | python | en | ['en', 'mi', 'en'] | True |
AuroraABBSolarPVMonitorSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
61,
4
] | [
63,
26
] | python | en | ['en', 'en', 'en'] | True |
AuroraABBSolarPVMonitorSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return POWER_WATT | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"POWER_WATT"
] | [
66,
4
] | [
68,
25
] | python | en | ['en', 'la', 'en'] | True |
AuroraABBSolarPVMonitorSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return DEVICE_CLASS_POWER | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_POWER"
] | [
71,
4
] | [
73,
33
] | python | en | ['en', 'en', 'en'] | True |
AuroraABBSolarPVMonitorSensor.update | (self) | Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
| Fetch new state data for the sensor. | def update(self):
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""
try:
self.client.connect()
# read ADC channel 3 (grid power output)
power_watts = self.client.measure(3, True)
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"connect",
"(",
")",
"# read ADC channel 3 (grid power output)",
"power_watts",
"=",
"self",
".",
"client",
".",
"measure",
"(",
"3",
",",
"True",
")",
"self",
".",
"_state",
... | [
75,
4
] | [
102,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up Microsoft Face. | Set up Microsoft Face. | async def async_setup(hass, config):
"""Set up Microsoft Face."""
entities = {}
face = MicrosoftFace(
hass,
config[DOMAIN].get(CONF_AZURE_REGION),
config[DOMAIN].get(CONF_API_KEY),
config[DOMAIN].get(CONF_TIMEOUT),
entities,
)
try:
# read exists group... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"entities",
"=",
"{",
"}",
"face",
"=",
"MicrosoftFace",
"(",
"hass",
",",
"config",
"[",
"DOMAIN",
"]",
".",
"get",
"(",
"CONF_AZURE_REGION",
")",
",",
"config",
"[",
"DOMAIN",
"]",
... | [
68,
0
] | [
199,
15
] | python | en | ['en', 'zu', 'en'] | True |
MicrosoftFaceGroupEntity.__init__ | (self, hass, api, g_id, name) | Initialize person/group entity. | Initialize person/group entity. | def __init__(self, hass, api, g_id, name):
"""Initialize person/group entity."""
self.hass = hass
self._api = api
self._id = g_id
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"api",
",",
"g_id",
",",
"name",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_id",
"=",
"g_id",
"self",
".",
"_name",
"=",
"name"
] | [
205,
4
] | [
210,
25
] | python | en | ['nl', 'en', 'en'] | True |
MicrosoftFaceGroupEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
213,
4
] | [
215,
25
] | python | en | ['en', 'en', 'en'] | True |
MicrosoftFaceGroupEntity.entity_id | (self) | Return entity id. | Return entity id. | def entity_id(self):
"""Return entity id."""
return f"{DOMAIN}.{self._id}" | [
"def",
"entity_id",
"(",
"self",
")",
":",
"return",
"f\"{DOMAIN}.{self._id}\""
] | [
218,
4
] | [
220,
37
] | python | en | ['en', 'cy', 'en'] | True |
MicrosoftFaceGroupEntity.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
return len(self._api.store[self._id]) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_api",
".",
"store",
"[",
"self",
".",
"_id",
"]",
")"
] | [
223,
4
] | [
225,
45
] | python | en | ['en', 'en', 'en'] | True |
MicrosoftFaceGroupEntity.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
228,
4
] | [
230,
20
] | python | en | ['en', 'en', 'en'] | True |
MicrosoftFaceGroupEntity.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
attr = {}
for name, p_id in self._api.store[self._id].items():
attr[name] = p_id
return attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"for",
"name",
",",
"p_id",
"in",
"self",
".",
"_api",
".",
"store",
"[",
"self",
".",
"_id",
"]",
".",
"items",
"(",
")",
":",
"attr",
"[",
"name",
"]",
"=",
"p_id",... | [
233,
4
] | [
239,
19
] | python | en | ['fr', 'en', 'en'] | True |
MicrosoftFace.__init__ | (self, hass, server_loc, api_key, timeout, entities) | Initialize Microsoft Face api. | Initialize Microsoft Face api. | def __init__(self, hass, server_loc, api_key, timeout, entities):
"""Initialize Microsoft Face api."""
self.hass = hass
self.websession = async_get_clientsession(hass)
self.timeout = timeout
self._api_key = api_key
self._server_url = f"https://{server_loc}.{FACE_API_URL}"... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"server_loc",
",",
"api_key",
",",
"timeout",
",",
"entities",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"websession",
"=",
"async_get_clientsession",
"(",
"hass",
")",
"self",
".",
"timeou... | [
245,
4
] | [
253,
33
] | python | en | ['en', 'sm', 'it'] | False |
MicrosoftFace.store | (self) | Store group/person data and IDs. | Store group/person data and IDs. | def store(self):
"""Store group/person data and IDs."""
return self._store | [
"def",
"store",
"(",
"self",
")",
":",
"return",
"self",
".",
"_store"
] | [
256,
4
] | [
258,
26
] | python | en | ['en', 'en', 'en'] | True |
MicrosoftFace.update_store | (self) | Load all group/person data into local store. | Load all group/person data into local store. | async def update_store(self):
"""Load all group/person data into local store."""
groups = await self.call_api("get", "persongroups")
tasks = []
for group in groups:
g_id = group["personGroupId"]
self._store[g_id] = {}
self._entities[g_id] = MicrosoftF... | [
"async",
"def",
"update_store",
"(",
"self",
")",
":",
"groups",
"=",
"await",
"self",
".",
"call_api",
"(",
"\"get\"",
",",
"\"persongroups\"",
")",
"tasks",
"=",
"[",
"]",
"for",
"group",
"in",
"groups",
":",
"g_id",
"=",
"group",
"[",
"\"personGroupId... | [
260,
4
] | [
280,
37
] | python | en | ['en', 'en', 'en'] | True |
MicrosoftFace.call_api | (self, method, function, data=None, binary=False, params=None) | Make an api call. | Make an api call. | async def call_api(self, method, function, data=None, binary=False, params=None):
"""Make an api call."""
headers = {"Ocp-Apim-Subscription-Key": self._api_key}
url = self._server_url.format(function)
payload = None
if binary:
headers[CONTENT_TYPE] = "application/oct... | [
"async",
"def",
"call_api",
"(",
"self",
",",
"method",
",",
"function",
",",
"data",
"=",
"None",
",",
"binary",
"=",
"False",
",",
"params",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"\"Ocp-Apim-Subscription-Key\"",
":",
"self",
".",
"_api_key",
"}",... | [
282,
4
] | [
321,
72
] | python | en | ['en', 'mi', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the MPD platform. | Set up the MPD platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MPD platform."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
name = config.get(CONF_NAME)
password = config.get(CONF_PASSWORD)
device = MpdDevice(host, port, password, name)
add_entities([device... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"name",
"=",
"co... | [
77,
0
] | [
85,
32
] | python | en | ['en', 'da', 'en'] | True |
MpdDevice.__init__ | (self, server, port, password, name) | Initialize the MPD device. | Initialize the MPD device. | def __init__(self, server, port, password, name):
"""Initialize the MPD device."""
self.server = server
self.port = port
self._name = name
self.password = password
self._status = None
self._currentsong = None
self._playlists = None
self._currentpl... | [
"def",
"__init__",
"(",
"self",
",",
"server",
",",
"port",
",",
"password",
",",
"name",
")",
":",
"self",
".",
"server",
"=",
"server",
"self",
".",
"port",
"=",
"port",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"password",
"=",
"password",
... | [
92,
4
] | [
112,
39
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice._connect | (self) | Connect to MPD. | Connect to MPD. | def _connect(self):
"""Connect to MPD."""
try:
self._client.connect(self.server, self.port)
if self.password is not None:
self._client.password(self.password)
except mpd.ConnectionError:
return
self._is_connected = True | [
"def",
"_connect",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_client",
".",
"connect",
"(",
"self",
".",
"server",
",",
"self",
".",
"port",
")",
"if",
"self",
".",
"password",
"is",
"not",
"None",
":",
"self",
".",
"_client",
".",
"password... | [
114,
4
] | [
124,
33
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice._disconnect | (self) | Disconnect from MPD. | Disconnect from MPD. | def _disconnect(self):
"""Disconnect from MPD."""
try:
self._client.disconnect()
except mpd.ConnectionError:
pass
self._is_connected = False
self._status = None | [
"def",
"_disconnect",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_client",
".",
"disconnect",
"(",
")",
"except",
"mpd",
".",
"ConnectionError",
":",
"pass",
"self",
".",
"_is_connected",
"=",
"False",
"self",
".",
"_status",
"=",
"None"
] | [
126,
4
] | [
133,
27
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice._fetch_status | (self) | Fetch status from MPD. | Fetch status from MPD. | def _fetch_status(self):
"""Fetch status from MPD."""
self._status = self._client.status()
self._currentsong = self._client.currentsong()
position = self._status.get("elapsed")
if position is None:
position = self._status.get("time")
if isinstance(posit... | [
"def",
"_fetch_status",
"(",
"self",
")",
":",
"self",
".",
"_status",
"=",
"self",
".",
"_client",
".",
"status",
"(",
")",
"self",
".",
"_currentsong",
"=",
"self",
".",
"_client",
".",
"currentsong",
"(",
")",
"position",
"=",
"self",
".",
"_status"... | [
135,
4
] | [
152,
32
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.available | (self) | Return true if MPD is available and connected. | Return true if MPD is available and connected. | def available(self):
"""Return true if MPD is available and connected."""
return self._is_connected | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_connected"
] | [
155,
4
] | [
157,
33
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.update | (self) | Get the latest data and update the state. | Get the latest data and update the state. | def update(self):
"""Get the latest data and update the state."""
try:
if not self._is_connected:
self._connect()
self._fetch_status()
except (mpd.ConnectionError, OSError, BrokenPipeError, ValueError) as error:
# Cleanly disconnect in case co... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"_is_connected",
":",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_fetch_status",
"(",
")",
"except",
"(",
"mpd",
".",
"ConnectionError",
",",
"OSError",
",",
"BrokenPip... | [
159,
4
] | [
169,
30
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.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"
] | [
172,
4
] | [
174,
25
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.state | (self) | Return the media state. | Return the media state. | def state(self):
"""Return the media state."""
if self._status is None:
return STATE_OFF
if self._status["state"] == "play":
return STATE_PLAYING
if self._status["state"] == "pause":
return STATE_PAUSED
if self._status["state"] == "stop":
... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_status",
"is",
"None",
":",
"return",
"STATE_OFF",
"if",
"self",
".",
"_status",
"[",
"\"state\"",
"]",
"==",
"\"play\"",
":",
"return",
"STATE_PLAYING",
"if",
"self",
".",
"_status",
"[",
"\"... | [
177,
4
] | [
188,
24
] | python | en | ['en', 'ig', 'en'] | True |
MpdDevice.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self._muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_muted"
] | [
191,
4
] | [
193,
26
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.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._currentsong.get("file") | [
"def",
"media_content_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"file\"",
")"
] | [
196,
4
] | [
198,
44
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.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 MEDIA_TYPE_MUSIC | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"return",
"MEDIA_TYPE_MUSIC"
] | [
201,
4
] | [
203,
31
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.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."""
# Time does not exist for streams
return self._currentsong.get("time") | [
"def",
"media_duration",
"(",
"self",
")",
":",
"# Time does not exist for streams",
"return",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"time\"",
")"
] | [
206,
4
] | [
209,
44
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_position | (self) | Position of current playing media in seconds.
This is returned as part of the mpd status rather than in the details
of the current song.
| Position of current playing media in seconds. | def media_position(self):
"""Position of current playing media in seconds.
This is returned as part of the mpd status rather than in the details
of the current song.
"""
return self._media_position | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position"
] | [
212,
4
] | [
218,
35
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_position_updated_at | (self) | Last valid time of media position. | Last valid time of media position. | def media_position_updated_at(self):
"""Last valid time of media position."""
return self._media_position_updated_at | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position_updated_at"
] | [
221,
4
] | [
223,
46
] | python | en | ['en', 'et', 'en'] | True |
MpdDevice.media_title | (self) | Return the title of current playing media. | Return the title of current playing media. | def media_title(self):
"""Return the title of current playing media."""
name = self._currentsong.get("name", None)
title = self._currentsong.get("title", None)
file_name = self._currentsong.get("file", None)
if name is None and title is None:
if file_name is None:
... | [
"def",
"media_title",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"name\"",
",",
"None",
")",
"title",
"=",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"title\"",
",",
"None",
")",
"file_name",
"=",
"self",
... | [
226,
4
] | [
241,
33
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_artist | (self) | Return the artist of current playing media (Music track only). | Return the artist of current playing media (Music track only). | def media_artist(self):
"""Return the artist of current playing media (Music track only)."""
return self._currentsong.get("artist") | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"artist\"",
")"
] | [
244,
4
] | [
246,
46
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_album_name | (self) | Return the album of current playing media (Music track only). | Return the album of current playing media (Music track only). | def media_album_name(self):
"""Return the album of current playing media (Music track only)."""
return self._currentsong.get("album") | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_currentsong",
".",
"get",
"(",
"\"album\"",
")"
] | [
249,
4
] | [
251,
45
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.volume_level | (self) | Return the volume level. | Return the volume level. | def volume_level(self):
"""Return the volume level."""
if "volume" in self._status:
return int(self._status["volume"]) / 100
return None | [
"def",
"volume_level",
"(",
"self",
")",
":",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"return",
"int",
"(",
"self",
".",
"_status",
"[",
"\"volume\"",
"]",
")",
"/",
"100",
"return",
"None"
] | [
254,
4
] | [
258,
19
] | python | en | ['en', 'no', 'en'] | True |
MpdDevice.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."""
if self._status is None:
return 0
supported = SUPPORT_MPD
if "volume" in self._status:
supported |= SUPPORT_VOLUME_SET | SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE
if self._... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_status",
"is",
"None",
":",
"return",
"0",
"supported",
"=",
"SUPPORT_MPD",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"supported",
"|=",
"SUPPORT_VOLUME_SET",
"|",
"SUPPORT... | [
261,
4
] | [
272,
24
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.source | (self) | Name of the current input source. | Name of the current input source. | def source(self):
"""Name of the current input source."""
return self._currentplaylist | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_currentplaylist"
] | [
275,
4
] | [
277,
36
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.source_list | (self) | Return the list of available input sources. | Return the list of available input sources. | def source_list(self):
"""Return the list of available input sources."""
return self._playlists | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_playlists"
] | [
280,
4
] | [
282,
30
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.select_source | (self, source) | Choose a different available playlist and play it. | Choose a different available playlist and play it. | def select_source(self, source):
"""Choose a different available playlist and play it."""
self.play_media(MEDIA_TYPE_PLAYLIST, source) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"play_media",
"(",
"MEDIA_TYPE_PLAYLIST",
",",
"source",
")"
] | [
284,
4
] | [
286,
52
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice._update_playlists | (self, **kwargs) | Update available MPD playlists. | Update available MPD playlists. | def _update_playlists(self, **kwargs):
"""Update available MPD playlists."""
try:
self._playlists = []
for playlist_data in self._client.listplaylists():
self._playlists.append(playlist_data["playlist"])
except mpd.CommandError as error:
self._... | [
"def",
"_update_playlists",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_playlists",
"=",
"[",
"]",
"for",
"playlist_data",
"in",
"self",
".",
"_client",
".",
"listplaylists",
"(",
")",
":",
"self",
".",
"_playlists",
".",... | [
289,
4
] | [
297,
73
] | python | en | ['fr', 'en', 'en'] | True |
MpdDevice.set_volume_level | (self, volume) | Set volume of media player. | Set volume of media player. | def set_volume_level(self, volume):
"""Set volume of media player."""
if "volume" in self._status:
self._client.setvol(int(volume * 100)) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"self",
".",
"_client",
".",
"setvol",
"(",
"int",
"(",
"volume",
"*",
"100",
")",
")"
] | [
299,
4
] | [
302,
50
] | python | en | ['en', 'da', 'en'] | True |
MpdDevice.volume_up | (self) | Service to send the MPD the command for volume up. | Service to send the MPD the command for volume up. | def volume_up(self):
"""Service to send the MPD the command for volume up."""
if "volume" in self._status:
current_volume = int(self._status["volume"])
if current_volume <= 100:
self._client.setvol(current_volume + 5) | [
"def",
"volume_up",
"(",
"self",
")",
":",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"current_volume",
"=",
"int",
"(",
"self",
".",
"_status",
"[",
"\"volume\"",
"]",
")",
"if",
"current_volume",
"<=",
"100",
":",
"self",
".",
"_client",
... | [
304,
4
] | [
310,
55
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.volume_down | (self) | Service to send the MPD the command for volume down. | Service to send the MPD the command for volume down. | def volume_down(self):
"""Service to send the MPD the command for volume down."""
if "volume" in self._status:
current_volume = int(self._status["volume"])
if current_volume >= 0:
self._client.setvol(current_volume - 5) | [
"def",
"volume_down",
"(",
"self",
")",
":",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"current_volume",
"=",
"int",
"(",
"self",
".",
"_status",
"[",
"\"volume\"",
"]",
")",
"if",
"current_volume",
">=",
"0",
":",
"self",
".",
"_client",
... | [
312,
4
] | [
318,
55
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_play | (self) | Service to send the MPD the command for play/pause. | Service to send the MPD the command for play/pause. | def media_play(self):
"""Service to send the MPD the command for play/pause."""
if self._status["state"] == "pause":
self._client.pause(0)
else:
self._client.play() | [
"def",
"media_play",
"(",
"self",
")",
":",
"if",
"self",
".",
"_status",
"[",
"\"state\"",
"]",
"==",
"\"pause\"",
":",
"self",
".",
"_client",
".",
"pause",
"(",
"0",
")",
"else",
":",
"self",
".",
"_client",
".",
"play",
"(",
")"
] | [
320,
4
] | [
325,
31
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_pause | (self) | Service to send the MPD the command for play/pause. | Service to send the MPD the command for play/pause. | def media_pause(self):
"""Service to send the MPD the command for play/pause."""
self._client.pause(1) | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"pause",
"(",
"1",
")"
] | [
327,
4
] | [
329,
29
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_stop | (self) | Service to send the MPD the command for stop. | Service to send the MPD the command for stop. | def media_stop(self):
"""Service to send the MPD the command for stop."""
self._client.stop() | [
"def",
"media_stop",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"stop",
"(",
")"
] | [
331,
4
] | [
333,
27
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_next_track | (self) | Service to send the MPD the command for next track. | Service to send the MPD the command for next track. | def media_next_track(self):
"""Service to send the MPD the command for next track."""
self._client.next() | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"next",
"(",
")"
] | [
335,
4
] | [
337,
27
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.media_previous_track | (self) | Service to send the MPD the command for previous track. | Service to send the MPD the command for previous track. | def media_previous_track(self):
"""Service to send the MPD the command for previous track."""
self._client.previous() | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"previous",
"(",
")"
] | [
339,
4
] | [
341,
31
] | python | en | ['en', 'en', 'en'] | True |
MpdDevice.mute_volume | (self, mute) | Mute. Emulated with set_volume_level. | Mute. Emulated with set_volume_level. | def mute_volume(self, mute):
"""Mute. Emulated with set_volume_level."""
if "volume" in self._status:
if mute:
self._muted_volume = self.volume_level
self.set_volume_level(0)
else:
self.set_volume_level(self._muted_volume)
... | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"if",
"\"volume\"",
"in",
"self",
".",
"_status",
":",
"if",
"mute",
":",
"self",
".",
"_muted_volume",
"=",
"self",
".",
"volume_level",
"self",
".",
"set_volume_level",
"(",
"0",
")",
"else",
... | [
343,
4
] | [
351,
30
] | 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.