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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
LockEntity.code_format | (self) | Regex for code format or None if no code is required. | Regex for code format or None if no code is required. | def code_format(self):
"""Regex for code format or None if no code is required."""
return None | [
"def",
"code_format",
"(",
"self",
")",
":",
"return",
"None"
] | [
86,
4
] | [
88,
19
] | python | en | ['en', 'en', 'en'] | True |
LockEntity.is_locked | (self) | Return true if the lock is locked. | Return true if the lock is locked. | def is_locked(self):
"""Return true if the lock is locked."""
return None | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"None"
] | [
91,
4
] | [
93,
19
] | python | en | ['en', 'mt', 'en'] | True |
LockEntity.lock | (self, **kwargs) | Lock the lock. | Lock the lock. | def lock(self, **kwargs):
"""Lock the lock."""
raise NotImplementedError() | [
"def",
"lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
95,
4
] | [
97,
35
] | python | en | ['en', 'la', 'en'] | True |
LockEntity.async_lock | (self, **kwargs) | Lock the lock. | Lock the lock. | async def async_lock(self, **kwargs):
"""Lock the lock."""
await self.hass.async_add_executor_job(ft.partial(self.lock, **kwargs)) | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"lock",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
99,
4
] | [
101,
79
] | python | en | ['en', 'la', 'en'] | True |
LockEntity.unlock | (self, **kwargs) | Unlock the lock. | Unlock the lock. | def unlock(self, **kwargs):
"""Unlock the lock."""
raise NotImplementedError() | [
"def",
"unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
103,
4
] | [
105,
35
] | python | en | ['en', 'ms', 'en'] | True |
LockEntity.async_unlock | (self, **kwargs) | Unlock the lock. | Unlock the lock. | async def async_unlock(self, **kwargs):
"""Unlock the lock."""
await self.hass.async_add_executor_job(ft.partial(self.unlock, **kwargs)) | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"unlock",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
107,
4
] | [
109,
81
] | python | en | ['en', 'ms', 'en'] | True |
LockEntity.open | (self, **kwargs) | Open the door latch. | Open the door latch. | def open(self, **kwargs):
"""Open the door latch."""
raise NotImplementedError() | [
"def",
"open",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
111,
4
] | [
113,
35
] | python | en | ['en', 'nl', 'en'] | True |
LockEntity.async_open | (self, **kwargs) | Open the door latch. | Open the door latch. | async def async_open(self, **kwargs):
"""Open the door latch."""
await self.hass.async_add_executor_job(ft.partial(self.open, **kwargs)) | [
"async",
"def",
"async_open",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"ft",
".",
"partial",
"(",
"self",
".",
"open",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
115,
4
] | [
117,
79
] | python | en | ['en', 'nl', 'en'] | True |
LockEntity.state_attributes | (self) | Return the state attributes. | Return the state attributes. | def state_attributes(self):
"""Return the state attributes."""
state_attr = {}
for prop, attr in PROP_TO_ATTR.items():
value = getattr(self, prop)
if value is not None:
state_attr[attr] = value
return state_attr | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"state_attr",
"=",
"{",
"}",
"for",
"prop",
",",
"attr",
"in",
"PROP_TO_ATTR",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"prop",
")",
"if",
"value",
"is",
"not",
"None",
... | [
120,
4
] | [
127,
25
] | python | en | ['en', 'en', 'en'] | True |
LockEntity.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
locked = self.is_locked
if locked is None:
return None
return STATE_LOCKED if locked else STATE_UNLOCKED | [
"def",
"state",
"(",
"self",
")",
":",
"locked",
"=",
"self",
".",
"is_locked",
"if",
"locked",
"is",
"None",
":",
"return",
"None",
"return",
"STATE_LOCKED",
"if",
"locked",
"else",
"STATE_UNLOCKED"
] | [
130,
4
] | [
135,
57
] | python | en | ['en', 'en', 'en'] | True |
LockDevice.__init_subclass__ | (cls, **kwargs) | Print deprecation warning. | Print deprecation warning. | def __init_subclass__(cls, **kwargs):
"""Print deprecation warning."""
super().__init_subclass__(**kwargs)
_LOGGER.warning(
"LockDevice is deprecated, modify %s to extend LockEntity",
cls.__name__,
) | [
"def",
"__init_subclass__",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init_subclass__",
"(",
"*",
"*",
"kwargs",
")",
"_LOGGER",
".",
"warning",
"(",
"\"LockDevice is deprecated, modify %s to extend LockEntity\"",
",",
"cls",
".",... | [
141,
4
] | [
147,
9
] | python | de | ['de', 'sv', 'en'] | False |
async_attach_trigger | (
hass, config, action, automation_info, *, platform_type: str = "zone"
) | Listen for state changes based on configuration. | Listen for state changes based on configuration. | async def async_attach_trigger(
hass, config, action, automation_info, *, platform_type: str = "zone"
) -> CALLBACK_TYPE:
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
zone_entity_id = config.get(CONF_ZONE)
event = config.get(CONF_EVENT)
job = Hass... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
",",
"*",
",",
"platform_type",
":",
"str",
"=",
"\"zone\"",
")",
"->",
"CALLBACK_TYPE",
":",
"entity_id",
"=",
"config",
".",
"get",
"(",
"CONF_ENTITY... | [
35,
0
] | [
87,
84
] | python | en | ['en', 'en', 'en'] | True |
test_owserver_binary_sensor | (owproxy, hass, device_id) | Test for 1-Wire binary sensor.
This test forces all entities to be enabled.
| Test for 1-Wire binary sensor. | async def test_owserver_binary_sensor(owproxy, hass, device_id):
"""Test for 1-Wire binary sensor.
This test forces all entities to be enabled.
"""
await async_setup_component(hass, "persistent_notification", {})
entity_registry = mock_registry(hass)
mock_device_sensor = MOCK_DEVICE_SENSORS[de... | [
"async",
"def",
"test_owserver_binary_sensor",
"(",
"owproxy",
",",
"hass",
",",
"device_id",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entity_registry",
"=",
"mock_registry",
"(",
"hass",
")"... | [
39,
0
] | [
85,
55
] | python | en | ['en', 'en', 'en'] | True |
ExitApp.__init__ | (self, reason, exit_code=1) | Initialize the exit app exception. | Initialize the exit app exception. | def __init__(self, reason, exit_code=1):
"""Initialize the exit app exception."""
self.reason = reason
self.exit_code = exit_code | [
"def",
"__init__",
"(",
"self",
",",
"reason",
",",
"exit_code",
"=",
"1",
")",
":",
"self",
".",
"reason",
"=",
"reason",
"self",
".",
"exit_code",
"=",
"exit_code"
] | [
6,
4
] | [
9,
34
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Frontier Silicon platform. | Set up the Frontier Silicon platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Frontier Silicon platform."""
if discovery_info is not None:
async_add_entities(
[AFSAPIDevice(discovery_info["ssdp_description"], DEFAULT_PASSWORD, None)],
True,
)
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"not",
"None",
":",
"async_add_entities",
"(",
"[",
"AFSAPIDevice",
"(",
"discovery_info",
... | [
68,
0
] | [
93,
16
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.__init__ | (self, device_url, password, name) | Initialize the Frontier Silicon API device. | Initialize the Frontier Silicon API device. | def __init__(self, device_url, password, name):
"""Initialize the Frontier Silicon API device."""
self._device_url = device_url
self._password = password
self._state = None
self._name = name
self._title = None
self._artist = None
self._album_name = None
... | [
"def",
"__init__",
"(",
"self",
",",
"device_url",
",",
"password",
",",
"name",
")",
":",
"self",
".",
"_device_url",
"=",
"device_url",
"self",
".",
"_password",
"=",
"password",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_name",
"=",
"name",
... | [
99,
4
] | [
114,
33
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.fs_device | (self) |
Create a fresh fsapi session.
A new session is created for each request in case someone else
connected to the device in between the updates and invalidated the
existing session (i.e UNDOK).
|
Create a fresh fsapi session. | def fs_device(self):
"""
Create a fresh fsapi session.
A new session is created for each request in case someone else
connected to the device in between the updates and invalidated the
existing session (i.e UNDOK).
"""
return AFSAPI(self._device_url, self._passwo... | [
"def",
"fs_device",
"(",
"self",
")",
":",
"return",
"AFSAPI",
"(",
"self",
".",
"_device_url",
",",
"self",
".",
"_password",
")"
] | [
118,
4
] | [
126,
55
] | python | en | ['en', 'error', 'th'] | False |
AFSAPIDevice.name | (self) | Return the device name. | Return the device name. | def name(self):
"""Return the device name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
129,
4
] | [
131,
25
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
return self._title | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_title"
] | [
134,
4
] | [
136,
26
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.media_artist | (self) | Artist of current playing media, music track only. | Artist of current playing media, music track only. | def media_artist(self):
"""Artist of current playing media, music track only."""
return self._artist | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_artist"
] | [
139,
4
] | [
141,
27
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.media_album_name | (self) | Album name of current playing media, music track only. | Album name of current playing media, music track only. | def media_album_name(self):
"""Album name of current playing media, music track only."""
return self._album_name | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_album_name"
] | [
144,
4
] | [
146,
31
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.media_content_type | (self) | Content type of current playing media. | Content type of current playing media. | def media_content_type(self):
"""Content type of current playing media."""
return MEDIA_TYPE_MUSIC | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"return",
"MEDIA_TYPE_MUSIC"
] | [
149,
4
] | [
151,
31
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.supported_features | (self) | Flag of media commands that are supported. | Flag of media commands that are supported. | def supported_features(self):
"""Flag of media commands that are supported."""
return SUPPORT_FRONTIER_SILICON | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_FRONTIER_SILICON"
] | [
154,
4
] | [
156,
39
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.state | (self) | Return the state of the player. | Return the state of the player. | def state(self):
"""Return the state of the player."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
159,
4
] | [
161,
26
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return self._source_list | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source_list"
] | [
165,
4
] | [
167,
32
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.source | (self) | Name of the current input source. | Name of the current input source. | def source(self):
"""Name of the current input source."""
return self._source | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source"
] | [
170,
4
] | [
172,
27
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.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._media_image_url | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_image_url"
] | [
175,
4
] | [
177,
36
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.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._volume_level | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume_level"
] | [
180,
4
] | [
182,
33
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_update | (self) | Get the latest date and update device state. | Get the latest date and update device state. | async def async_update(self):
"""Get the latest date and update device state."""
fs_device = self.fs_device
if not self._name:
self._name = await fs_device.get_friendly_name()
if not self._source_list:
self._source_list = await fs_device.get_mode_list()
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"fs_device",
"=",
"self",
".",
"fs_device",
"if",
"not",
"self",
".",
"_name",
":",
"self",
".",
"_name",
"=",
"await",
"fs_device",
".",
"get_friendly_name",
"(",
")",
"if",
"not",
"self",
".",
"_... | [
184,
4
] | [
237,
37
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_turn_on | (self) | Turn on the device. | Turn on the device. | async def async_turn_on(self):
"""Turn on the device."""
await self.fs_device.set_power(True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"set_power",
"(",
"True",
")"
] | [
241,
4
] | [
243,
44
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_turn_off | (self) | Turn off the device. | Turn off the device. | async def async_turn_off(self):
"""Turn off the device."""
await self.fs_device.set_power(False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"set_power",
"(",
"False",
")"
] | [
245,
4
] | [
247,
45
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_play | (self) | Send play command. | Send play command. | async def async_media_play(self):
"""Send play command."""
await self.fs_device.play() | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"play",
"(",
")"
] | [
249,
4
] | [
251,
35
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_pause | (self) | Send pause command. | Send pause command. | async def async_media_pause(self):
"""Send pause command."""
await self.fs_device.pause() | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"pause",
"(",
")"
] | [
253,
4
] | [
255,
36
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_play_pause | (self) | Send play/pause command. | Send play/pause command. | async def async_media_play_pause(self):
"""Send play/pause command."""
if "playing" in self._state:
await self.fs_device.pause()
else:
await self.fs_device.play() | [
"async",
"def",
"async_media_play_pause",
"(",
"self",
")",
":",
"if",
"\"playing\"",
"in",
"self",
".",
"_state",
":",
"await",
"self",
".",
"fs_device",
".",
"pause",
"(",
")",
"else",
":",
"await",
"self",
".",
"fs_device",
".",
"play",
"(",
")"
] | [
257,
4
] | [
262,
39
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_stop | (self) | Send play/pause command. | Send play/pause command. | async def async_media_stop(self):
"""Send play/pause command."""
await self.fs_device.pause() | [
"async",
"def",
"async_media_stop",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"pause",
"(",
")"
] | [
264,
4
] | [
266,
36
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_previous_track | (self) | Send previous track command (results in rewind). | Send previous track command (results in rewind). | async def async_media_previous_track(self):
"""Send previous track command (results in rewind)."""
await self.fs_device.rewind() | [
"async",
"def",
"async_media_previous_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"rewind",
"(",
")"
] | [
268,
4
] | [
270,
37
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_media_next_track | (self) | Send next track command (results in fast-forward). | Send next track command (results in fast-forward). | async def async_media_next_track(self):
"""Send next track command (results in fast-forward)."""
await self.fs_device.forward() | [
"async",
"def",
"async_media_next_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"forward",
"(",
")"
] | [
272,
4
] | [
274,
38
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.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._mute | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_mute"
] | [
278,
4
] | [
280,
25
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_mute_volume | (self, mute) | Send mute command. | Send mute command. | async def async_mute_volume(self, mute):
"""Send mute command."""
await self.fs_device.set_mute(mute) | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"set_mute",
"(",
"mute",
")"
] | [
282,
4
] | [
284,
43
] | python | en | ['en', 'co', 'en'] | True |
AFSAPIDevice.async_volume_up | (self) | Send volume up command. | Send volume up command. | async def async_volume_up(self):
"""Send volume up command."""
volume = await self.fs_device.get_volume()
volume = int(volume or 0) + 1
await self.fs_device.set_volume(min(volume, self._max_volume)) | [
"async",
"def",
"async_volume_up",
"(",
"self",
")",
":",
"volume",
"=",
"await",
"self",
".",
"fs_device",
".",
"get_volume",
"(",
")",
"volume",
"=",
"int",
"(",
"volume",
"or",
"0",
")",
"+",
"1",
"await",
"self",
".",
"fs_device",
".",
"set_volume"... | [
287,
4
] | [
291,
70
] | python | en | ['en', 'en', 'en'] | True |
AFSAPIDevice.async_volume_down | (self) | Send volume down command. | Send volume down command. | async def async_volume_down(self):
"""Send volume down command."""
volume = await self.fs_device.get_volume()
volume = int(volume or 0) - 1
await self.fs_device.set_volume(max(volume, 0)) | [
"async",
"def",
"async_volume_down",
"(",
"self",
")",
":",
"volume",
"=",
"await",
"self",
".",
"fs_device",
".",
"get_volume",
"(",
")",
"volume",
"=",
"int",
"(",
"volume",
"or",
"0",
")",
"-",
"1",
"await",
"self",
".",
"fs_device",
".",
"set_volum... | [
293,
4
] | [
297,
55
] | python | en | ['en', 'it', 'en'] | True |
AFSAPIDevice.async_set_volume_level | (self, volume) | Set volume command. | Set volume command. | async def async_set_volume_level(self, volume):
"""Set volume command."""
if self._max_volume: # Can't do anything sensible if not set
volume = int(volume * self._max_volume)
await self.fs_device.set_volume(volume) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"if",
"self",
".",
"_max_volume",
":",
"# Can't do anything sensible if not set",
"volume",
"=",
"int",
"(",
"volume",
"*",
"self",
".",
"_max_volume",
")",
"await",
"self",
".",
"... | [
299,
4
] | [
303,
51
] | python | bg-Latn | ['nl', 'bg-Latn', 'en'] | False |
AFSAPIDevice.async_select_source | (self, source) | Select input source. | Select input source. | async def async_select_source(self, source):
"""Select input source."""
await self.fs_device.set_mode(source) | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
")",
":",
"await",
"self",
".",
"fs_device",
".",
"set_mode",
"(",
"source",
")"
] | [
305,
4
] | [
307,
45
] | python | en | ['fr', 'su', 'en'] | False |
has_location | (state: State) | Test if state contains a valid location.
Async friendly.
| Test if state contains a valid location. | def has_location(state: State) -> bool:
"""Test if state contains a valid location.
Async friendly.
"""
# type ignore: https://github.com/python/mypy/issues/7207
return (
isinstance(state, State) # type: ignore
and isinstance(state.attributes.get(ATTR_LATITUDE), float)
and ... | [
"def",
"has_location",
"(",
"state",
":",
"State",
")",
"->",
"bool",
":",
"# type ignore: https://github.com/python/mypy/issues/7207",
"return",
"(",
"isinstance",
"(",
"state",
",",
"State",
")",
"# type: ignore",
"and",
"isinstance",
"(",
"state",
".",
"attribute... | [
15,
0
] | [
25,
5
] | python | en | ['en', 'en', 'en'] | True |
closest | (
latitude: float, longitude: float, states: Sequence[State]
) | Return closest state to point.
Async friendly.
| Return closest state to point. | def closest(
latitude: float, longitude: float, states: Sequence[State]
) -> Optional[State]:
"""Return closest state to point.
Async friendly.
"""
with_location = [state for state in states if has_location(state)]
if not with_location:
return None
return min(
with_locatio... | [
"def",
"closest",
"(",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"states",
":",
"Sequence",
"[",
"State",
"]",
")",
"->",
"Optional",
"[",
"State",
"]",
":",
"with_location",
"=",
"[",
"state",
"for",
"state",
"in",
"states",
"if",... | [
28,
0
] | [
49,
5
] | python | en | ['en', 'en', 'en'] | True |
find_coordinates | (
hass: HomeAssistantType, entity_id: str, recursion_history: Optional[list] = None
) | Find the gps coordinates of the entity in the form of '90.000,180.000'. | Find the gps coordinates of the entity in the form of '90.000,180.000'. | def find_coordinates(
hass: HomeAssistantType, entity_id: str, recursion_history: Optional[list] = None
) -> Optional[str]:
"""Find the gps coordinates of the entity in the form of '90.000,180.000'."""
entity_state = hass.states.get(entity_id)
if entity_state is None:
_LOGGER.error("Unable to f... | [
"def",
"find_coordinates",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entity_id",
":",
"str",
",",
"recursion_history",
":",
"Optional",
"[",
"list",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"entity_state",
"=",
"hass",
".",
"states... | [
52,
0
] | [
104,
33
] | python | en | ['en', 'en', 'en'] | True |
_get_location_from_attributes | (entity_state: State) | Get the lat/long string from an entities attributes. | Get the lat/long string from an entities attributes. | def _get_location_from_attributes(entity_state: State) -> str:
"""Get the lat/long string from an entities attributes."""
attr = entity_state.attributes
return "{},{}".format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)) | [
"def",
"_get_location_from_attributes",
"(",
"entity_state",
":",
"State",
")",
"->",
"str",
":",
"attr",
"=",
"entity_state",
".",
"attributes",
"return",
"\"{},{}\"",
".",
"format",
"(",
"attr",
".",
"get",
"(",
"ATTR_LATITUDE",
")",
",",
"attr",
".",
"get... | [
107,
0
] | [
110,
76
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Platform setup. | Platform setup. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Platform setup."""
api = await real_time_api(config[CONF_IP_ADDRESS], config[CONF_PORT])
endpoint = RealTimeDataEndpoint(hass, api)
resp = await api.get_data()
serial = resp.serial_number
hass.async_add_job... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"api",
"=",
"await",
"real_time_api",
"(",
"config",
"[",
"CONF_IP_ADDRESS",
"]",
",",
"config",
"[",
"CONF_PORT",
"]",... | [
27,
0
] | [
42,
31
] | python | en | ['en', 'ru', 'en'] | False |
RealTimeDataEndpoint.__init__ | (self, hass, api) | Initialize the sensor. | Initialize the sensor. | def __init__(self, hass, api):
"""Initialize the sensor."""
self.hass = hass
self.api = api
self.ready = asyncio.Event()
self.sensors = [] | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"api",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"api",
"=",
"api",
"self",
".",
"ready",
"=",
"asyncio",
".",
"Event",
"(",
")",
"self",
".",
"sensors",
"=",
"[",
"]"
] | [
48,
4
] | [
53,
25
] | python | en | ['en', 'en', 'en'] | True |
RealTimeDataEndpoint.async_refresh | (self, now=None) | Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
| Fetch new state data for the sensor. | async def async_refresh(self, now=None):
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""
try:
api_response = await self.api.get_data()
self.ready.set()
except InverterError as err:
... | [
"async",
"def",
"async_refresh",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"try",
":",
"api_response",
"=",
"await",
"self",
".",
"api",
".",
"get_data",
"(",
")",
"self",
".",
"ready",
".",
"set",
"(",
")",
"except",
"InverterError",
"as",
"er... | [
55,
4
] | [
72,
55
] | python | en | ['en', 'en', 'en'] | True |
Inverter.__init__ | (self, uid, serial, key, unit) | Initialize an inverter sensor. | Initialize an inverter sensor. | def __init__(self, uid, serial, key, unit):
"""Initialize an inverter sensor."""
self.uid = uid
self.serial = serial
self.key = key
self.value = None
self.unit = unit | [
"def",
"__init__",
"(",
"self",
",",
"uid",
",",
"serial",
",",
"key",
",",
"unit",
")",
":",
"self",
".",
"uid",
"=",
"uid",
"self",
".",
"serial",
"=",
"serial",
"self",
".",
"key",
"=",
"key",
"self",
".",
"value",
"=",
"None",
"self",
".",
... | [
78,
4
] | [
84,
24
] | python | en | ['en', 'lb', 'nl'] | False |
Inverter.state | (self) | State of this inverter attribute. | State of this inverter attribute. | def state(self):
"""State of this inverter attribute."""
return self.value | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"value"
] | [
87,
4
] | [
89,
25
] | python | en | ['en', 'en', 'en'] | True |
Inverter.unique_id | (self) | Return unique id. | Return unique id. | def unique_id(self):
"""Return unique id."""
return self.uid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"uid"
] | [
92,
4
] | [
94,
23
] | python | en | ['fr', 'la', 'en'] | False |
Inverter.name | (self) | Name of this inverter attribute. | Name of this inverter attribute. | def name(self):
"""Name of this inverter attribute."""
return f"Solax {self.serial} {self.key}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"Solax {self.serial} {self.key}\""
] | [
97,
4
] | [
99,
48
] | python | en | ['en', 'en', 'en'] | True |
Inverter.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self.unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"unit"
] | [
102,
4
] | [
104,
24
] | python | en | ['en', 'la', 'en'] | True |
Inverter.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
107,
4
] | [
109,
20
] | python | en | ['en', 'en', 'en'] | True |
PowerWallEntity.__init__ | (
self, coordinator, site_info, status, device_type, powerwalls_serial_numbers
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, coordinator, site_info, status, device_type, powerwalls_serial_numbers
):
"""Initialize the sensor."""
super().__init__(coordinator)
self._site_info = site_info
self._device_type = device_type
self._version = status.version
# The serial num... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"site_info",
",",
"status",
",",
"device_type",
",",
"powerwalls_serial_numbers",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_site_info",
"=",
"site_info",
"se... | [
10,
4
] | [
19,
65
] | python | en | ['en', 'en', 'en'] | True |
PowerWallEntity.device_info | (self) | Powerwall device info. | Powerwall device info. | def device_info(self):
"""Powerwall device info."""
device_info = {
"identifiers": {(DOMAIN, self.base_unique_id)},
"name": self._site_info.site_name,
"manufacturer": MANUFACTURER,
}
model = MODEL
model += f" ({self._device_type.name})"
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"base_unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_site_info",
".",
"site_name",
",",
"\"manufacturer\"",
":",... | [
22,
4
] | [
33,
26
] | python | en | ['en', 'pl', 'en'] | True |
test_flow_aborts_already_setup | (hass, config_entry) | Test flow aborts when entry already setup. | Test flow aborts when entry already setup. | async def test_flow_aborts_already_setup(hass, config_entry):
"""Test flow aborts when entry already setup."""
config_entry.add_to_hass(hass)
flow = HeosFlowHandler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert resu... | [
"async",
"def",
"test_flow_aborts_already_setup",
"(",
"hass",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"flow",
"=",
"HeosFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".... | [
15,
0
] | [
22,
56
] | python | en | ['en', 'el-Latn', 'en'] | True |
test_no_host_shows_form | (hass) | Test form is shown when host not provided. | Test form is shown when host not provided. | async def test_no_host_shows_form(hass):
"""Test form is shown when host not provided."""
flow = HeosFlowHandler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
assert result["errors"] == {} | [
"async",
"def",
"test_no_host_shows_form",
"(",
"hass",
")",
":",
"flow",
"=",
"HeosFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
... | [
25,
0
] | [
32,
33
] | python | en | ['en', 'en', 'en'] | True |
test_cannot_connect_shows_error_form | (hass, controller) | Test form is shown with error when cannot connect. | Test form is shown with error when cannot connect. | async def test_cannot_connect_shows_error_form(hass, controller):
"""Test form is shown with error when cannot connect."""
controller.connect.side_effect = HeosError()
result = await hass.config_entries.flow.async_init(
heos.DOMAIN, context={"source": "user"}, data={CONF_HOST: "127.0.0.1"}
)
... | [
"async",
"def",
"test_cannot_connect_shows_error_form",
"(",
"hass",
",",
"controller",
")",
":",
"controller",
".",
"connect",
".",
"side_effect",
"=",
"HeosError",
"(",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
35,
0
] | [
47,
38
] | python | en | ['en', 'en', 'en'] | True |
test_create_entry_when_host_valid | (hass, controller) | Test result type is create entry when host is valid. | Test result type is create entry when host is valid. | async def test_create_entry_when_host_valid(hass, controller):
"""Test result type is create entry when host is valid."""
data = {CONF_HOST: "127.0.0.1"}
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_create_entry_when_host_valid",
"(",
"hass",
",",
"controller",
")",
":",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"127.0.0.1\"",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.heos.async_setup_entry\"",
",",
"return_value",
"=",
"True",
")",... | [
50,
0
] | [
62,
52
] | python | en | ['en', 'en', 'en'] | True |
test_create_entry_when_friendly_name_valid | (hass, controller) | Test result type is create entry when friendly name is valid. | Test result type is create entry when friendly name is valid. | async def test_create_entry_when_friendly_name_valid(hass, controller):
"""Test result type is create entry when friendly name is valid."""
hass.data[DATA_DISCOVERED_HOSTS] = {"Office (127.0.0.1)": "127.0.0.1"}
data = {CONF_HOST: "Office (127.0.0.1)"}
with patch("homeassistant.components.heos.async_setu... | [
"async",
"def",
"test_create_entry_when_friendly_name_valid",
"(",
"hass",
",",
"controller",
")",
":",
"hass",
".",
"data",
"[",
"DATA_DISCOVERED_HOSTS",
"]",
"=",
"{",
"\"Office (127.0.0.1)\"",
":",
"\"127.0.0.1\"",
"}",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"Of... | [
65,
0
] | [
79,
53
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_shows_create_form | (hass, controller, discovery_data) | Test discovery shows form to confirm setup and subsequent abort. | Test discovery shows form to confirm setup and subsequent abort. | async def test_discovery_shows_create_form(hass, controller, discovery_data):
"""Test discovery shows form to confirm setup and subsequent abort."""
await hass.config_entries.flow.async_init(
heos.DOMAIN, context={"source": "ssdp"}, data=discovery_data
)
await hass.async_block_till_done()
f... | [
"async",
"def",
"test_discovery_shows_create_form",
"(",
"hass",
",",
"controller",
",",
"discovery_data",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"heos",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":"... | [
82,
0
] | [
108,
5
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_flow_aborts_already_setup | (
hass, controller, discovery_data, config_entry
) | Test discovery flow aborts when entry already setup. | Test discovery flow aborts when entry already setup. | async def test_discovery_flow_aborts_already_setup(
hass, controller, discovery_data, config_entry
):
"""Test discovery flow aborts when entry already setup."""
config_entry.add_to_hass(hass)
flow = HeosFlowHandler()
flow.hass = hass
result = await flow.async_step_ssdp(discovery_data)
assert... | [
"async",
"def",
"test_discovery_flow_aborts_already_setup",
"(",
"hass",
",",
"controller",
",",
"discovery_data",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"flow",
"=",
"HeosFlowHandler",
"(",
")",
"flow",
".",
"hass",
... | [
111,
0
] | [
120,
56
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_sets_the_unique_id | (hass, controller, discovery_data) | Test discovery sets the unique id. | Test discovery sets the unique id. | async def test_discovery_sets_the_unique_id(hass, controller, discovery_data):
"""Test discovery sets the unique id."""
port = urlparse(discovery_data[ssdp.ATTR_SSDP_LOCATION]).port
discovery_data[ssdp.ATTR_SSDP_LOCATION] = f"http://127.0.0.2:{port}/"
discovery_data[ssdp.ATTR_UPNP_FRIENDLY_NAME] = "Bed... | [
"async",
"def",
"test_discovery_sets_the_unique_id",
"(",
"hass",
",",
"controller",
",",
"discovery_data",
")",
":",
"port",
"=",
"urlparse",
"(",
"discovery_data",
"[",
"ssdp",
".",
"ATTR_SSDP_LOCATION",
"]",
")",
".",
"port",
"discovery_data",
"[",
"ssdp",
".... | [
123,
0
] | [
137,
83
] | python | en | ['en', 'en', 'en'] | True |
test_import_sets_the_unique_id | (hass, controller) | Test import sets the unique id. | Test import sets the unique id. | async def test_import_sets_the_unique_id(hass, controller):
"""Test import sets the unique id."""
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_init(
heos.DOMAIN,
context={"source": SOURCE_IMPORT},... | [
"async",
"def",
"test_import_sets_the_unique_id",
"(",
"hass",
",",
"controller",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.heos.async_setup_entry\"",
",",
"return_value",
"=",
"True",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
... | [
140,
0
] | [
151,
47
] | python | en | ['en', 'fr', 'en'] | True |
async_setup_scanner | (hass, config, async_see, discovery_info=None) | Set up the MQTT tracker. | Set up the MQTT tracker. | async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Set up the MQTT tracker."""
devices = config[CONF_DEVICES]
qos = config[CONF_QOS]
payload_home = config[CONF_PAYLOAD_HOME]
payload_not_home = config[CONF_PAYLOAD_NOT_HOME]
source_type = config.get(CONF_SOURCE_TYPE)
... | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
",",
"config",
",",
"async_see",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"config",
"[",
"CONF_DEVICES",
"]",
"qos",
"=",
"config",
"[",
"CONF_QOS",
"]",
"payload_home",
"=",
"config",
... | [
29,
0
] | [
57,
15
] | python | en | ['en', 'mt', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Rain Bird switches over a Rain Bird controller. | Set up Rain Bird switches over a Rain Bird controller. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Rain Bird switches over a Rain Bird controller."""
if discovery_info is None:
return
controller: RainbirdController = hass.data[DATA_RAINBIRD][
discovery_info[RAINBIRD_CONTROLLER]
]
available_stations: A... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"controller",
":",
"RainbirdController",
"=",
"hass",
".",
"data",
"[",
"DATA_RAINBIRD"... | [
22,
0
] | [
64,
5
] | python | en | ['en', 'lb', 'en'] | True |
RainBirdSwitch.__init__ | (self, controller: RainbirdController, zone, time, name) | Initialize a Rain Bird Switch Device. | Initialize a Rain Bird Switch Device. | def __init__(self, controller: RainbirdController, zone, time, name):
"""Initialize a Rain Bird Switch Device."""
self._rainbird = controller
self._zone = zone
self._name = name
self._state = None
self._duration = time
self._attributes = {ATTR_DURATION: self._dura... | [
"def",
"__init__",
"(",
"self",
",",
"controller",
":",
"RainbirdController",
",",
"zone",
",",
"time",
",",
"name",
")",
":",
"self",
".",
"_rainbird",
"=",
"controller",
"self",
".",
"_zone",
"=",
"zone",
"self",
".",
"_name",
"=",
"name",
"self",
".... | [
70,
4
] | [
77,
78
] | python | en | ['en', 'pl', 'en'] | True |
RainBirdSwitch.device_state_attributes | (self) | Return state attributes. | Return state attributes. | def device_state_attributes(self):
"""Return state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
80,
4
] | [
82,
31
] | python | en | ['en', 'co', 'en'] | True |
RainBirdSwitch.name | (self) | Get the name of the switch. | Get the name of the switch. | def name(self):
"""Get the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
85,
4
] | [
87,
25
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
if self._rainbird.irrigate_zone(
int(self._zone),
int(kwargs[ATTR_DURATION] if ATTR_DURATION in kwargs else self._duration),
):
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rainbird",
".",
"irrigate_zone",
"(",
"int",
"(",
"self",
".",
"_zone",
")",
",",
"int",
"(",
"kwargs",
"[",
"ATTR_DURATION",
"]",
"if",
"ATTR_DURATION",
"in",
"kw... | [
89,
4
] | [
95,
30
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
if self._rainbird.stop_irrigation():
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rainbird",
".",
"stop_irrigation",
"(",
")",
":",
"self",
".",
"_state",
"=",
"False"
] | [
97,
4
] | [
100,
31
] | python | en | ['en', 'en', 'en'] | True |
RainBirdSwitch.update | (self) | Update switch status. | Update switch status. | def update(self):
"""Update switch status."""
self._state = self._rainbird.get_zone_state(self._zone) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_rainbird",
".",
"get_zone_state",
"(",
"self",
".",
"_zone",
")"
] | [
102,
4
] | [
104,
63
] | python | en | ['en', 'sn', 'en'] | True |
RainBirdSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
107,
4
] | [
109,
26
] | python | en | ['en', 'fy', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
if cur_state is None:
_LOGGE... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistantType",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",... | [
22,
0
] | [
55,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce Automation states. | Reproduce Automation states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Automation states."""
await asyncio.gather(
*(
_async_reproduce_state(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
58,
0
] | [
73,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass) | Test we can discover scripts. | Test we can discover scripts. | async def test_setup(hass):
"""Test we can discover scripts."""
scripts = [
"/some/config/dir/python_scripts/hello.py",
"/some/config/dir/python_scripts/world_beer.py",
]
with patch(
"homeassistant.components.python_script.os.path.isdir", return_value=True
), patch("homeassis... | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"scripts",
"=",
"[",
"\"/some/config/dir/python_scripts/hello.py\"",
",",
"\"/some/config/dir/python_scripts/world_beer.py\"",
",",
"]",
"with",
"patch",
"(",
"\"homeassistant.components.python_script.os.path.isdir\"",
",",
... | [
11,
0
] | [
41,
35
] | python | en | ['nl', 'en', 'en'] | True |
test_setup_fails_on_no_dir | (hass, caplog) | Test we fail setup when no dir found. | Test we fail setup when no dir found. | async def test_setup_fails_on_no_dir(hass, caplog):
"""Test we fail setup when no dir found."""
with patch(
"homeassistant.components.python_script.os.path.isdir", return_value=False
):
res = await async_setup_component(hass, "python_script", {})
assert not res
assert "Folder python... | [
"async",
"def",
"test_setup_fails_on_no_dir",
"(",
"hass",
",",
"caplog",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.python_script.os.path.isdir\"",
",",
"return_value",
"=",
"False",
")",
":",
"res",
"=",
"await",
"async_setup_component",
"(",
"hass"... | [
44,
0
] | [
52,
83
] | python | en | ['en', 'gd', 'en'] | True |
test_execute_with_data | (hass, caplog) | Test executing a script. | Test executing a script. | async def test_execute_with_data(hass, caplog):
"""Test executing a script."""
caplog.set_level(logging.WARNING)
source = """
hass.states.set('test.entity', data.get('name', 'not set'))
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {"name": "paulus"})
await hass.async_block_... | [
"async",
"def",
"test_execute_with_data",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"WARNING",
")",
"source",
"=",
"\"\"\"\nhass.states.set('test.entity', data.get('name', 'not set'))\n \"\"\"",
"hass",
".",
"async_add_execu... | [
55,
0
] | [
68,
28
] | python | en | ['en', 'ca', 'en'] | True |
test_execute_warns_print | (hass, caplog) | Test print triggers warning. | Test print triggers warning. | async def test_execute_warns_print(hass, caplog):
"""Test print triggers warning."""
caplog.set_level(logging.WARNING)
source = """
print("This triggers warning.")
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert "Don't use pri... | [
"async",
"def",
"test_execute_warns_print",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"WARNING",
")",
"source",
"=",
"\"\"\"\nprint(\"This triggers warning.\")\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"exec... | [
71,
0
] | [
81,
61
] | python | en | ['en', 'mt', 'en'] | True |
test_execute_logging | (hass, caplog) | Test logging works. | Test logging works. | async def test_execute_logging(hass, caplog):
"""Test logging works."""
caplog.set_level(logging.INFO)
source = """
logger.info('Logging from inside script')
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert "Logging from inside... | [
"async",
"def",
"test_execute_logging",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"INFO",
")",
"source",
"=",
"\"\"\"\nlogger.info('Logging from inside script')\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"exe... | [
84,
0
] | [
94,
54
] | python | da | ['nl', 'da', 'en'] | False |
test_execute_compile_error | (hass, caplog) | Test compile error logs error. | Test compile error logs error. | async def test_execute_compile_error(hass, caplog):
"""Test compile error logs error."""
caplog.set_level(logging.ERROR)
source = """
this is not valid Python
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert "Error loading scri... | [
"async",
"def",
"test_execute_compile_error",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\nthis is not valid Python\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"execute",
"... | [
97,
0
] | [
107,
56
] | python | it | ['nb', 'la', 'it'] | False |
test_execute_runtime_error | (hass, caplog) | Test compile error logs error. | Test compile error logs error. | async def test_execute_runtime_error(hass, caplog):
"""Test compile error logs error."""
caplog.set_level(logging.ERROR)
source = """
raise Exception('boom')
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert "Error executing scr... | [
"async",
"def",
"test_execute_runtime_error",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\nraise Exception('boom')\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"execute",
",... | [
110,
0
] | [
120,
56
] | python | it | ['nb', 'la', 'it'] | False |
test_accessing_async_methods | (hass, caplog) | Test compile error logs error. | Test compile error logs error. | async def test_accessing_async_methods(hass, caplog):
"""Test compile error logs error."""
caplog.set_level(logging.ERROR)
source = """
hass.async_stop()
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert "Not allowed to access a... | [
"async",
"def",
"test_accessing_async_methods",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\nhass.async_stop()\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"execute",
",",
... | [
123,
0
] | [
133,
63
] | python | it | ['nb', 'la', 'it'] | False |
test_using_complex_structures | (hass, caplog) | Test that dicts and lists work. | Test that dicts and lists work. | async def test_using_complex_structures(hass, caplog):
"""Test that dicts and lists work."""
caplog.set_level(logging.INFO)
source = """
mydict = {"a": 1, "b": 2}
mylist = [1, 2, 3, 4]
logger.info('Logging from inside script: %s %s' % (mydict["a"], mylist[2]))
"""
hass.async_add_executor_job(execut... | [
"async",
"def",
"test_using_complex_structures",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"INFO",
")",
"source",
"=",
"\"\"\"\nmydict = {\"a\": 1, \"b\": 2}\nmylist = [1, 2, 3, 4]\nlogger.info('Logging from inside script: %s %s' % (... | [
136,
0
] | [
148,
59
] | python | en | ['en', 'en', 'en'] | True |
test_accessing_forbidden_methods | (hass, caplog) | Test compile error logs error. | Test compile error logs error. | async def test_accessing_forbidden_methods(hass, caplog):
"""Test compile error logs error."""
caplog.set_level(logging.ERROR)
for source, name in {
"hass.stop()": "HomeAssistant.stop",
"dt_util.set_default_time_zone()": "module.set_default_time_zone",
"datetime.non_existing": "modu... | [
"async",
"def",
"test_accessing_forbidden_methods",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"for",
"source",
",",
"name",
"in",
"{",
"\"hass.stop()\"",
":",
"\"HomeAssistant.stop\"",
",",
"\"dt_util.se... | [
151,
0
] | [
164,
61
] | python | it | ['nb', 'la', 'it'] | False |
test_iterating | (hass) | Test compile error logs error. | Test compile error logs error. | async def test_iterating(hass):
"""Test compile error logs error."""
source = """
for i in [1, 2]:
hass.states.set('hello.{}'.format(i), 'world')
"""
hass.async_add_executor_job(execute, hass, "test.py", source, {})
await hass.async_block_till_done()
assert hass.states.is_state("hello.1", ... | [
"async",
"def",
"test_iterating",
"(",
"hass",
")",
":",
"source",
"=",
"\"\"\"\nfor i in [1, 2]:\n hass.states.set('hello.{}'.format(i), 'world')\n \"\"\"",
"hass",
".",
"async_add_executor_job",
"(",
"execute",
",",
"hass",
",",
"\"test.py\"",
",",
"source",
",",
... | [
167,
0
] | [
178,
51
] | python | it | ['nb', 'la', 'it'] | False |
test_unpacking_sequence | (hass, caplog) | Test compile error logs error. | Test compile error logs error. | async def test_unpacking_sequence(hass, caplog):
"""Test compile error logs error."""
caplog.set_level(logging.ERROR)
source = """
a,b = (1,2)
ab_list = [(a,b) for a,b in [(1, 2), (3, 4)]]
hass.states.set('hello.a', a)
hass.states.set('hello.b', b)
hass.states.set('hello.ab_list', '{}'.format(ab_list))
"""
... | [
"async",
"def",
"test_unpacking_sequence",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\na,b = (1,2)\nab_list = [(a,b) for a,b in [(1, 2), (3, 4)]]\nhass.states.set('hello.a', a)\nhass.states.set('he... | [
181,
0
] | [
200,
28
] | python | it | ['nb', 'la', 'it'] | False |
test_execute_sorted | (hass, caplog) | Test sorted() function. | Test sorted() function. | async def test_execute_sorted(hass, caplog):
"""Test sorted() function."""
caplog.set_level(logging.ERROR)
source = """
a = sorted([3,1,2])
assert(a == [1,2,3])
hass.states.set('hello.a', a[0])
hass.states.set('hello.b', a[1])
hass.states.set('hello.c', a[2])
"""
hass.async_add_executor_job(execute, ha... | [
"async",
"def",
"test_execute_sorted",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\na = sorted([3,1,2])\nassert(a == [1,2,3])\nhass.states.set('hello.a', a[0])\nhass.states.set('hello.b', a[1])\nha... | [
203,
0
] | [
220,
28
] | python | en | ['de', 'en', 'en'] | True |
test_exposed_modules | (hass, caplog) | Test datetime and time modules exposed. | Test datetime and time modules exposed. | async def test_exposed_modules(hass, caplog):
"""Test datetime and time modules exposed."""
caplog.set_level(logging.ERROR)
source = """
hass.states.set('module.time', time.strftime('%Y', time.gmtime(521276400)))
hass.states.set('module.time_strptime',
time.strftime('%H:%M', time.strptime('1... | [
"async",
"def",
"test_exposed_modules",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\nhass.states.set('module.time', time.strftime('%Y', time.gmtime(521276400)))\nhass.states.set('module.time_strptim... | [
223,
0
] | [
242,
28
] | python | en | ['en', 'en', 'en'] | True |
test_execute_functions | (hass, caplog) | Test functions defined in script can call one another. | Test functions defined in script can call one another. | async def test_execute_functions(hass, caplog):
"""Test functions defined in script can call one another."""
caplog.set_level(logging.ERROR)
source = """
def a():
hass.states.set('hello.a', 'one')
def b():
a()
hass.states.set('hello.b', 'two')
b()
"""
hass.async_add_executor_job(execute, h... | [
"async",
"def",
"test_execute_functions",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"ERROR",
")",
"source",
"=",
"\"\"\"\ndef a():\n hass.states.set('hello.a', 'one')\n\ndef b():\n a()\n hass.states.set('hello.b', 'two')\n\n... | [
245,
0
] | [
264,
28
] | python | en | ['en', 'en', 'en'] | True |
test_reload | (hass) | Test we can re-discover scripts. | Test we can re-discover scripts. | async def test_reload(hass):
"""Test we can re-discover scripts."""
scripts = [
"/some/config/dir/python_scripts/hello.py",
"/some/config/dir/python_scripts/world_beer.py",
]
with patch(
"homeassistant.components.python_script.os.path.isdir", return_value=True
), patch("homea... | [
"async",
"def",
"test_reload",
"(",
"hass",
")",
":",
"scripts",
"=",
"[",
"\"/some/config/dir/python_scripts/hello.py\"",
",",
"\"/some/config/dir/python_scripts/world_beer.py\"",
",",
"]",
"with",
"patch",
"(",
"\"homeassistant.components.python_script.os.path.isdir\"",
",",
... | [
267,
0
] | [
295,
63
] | python | en | ['en', 'en', 'en'] | True |
test_service_descriptions | (hass) | Test that service descriptions are loaded and reloaded correctly. | Test that service descriptions are loaded and reloaded correctly. | async def test_service_descriptions(hass):
"""Test that service descriptions are loaded and reloaded correctly."""
# Test 1: no user-provided services.yaml file
scripts1 = [
"/some/config/dir/python_scripts/hello.py",
"/some/config/dir/python_scripts/world_beer.py",
]
service_descri... | [
"async",
"def",
"test_service_descriptions",
"(",
"hass",
")",
":",
"# Test 1: no user-provided services.yaml file",
"scripts1",
"=",
"[",
"\"/some/config/dir/python_scripts/hello.py\"",
",",
"\"/some/config/dir/python_scripts/world_beer.py\"",
",",
"]",
"service_descriptions1",
"=... | [
298,
0
] | [
390,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sleep_warns_one | (hass, caplog) | Test time.sleep warns once. | Test time.sleep warns once. | async def test_sleep_warns_one(hass, caplog):
"""Test time.sleep warns once."""
caplog.set_level(logging.WARNING)
source = """
time.sleep(2)
time.sleep(5)
"""
with patch("homeassistant.components.python_script.time.sleep"):
hass.async_add_executor_job(execute, hass, "test.py", source, {})
... | [
"async",
"def",
"test_sleep_warns_one",
"(",
"hass",
",",
"caplog",
")",
":",
"caplog",
".",
"set_level",
"(",
"logging",
".",
"WARNING",
")",
"source",
"=",
"\"\"\"\ntime.sleep(2)\ntime.sleep(5)\n\"\"\"",
"with",
"patch",
"(",
"\"homeassistant.components.python_script.... | [
393,
0
] | [
405,
47
] | python | en | ['en', 'ceb', 'en'] | True |
VCRDataset.__init__ | (self, ann_file, image_set, root_path, data_path, transform=None, task='Q2A', test_mode=False,
zip_mode=False, cache_mode=False, cache_db=False, ignore_db_cache=True,
basic_tokenizer=None, tokenizer=None, pretrained_model_name=None,
only_use_relevant_dets=False, add_im... |
Visual Commonsense Reasoning Dataset
:param ann_file: annotation jsonl file
:param image_set: image folder name, e.g., 'vcr1images'
:param root_path: root path to cache database loaded from annotation file
:param data_path: path to vcr dataset
:param transform: transfor... |
Visual Commonsense Reasoning Dataset | def __init__(self, ann_file, image_set, root_path, data_path, transform=None, task='Q2A', test_mode=False,
zip_mode=False, cache_mode=False, cache_db=False, ignore_db_cache=True,
basic_tokenizer=None, tokenizer=None, pretrained_model_name=None,
only_use_relevant_dets=F... | [
"def",
"__init__",
"(",
"self",
",",
"ann_file",
",",
"image_set",
",",
"root_path",
",",
"data_path",
",",
"transform",
"=",
"None",
",",
"task",
"=",
"'Q2A'",
",",
"test_mode",
"=",
"False",
",",
"zip_mode",
"=",
"False",
",",
"cache_mode",
"=",
"False... | [
26,
4
] | [
117,
31
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the KWB component. | Set up the KWB component. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the KWB component."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
device = config.get(CONF_DEVICE)
connection_type = config.get(CONF_TYPE)
raw = config.get(CONF_RAW)
client_name = config.get(CONF_NAM... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"device",
"=",
"... | [
46,
0
] | [
73,
25
] | python | en | ['en', 'en', 'en'] | True |
KWBSensor.__init__ | (self, easyfire, sensor, client_name) | Initialize the KWB sensor. | Initialize the KWB sensor. | def __init__(self, easyfire, sensor, client_name):
"""Initialize the KWB sensor."""
self._easyfire = easyfire
self._sensor = sensor
self._client_name = client_name
self._name = self._sensor.name | [
"def",
"__init__",
"(",
"self",
",",
"easyfire",
",",
"sensor",
",",
"client_name",
")",
":",
"self",
".",
"_easyfire",
"=",
"easyfire",
"self",
".",
"_sensor",
"=",
"sensor",
"self",
".",
"_client_name",
"=",
"client_name",
"self",
".",
"_name",
"=",
"s... | [
79,
4
] | [
84,
38
] | python | en | ['en', 'sq', 'en'] | True |
KWBSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return f"{self._client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._client_name} {self._name}\""
] | [
87,
4
] | [
89,
50
] | python | en | ['en', 'ig', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.