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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MediaPlayerEntity.support_stop | (self) | Boolean if stop is supported. | Boolean if stop is supported. | def support_stop(self):
"""Boolean if stop is supported."""
return bool(self.supported_features & SUPPORT_STOP) | [
"def",
"support_stop",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_STOP",
")"
] | [
685,
4
] | [
687,
59
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_seek | (self) | Boolean if seek is supported. | Boolean if seek is supported. | def support_seek(self):
"""Boolean if seek is supported."""
return bool(self.supported_features & SUPPORT_SEEK) | [
"def",
"support_seek",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_SEEK",
")"
] | [
690,
4
] | [
692,
59
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_volume_set | (self) | Boolean if setting volume is supported. | Boolean if setting volume is supported. | def support_volume_set(self):
"""Boolean if setting volume is supported."""
return bool(self.supported_features & SUPPORT_VOLUME_SET) | [
"def",
"support_volume_set",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_VOLUME_SET",
")"
] | [
695,
4
] | [
697,
65
] | python | en | ['nl', 'en', 'en'] | True |
MediaPlayerEntity.support_volume_mute | (self) | Boolean if muting volume is supported. | Boolean if muting volume is supported. | def support_volume_mute(self):
"""Boolean if muting volume is supported."""
return bool(self.supported_features & SUPPORT_VOLUME_MUTE) | [
"def",
"support_volume_mute",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_VOLUME_MUTE",
")"
] | [
700,
4
] | [
702,
66
] | python | en | ['nl', 'en', 'en'] | True |
MediaPlayerEntity.support_previous_track | (self) | Boolean if previous track command supported. | Boolean if previous track command supported. | def support_previous_track(self):
"""Boolean if previous track command supported."""
return bool(self.supported_features & SUPPORT_PREVIOUS_TRACK) | [
"def",
"support_previous_track",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_PREVIOUS_TRACK",
")"
] | [
705,
4
] | [
707,
69
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_next_track | (self) | Boolean if next track command supported. | Boolean if next track command supported. | def support_next_track(self):
"""Boolean if next track command supported."""
return bool(self.supported_features & SUPPORT_NEXT_TRACK) | [
"def",
"support_next_track",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_NEXT_TRACK",
")"
] | [
710,
4
] | [
712,
65
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_play_media | (self) | Boolean if play media command supported. | Boolean if play media command supported. | def support_play_media(self):
"""Boolean if play media command supported."""
return bool(self.supported_features & SUPPORT_PLAY_MEDIA) | [
"def",
"support_play_media",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_PLAY_MEDIA",
")"
] | [
715,
4
] | [
717,
65
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_select_source | (self) | Boolean if select source command supported. | Boolean if select source command supported. | def support_select_source(self):
"""Boolean if select source command supported."""
return bool(self.supported_features & SUPPORT_SELECT_SOURCE) | [
"def",
"support_select_source",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_SELECT_SOURCE",
")"
] | [
720,
4
] | [
722,
68
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_select_sound_mode | (self) | Boolean if select sound mode command supported. | Boolean if select sound mode command supported. | def support_select_sound_mode(self):
"""Boolean if select sound mode command supported."""
return bool(self.supported_features & SUPPORT_SELECT_SOUND_MODE) | [
"def",
"support_select_sound_mode",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_SELECT_SOUND_MODE",
")"
] | [
725,
4
] | [
727,
72
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_clear_playlist | (self) | Boolean if clear playlist command supported. | Boolean if clear playlist command supported. | def support_clear_playlist(self):
"""Boolean if clear playlist command supported."""
return bool(self.supported_features & SUPPORT_CLEAR_PLAYLIST) | [
"def",
"support_clear_playlist",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_CLEAR_PLAYLIST",
")"
] | [
730,
4
] | [
732,
69
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.support_shuffle_set | (self) | Boolean if shuffle is supported. | Boolean if shuffle is supported. | def support_shuffle_set(self):
"""Boolean if shuffle is supported."""
return bool(self.supported_features & SUPPORT_SHUFFLE_SET) | [
"def",
"support_shuffle_set",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"supported_features",
"&",
"SUPPORT_SHUFFLE_SET",
")"
] | [
735,
4
] | [
737,
66
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.async_toggle | (self) | Toggle the power on the media player. | Toggle the power on the media player. | async def async_toggle(self):
"""Toggle the power on the media player."""
if hasattr(self, "toggle"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.toggle)
return
if self.state in [STATE_OFF, STATE_IDLE]:
await self.async... | [
"async",
"def",
"async_toggle",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"toggle\"",
")",
":",
"# pylint: disable=no-member",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"toggle",
")",
"return",
"if",
"se... | [
739,
4
] | [
749,
39
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.async_volume_up | (self) | Turn volume up for media player.
This method is a coroutine.
| Turn volume up for media player. | async def async_volume_up(self):
"""Turn volume up for media player.
This method is a coroutine.
"""
if hasattr(self, "volume_up"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.volume_up)
return
if self.volume_level... | [
"async",
"def",
"async_volume_up",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"volume_up\"",
")",
":",
"# pylint: disable=no-member",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"volume_up",
")",
"return",
"i... | [
751,
4
] | [
762,
78
] | python | en | ['en', 'no', 'en'] | True |
MediaPlayerEntity.async_volume_down | (self) | Turn volume down for media player.
This method is a coroutine.
| Turn volume down for media player. | async def async_volume_down(self):
"""Turn volume down for media player.
This method is a coroutine.
"""
if hasattr(self, "volume_down"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.volume_down)
return
if self.volu... | [
"async",
"def",
"async_volume_down",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"volume_down\"",
")",
":",
"# pylint: disable=no-member",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"volume_down",
")",
"return"... | [
764,
4
] | [
775,
78
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.async_media_play_pause | (self) | Play or pause the media player. | Play or pause the media player. | async def async_media_play_pause(self):
"""Play or pause the media player."""
if hasattr(self, "media_play_pause"):
# pylint: disable=no-member
await self.hass.async_add_executor_job(self.media_play_pause)
return
if self.state == STATE_PLAYING:
aw... | [
"async",
"def",
"async_media_play_pause",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"media_play_pause\"",
")",
":",
"# pylint: disable=no-member",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"media_play_pause",
... | [
777,
4
] | [
787,
41
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.entity_picture | (self) | Return image of the media playing. | Return image of the media playing. | def entity_picture(self):
"""Return image of the media playing."""
if self.state == STATE_OFF:
return None
if self.media_image_remotely_accessible:
return self.media_image_url
return self.media_image_local | [
"def",
"entity_picture",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_OFF",
":",
"return",
"None",
"if",
"self",
".",
"media_image_remotely_accessible",
":",
"return",
"self",
".",
"media_image_url",
"return",
"self",
".",
"media_image_local"
... | [
790,
4
] | [
798,
37
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.media_image_local | (self) | Return local url to media image. | Return local url to media image. | def media_image_local(self):
"""Return local url to media image."""
image_hash = self.media_image_hash
if image_hash is None:
return None
return (
f"/api/media_player_proxy/{self.entity_id}?"
f"token={self.access_token}&cache={image_hash}"
) | [
"def",
"media_image_local",
"(",
"self",
")",
":",
"image_hash",
"=",
"self",
".",
"media_image_hash",
"if",
"image_hash",
"is",
"None",
":",
"return",
"None",
"return",
"(",
"f\"/api/media_player_proxy/{self.entity_id}?\"",
"f\"token={self.access_token}&cache={image_hash}\... | [
801,
4
] | [
811,
9
] | python | en | ['en', 'la', 'en'] | True |
MediaPlayerEntity.capability_attributes | (self) | Return capability attributes. | Return capability attributes. | def capability_attributes(self):
"""Return capability attributes."""
supported_features = self.supported_features or 0
data = {}
if supported_features & SUPPORT_SELECT_SOURCE:
source_list = self.source_list
if source_list:
data[ATTR_INPUT_SOURCE_L... | [
"def",
"capability_attributes",
"(",
"self",
")",
":",
"supported_features",
"=",
"self",
".",
"supported_features",
"or",
"0",
"data",
"=",
"{",
"}",
"if",
"supported_features",
"&",
"SUPPORT_SELECT_SOURCE",
":",
"source_list",
"=",
"self",
".",
"source_list",
... | [
814,
4
] | [
829,
19
] | python | en | ['en', 'la', 'en'] | True |
MediaPlayerEntity.state_attributes | (self) | Return the state attributes. | Return the state attributes. | def state_attributes(self):
"""Return the state attributes."""
if self.state == STATE_OFF:
return None
state_attr = {}
for attr in ATTR_TO_PROPERTY:
value = getattr(self, attr)
if value is not None:
state_attr[attr] = value
i... | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_OFF",
":",
"return",
"None",
"state_attr",
"=",
"{",
"}",
"for",
"attr",
"in",
"ATTR_TO_PROPERTY",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"... | [
832,
4
] | [
847,
25
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerEntity.async_browse_media | (
self,
media_content_type: Optional[str] = None,
media_content_id: Optional[str] = None,
) | Return a BrowseMedia instance.
The BrowseMedia instance will be used by the
"media_player/browse_media" websocket command.
| Return a BrowseMedia instance. | async def async_browse_media(
self,
media_content_type: Optional[str] = None,
media_content_id: Optional[str] = None,
) -> "BrowseMedia":
"""Return a BrowseMedia instance.
The BrowseMedia instance will be used by the
"media_player/browse_media" websocket command.
... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"media_content_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"\"BrowseMedia\"",
":",
"raise",
"NotImplemen... | [
849,
4
] | [
859,
35
] | python | en | ['en', 'co', 'en'] | True |
MediaPlayerEntity._async_fetch_image_from_cache | (self, url) | Fetch image.
Images are cached in memory (the images are typically 10-100kB in size).
| Fetch image. | async def _async_fetch_image_from_cache(self, url):
"""Fetch image.
Images are cached in memory (the images are typically 10-100kB in size).
"""
cache_images = ENTITY_IMAGE_CACHE[CACHE_IMAGES]
cache_maxsize = ENTITY_IMAGE_CACHE[CACHE_MAXSIZE]
if urlparse(url).hostname i... | [
"async",
"def",
"_async_fetch_image_from_cache",
"(",
"self",
",",
"url",
")",
":",
"cache_images",
"=",
"ENTITY_IMAGE_CACHE",
"[",
"CACHE_IMAGES",
"]",
"cache_maxsize",
"=",
"ENTITY_IMAGE_CACHE",
"[",
"CACHE_MAXSIZE",
"]",
"if",
"urlparse",
"(",
"url",
")",
".",
... | [
861,
4
] | [
886,
36
] | python | en | ['en', 'zu', 'en'] | False |
MediaPlayerEntity._async_fetch_image | (self, url) | Retrieve an image. | Retrieve an image. | async def _async_fetch_image(self, url):
"""Retrieve an image."""
content, content_type = (None, None)
websession = async_get_clientsession(self.hass)
try:
with async_timeout.timeout(10):
response = await websession.get(url)
if response.status... | [
"async",
"def",
"_async_fetch_image",
"(",
"self",
",",
"url",
")",
":",
"content",
",",
"content_type",
"=",
"(",
"None",
",",
"None",
")",
"websession",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"try",
":",
"with",
"async_timeout",
"... | [
888,
4
] | [
908,
36
] | python | en | ['en', 'ga', 'en'] | True |
MediaPlayerEntity.get_browse_image_url | (
self,
media_content_type: str,
media_content_id: str,
media_image_id: Optional[str] = None,
) | Generate an url for a media browser image. | Generate an url for a media browser image. | def get_browse_image_url(
self,
media_content_type: str,
media_content_id: str,
media_image_id: Optional[str] = None,
) -> str:
"""Generate an url for a media browser image."""
url_path = (
f"/api/media_player_proxy/{self.entity_id}/browse_media"
... | [
"def",
"get_browse_image_url",
"(",
"self",
",",
"media_content_type",
":",
"str",
",",
"media_content_id",
":",
"str",
",",
"media_image_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"str",
":",
"url_path",
"=",
"(",
"f\"/api/media_pla... | [
910,
4
] | [
926,
55
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerImageView.__init__ | (self, component) | Initialize a media player view. | Initialize a media player view. | def __init__(self, component):
"""Initialize a media player view."""
self.component = component | [
"def",
"__init__",
"(",
"self",
",",
"component",
")",
":",
"self",
".",
"component",
"=",
"component"
] | [
939,
4
] | [
941,
34
] | python | en | ['en', 'en', 'en'] | True |
MediaPlayerImageView.get | (
self,
request: web.Request,
entity_id: str,
media_content_type: Optional[str] = None,
media_content_id: Optional[str] = None,
) | Start a get request. | Start a get request. | async def get(
self,
request: web.Request,
entity_id: str,
media_content_type: Optional[str] = None,
media_content_id: Optional[str] = None,
) -> web.Response:
"""Start a get request."""
player = self.component.get_entity(entity_id)
if player is None:
... | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
",",
"entity_id",
":",
"str",
",",
"media_content_type",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"media_content_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"Non... | [
943,
4
] | [
976,
82
] | python | en | ['en', 'lb', 'en'] | True |
MediaPlayerDevice.__init_subclass__ | (cls, **kwargs) | Print deprecation warning. | Print deprecation warning. | def __init_subclass__(cls, **kwargs):
"""Print deprecation warning."""
super().__init_subclass__(**kwargs)
_LOGGER.warning(
"MediaPlayerDevice is deprecated, modify %s to extend MediaPlayerEntity",
cls.__name__,
) | [
"def",
"__init_subclass__",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init_subclass__",
"(",
"*",
"*",
"kwargs",
")",
"_LOGGER",
".",
"warning",
"(",
"\"MediaPlayerDevice is deprecated, modify %s to extend MediaPlayerEntity\"",
",",
... | [
1098,
4
] | [
1104,
9
] | python | de | ['de', 'sv', 'en'] | False |
BrowseMedia.__init__ | (
self,
*,
media_class: str,
media_content_id: str,
media_content_type: str,
title: str,
can_play: bool,
can_expand: bool,
children: Optional[List["BrowseMedia"]] = None,
children_media_class: Optional[str] = None,
thumbnail: Option... | Initialize browse media item. | Initialize browse media item. | def __init__(
self,
*,
media_class: str,
media_content_id: str,
media_content_type: str,
title: str,
can_play: bool,
can_expand: bool,
children: Optional[List["BrowseMedia"]] = None,
children_media_class: Optional[str] = None,
thumb... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"media_class",
":",
"str",
",",
"media_content_id",
":",
"str",
",",
"media_content_type",
":",
"str",
",",
"title",
":",
"str",
",",
"can_play",
":",
"bool",
",",
"can_expand",
":",
"bool",
",",
"children",... | [
1110,
4
] | [
1132,
34
] | python | en | ['en', 'en', 'en'] | True |
BrowseMedia.as_dict | (self, *, parent: bool = True) | Convert Media class to browse media dictionary. | Convert Media class to browse media dictionary. | def as_dict(self, *, parent: bool = True) -> dict:
"""Convert Media class to browse media dictionary."""
if self.children_media_class is None:
self.calculate_children_class()
response = {
"title": self.title,
"media_class": self.media_class,
"medi... | [
"def",
"as_dict",
"(",
"self",
",",
"*",
",",
"parent",
":",
"bool",
"=",
"True",
")",
"->",
"dict",
":",
"if",
"self",
".",
"children_media_class",
"is",
"None",
":",
"self",
".",
"calculate_children_class",
"(",
")",
"response",
"=",
"{",
"\"title\"",
... | [
1134,
4
] | [
1160,
23
] | python | it | ['it', 'en', 'it'] | True |
BrowseMedia.calculate_children_class | (self) | Count the children media classes and calculate the correct class. | Count the children media classes and calculate the correct class. | def calculate_children_class(self) -> None:
"""Count the children media classes and calculate the correct class."""
if self.children is None or len(self.children) == 0:
return
self.children_media_class = MEDIA_CLASS_DIRECTORY
proposed_class = self.children[0].media_class
... | [
"def",
"calculate_children_class",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"children",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"children",
")",
"==",
"0",
":",
"return",
"self",
".",
"children_media_class",
"=",
"MEDIA_CLASS_DIRECTORY",
... | [
1162,
4
] | [
1171,
54
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a sensor for a raincloud device. | Set up a sensor for a raincloud device. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a sensor for a raincloud device."""
raincloud = hass.data[DATA_RAINCLOUD].data
default_watering_timer = config.get(CONF_WATERING_TIME)
sensors = []
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
# crea... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"raincloud",
"=",
"hass",
".",
"data",
"[",
"DATA_RAINCLOUD",
"]",
".",
"data",
"default_watering_timer",
"=",
"config",
".",
"get",
"(",
... | [
33,
0
] | [
44,
31
] | python | en | ['en', 'ca', 'en'] | True |
RainCloudSwitch.__init__ | (self, default_watering_timer, *args) | Initialize a switch for raincloud device. | Initialize a switch for raincloud device. | def __init__(self, default_watering_timer, *args):
"""Initialize a switch for raincloud device."""
super().__init__(*args)
self._default_watering_timer = default_watering_timer | [
"def",
"__init__",
"(",
"self",
",",
"default_watering_timer",
",",
"*",
"args",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
")",
"self",
".",
"_default_watering_timer",
"=",
"default_watering_timer"
] | [
50,
4
] | [
53,
61
] | python | en | ['en', 'en', 'en'] | True |
RainCloudSwitch.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 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
56,
4
] | [
58,
26
] | python | en | ['en', 'fy', 'en'] | True |
RainCloudSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
if self._sensor_type == "manual_watering":
self.data.watering_time = self._default_watering_timer
elif self._sensor_type == "auto_watering":
self.data.auto_watering = True
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_sensor_type",
"==",
"\"manual_watering\"",
":",
"self",
".",
"data",
".",
"watering_time",
"=",
"self",
".",
"_default_watering_timer",
"elif",
"self",
".",
"_sensor_type"... | [
60,
4
] | [
66,
26
] | python | en | ['en', 'en', 'en'] | True |
RainCloudSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
if self._sensor_type == "manual_watering":
self.data.watering_time = "off"
elif self._sensor_type == "auto_watering":
self.data.auto_watering = False
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_sensor_type",
"==",
"\"manual_watering\"",
":",
"self",
".",
"data",
".",
"watering_time",
"=",
"\"off\"",
"elif",
"self",
".",
"_sensor_type",
"==",
"\"auto_watering\"",... | [
68,
4
] | [
74,
27
] | python | en | ['en', 'en', 'en'] | True |
RainCloudSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
_LOGGER.debug("Updating RainCloud switch: %s", self._name)
if self._sensor_type == "manual_watering":
self._state = bool(self.data.watering_time)
elif self._sensor_type == "auto_watering":
self._state = self.data.auto_w... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating RainCloud switch: %s\"",
",",
"self",
".",
"_name",
")",
"if",
"self",
".",
"_sensor_type",
"==",
"\"manual_watering\"",
":",
"self",
".",
"_state",
"=",
"bool",
"(",
"self",
... | [
76,
4
] | [
82,
49
] | python | en | ['fr', 'en', 'en'] | True |
RainCloudSwitch.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,
"default_manual_timer": self._default_watering_timer,
"identifier": self.data.serial,
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"\"default_manual_timer\"",
":",
"self",
".",
"_default_watering_timer",
",",
"\"identifier\"",
":",
"self",
".",
"data",
".",
"serial",
",",
"}"
] | [
85,
4
] | [
91,
9
] | python | en | ['en', 'en', 'en'] | True |
load_json | (path) | Loads the given JSON file. | Loads the given JSON file. | def load_json(path):
"""Loads the given JSON file."""
with open(path, 'r') as f:
return json.load(f) | [
"def",
"load_json",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
")"
] | [
26,
0
] | [
29,
27
] | python | en | ['en', 'en', 'en'] | True |
nix_prefetch_url | (url, algo='sha256') | Prefetches the content of the given URL. | Prefetches the content of the given URL. | def nix_prefetch_url(url, algo='sha256'):
"""Prefetches the content of the given URL."""
print(f'nix-prefetch-url {url}')
out = subprocess.check_output(['nix-prefetch-url', '--type', algo, url])
return out.decode('utf-8').rstrip() | [
"def",
"nix_prefetch_url",
"(",
"url",
",",
"algo",
"=",
"'sha256'",
")",
":",
"print",
"(",
"f'nix-prefetch-url {url}'",
")",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'nix-prefetch-url'",
",",
"'--type'",
",",
"algo",
",",
"url",
"]",
")",
... | [
32,
0
] | [
36,
39
] | python | en | ['en', 'en', 'en'] | True |
nix_prefetch_git | (url, rev) | Prefetches the requested Git revision of the given repository URL. | Prefetches the requested Git revision of the given repository URL. | def nix_prefetch_git(url, rev):
"""Prefetches the requested Git revision of the given repository URL."""
print(f'nix-prefetch-git {url} {rev}')
out = subprocess.check_output(['nix-prefetch-git', '--quiet', '--url', url, '--rev', rev])
return json.loads(out) | [
"def",
"nix_prefetch_git",
"(",
"url",
",",
"rev",
")",
":",
"print",
"(",
"f'nix-prefetch-git {url} {rev}'",
")",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'nix-prefetch-git'",
",",
"'--quiet'",
",",
"'--url'",
",",
"url",
",",
"'--rev'",
",",... | [
39,
0
] | [
43,
26
] | python | en | ['en', 'en', 'en'] | True |
get_file_revision | (revision, file_path) | Fetches the requested Git revision of the given Chromium file. | Fetches the requested Git revision of the given Chromium file. | def get_file_revision(revision, file_path):
"""Fetches the requested Git revision of the given Chromium file."""
url = f'https://raw.githubusercontent.com/chromium/chromium/{revision}/{file_path}'
with urlopen(url) as http_response:
return http_response.read() | [
"def",
"get_file_revision",
"(",
"revision",
",",
"file_path",
")",
":",
"url",
"=",
"f'https://raw.githubusercontent.com/chromium/chromium/{revision}/{file_path}'",
"with",
"urlopen",
"(",
"url",
")",
"as",
"http_response",
":",
"return",
"http_response",
".",
"read",
... | [
46,
0
] | [
50,
35
] | python | en | ['en', 'en', 'en'] | True |
get_matching_chromedriver | (version) | Gets the matching chromedriver version for the given Chromium version. | Gets the matching chromedriver version for the given Chromium version. | def get_matching_chromedriver(version):
"""Gets the matching chromedriver version for the given Chromium version."""
# See https://chromedriver.chromium.org/downloads/version-selection
build = re.sub('.[0-9]+$', '', version)
chromedriver_version_url = f'https://chromedriver.storage.googleapis.com/LATEST... | [
"def",
"get_matching_chromedriver",
"(",
"version",
")",
":",
"# See https://chromedriver.chromium.org/downloads/version-selection",
"build",
"=",
"re",
".",
"sub",
"(",
"'.[0-9]+$'",
",",
"''",
",",
"version",
")",
"chromedriver_version_url",
"=",
"f'https://chromedriver.s... | [
53,
0
] | [
67,
9
] | python | en | ['en', 'en', 'en'] | True |
get_channel_dependencies | (version) | Gets all dependencies for the given Chromium version. | Gets all dependencies for the given Chromium version. | def get_channel_dependencies(version):
"""Gets all dependencies for the given Chromium version."""
deps = get_file_revision(version, 'DEPS')
gn_pattern = b"'gn_version': 'git_revision:([0-9a-f]{40})'"
gn_commit = re.search(gn_pattern, deps).group(1).decode()
gn = nix_prefetch_git('https://gn.googles... | [
"def",
"get_channel_dependencies",
"(",
"version",
")",
":",
"deps",
"=",
"get_file_revision",
"(",
"version",
",",
"'DEPS'",
")",
"gn_pattern",
"=",
"b\"'gn_version': 'git_revision:([0-9a-f]{40})'\"",
"gn_commit",
"=",
"re",
".",
"search",
"(",
"gn_pattern",
",",
"... | [
70,
0
] | [
83,
5
] | python | en | ['en', 'en', 'en'] | True |
get_latest_ungoogled_chromium_tag | () | Returns the latest ungoogled-chromium tag using the GitHub API. | Returns the latest ungoogled-chromium tag using the GitHub API. | def get_latest_ungoogled_chromium_tag():
"""Returns the latest ungoogled-chromium tag using the GitHub API."""
api_tag_url = 'https://api.github.com/repos/Eloston/ungoogled-chromium/tags?per_page=1'
with urlopen(api_tag_url) as http_response:
tag_data = json.load(http_response)
return tag_da... | [
"def",
"get_latest_ungoogled_chromium_tag",
"(",
")",
":",
"api_tag_url",
"=",
"'https://api.github.com/repos/Eloston/ungoogled-chromium/tags?per_page=1'",
"with",
"urlopen",
"(",
"api_tag_url",
")",
"as",
"http_response",
":",
"tag_data",
"=",
"json",
".",
"load",
"(",
"... | [
86,
0
] | [
91,
34
] | python | en | ['en', 'zu', 'en'] | True |
get_latest_ungoogled_chromium_build | () | Returns a dictionary for the latest ungoogled-chromium build. | Returns a dictionary for the latest ungoogled-chromium build. | def get_latest_ungoogled_chromium_build():
"""Returns a dictionary for the latest ungoogled-chromium build."""
tag = get_latest_ungoogled_chromium_tag()
version = tag.split('-')[0]
return {
'channel': 'ungoogled-chromium',
'version': version,
'ungoogled_tag': tag
} | [
"def",
"get_latest_ungoogled_chromium_build",
"(",
")",
":",
"tag",
"=",
"get_latest_ungoogled_chromium_tag",
"(",
")",
"version",
"=",
"tag",
".",
"split",
"(",
"'-'",
")",
"[",
"0",
"]",
"return",
"{",
"'channel'",
":",
"'ungoogled-chromium'",
",",
"'version'"... | [
94,
0
] | [
102,
5
] | python | en | ['en', 'en', 'en'] | True |
channel_name_to_attr_name | (channel_name) | Maps a channel name to the corresponding main Nixpkgs attribute name. | Maps a channel name to the corresponding main Nixpkgs attribute name. | def channel_name_to_attr_name(channel_name):
"""Maps a channel name to the corresponding main Nixpkgs attribute name."""
if channel_name == 'stable':
return 'chromium'
if channel_name == 'beta':
return 'chromiumBeta'
if channel_name == 'dev':
return 'chromiumDev'
if channel_n... | [
"def",
"channel_name_to_attr_name",
"(",
"channel_name",
")",
":",
"if",
"channel_name",
"==",
"'stable'",
":",
"return",
"'chromium'",
"if",
"channel_name",
"==",
"'beta'",
":",
"return",
"'chromiumBeta'",
"if",
"channel_name",
"==",
"'dev'",
":",
"return",
"'chr... | [
105,
0
] | [
116,
15
] | python | en | ['en', 'en', 'en'] | True |
print_updates | (channels_old, channels_new) | Print a summary of the updates. | Print a summary of the updates. | def print_updates(channels_old, channels_new):
"""Print a summary of the updates."""
print('Updates:')
for channel_name in channels_old:
version_old = channels_old[channel_name]["version"]
version_new = channels_new[channel_name]["version"]
if LooseVersion(version_old) < LooseVersion... | [
"def",
"print_updates",
"(",
"channels_old",
",",
"channels_new",
")",
":",
"print",
"(",
"'Updates:'",
")",
"for",
"channel_name",
"in",
"channels_old",
":",
"version_old",
"=",
"channels_old",
"[",
"channel_name",
"]",
"[",
"\"version\"",
"]",
"version_new",
"... | [
119,
0
] | [
127,
67
] | python | en | ['en', 'en', 'en'] | True |
_obj_to_dict | (obj) | Convert an object into a hash for debug. | Convert an object into a hash for debug. | def _obj_to_dict(obj):
"""Convert an object into a hash for debug."""
return {
key: getattr(obj, key)
for key in dir(obj)
if key[0] != "_" and not callable(getattr(obj, key))
} | [
"def",
"_obj_to_dict",
"(",
"obj",
")",
":",
"return",
"{",
"key",
":",
"getattr",
"(",
"obj",
",",
"key",
")",
"for",
"key",
"in",
"dir",
"(",
"obj",
")",
"if",
"key",
"[",
"0",
"]",
"!=",
"\"_\"",
"and",
"not",
"callable",
"(",
"getattr",
"(",
... | [
252,
0
] | [
258,
5
] | python | en | ['en', 'en', 'en'] | True |
_value_name | (value) | Return the name of the value. | Return the name of the value. | def _value_name(value):
"""Return the name of the value."""
return f"{node_name(value.node)} {value.label}".strip() | [
"def",
"_value_name",
"(",
"value",
")",
":",
"return",
"f\"{node_name(value.node)} {value.label}\"",
".",
"strip",
"(",
")"
] | [
261,
0
] | [
263,
59
] | python | en | ['en', 'en', 'en'] | True |
nice_print_node | (node) | Print a nice formatted node to the output (debug method). | Print a nice formatted node to the output (debug method). | def nice_print_node(node):
"""Print a nice formatted node to the output (debug method)."""
node_dict = _obj_to_dict(node)
node_dict["values"] = {
value_id: _obj_to_dict(value) for value_id, value in node.values.items()
}
_LOGGER.info("FOUND NODE %s \n%s", node.product_name, node_dict) | [
"def",
"nice_print_node",
"(",
"node",
")",
":",
"node_dict",
"=",
"_obj_to_dict",
"(",
"node",
")",
"node_dict",
"[",
"\"values\"",
"]",
"=",
"{",
"value_id",
":",
"_obj_to_dict",
"(",
"value",
")",
"for",
"value_id",
",",
"value",
"in",
"node",
".",
"v... | [
266,
0
] | [
273,
68
] | python | en | ['en', 'en', 'en'] | True |
get_config_value | (node, value_index, tries=5) | Return the current configuration value for a specific index. | Return the current configuration value for a specific index. | def get_config_value(node, value_index, tries=5):
"""Return the current configuration value for a specific index."""
try:
for value in node.values.values():
if (
value.command_class == const.COMMAND_CLASS_CONFIGURATION
and value.index == value_index
... | [
"def",
"get_config_value",
"(",
"node",
",",
"value_index",
",",
"tries",
"=",
"5",
")",
":",
"try",
":",
"for",
"value",
"in",
"node",
".",
"values",
".",
"values",
"(",
")",
":",
"if",
"(",
"value",
".",
"command_class",
"==",
"const",
".",
"COMMAN... | [
276,
0
] | [
291,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Z-Wave platform (generic part). | Set up the Z-Wave platform (generic part). | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Z-Wave platform (generic part)."""
if discovery_info is None or DATA_NETWORK not in hass.data:
return False
device = hass.data[DATA_DEVICES].get(discovery_info[const.DISCOVERY_DEVICE])
if device... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
"or",
"DATA_NETWORK",
"not",
"in",
"hass",
".",
"data",
":",
"return",
"False",
... | [
294,
0
] | [
304,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup | (hass, config) | Set up Z-Wave components. | Set up Z-Wave components. | async def async_setup(hass, config):
"""Set up Z-Wave components."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
hass.data[DATA_ZWAVE_CONFIG] = conf
if not hass.config_entries.async_entries(DOMAIN):
hass.async_create_task(
hass.config_entries.flow.async_i... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"hass",
".",
"data",
"[",
"DATA_ZWAVE_CONFIG",
"]",
"=",
"conf",
"if",
"not",
... | [
307,
0
] | [
329,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up Z-Wave from a config entry.
Will automatically load components to support devices found on the network.
| Set up Z-Wave from a config entry. | async def async_setup_entry(hass, config_entry):
"""Set up Z-Wave from a config entry.
Will automatically load components to support devices found on the network.
"""
# pylint: disable=import-error
from openzwave.group import ZWaveGroup
from openzwave.network import ZWaveNetwork
from openzw... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"# pylint: disable=import-error",
"from",
"openzwave",
".",
"group",
"import",
"ZWaveGroup",
"from",
"openzwave",
".",
"network",
"import",
"ZWaveNetwork",
"from",
"openzwave",
".",
"op... | [
332,
0
] | [
1001,
15
] | python | en | ['en', 'en', 'en'] | True |
compute_value_unique_id | (node, value) | Compute unique_id a value would get if it were to get one. | Compute unique_id a value would get if it were to get one. | def compute_value_unique_id(node, value):
"""Compute unique_id a value would get if it were to get one."""
return f"{node.node_id}-{value.object_id}" | [
"def",
"compute_value_unique_id",
"(",
"node",
",",
"value",
")",
":",
"return",
"f\"{node.node_id}-{value.object_id}\""
] | [
1326,
0
] | [
1328,
46
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntityValues.__init__ | (
self, hass, schema, primary_value, zwave_config, device_config, registry
) | Initialize the values object with the passed entity schema. | Initialize the values object with the passed entity schema. | def __init__(
self, hass, schema, primary_value, zwave_config, device_config, registry
):
"""Initialize the values object with the passed entity schema."""
self._hass = hass
self._zwave_config = zwave_config
self._device_config = device_config
self._schema = copy.deep... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"schema",
",",
"primary_value",
",",
"zwave_config",
",",
"device_config",
",",
"registry",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_zwave_config",
"=",
"zwave_config",
"self",
".",
"_dev... | [
1007,
4
] | [
1034,
34
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntityValues.__getattr__ | (self, name) | Get the specified value for this entity. | Get the specified value for this entity. | def __getattr__(self, name):
"""Get the specified value for this entity."""
return self._values[name] | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_values",
"[",
"name",
"]"
] | [
1036,
4
] | [
1038,
33
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntityValues.__iter__ | (self) | Allow iteration over all values. | Allow iteration over all values. | def __iter__(self):
"""Allow iteration over all values."""
return iter(self._values.values()) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"_values",
".",
"values",
"(",
")",
")"
] | [
1040,
4
] | [
1042,
42
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntityValues.check_value | (self, value) | Check if the new value matches a missing value for this entity.
If a match is found, it is added to the values mapping.
| Check if the new value matches a missing value for this entity. | def check_value(self, value):
"""Check if the new value matches a missing value for this entity.
If a match is found, it is added to the values mapping.
"""
if not check_node_schema(value.node, self._schema):
return
for name in self._values:
if self._valu... | [
"def",
"check_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"check_node_schema",
"(",
"value",
".",
"node",
",",
"self",
".",
"_schema",
")",
":",
"return",
"for",
"name",
"in",
"self",
".",
"_values",
":",
"if",
"self",
".",
"_values",
"... | [
1044,
4
] | [
1061,
38
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntityValues._check_entity_ready | (self) | Check if all required values are discovered and create entity. | Check if all required values are discovered and create entity. | def _check_entity_ready(self):
"""Check if all required values are discovered and create entity."""
if self._workaround_ignore:
return
if self._entity is not None:
return
for name in self._schema[const.DISC_VALUES]:
if self._values[name] is None and n... | [
"def",
"_check_entity_ready",
"(",
"self",
")",
":",
"if",
"self",
".",
"_workaround_ignore",
":",
"return",
"if",
"self",
".",
"_entity",
"is",
"not",
"None",
":",
"return",
"for",
"name",
"in",
"self",
".",
"_schema",
"[",
"const",
".",
"DISC_VALUES",
... | [
1063,
4
] | [
1178,
83
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.__init__ | (self, values, domain) | Initialize the z-Wave device. | Initialize the z-Wave device. | def __init__(self, values, domain):
"""Initialize the z-Wave device."""
# pylint: disable=import-error
super().__init__()
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
self.values = values
self.node = values.primary.node
sel... | [
"def",
"__init__",
"(",
"self",
",",
"values",
",",
"domain",
")",
":",
"# pylint: disable=import-error",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"from",
"openzwave",
".",
"network",
"import",
"ZWaveNetwork",
"from",
"pydispatch",
"import",
"dispatcher",
... | [
1184,
4
] | [
1201,
9
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.network_value_changed | (self, value) | Handle a value change on the network. | Handle a value change on the network. | def network_value_changed(self, value):
"""Handle a value change on the network."""
if value.value_id in [v.value_id for v in self.values if v]:
return self.value_changed() | [
"def",
"network_value_changed",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
".",
"value_id",
"in",
"[",
"v",
".",
"value_id",
"for",
"v",
"in",
"self",
".",
"values",
"if",
"v",
"]",
":",
"return",
"self",
".",
"value_changed",
"(",
")"
] | [
1203,
4
] | [
1206,
39
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.value_added | (self) | Handle a new value of this entity. | Handle a new value of this entity. | def value_added(self):
"""Handle a new value of this entity.""" | [
"def",
"value_added",
"(",
"self",
")",
":"
] | [
1208,
4
] | [
1209,
48
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.value_changed | (self) | Handle a changed value for this entity's node. | Handle a changed value for this entity's node. | def value_changed(self):
"""Handle a changed value for this entity's node."""
self._update_attributes()
self.update_properties()
self.maybe_schedule_update() | [
"def",
"value_changed",
"(",
"self",
")",
":",
"self",
".",
"_update_attributes",
"(",
")",
"self",
".",
"update_properties",
"(",
")",
"self",
".",
"maybe_schedule_update",
"(",
")"
] | [
1211,
4
] | [
1215,
36
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.value_renamed | (self, update_ids=False) | Rename the node and update any IDs. | Rename the node and update any IDs. | async def value_renamed(self, update_ids=False):
"""Rename the node and update any IDs."""
self._name = _value_name(self.values.primary)
if update_ids:
# Update entity ID.
ent_reg = await async_get_entity_registry(self.hass)
new_entity_id = ent_reg.async_gener... | [
"async",
"def",
"value_renamed",
"(",
"self",
",",
"update_ids",
"=",
"False",
")",
":",
"self",
".",
"_name",
"=",
"_value_name",
"(",
"self",
".",
"values",
".",
"primary",
")",
"if",
"update_ids",
":",
"# Update entity ID.",
"ent_reg",
"=",
"await",
"as... | [
1217,
4
] | [
1235,
35
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.async_added_to_hass | (self) | Add device to dict. | Add device to dict. | async def async_added_to_hass(self):
"""Add device to dict."""
async_dispatcher_connect(
self.hass,
SIGNAL_REFRESH_ENTITY_FORMAT.format(self.entity_id),
self.refresh_from_network,
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_REFRESH_ENTITY_FORMAT",
".",
"format",
"(",
"self",
".",
"entity_id",
")",
",",
"self",
".",
"refresh_from_network",
",",
")"
] | [
1237,
4
] | [
1243,
9
] | python | en | ['it', 'en', 'en'] | True |
ZWaveDeviceEntity._update_attributes | (self) | Update the node attributes. May only be used inside callback. | Update the node attributes. May only be used inside callback. | def _update_attributes(self):
"""Update the node attributes. May only be used inside callback."""
self.node_id = self.node.node_id
self._name = _value_name(self.values.primary)
if not self._unique_id:
self._unique_id = self._compute_unique_id()
if self._unique_id:... | [
"def",
"_update_attributes",
"(",
"self",
")",
":",
"self",
".",
"node_id",
"=",
"self",
".",
"node",
".",
"node_id",
"self",
".",
"_name",
"=",
"_value_name",
"(",
"self",
".",
"values",
".",
"primary",
")",
"if",
"not",
"self",
".",
"_unique_id",
":"... | [
1245,
4
] | [
1259,
41
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.update_properties | (self) | Update on data changes for node values. | Update on data changes for node values. | def update_properties(self):
"""Update on data changes for node values.""" | [
"def",
"update_properties",
"(",
"self",
")",
":"
] | [
1261,
4
] | [
1262,
53
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
1265,
4
] | [
1267,
20
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
1270,
4
] | [
1272,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
ZWaveDeviceEntity.device_info | (self) | Return device information. | Return device information. | def device_info(self):
"""Return device information."""
identifier, name = node_device_id_and_name(
self.node, self.values.primary.instance
)
info = {
"name": name,
"identifiers": {identifier},
"manufacturer": self.node.manufacturer_name,
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"identifier",
",",
"name",
"=",
"node_device_id_and_name",
"(",
"self",
".",
"node",
",",
"self",
".",
"values",
".",
"primary",
".",
"instance",
")",
"info",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"identif... | [
1275,
4
] | [
1290,
19
] | python | da | ['es', 'da', 'en'] | False |
ZWaveDeviceEntity.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"
] | [
1293,
4
] | [
1295,
25
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.device_state_attributes | (self) | Return the device specific state attributes. | Return the device specific state attributes. | def device_state_attributes(self):
"""Return the device specific state attributes."""
attrs = {
const.ATTR_NODE_ID: self.node_id,
const.ATTR_VALUE_INDEX: self.values.primary.index,
const.ATTR_VALUE_INSTANCE: self.values.primary.instance,
const.ATTR_VALUE_I... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"const",
".",
"ATTR_NODE_ID",
":",
"self",
".",
"node_id",
",",
"const",
".",
"ATTR_VALUE_INDEX",
":",
"self",
".",
"values",
".",
"primary",
".",
"index",
",",
"const",
".",
"AT... | [
1298,
4
] | [
1310,
20
] | python | en | ['en', 'en', 'en'] | True |
ZWaveDeviceEntity.refresh_from_network | (self) | Refresh all dependent values from zwave network. | Refresh all dependent values from zwave network. | def refresh_from_network(self):
"""Refresh all dependent values from zwave network."""
for value in self.values:
if value is not None:
self.node.refresh_value(value.value_id) | [
"def",
"refresh_from_network",
"(",
"self",
")",
":",
"for",
"value",
"in",
"self",
".",
"values",
":",
"if",
"value",
"is",
"not",
"None",
":",
"self",
".",
"node",
".",
"refresh_value",
"(",
"value",
".",
"value_id",
")"
] | [
1312,
4
] | [
1316,
55
] | python | en | ['en', 'en', 'en'] | True |
async_get_scanner | (hass, config) | Return the UPC device scanner. | Return the UPC device scanner. | async def async_get_scanner(hass, config):
"""Return the UPC device scanner."""
conf = config[DOMAIN]
session = hass.helpers.aiohttp_client.async_get_clientsession()
connect_box = ConnectBox(session, conf[CONF_PASSWORD], host=conf[CONF_HOST])
# Check login data
try:
await connect_box.as... | [
"async",
"def",
"async_get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"session",
"=",
"hass",
".",
"helpers",
".",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
")",
"connect_box",
"=",
"ConnectBox",
"... | [
28,
0
] | [
49,
40
] | python | en | ['en', 'no', 'en'] | True |
UPCDeviceScanner.__init__ | (self, connect_box: ConnectBox) | Initialize the scanner. | Initialize the scanner. | def __init__(self, connect_box: ConnectBox):
"""Initialize the scanner."""
self.connect_box: ConnectBox = connect_box | [
"def",
"__init__",
"(",
"self",
",",
"connect_box",
":",
"ConnectBox",
")",
":",
"self",
".",
"connect_box",
":",
"ConnectBox",
"=",
"connect_box"
] | [
55,
4
] | [
57,
50
] | python | en | ['en', 'en', 'en'] | True |
UPCDeviceScanner.async_scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | async def async_scan_devices(self) -> List[str]:
"""Scan for new devices and return a list with found device IDs."""
try:
await self.connect_box.async_get_devices()
except ConnectBoxError:
return []
return [device.mac for device in self.connect_box.devices] | [
"async",
"def",
"async_scan_devices",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"try",
":",
"await",
"self",
".",
"connect_box",
".",
"async_get_devices",
"(",
")",
"except",
"ConnectBoxError",
":",
"return",
"[",
"]",
"return",
"[",
"device",
... | [
59,
4
] | [
66,
66
] | python | en | ['en', 'en', 'en'] | True |
UPCDeviceScanner.async_get_device_name | (self, device: str) | Get the device name (the name of the wireless device not used). | Get the device name (the name of the wireless device not used). | async def async_get_device_name(self, device: str) -> Optional[str]:
"""Get the device name (the name of the wireless device not used)."""
for connected_device in self.connect_box.devices:
if (
connected_device.mac == device
and connected_device.hostname.lower... | [
"async",
"def",
"async_get_device_name",
"(",
"self",
",",
"device",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"for",
"connected_device",
"in",
"self",
".",
"connect_box",
".",
"devices",
":",
"if",
"(",
"connected_device",
".",
"mac",
"==",... | [
68,
4
] | [
77,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_devices) | Set up the sensor platform. | Set up the sensor platform. | async def async_setup_entry(hass, config_entry, async_add_devices):
"""Set up the sensor platform."""
hub = hass.data[DOMAIN][config_entry.entry_id]
session = aiohttp_client.async_get_clientsession(hass)
sensor = HVVDepartureSensor(hass, config_entry, session, hub)
async_add_devices([sensor], True... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_devices",
")",
":",
"hub",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"session",
"=",
"aiohttp_client",
".",
"async_get_clients... | [
35,
0
] | [
42,
37
] | python | en | ['en', 'da', 'en'] | True |
HVVDepartureSensor.__init__ | (self, hass, config_entry, session, hub) | Initialize. | Initialize. | def __init__(self, hass, config_entry, session, hub):
"""Initialize."""
self.config_entry = config_entry
self.station_name = self.config_entry.data[CONF_STATION]["name"]
self.attr = {ATTR_ATTRIBUTION: ATTRIBUTION}
self._available = False
self._state = None
self._n... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
",",
"session",
",",
"hub",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"station_name",
"=",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_STATION",
"]",
... | [
48,
4
] | [
58,
26
] | python | en | ['en', 'en', 'it'] | False |
HVVDepartureSensor.async_update | (self, **kwargs) | Update the sensor. | Update the sensor. | async def async_update(self, **kwargs):
"""Update the sensor."""
departure_time = utcnow() + timedelta(
minutes=self.config_entry.options.get("offset", 0)
)
departure_time_tz_berlin = departure_time.astimezone(timezone("Europe/Berlin"))
payload = {
"sta... | [
"async",
"def",
"async_update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"departure_time",
"=",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"minutes",
"=",
"self",
".",
"config_entry",
".",
"options",
".",
"get",
"(",
"\"offset\"",
",",
"0",
")",... | [
61,
4
] | [
149,
41
] | python | en | ['en', 'nl', 'en'] | True |
HVVDepartureSensor.unique_id | (self) | Return a unique ID to use for this sensor. | Return a unique ID to use for this sensor. | def unique_id(self):
"""Return a unique ID to use for this sensor."""
station_id = self.config_entry.data[CONF_STATION]["id"]
station_type = self.config_entry.data[CONF_STATION]["type"]
return f"{self.config_entry.entry_id}-{station_id}-{station_type}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"station_id",
"=",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_STATION",
"]",
"[",
"\"id\"",
"]",
"station_type",
"=",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_STATION",
"]",
"[",
"\"type\"",
... | [
152,
4
] | [
157,
74
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.device_info | (self) | Return the device info for this sensor. | Return the device info for this sensor. | def device_info(self):
"""Return the device info for this sensor."""
return {
"identifiers": {
(
DOMAIN,
self.config_entry.entry_id,
self.config_entry.data[CONF_STATION]["id"],
self.config_entry.d... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"config_entry",
".",
"entry_id",
",",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_STATION",
"]",
"[",
"\"id\"",
"]",
",",
... | [
160,
4
] | [
173,
9
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.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"
] | [
176,
4
] | [
178,
25
] | python | en | ['en', 'mi', 'en'] | True |
HVVDepartureSensor.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"
] | [
181,
4
] | [
183,
26
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.icon | (self) | Return the icon of the sensor. | Return the icon of the sensor. | def icon(self):
"""Return the icon of the sensor."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
186,
4
] | [
188,
19
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
191,
4
] | [
193,
30
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
196,
4
] | [
198,
37
] | python | en | ['en', 'en', 'en'] | True |
HVVDepartureSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self.attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"attr"
] | [
201,
4
] | [
203,
24
] | python | en | ['en', 'en', 'en'] | True |
test_default_setup | (hass, monkeypatch) | Test all basic functionality of the rflink switch component. | Test all basic functionality of the rflink switch component. | async def test_default_setup(hass, monkeypatch):
"""Test all basic functionality of the rflink switch component."""
# setup mocking rflink module
event_callback, create, protocol, _ = await mock_rflink(
hass, CONFIG, DOMAIN, monkeypatch
)
# make sure arguments are passed
assert create.c... | [
"async",
"def",
"test_default_setup",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"# setup mocking rflink module",
"event_callback",
",",
"create",
",",
"protocol",
",",
"_",
"=",
"await",
"mock_rflink",
"(",
"hass",
",",
"CONFIG",
",",
"DOMAIN",
",",
"monkeypatc... | [
34,
0
] | [
95,
68
] | python | en | ['en', 'en', 'en'] | True |
test_group_alias | (hass, monkeypatch) | Group aliases should only respond to group commands (allon/alloff). | Group aliases should only respond to group commands (allon/alloff). | async def test_group_alias(hass, monkeypatch):
"""Group aliases should only respond to group commands (allon/alloff)."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"devices": {
"protocol_0_0": {"name": "test", "group_ali... | [
"async",
"def",
"test_group_alias",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"devices\"",
":",
"{",
"... | [
98,
0
] | [
125,
58
] | python | en | ['en', 'en', 'en'] | True |
test_nogroup_alias | (hass, monkeypatch) | Non group aliases should not respond to group commands. | Non group aliases should not respond to group commands. | async def test_nogroup_alias(hass, monkeypatch):
"""Non group aliases should not respond to group commands."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"devices": {
"protocol_0_0": {
"name": "test",... | [
"async",
"def",
"test_nogroup_alias",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"devices\"",
":",
"{",
... | [
128,
0
] | [
158,
58
] | python | en | ['en', 'en', 'en'] | True |
test_nogroup_device_id | (hass, monkeypatch) | Device id that do not respond to group commands (allon/alloff). | Device id that do not respond to group commands (allon/alloff). | async def test_nogroup_device_id(hass, monkeypatch):
"""Device id that do not respond to group commands (allon/alloff)."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"devices": {"test_nogroup_0_0": {"name": "test", "group": False}},
... | [
"async",
"def",
"test_nogroup_device_id",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"devices\"",
":",
"{... | [
161,
0
] | [
186,
58
] | python | en | ['en', 'en', 'en'] | True |
test_device_defaults | (hass, monkeypatch) | Event should fire if device_defaults config says so. | Event should fire if device_defaults config says so. | async def test_device_defaults(hass, monkeypatch):
"""Event should fire if device_defaults config says so."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"device_defaults": {"fire_event": True},
"devices": {
"... | [
"async",
"def",
"test_device_defaults",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"device_defaults\"",
":"... | [
189,
0
] | [
218,
75
] | python | en | ['en', 'en', 'en'] | True |
test_not_firing_default | (hass, monkeypatch) | By default no bus events should be fired. | By default no bus events should be fired. | async def test_not_firing_default(hass, monkeypatch):
"""By default no bus events should be fired."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"devices": {
"protocol_0_0": {"name": "test", "aliases": ["test_alias_0_0"]... | [
"async",
"def",
"test_not_firing_default",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"devices\"",
":",
"... | [
221,
0
] | [
248,
47
] | python | en | ['en', 'en', 'en'] | True |
test_restore_state | (hass, monkeypatch) | Ensure states are restored on startup. | Ensure states are restored on startup. | async def test_restore_state(hass, monkeypatch):
"""Ensure states are restored on startup."""
config = {
"rflink": {"port": "/dev/ttyABC0"},
DOMAIN: {
"platform": "rflink",
"devices": {
"test": {"name": "s1", "aliases": ["test_alias_0_0"]},
... | [
"async",
"def",
"test_restore_state",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
",",
"\"devices\"",
":",
"{",
... | [
251,
0
] | [
286,
44
] | python | en | ['en', 'en', 'en'] | True |
PortOrderExporter.add | (self, order) | Add an order to export, it will be ignored if export is disabled.
Args:
order (object): Order to export.
| Add an order to export, it will be ignored if export is disabled. | def add(self, order):
"""Add an order to export, it will be ignored if export is disabled.
Args:
order (object): Order to export.
"""
if self._enabled:
self._orders.append(order) | [
"def",
"add",
"(",
"self",
",",
"order",
")",
":",
"if",
"self",
".",
"_enabled",
":",
"self",
".",
"_orders",
".",
"append",
"(",
"order",
")"
] | [
14,
4
] | [
21,
38
] | python | en | ['en', 'en', 'en'] | True |
PortOrderExporter.dump | (self, folder: str) | Dump current orders to csv.
Args:
folder (str): Folder to hold dump file.
| Dump current orders to csv. | def dump(self, folder: str):
"""Dump current orders to csv.
Args:
folder (str): Folder to hold dump file.
"""
if self._enabled:
with open(f"{folder}/orders.csv", "w+", newline="") as fp:
writer = csv.writer(fp)
writer.writerow(
... | [
"def",
"dump",
"(",
"self",
",",
"folder",
":",
"str",
")",
":",
"if",
"self",
".",
"_enabled",
":",
"with",
"open",
"(",
"f\"{folder}/orders.csv\"",
",",
"\"w+\"",
",",
"newline",
"=",
"\"\"",
")",
"as",
"fp",
":",
"writer",
"=",
"csv",
".",
"writer... | [
23,
4
] | [
41,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the wake on LAN component. | Set up the wake on LAN component. | async def async_setup(hass, config):
"""Set up the wake on LAN component."""
async def send_magic_packet(call):
"""Send magic packet to wake up a device."""
mac_address = call.data.get(CONF_MAC)
broadcast_address = call.data.get(CONF_BROADCAST_ADDRESS)
broadcast_port = call.data... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"async",
"def",
"send_magic_packet",
"(",
"call",
")",
":",
"\"\"\"Send magic packet to wake up a device.\"\"\"",
"mac_address",
"=",
"call",
".",
"data",
".",
"get",
"(",
"CONF_MAC",
")",
"bro... | [
25,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
storage_setup | (hass, hass_storage) | Storage setup. | Storage setup. | def storage_setup(hass, hass_storage):
"""Storage setup."""
async def _storage(items=None, config=None):
if items is None:
hass_storage[DOMAIN] = {
"key": DOMAIN,
"version": 1,
"data": {
"items": [
{... | [
"def",
"storage_setup",
"(",
"hass",
",",
"hass_storage",
")",
":",
"async",
"def",
"_storage",
"(",
"items",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"if",
"items",
"is",
"None",
":",
"hass_storage",
"[",
"DOMAIN",
"]",
"=",
"{",
"\"key\"",
... | [
37,
0
] | [
69,
19
] | python | en | ['en', 'bs', 'en'] | False |
test_config | (hass) | Test config. | Test config. | async def test_config(hass):
"""Test config."""
invalid_configs = [None, 1, {}, {"name with space": None}]
for cfg in invalid_configs:
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg}) | [
"async",
"def",
"test_config",
"(",
"hass",
")",
":",
"invalid_configs",
"=",
"[",
"None",
",",
"1",
",",
"{",
"}",
",",
"{",
"\"name with space\"",
":",
"None",
"}",
"]",
"for",
"cfg",
"in",
"invalid_configs",
":",
"assert",
"not",
"await",
"async_setup... | [
72,
0
] | [
77,
75
] | python | en | ['en', 'en', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.