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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ZerprocLight.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) -> None:
"""Run when entity about to be added to hass."""
self.async_on_remove(
self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, self.on_hass_shutdown
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"bus",
".",
"async_listen_once",
"(",
"EVENT_HOMEASSISTANT_STOP",
",",
"self",
".",
"on_hass_shutdown",
")",
")"
] | [
109,
4
] | [
115,
9
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.async_will_remove_from_hass | (self) | Run when entity will be removed from hass. | Run when entity will be removed from hass. | async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass."""
await self.hass.async_add_executor_job(self._light.disconnect) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_light",
".",
"disconnect",
")"
] | [
117,
4
] | [
119,
70
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.on_hass_shutdown | (self, event) | Execute when Home Assistant is shutting down. | Execute when Home Assistant is shutting down. | def on_hass_shutdown(self, event):
"""Execute when Home Assistant is shutting down."""
self._light.disconnect() | [
"def",
"on_hass_shutdown",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_light",
".",
"disconnect",
"(",
")"
] | [
121,
4
] | [
123,
32
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self):
"""Return the display name of this light."""
return self._light.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light",
".",
"name"
] | [
126,
4
] | [
128,
31
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.unique_id | (self) | Return the ID of this light. | Return the ID of this light. | def unique_id(self):
"""Return the ID of this light."""
return self._light.address | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_light",
".",
"address"
] | [
131,
4
] | [
133,
34
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.device_info | (self) | Device info for this light. | Device info for this light. | def device_info(self):
"""Device info for this light."""
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": self.name,
"manufacturer": "Zerproc",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"Zerproc\"",
",",
"}"
] | [
136,
4
] | [
142,
9
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self) -> Optional[str]:
"""Return the icon to use in the frontend."""
return "mdi:string-lights" | [
"def",
"icon",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"\"mdi:string-lights\""
] | [
145,
4
] | [
147,
34
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_ZERPROC | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_ZERPROC"
] | [
150,
4
] | [
152,
30
] | python | en | ['da', 'en', 'en'] | True |
ZerprocLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
155,
4
] | [
157,
31
] | python | en | ['en', 'no', 'en'] | True |
ZerprocLight.hs_color | (self) | Return the hs color. | Return the hs color. | def hs_color(self):
"""Return the hs color."""
return self._hs_color | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs_color"
] | [
160,
4
] | [
162,
29
] | python | en | ['en', 'fr', 'en'] | True |
ZerprocLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
165,
4
] | [
167,
26
] | python | en | ['en', 'et', 'en'] | True |
ZerprocLight.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"
] | [
170,
4
] | [
172,
30
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
if ATTR_BRIGHTNESS in kwargs or ATTR_HS_COLOR in kwargs:
default_hs = (0, 0) if self._hs_color is None else self._hs_color
hue_sat = kwargs.get(ATTR_HS_COLOR, default_hs)
default_brightness = 255 if se... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
"or",
"ATTR_HS_COLOR",
"in",
"kwargs",
":",
"default_hs",
"=",
"(",
"0",
",",
"0",
")",
"if",
"self",
".",
"_hs_color",
"is",
"None",
"else",
"... | [
174,
4
] | [
186,
33
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
self._light.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_light",
".",
"turn_off",
"(",
")"
] | [
188,
4
] | [
190,
30
] | python | en | ['en', 'en', 'en'] | True |
ZerprocLight.update | (self) | Fetch new state data for this light. | Fetch new state data for this light. | def update(self):
"""Fetch new state data for this light."""
try:
state = self._light.get_state()
except pyzerproc.ZerprocException:
if self._available:
_LOGGER.warning("Unable to connect to %s", self.entity_id)
self._available = False
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"state",
"=",
"self",
".",
"_light",
".",
"get_state",
"(",
")",
"except",
"pyzerproc",
".",
"ZerprocException",
":",
"if",
"self",
".",
"_available",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Unable to c... | [
192,
4
] | [
207,
59
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up Abode integration. | Set up Abode integration. | async def async_setup(hass, config):
"""Set up Abode integration."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=deepcopy(conf)
)
)
r... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow... | [
91,
0
] | [
104,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up Abode integration from a config entry. | Set up Abode integration from a config entry. | async def async_setup_entry(hass, config_entry):
"""Set up Abode integration from a config entry."""
username = config_entry.data.get(CONF_USERNAME)
password = config_entry.data.get(CONF_PASSWORD)
polling = config_entry.data.get(CONF_POLLING)
try:
cache = hass.config.path(DEFAULT_CACHEDB)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"username",
"=",
"config_entry",
".",
"data",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"config_entry",
".",
"data",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"pollin... | [
107,
0
] | [
133,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
hass.services.async_remove(DOMAIN, SERVICE_SETTINGS)
hass.services.async_remove(DOMAIN, SERVICE_CAPTURE_IMAGE)
hass.services.async_remove(DOMAIN, SERVICE_TRIGGER_AUTOMATION)
tasks = []
for platform in ABODE_PLATFORM... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"services",
".",
"async_remove",
"(",
"DOMAIN",
",",
"SERVICE_SETTINGS",
")",
"hass",
".",
"services",
".",
"async_remove",
"(",
"DOMAIN",
",",
"SERVICE_CAPTURE_IMAGE"... | [
136,
0
] | [
157,
15
] | python | en | ['en', 'es', 'en'] | True |
setup_hass_services | (hass) | Home Assistant services. | Home Assistant services. | def setup_hass_services(hass):
"""Home Assistant services."""
def change_setting(call):
"""Change an Abode system setting."""
setting = call.data.get(ATTR_SETTING)
value = call.data.get(ATTR_VALUE)
try:
hass.data[DOMAIN].abode.set_setting(setting, value)
exc... | [
"def",
"setup_hass_services",
"(",
"hass",
")",
":",
"def",
"change_setting",
"(",
"call",
")",
":",
"\"\"\"Change an Abode system setting.\"\"\"",
"setting",
"=",
"call",
".",
"data",
".",
"get",
"(",
"ATTR_SETTING",
")",
"value",
"=",
"call",
".",
"data",
".... | [
160,
0
] | [
211,
5
] | python | en | ['fr', 'en', 'en'] | True |
setup_hass_events | (hass) | Home Assistant start and stop callbacks. | Home Assistant start and stop callbacks. | async def setup_hass_events(hass):
"""Home Assistant start and stop callbacks."""
def logout(event):
"""Logout of Abode."""
if not hass.data[DOMAIN].polling:
hass.data[DOMAIN].abode.events.stop()
hass.data[DOMAIN].abode.logout()
LOGGER.info("Logged out of Abode")
... | [
"async",
"def",
"setup_hass_events",
"(",
"hass",
")",
":",
"def",
"logout",
"(",
"event",
")",
":",
"\"\"\"Logout of Abode.\"\"\"",
"if",
"not",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"polling",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
... | [
214,
0
] | [
230,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_abode_events | (hass) | Event callbacks. | Event callbacks. | def setup_abode_events(hass):
"""Event callbacks."""
def event_callback(event, event_json):
"""Handle an event callback from Abode."""
data = {
ATTR_DEVICE_ID: event_json.get(ATTR_DEVICE_ID, ""),
ATTR_DEVICE_NAME: event_json.get(ATTR_DEVICE_NAME, ""),
ATTR_DE... | [
"def",
"setup_abode_events",
"(",
"hass",
")",
":",
"def",
"event_callback",
"(",
"event",
",",
"event_json",
")",
":",
"\"\"\"Handle an event callback from Abode.\"\"\"",
"data",
"=",
"{",
"ATTR_DEVICE_ID",
":",
"event_json",
".",
"get",
"(",
"ATTR_DEVICE_ID",
",",... | [
233,
0
] | [
272,
9
] | python | en | ['en', 'bs', 'en'] | False |
AbodeSystem.__init__ | (self, abode, polling) | Initialize the system. | Initialize the system. | def __init__(self, abode, polling):
"""Initialize the system."""
self.abode = abode
self.polling = polling
self.entity_ids = set()
self.logout_listener = None | [
"def",
"__init__",
"(",
"self",
",",
"abode",
",",
"polling",
")",
":",
"self",
".",
"abode",
"=",
"abode",
"self",
".",
"polling",
"=",
"polling",
"self",
".",
"entity_ids",
"=",
"set",
"(",
")",
"self",
".",
"logout_listener",
"=",
"None"
] | [
83,
4
] | [
88,
35
] | python | en | ['en', 'en', 'en'] | True |
AbodeEntity.__init__ | (self, data) | Initialize Abode entity. | Initialize Abode entity. | def __init__(self, data):
"""Initialize Abode entity."""
self._data = data
self._available = True | [
"def",
"__init__",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_available",
"=",
"True"
] | [
278,
4
] | [
281,
30
] | python | es | ['es', 'zu', 'it'] | False |
AbodeEntity.available | (self) | Return the available state. | Return the available state. | def available(self):
"""Return the available state."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
284,
4
] | [
286,
30
] | python | en | ['en', 'en', 'en'] | True |
AbodeEntity.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return self._data.polling | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"polling"
] | [
289,
4
] | [
291,
33
] | python | en | ['en', 'en', 'en'] | True |
AbodeEntity.async_added_to_hass | (self) | Subscribe to Abode connection status updates. | Subscribe to Abode connection status updates. | async def async_added_to_hass(self):
"""Subscribe to Abode connection status updates."""
await self.hass.async_add_executor_job(
self._data.abode.events.add_connection_status_callback,
self.unique_id,
self._update_connection_status,
)
self.hass.data[D... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_data",
".",
"abode",
".",
"events",
".",
"add_connection_status_callback",
",",
"self",
".",
"unique_id",
",",
"self"... | [
293,
4
] | [
301,
61
] | python | en | ['en', 'en', 'en'] | True |
AbodeEntity.async_will_remove_from_hass | (self) | Unsubscribe from Abode connection status updates. | Unsubscribe from Abode connection status updates. | async def async_will_remove_from_hass(self):
"""Unsubscribe from Abode connection status updates."""
await self.hass.async_add_executor_job(
self._data.abode.events.remove_connection_status_callback, self.unique_id
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_data",
".",
"abode",
".",
"events",
".",
"remove_connection_status_callback",
",",
"self",
".",
"unique_id",
")... | [
303,
4
] | [
307,
9
] | python | en | ['en', 'en', 'en'] | True |
AbodeEntity._update_connection_status | (self) | Update the entity available property. | Update the entity available property. | def _update_connection_status(self):
"""Update the entity available property."""
self._available = self._data.abode.events.connected
self.schedule_update_ha_state() | [
"def",
"_update_connection_status",
"(",
"self",
")",
":",
"self",
".",
"_available",
"=",
"self",
".",
"_data",
".",
"abode",
".",
"events",
".",
"connected",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
309,
4
] | [
312,
39
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice.__init__ | (self, data, device) | Initialize Abode device. | Initialize Abode device. | def __init__(self, data, device):
"""Initialize Abode device."""
super().__init__(data)
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"data",
")",
"self",
".",
"_device",
"=",
"device"
] | [
318,
4
] | [
321,
29
] | python | en | ['fr', 'en', 'it'] | False |
AbodeDevice.async_added_to_hass | (self) | Subscribe to device events. | Subscribe to device events. | async def async_added_to_hass(self):
"""Subscribe to device events."""
await super().async_added_to_hass()
await self.hass.async_add_executor_job(
self._data.abode.events.add_device_callback,
self._device.device_id,
self._update_callback,
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_data",
".",
"abode",
".",
"events",
".",
"add_d... | [
323,
4
] | [
330,
9
] | python | en | ['it', 'en', 'en'] | True |
AbodeDevice.async_will_remove_from_hass | (self) | Unsubscribe from device events. | Unsubscribe from device events. | async def async_will_remove_from_hass(self):
"""Unsubscribe from device events."""
await super().async_will_remove_from_hass()
await self.hass.async_add_executor_job(
self._data.abode.events.remove_all_device_callbacks, self._device.device_id
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_data",
".",
"abode",
".",
"events",... | [
332,
4
] | [
337,
9
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
self._device.refresh() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"refresh",
"(",
")"
] | [
339,
4
] | [
341,
30
] | python | en | ['fr', 'en', 'en'] | True |
AbodeDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
344,
4
] | [
346,
32
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
"device_id": self._device.device_id,
"battery_low": self._device.battery_low,
"no_response": self._device.no_response,
"device_type": ... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"\"device_id\"",
":",
"self",
".",
"_device",
".",
"device_id",
",",
"\"battery_low\"",
":",
"self",
".",
"_device",
".",
"battery_low",
",",
"... | [
349,
4
] | [
357,
9
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice.unique_id | (self) | Return a unique ID to use for this device. | Return a unique ID to use for this device. | def unique_id(self):
"""Return a unique ID to use for this device."""
return self._device.device_uuid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"device_uuid"
] | [
360,
4
] | [
362,
39
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice.device_info | (self) | Return device registry information for this entity. | Return device registry information for this entity. | def device_info(self):
"""Return device registry information for this entity."""
return {
"identifiers": {(DOMAIN, self._device.device_id)},
"manufacturer": "Abode",
"name": self._device.name,
"device_type": self._device.type,
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"device_id",
")",
"}",
",",
"\"manufacturer\"",
":",
"\"Abode\"",
",",
"\"name\"",
":",
"self",
".",
"_device",
".",... | [
365,
4
] | [
372,
9
] | python | en | ['en', 'en', 'en'] | True |
AbodeDevice._update_callback | (self, device) | Update the device state. | Update the device state. | def _update_callback(self, device):
"""Update the device state."""
self.schedule_update_ha_state() | [
"def",
"_update_callback",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
374,
4
] | [
376,
39
] | python | en | ['en', 'en', 'en'] | True |
AbodeAutomation.__init__ | (self, data, automation) | Initialize for Abode automation. | Initialize for Abode automation. | def __init__(self, data, automation):
"""Initialize for Abode automation."""
super().__init__(data)
self._automation = automation | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"automation",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"data",
")",
"self",
".",
"_automation",
"=",
"automation"
] | [
382,
4
] | [
385,
37
] | python | en | ['en', 'en', 'en'] | True |
AbodeAutomation.update | (self) | Update automation state. | Update automation state. | def update(self):
"""Update automation state."""
self._automation.refresh() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_automation",
".",
"refresh",
"(",
")"
] | [
387,
4
] | [
389,
34
] | python | en | ['de', 'en', 'en'] | True |
AbodeAutomation.name | (self) | Return the name of the automation. | Return the name of the automation. | def name(self):
"""Return the name of the automation."""
return self._automation.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_automation",
".",
"name"
] | [
392,
4
] | [
394,
36
] | python | en | ['en', 'en', 'en'] | True |
AbodeAutomation.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION, "type": "CUE automation"} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"\"type\"",
":",
"\"CUE automation\"",
"}"
] | [
397,
4
] | [
399,
72
] | python | en | ['en', 'en', 'en'] | True |
AbodeAutomation.unique_id | (self) | Return a unique ID to use for this automation. | Return a unique ID to use for this automation. | def unique_id(self):
"""Return a unique ID to use for this automation."""
return self._automation.automation_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_automation",
".",
"automation_id"
] | [
402,
4
] | [
404,
45
] | python | en | ['en', 'en', 'en'] | True |
test_platform_manually_configured | (hass) | Test that we do not discover anything or try to set up a gateway. | Test that we do not discover anything or try to set up a gateway. | async def test_platform_manually_configured(hass):
"""Test that we do not discover anything or try to set up a gateway."""
assert (
await async_setup_component(
hass, LOCK_DOMAIN, {"lock": {"platform": DECONZ_DOMAIN}}
)
is True
)
assert DECONZ_DOMAIN not in hass.data | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"DECONZ_DOMAIN",
"}",
"}",
")",
"is",
"True",
")"... | [
35,
0
] | [
43,
41
] | python | en | ['en', 'en', 'en'] | True |
test_no_locks | (hass) | Test that no lock entities are created. | Test that no lock entities are created. | async def test_no_locks(hass):
"""Test that no lock entities are created."""
await setup_deconz_integration(hass)
assert len(hass.states.async_all()) == 0 | [
"async",
"def",
"test_no_locks",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"0"
] | [
46,
0
] | [
49,
44
] | python | en | ['en', 'en', 'en'] | True |
test_locks | (hass) | Test that all supported lock entities are created. | Test that all supported lock entities are created. | async def test_locks(hass):
"""Test that all supported lock entities are created."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["lights"] = deepcopy(LOCKS)
config_entry = await setup_deconz_integration(hass, get_state_response=data)
gateway = get_gateway_from_config_entry(hass, config_entry)
asse... | [
"async",
"def",
"test_locks",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"lights\"",
"]",
"=",
"deepcopy",
"(",
"LOCKS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
",",
"get... | [
52,
0
] | [
107,
44
] | python | en | ['en', 'en', 'en'] | True |
mock_rflink | (
hass, config, domain, monkeypatch, failures=None, failcommand=False
) | Create mock RFLink asyncio protocol, test component setup. | Create mock RFLink asyncio protocol, test component setup. | async def mock_rflink(
hass, config, domain, monkeypatch, failures=None, failcommand=False
):
"""Create mock RFLink asyncio protocol, test component setup."""
transport, protocol = (Mock(), Mock())
async def send_command_ack(*command):
return not failcommand
protocol.send_command_ack = Moc... | [
"async",
"def",
"mock_rflink",
"(",
"hass",
",",
"config",
",",
"domain",
",",
"monkeypatch",
",",
"failures",
"=",
"None",
",",
"failcommand",
"=",
"False",
")",
":",
"transport",
",",
"protocol",
"=",
"(",
"Mock",
"(",
")",
",",
"Mock",
"(",
")",
"... | [
20,
0
] | [
65,
69
] | python | ceb | ['es', 'ceb', 'en'] | False |
test_version_banner | (hass, monkeypatch) | Test sending unknown commands doesn't cause issues. | Test sending unknown commands doesn't cause issues. | async def test_version_banner(hass, monkeypatch):
"""Test sending unknown commands doesn't cause issues."""
# use sensor domain during testing main platform
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0"},
domain: {
"platform": "rflink",
"devices":... | [
"async",
"def",
"test_version_banner",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"# use sensor domain during testing main platform",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"domain",
":... | [
68,
0
] | [
90,
5
] | python | en | ['en', 'en', 'en'] | True |
test_send_no_wait | (hass, monkeypatch) | Test command sending without ack. | Test command sending without ack. | async def test_send_no_wait(hass, monkeypatch):
"""Test command sending without ack."""
domain = "switch"
config = {
"rflink": {"port": "/dev/ttyABC0", "wait_for_ack": False},
domain: {
"platform": "rflink",
"devices": {
"protocol_0_0": {"name": "test"... | [
"async",
"def",
"test_send_no_wait",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"switch\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"\"wait_for_ack\"",
":",
"False",
"}",
",",
"domain",
":",
"{",... | [
93,
0
] | [
116,
65
] | python | en | ['en', 'en', 'en'] | True |
test_cover_send_no_wait | (hass, monkeypatch) | Test command sending to a cover device without ack. | Test command sending to a cover device without ack. | async def test_cover_send_no_wait(hass, monkeypatch):
"""Test command sending to a cover device without ack."""
domain = "cover"
config = {
"rflink": {"port": "/dev/ttyABC0", "wait_for_ack": False},
domain: {
"platform": "rflink",
"devices": {
"RTS_010... | [
"async",
"def",
"test_cover_send_no_wait",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"cover\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"\"wait_for_ack\"",
":",
"False",
"}",
",",
"domain",
":",
... | [
119,
0
] | [
142,
66
] | python | en | ['en', 'en', 'en'] | True |
test_send_command | (hass, monkeypatch) | Test send_command service. | Test send_command service. | async def test_send_command(hass, monkeypatch):
"""Test send_command service."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(hass, config, domain, monkeypatch)
hass.async_create_task(
hass.services.... | [
"async",
"def",
"test_send_command",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_",
",",
"protoc... | [
145,
0
] | [
162,
68
] | python | en | ['en', 'fr', 'en'] | True |
test_send_command_invalid_arguments | (hass, monkeypatch) | Test send_command service. | Test send_command service. | async def test_send_command_invalid_arguments(hass, monkeypatch):
"""Test send_command service."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(hass, config, domain, monkeypatch)
# one argument missing
w... | [
"async",
"def",
"test_send_command_invalid_arguments",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_"... | [
165,
0
] | [
195,
77
] | python | en | ['en', 'fr', 'en'] | True |
test_reconnecting_after_disconnect | (hass, monkeypatch) | An unexpected disconnect should cause a reconnect. | An unexpected disconnect should cause a reconnect. | async def test_reconnecting_after_disconnect(hass, monkeypatch):
"""An unexpected disconnect should cause a reconnect."""
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {"platform": "rflink"},
}
# setup mocking rflink module
... | [
"async",
"def",
"test_reconnecting_after_disconnect",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"do... | [
198,
0
] | [
219,
38
] | python | en | ['en', 'en', 'en'] | True |
test_reconnecting_after_failure | (hass, monkeypatch) | A failure to reconnect should be retried. | A failure to reconnect should be retried. | async def test_reconnecting_after_failure(hass, monkeypatch):
"""A failure to reconnect should be retried."""
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {"platform": "rflink"},
}
# success first time but fail second
failu... | [
"async",
"def",
"test_reconnecting_after_failure",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"domai... | [
222,
0
] | [
246,
38
] | python | en | ['en', 'en', 'en'] | True |
test_error_when_not_connected | (hass, monkeypatch) | Sending command should error when not connected. | Sending command should error when not connected. | async def test_error_when_not_connected(hass, monkeypatch):
"""Sending command should error when not connected."""
domain = "switch"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {
"platform": "rflink",
"devices": {
... | [
"async",
"def",
"test_error_when_not_connected",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"switch\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"domain"... | [
249,
0
] | [
276,
77
] | python | en | ['en', 'en', 'en'] | True |
test_async_send_command_error | (hass, monkeypatch) | Sending command should error when protocol fails. | Sending command should error when protocol fails. | async def test_async_send_command_error(hass, monkeypatch):
"""Sending command should error when protocol fails."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(
hass, config, domain, monkeypatch, failcom... | [
"async",
"def",
"test_async_send_command_error",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_",
",... | [
279,
0
] | [
297,
80
] | python | en | ['en', 'it', 'en'] | True |
test_race_condition | (hass, monkeypatch) | Test race condition for unknown components. | Test race condition for unknown components. | async def test_race_condition(hass, monkeypatch):
"""Test race condition for unknown components."""
domain = "light"
config = {"rflink": {"port": "/dev/ttyABC0"}, domain: {"platform": "rflink"}}
tmp_entity = TMP_ENTITY.format("test3")
# setup mocking rflink module
event_callback, _, _, _ = awai... | [
"async",
"def",
"test_race_condition",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"light\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"domain",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
"}... | [
300,
0
] | [
333,
35
] | python | en | ['en', 'en', 'en'] | True |
test_not_connected | (hass, monkeypatch) | Test Error when sending commands to a disconnected device. | Test Error when sending commands to a disconnected device. | async def test_not_connected(hass, monkeypatch):
"""Test Error when sending commands to a disconnected device."""
import pytest
from homeassistant.core import HomeAssistantError
test_device = RflinkCommand("DUMMY_DEVICE")
RflinkCommand.set_rflink_protocol(None)
with pytest.raises(HomeAssistant... | [
"async",
"def",
"test_not_connected",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"import",
"pytest",
"from",
"homeassistant",
".",
"core",
"import",
"HomeAssistantError",
"test_device",
"=",
"RflinkCommand",
"(",
"\"DUMMY_DEVICE\"",
")",
"RflinkCommand",
".",
"set_r... | [
336,
0
] | [
345,
58
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Deluge switch. | Set up the Deluge switch. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Deluge switch."""
name = config[CONF_NAME]
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
port = config[CONF_PORT]
deluge_api = DelugeRPCClient(host, port, usernam... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"username",
"=",
"config",
"[",
"CONF_USERNA... | [
36,
0
] | [
52,
50
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.__init__ | (self, deluge_client, name) | Initialize the Deluge switch. | Initialize the Deluge switch. | def __init__(self, deluge_client, name):
"""Initialize the Deluge switch."""
self._name = name
self.deluge_client = deluge_client
self._state = STATE_OFF
self._available = False | [
"def",
"__init__",
"(",
"self",
",",
"deluge_client",
",",
"name",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"deluge_client",
"=",
"deluge_client",
"self",
".",
"_state",
"=",
"STATE_OFF",
"self",
".",
"_available",
"=",
"False"
] | [
58,
4
] | [
63,
31
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.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"
] | [
66,
4
] | [
68,
25
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
71,
4
] | [
73,
26
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state == STATE_ON | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"==",
"STATE_ON"
] | [
76,
4
] | [
78,
38
] | python | en | ['en', 'fy', 'en'] | True |
DelugeSwitch.available | (self) | Return true if device is available. | Return true if device is available. | def available(self):
"""Return true if device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
81,
4
] | [
83,
30
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
torrent_ids = self.deluge_client.call("core.get_session_state")
self.deluge_client.call("core.resume_torrent", torrent_ids) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"torrent_ids",
"=",
"self",
".",
"deluge_client",
".",
"call",
"(",
"\"core.get_session_state\"",
")",
"self",
".",
"deluge_client",
".",
"call",
"(",
"\"core.resume_torrent\"",
",",
"torrent_id... | [
85,
4
] | [
88,
67
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
torrent_ids = self.deluge_client.call("core.get_session_state")
self.deluge_client.call("core.pause_torrent", torrent_ids) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"torrent_ids",
"=",
"self",
".",
"deluge_client",
".",
"call",
"(",
"\"core.get_session_state\"",
")",
"self",
".",
"deluge_client",
".",
"call",
"(",
"\"core.pause_torrent\"",
",",
"torrent_id... | [
90,
4
] | [
93,
66
] | python | en | ['en', 'en', 'en'] | True |
DelugeSwitch.update | (self) | Get the latest data from deluge and updates the state. | Get the latest data from deluge and updates the state. | def update(self):
"""Get the latest data from deluge and updates the state."""
try:
torrent_list = self.deluge_client.call(
"core.get_torrents_status", {}, ["paused"]
)
self._available = True
except FailedToReconnectException:
_LOG... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"torrent_list",
"=",
"self",
".",
"deluge_client",
".",
"call",
"(",
"\"core.get_torrents_status\"",
",",
"{",
"}",
",",
"[",
"\"paused\"",
"]",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"F... | [
95,
4
] | [
113,
31
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up Eufy devices. | Set up Eufy devices. | def setup(hass, config):
"""Set up Eufy devices."""
if CONF_USERNAME in config[DOMAIN] and CONF_PASSWORD in config[DOMAIN]:
data = lakeside.get_devices(
config[DOMAIN][CONF_USERNAME], config[DOMAIN][CONF_PASSWORD]
)
for device in data:
kind = device["type"]
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"CONF_USERNAME",
"in",
"config",
"[",
"DOMAIN",
"]",
"and",
"CONF_PASSWORD",
"in",
"config",
"[",
"DOMAIN",
"]",
":",
"data",
"=",
"lakeside",
".",
"get_devices",
"(",
"config",
"[",
"DOMAIN",
... | [
53,
0
] | [
77,
15
] | python | en | ['en', 'en', 'en'] | True |
catch_request_errors | () | Catch asyncio.TimeoutError, aiohttp.ClientError errors. | Catch asyncio.TimeoutError, aiohttp.ClientError errors. | def catch_request_errors():
"""Catch asyncio.TimeoutError, aiohttp.ClientError errors."""
def call_wrapper(func):
"""Call wrapper for decorator."""
@functools.wraps(func)
async def wrapper(self, *args, **kwargs):
"""Catch asyncio.TimeoutError, aiohttp.ClientError errors."""... | [
"def",
"catch_request_errors",
"(",
")",
":",
"def",
"call_wrapper",
"(",
"func",
")",
":",
"\"\"\"Call wrapper for decorator.\"\"\"",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
... | [
94,
0
] | [
110,
23
] | python | it | ['cy', 'it', 'it'] | True |
async_start_event_handler | (
hass: HomeAssistantType,
server_host: str,
server_port: int,
requester,
callback_url_override: Optional[str] = None,
) | Register notify view. | Register notify view. | async def async_start_event_handler(
hass: HomeAssistantType,
server_host: str,
server_port: int,
requester,
callback_url_override: Optional[str] = None,
):
"""Register notify view."""
hass_data = hass.data[DLNA_DMR_DATA]
if "event_handler" in hass_data:
return hass_data["event_h... | [
"async",
"def",
"async_start_event_handler",
"(",
"hass",
":",
"HomeAssistantType",
",",
"server_host",
":",
"str",
",",
"server_port",
":",
"int",
",",
"requester",
",",
"callback_url_override",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
":",
... | [
113,
0
] | [
145,
37
] | python | en | ['en', 'de', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config, async_add_entities, discovery_info=None
) | Set up DLNA DMR platform. | Set up DLNA DMR platform. | async def async_setup_platform(
hass: HomeAssistantType, config, async_add_entities, discovery_info=None
):
"""Set up DLNA DMR platform."""
if config.get(CONF_URL) is not None:
url = config[CONF_URL]
name = config.get(CONF_NAME)
elif discovery_info is not None:
url = discovery_in... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"config",
".",
"get",
"(",
"CONF_URL",
")",
"is",
"not",
"None",
":",
"url",
"=",
"... | [
148,
0
] | [
193,
38
] | python | en | ['en', 'da', 'en'] | True |
DlnaDmrDevice.__init__ | (self, dmr_device, name=None) | Initialize DLNA DMR device. | Initialize DLNA DMR device. | def __init__(self, dmr_device, name=None):
"""Initialize DLNA DMR device."""
self._device = dmr_device
self._name = name
self._available = False
self._subscription_renew_time = None | [
"def",
"__init__",
"(",
"self",
",",
"dmr_device",
",",
"name",
"=",
"None",
")",
":",
"self",
".",
"_device",
"=",
"dmr_device",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_available",
"=",
"False",
"self",
".",
"_subscription_renew_time",
"=",
"N... | [
199,
4
] | [
205,
44
] | python | es | ['es', 'pl', 'it'] | False |
DlnaDmrDevice.async_added_to_hass | (self) | Handle addition. | Handle addition. | async def async_added_to_hass(self):
"""Handle addition."""
self._device.on_event = self._on_event
# Register unsubscribe on stop
bus = self.hass.bus
bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_on_hass_stop) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"on_event",
"=",
"self",
".",
"_on_event",
"# Register unsubscribe on stop",
"bus",
"=",
"self",
".",
"hass",
".",
"bus",
"bus",
".",
"async_listen_once",
"(",
"EVENT_HO... | [
207,
4
] | [
213,
81
] | python | en | ['en', 'ja', 'en'] | False |
DlnaDmrDevice.available | (self) | Device is available. | Device is available. | def available(self):
"""Device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
216,
4
] | [
218,
30
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice._async_on_hass_stop | (self, event) | Event handler on Home Assistant stop. | Event handler on Home Assistant stop. | async def _async_on_hass_stop(self, event):
"""Event handler on Home Assistant stop."""
async with self.hass.data[DLNA_DMR_DATA]["lock"]:
await self._device.async_unsubscribe_services() | [
"async",
"def",
"_async_on_hass_stop",
"(",
"self",
",",
"event",
")",
":",
"async",
"with",
"self",
".",
"hass",
".",
"data",
"[",
"DLNA_DMR_DATA",
"]",
"[",
"\"lock\"",
"]",
":",
"await",
"self",
".",
"_device",
".",
"async_unsubscribe_services",
"(",
")... | [
220,
4
] | [
223,
59
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_update | (self) | Retrieve the latest data. | Retrieve the latest data. | async def async_update(self):
"""Retrieve the latest data."""
was_available = self._available
try:
await self._device.async_update()
self._available = True
except (asyncio.TimeoutError, aiohttp.ClientError):
self._available = False
_LOGGER... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"was_available",
"=",
"self",
".",
"_available",
"try",
":",
"await",
"self",
".",
"_device",
".",
"async_update",
"(",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"(",
"asyncio",
".",
"Ti... | [
225,
4
] | [
248,
56
] | python | en | ['en', 'ga', 'en'] | True |
DlnaDmrDevice._on_event | (self, service, state_variables) | State variable(s) changed, let home-assistant know. | State variable(s) changed, let home-assistant know. | def _on_event(self, service, state_variables):
"""State variable(s) changed, let home-assistant know."""
self.schedule_update_ha_state() | [
"def",
"_on_event",
"(",
"self",
",",
"service",
",",
"state_variables",
")",
":",
"self",
".",
"schedule_update_ha_state",
"(",
")"
] | [
250,
4
] | [
252,
39
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.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."""
supported_features = 0
if self._device.has_volume_level:
supported_features |= SUPPORT_VOLUME_SET
if self._device.has_volume_mute:
supported_features |= SUPPORT_VOLUME_MUTE
... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"0",
"if",
"self",
".",
"_device",
".",
"has_volume_level",
":",
"supported_features",
"|=",
"SUPPORT_VOLUME_SET",
"if",
"self",
".",
"_device",
".",
"has_volume_mute",
":",
"supported_... | [
255,
4
] | [
278,
33
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
return self._device.volume_level | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"volume_level"
] | [
281,
4
] | [
283,
40
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.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."""
await self._device.async_set_volume_level(volume) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_device",
".",
"async_set_volume_level",
"(",
"volume",
")"
] | [
286,
4
] | [
288,
57
] | python | en | ['fr', 'zu', 'en'] | False |
DlnaDmrDevice.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._device.is_volume_muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"is_volume_muted"
] | [
291,
4
] | [
293,
43
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_mute_volume | (self, mute) | Mute the volume. | Mute the volume. | async def async_mute_volume(self, mute):
"""Mute the volume."""
desired_mute = bool(mute)
await self._device.async_mute_volume(desired_mute) | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"desired_mute",
"=",
"bool",
"(",
"mute",
")",
"await",
"self",
".",
"_device",
".",
"async_mute_volume",
"(",
"desired_mute",
")"
] | [
296,
4
] | [
299,
58
] | python | en | ['en', 'sn', 'en'] | True |
DlnaDmrDevice.async_media_pause | (self) | Send pause command. | Send pause command. | async def async_media_pause(self):
"""Send pause command."""
if not self._device.can_pause:
_LOGGER.debug("Cannot do Pause")
return
await self._device.async_pause() | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_pause",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Pause\"",
")",
"return",
"await",
"self",
".",
"_device",
".",
"async_pause",
"(",
")"
] | [
302,
4
] | [
308,
40
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_media_play | (self) | Send play command. | Send play command. | async def async_media_play(self):
"""Send play command."""
if not self._device.can_play:
_LOGGER.debug("Cannot do Play")
return
await self._device.async_play() | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_play",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Play\"",
")",
"return",
"await",
"self",
".",
"_device",
".",
"async_play",
"(",
")"
] | [
311,
4
] | [
317,
39
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_media_stop | (self) | Send stop command. | Send stop command. | async def async_media_stop(self):
"""Send stop command."""
if not self._device.can_stop:
_LOGGER.debug("Cannot do Stop")
return
await self._device.async_stop() | [
"async",
"def",
"async_media_stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_stop",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Stop\"",
")",
"return",
"await",
"self",
".",
"_device",
".",
"async_stop",
"(",
")"
] | [
320,
4
] | [
326,
39
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_media_seek | (self, position) | Send seek command. | Send seek command. | async def async_media_seek(self, position):
"""Send seek command."""
if not self._device.can_seek_rel_time:
_LOGGER.debug("Cannot do Seek/rel_time")
return
time = timedelta(seconds=position)
await self._device.async_seek_rel_time(time) | [
"async",
"def",
"async_media_seek",
"(",
"self",
",",
"position",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_seek_rel_time",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Seek/rel_time\"",
")",
"return",
"time",
"=",
"timedelta",
"(",
"seconds"... | [
329,
4
] | [
336,
52
] | python | en | ['en', 'ig', 'en'] | True |
DlnaDmrDevice.async_play_media | (self, media_type, media_id, **kwargs) | Play a piece of media. | Play a piece of media. | async def async_play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
title = "Home Assistant"
mime_type = HOME_ASSISTANT_UPNP_MIME_TYPE_MAPPING.get(media_type, media_type)
upnp_class = HOME_ASSISTANT_UPNP_CLASS_MAPPING.get(
media_type, UPNP_CLASS_DEF... | [
"async",
"def",
"async_play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"title",
"=",
"\"Home Assistant\"",
"mime_type",
"=",
"HOME_ASSISTANT_UPNP_MIME_TYPE_MAPPING",
".",
"get",
"(",
"media_type",
",",
"media_type",... | [
339,
4
] | [
362,
37
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.async_media_previous_track | (self) | Send previous track command. | Send previous track command. | async def async_media_previous_track(self):
"""Send previous track command."""
if not self._device.can_previous:
_LOGGER.debug("Cannot do Previous")
return
await self._device.async_previous() | [
"async",
"def",
"async_media_previous_track",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_previous",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Previous\"",
")",
"return",
"await",
"self",
".",
"_device",
".",
"async_previous",
"... | [
365,
4
] | [
371,
43
] | python | en | ['en', 'it', 'en'] | True |
DlnaDmrDevice.async_media_next_track | (self) | Send next track command. | Send next track command. | async def async_media_next_track(self):
"""Send next track command."""
if not self._device.can_next:
_LOGGER.debug("Cannot do Next")
return
await self._device.async_next() | [
"async",
"def",
"async_media_next_track",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_device",
".",
"can_next",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Cannot do Next\"",
")",
"return",
"await",
"self",
".",
"_device",
".",
"async_next",
"(",
")"
] | [
374,
4
] | [
380,
39
] | python | en | ['en', 'pt', 'en'] | True |
DlnaDmrDevice.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
return self._device.media_title | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"media_title"
] | [
383,
4
] | [
385,
39
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.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._device.media_image_url | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"media_image_url"
] | [
388,
4
] | [
390,
43
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.state | (self) | State of the player. | State of the player. | def state(self):
"""State of the player."""
if not self._available:
return STATE_OFF
if self._device.state is None:
return STATE_ON
if self._device.state == DeviceState.PLAYING:
return STATE_PLAYING
if self._device.state == DeviceState.PAUSED:... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_available",
":",
"return",
"STATE_OFF",
"if",
"self",
".",
"_device",
".",
"state",
"is",
"None",
":",
"return",
"STATE_ON",
"if",
"self",
".",
"_device",
".",
"state",
"==",
"DeviceSta... | [
393,
4
] | [
405,
25
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.media_duration | (self) | Duration of current playing media in seconds. | Duration of current playing media in seconds. | def media_duration(self):
"""Duration of current playing media in seconds."""
return self._device.media_duration | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"media_duration"
] | [
408,
4
] | [
410,
42
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.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._device.media_position | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"media_position"
] | [
413,
4
] | [
415,
42
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.media_position_updated_at | (self) | When was the position of the current playing media valid.
Returns value from homeassistant.util.dt.utcnow().
| 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.
Returns value from homeassistant.util.dt.utcnow().
"""
return self._device.media_position_updated_at | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"media_position_updated_at"
] | [
418,
4
] | [
423,
53
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self) -> str:
"""Return the name of the device."""
if self._name:
return self._name
return self._device.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_name",
":",
"return",
"self",
".",
"_name",
"return",
"self",
".",
"_device",
".",
"name"
] | [
426,
4
] | [
430,
32
] | python | en | ['en', 'en', 'en'] | True |
DlnaDmrDevice.unique_id | (self) | Return an unique ID. | Return an unique ID. | def unique_id(self) -> str:
"""Return an unique ID."""
return self._device.udn | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"udn"
] | [
433,
4
] | [
435,
31
] | python | fr | ['fr', 'fr', 'en'] | True |
setup | (hass, config) | Create the ViCare component. | Create the ViCare component. | def setup(hass, config):
"""Create the ViCare component."""
conf = config[DOMAIN]
params = {"token_file": hass.config.path(STORAGE_DIR, "vicare_token.save")}
if conf.get(CONF_CIRCUIT) is not None:
params["circuit"] = conf[CONF_CIRCUIT]
params["cacheDuration"] = conf.get(CONF_SCAN_INTERVAL)
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"params",
"=",
"{",
"\"token_file\"",
":",
"hass",
".",
"config",
".",
"path",
"(",
"STORAGE_DIR",
",",
"\"vicare_token.save\"",
")",
"}",
"if",
"conf",
".... | [
63,
0
] | [
95,
15
] | python | en | ['en', 'en', 'en'] | True |
request_stream | (hass, stream_source, *, fmt="hls", keepalive=False, options=None) | Set up stream with token. | Set up stream with token. | def request_stream(hass, stream_source, *, fmt="hls", keepalive=False, options=None):
"""Set up stream with token."""
if DOMAIN not in hass.config.components:
raise HomeAssistantError("Stream integration is not set up.")
if options is None:
options = {}
# For RTSP streams, prefer TCP
... | [
"def",
"request_stream",
"(",
"hass",
",",
"stream_source",
",",
"*",
",",
"fmt",
"=",
"\"hls\"",
",",
"keepalive",
"=",
"False",
",",
"options",
"=",
"None",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"hass",
".",
"config",
".",
"components",
":",
"raise"... | [
43,
0
] | [
77,
65
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up stream. | Set up stream. | async def async_setup(hass, config):
"""Set up stream."""
# Set log level to error for libav
logging.getLogger("libav").setLevel(logging.ERROR)
logging.getLogger("libav.mp4").setLevel(logging.ERROR)
# Keep import here so that we can import stream integration without installing reqs
# pylint: di... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"# Set log level to error for libav",
"logging",
".",
"getLogger",
"(",
"\"libav\"",
")",
".",
"setLevel",
"(",
"logging",
".",
"ERROR",
")",
"logging",
".",
"getLogger",
"(",
"\"libav.mp4\"",
... | [
80,
0
] | [
119,
15
] | python | en | ['en', 'ky', 'en'] | True |
async_handle_record_service | (hass, call) | Handle save video service calls. | Handle save video service calls. | async def async_handle_record_service(hass, call):
"""Handle save video service calls."""
stream_source = call.data[CONF_STREAM_SOURCE]
video_path = call.data[CONF_FILENAME]
duration = call.data[CONF_DURATION]
lookback = call.data[CONF_LOOKBACK]
# Check for file access
if not hass.config.is... | [
"async",
"def",
"async_handle_record_service",
"(",
"hass",
",",
"call",
")",
":",
"stream_source",
"=",
"call",
".",
"data",
"[",
"CONF_STREAM_SOURCE",
"]",
"video_path",
"=",
"call",
".",
"data",
"[",
"CONF_FILENAME",
"]",
"duration",
"=",
"call",
".",
"da... | [
204,
0
] | [
239,
65
] | 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.