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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
feedforward | (inputs,
num_units,
scope="multihead_attention") | Point-wise feed forward net.
Args:
inputs: A 3d tensor with shape of [N, T, C].
num_units: A list of two integers.
scope: Optional scope for `variable_scope`.
reuse: Boolean, whether to reuse the weights of a previous layer
by the same name.
Returns:
A 3d tensor with the ... | Point-wise feed forward net. | def feedforward(inputs,
num_units,
scope="multihead_attention"):
'''Point-wise feed forward net.
Args:
inputs: A 3d tensor with shape of [N, T, C].
num_units: A list of two integers.
scope: Optional scope for `variable_scope`.
reuse: Boolean, whether to r... | [
"def",
"feedforward",
"(",
"inputs",
",",
"num_units",
",",
"scope",
"=",
"\"multihead_attention\"",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"scope",
")",
":",
"# Inner layer",
"params",
"=",
"{",
"\"inputs\"",
":",
"inputs",
",",
"\"filters\"",
... | [
207,
0
] | [
239,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entries) | Set up the binary_sensor platform. | Set up the binary_sensor platform. | async def async_setup_entry(hass, entry, async_add_entries):
"""Set up the binary_sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
name = coordinator.name
entity = AuroraSensor(coordinator, name)
async_add_entries([entity]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entries",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"COORDINATOR",
"]",
"name",
"=",
"coordinator",
".",
... | [
20,
0
] | [
27,
31
] | python | en | ['en', 'pt', 'en'] | True |
AuroraSensor.__init__ | (self, coordinator: AuroraDataUpdateCoordinator, name) | Define the binary sensor for the Aurora integration. | Define the binary sensor for the Aurora integration. | def __init__(self, coordinator: AuroraDataUpdateCoordinator, name):
"""Define the binary sensor for the Aurora integration."""
super().__init__(coordinator=coordinator)
self._name = name
self.coordinator = coordinator
self._unique_id = f"{self.coordinator.latitude}_{self.coordin... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"AuroraDataUpdateCoordinator",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordinator",
")",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"coordinator",
"... | [
33,
4
] | [
39,
85
] | python | en | ['en', 'it', 'en'] | True |
AuroraSensor.unique_id | (self) | Define the unique id based on the latitude and longitude. | Define the unique id based on the latitude and longitude. | def unique_id(self):
"""Define the unique id based on the latitude and longitude."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
42,
4
] | [
44,
30
] | python | en | ['en', 'en', 'en'] | True |
AuroraSensor.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"
] | [
47,
4
] | [
49,
25
] | python | en | ['en', 'mi', 'en'] | True |
AuroraSensor.is_on | (self) | Return true if aurora is visible. | Return true if aurora is visible. | def is_on(self):
"""Return true if aurora is visible."""
return self.coordinator.data > self.coordinator.threshold | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
">",
"self",
".",
"coordinator",
".",
"threshold"
] | [
52,
4
] | [
54,
65
] | python | en | ['en', 'de', 'en'] | True |
AuroraSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {"attribution": ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"attribution\"",
":",
"ATTRIBUTION",
"}"
] | [
57,
4
] | [
59,
43
] | python | en | ['en', 'en', 'en'] | True |
AuroraSensor.icon | (self) | Return the icon for the sensor. | Return the icon for the sensor. | def icon(self):
"""Return the icon for the sensor."""
return "mdi:hazard-lights" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:hazard-lights\""
] | [
62,
4
] | [
64,
34
] | python | en | ['en', 'en', 'en'] | True |
AuroraSensor.device_info | (self) | Define the device based on name. | Define the device based on name. | def device_info(self):
"""Define the device based on name."""
return {
ATTR_IDENTIFIERS: {(DOMAIN, self._unique_id)},
ATTR_NAME: self.coordinator.name,
ATTR_MANUFACTURER: "NOAA",
ATTR_MODEL: "Aurora Visibility Sensor",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_IDENTIFIERS",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
",",
"ATTR_NAME",
":",
"self",
".",
"coordinator",
".",
"name",
",",
"ATTR_MANUFACTURER",
":",
"\"NOAA\"",
... | [
67,
4
] | [
74,
9
] | python | en | ['en', 'en', 'en'] | True |
SmartHomeError.__init__ | (self, code, msg) | Log error code. | Log error code. | def __init__(self, code, msg):
"""Log error code."""
super().__init__(msg)
self.code = code | [
"def",
"__init__",
"(",
"self",
",",
"code",
",",
"msg",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"msg",
")",
"self",
".",
"code",
"=",
"code"
] | [
10,
4
] | [
13,
24
] | python | da | ['da', 'eu', 'en'] | False |
SmartHomeError.to_response | (self) | Convert to a response format. | Convert to a response format. | def to_response(self):
"""Convert to a response format."""
return {"errorCode": self.code} | [
"def",
"to_response",
"(",
"self",
")",
":",
"return",
"{",
"\"errorCode\"",
":",
"self",
".",
"code",
"}"
] | [
15,
4
] | [
17,
39
] | python | en | ['en', 'en', 'en'] | True |
ChallengeNeeded.__init__ | (self, challenge_type) | Initialize challenge needed error. | Initialize challenge needed error. | def __init__(self, challenge_type):
"""Initialize challenge needed error."""
super().__init__(ERR_CHALLENGE_NEEDED, f"Challenge needed: {challenge_type}")
self.challenge_type = challenge_type | [
"def",
"__init__",
"(",
"self",
",",
"challenge_type",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"ERR_CHALLENGE_NEEDED",
",",
"f\"Challenge needed: {challenge_type}\"",
")",
"self",
".",
"challenge_type",
"=",
"challenge_type"
] | [
26,
4
] | [
29,
44
] | python | en | ['en', 'nl', 'en'] | True |
ChallengeNeeded.to_response | (self) | Convert to a response format. | Convert to a response format. | def to_response(self):
"""Convert to a response format."""
return {
"errorCode": self.code,
"challengeNeeded": {"type": self.challenge_type},
} | [
"def",
"to_response",
"(",
"self",
")",
":",
"return",
"{",
"\"errorCode\"",
":",
"self",
".",
"code",
",",
"\"challengeNeeded\"",
":",
"{",
"\"type\"",
":",
"self",
".",
"challenge_type",
"}",
",",
"}"
] | [
31,
4
] | [
36,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Acmeda Rollers from a config entry. | Set up the Acmeda Rollers from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Acmeda Rollers from a config entry."""
hub = hass.data[DOMAIN][config_entry.entry_id]
current = set()
@callback
def async_add_acmeda_covers():
async_add_acmeda_entities(
hass, AcmedaCover, config... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"hub",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"current",
"=",
"set",
"(",
")",
"@",
"callback",
... | [
21,
0
] | [
39,
5
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.current_cover_position | (self) | Return the current position of the roller blind.
None is unknown, 0 is closed, 100 is fully open.
| Return the current position of the roller blind. | def current_cover_position(self):
"""Return the current position of the roller blind.
None is unknown, 0 is closed, 100 is fully open.
"""
position = None
if self.roller.type != 7:
position = 100 - self.roller.closed_percent
return position | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"position",
"=",
"None",
"if",
"self",
".",
"roller",
".",
"type",
"!=",
"7",
":",
"position",
"=",
"100",
"-",
"self",
".",
"roller",
".",
"closed_percent",
"return",
"position"
] | [
46,
4
] | [
54,
23
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.current_cover_tilt_position | (self) | Return the current tilt of the roller blind.
None is unknown, 0 is closed, 100 is fully open.
| Return the current tilt of the roller blind. | def current_cover_tilt_position(self):
"""Return the current tilt of the roller blind.
None is unknown, 0 is closed, 100 is fully open.
"""
position = None
if self.roller.type in [7, 10]:
position = 100 - self.roller.closed_percent
return position | [
"def",
"current_cover_tilt_position",
"(",
"self",
")",
":",
"position",
"=",
"None",
"if",
"self",
".",
"roller",
".",
"type",
"in",
"[",
"7",
",",
"10",
"]",
":",
"position",
"=",
"100",
"-",
"self",
".",
"roller",
".",
"closed_percent",
"return",
"p... | [
57,
4
] | [
65,
23
] | python | en | ['en', 'da', 'en'] | True |
AcmedaCover.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
supported_features = 0
if self.current_cover_position is not None:
supported_features |= (
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
)
if self.current_cover_tilt_... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"0",
"if",
"self",
".",
"current_cover_position",
"is",
"not",
"None",
":",
"supported_features",
"|=",
"(",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE",
"|",
"SUPPORT_STOP",
"|",
"SUPPORT_SET... | [
68,
4
] | [
83,
33
] | python | en | ['da', 'en', 'en'] | True |
AcmedaCover.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
return self.roller.closed_percent == 100 | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"roller",
".",
"closed_percent",
"==",
"100"
] | [
86,
4
] | [
88,
48
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_close_cover | (self, **kwargs) | Close the roller. | Close the roller. | async def async_close_cover(self, **kwargs):
"""Close the roller."""
await self.roller.move_down() | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_down",
"(",
")"
] | [
90,
4
] | [
92,
37
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_open_cover | (self, **kwargs) | Open the roller. | Open the roller. | async def async_open_cover(self, **kwargs):
"""Open the roller."""
await self.roller.move_up() | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_up",
"(",
")"
] | [
94,
4
] | [
96,
35
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_stop_cover | (self, **kwargs) | Stop the roller. | Stop the roller. | async def async_stop_cover(self, **kwargs):
"""Stop the roller."""
await self.roller.move_stop() | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_stop",
"(",
")"
] | [
98,
4
] | [
100,
37
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_set_cover_position | (self, **kwargs) | Move the roller shutter to a specific position. | Move the roller shutter to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the roller shutter to a specific position."""
await self.roller.move_to(100 - kwargs[ATTR_POSITION]) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_to",
"(",
"100",
"-",
"kwargs",
"[",
"ATTR_POSITION",
"]",
")"
] | [
102,
4
] | [
104,
62
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_close_cover_tilt | (self, **kwargs) | Close the roller. | Close the roller. | async def async_close_cover_tilt(self, **kwargs):
"""Close the roller."""
await self.roller.move_down() | [
"async",
"def",
"async_close_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_down",
"(",
")"
] | [
106,
4
] | [
108,
37
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_open_cover_tilt | (self, **kwargs) | Open the roller. | Open the roller. | async def async_open_cover_tilt(self, **kwargs):
"""Open the roller."""
await self.roller.move_up() | [
"async",
"def",
"async_open_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_up",
"(",
")"
] | [
110,
4
] | [
112,
35
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_stop_cover_tilt | (self, **kwargs) | Stop the roller. | Stop the roller. | async def async_stop_cover_tilt(self, **kwargs):
"""Stop the roller."""
await self.roller.move_stop() | [
"async",
"def",
"async_stop_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_stop",
"(",
")"
] | [
114,
4
] | [
116,
37
] | python | en | ['en', 'en', 'en'] | True |
AcmedaCover.async_set_cover_tilt | (self, **kwargs) | Tilt the roller shutter to a specific position. | Tilt the roller shutter to a specific position. | async def async_set_cover_tilt(self, **kwargs):
"""Tilt the roller shutter to a specific position."""
await self.roller.move_to(100 - kwargs[ATTR_POSITION]) | [
"async",
"def",
"async_set_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"roller",
".",
"move_to",
"(",
"100",
"-",
"kwargs",
"[",
"ATTR_POSITION",
"]",
")"
] | [
118,
4
] | [
120,
62
] | python | en | ['en', 'en', 'en'] | True |
lastfm_network_fixture | () | Create fixture for LastFMNetwork. | Create fixture for LastFMNetwork. | def lastfm_network_fixture():
"""Create fixture for LastFMNetwork."""
with patch("pylast.LastFMNetwork") as lastfm_network:
yield lastfm_network | [
"def",
"lastfm_network_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"pylast.LastFMNetwork\"",
")",
"as",
"lastfm_network",
":",
"yield",
"lastfm_network"
] | [
40,
0
] | [
43,
28
] | python | en | ['en', 'nl', 'en'] | True |
test_update_not_playing | (hass, lastfm_network) | Test update when no playing song. | Test update when no playing song. | async def test_update_not_playing(hass, lastfm_network):
"""Test update when no playing song."""
lastfm_network.return_value.get_user.return_value = MockUser(None)
assert await async_setup_component(
hass,
sensor.DOMAIN,
{"sensor": {"platform": "lastfm", "api_key": "secret-key", "u... | [
"async",
"def",
"test_update_not_playing",
"(",
"hass",
",",
"lastfm_network",
")",
":",
"lastfm_network",
".",
"return_value",
".",
"get_user",
".",
"return_value",
"=",
"MockUser",
"(",
"None",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
... | [
46,
0
] | [
62,
46
] | python | en | ['en', 'en', 'en'] | True |
test_update_playing | (hass, lastfm_network) | Test update when song playing. | Test update when song playing. | async def test_update_playing(hass, lastfm_network):
"""Test update when song playing."""
lastfm_network.return_value.get_user.return_value = MockUser(
Track("artist", "title", None)
)
assert await async_setup_component(
hass,
sensor.DOMAIN,
{"sensor": {"platform": "las... | [
"async",
"def",
"test_update_playing",
"(",
"hass",
",",
"lastfm_network",
")",
":",
"lastfm_network",
".",
"return_value",
".",
"get_user",
".",
"return_value",
"=",
"MockUser",
"(",
"Track",
"(",
"\"artist\"",
",",
"\"title\"",
",",
"None",
")",
")",
"assert... | [
65,
0
] | [
83,
42
] | python | en | ['en', 'en', 'en'] | True |
MockUser.__init__ | (self, now_playing_result) | Initialize the mock. | Initialize the mock. | def __init__(self, now_playing_result):
"""Initialize the mock."""
self._now_playing_result = now_playing_result | [
"def",
"__init__",
"(",
"self",
",",
"now_playing_result",
")",
":",
"self",
".",
"_now_playing_result",
"=",
"now_playing_result"
] | [
14,
4
] | [
16,
53
] | python | en | ['en', 'en', 'en'] | True |
MockUser.get_playcount | (self) | Get mock play count. | Get mock play count. | def get_playcount(self):
"""Get mock play count."""
return 1 | [
"def",
"get_playcount",
"(",
"self",
")",
":",
"return",
"1"
] | [
18,
4
] | [
20,
16
] | python | en | ['pl', 'en', 'en'] | True |
MockUser.get_image | (self) | Get mock image. | Get mock image. | def get_image(self):
"""Get mock image."""
pass | [
"def",
"get_image",
"(",
"self",
")",
":",
"pass"
] | [
22,
4
] | [
24,
12
] | python | da | ['pl', 'da', 'en'] | False |
MockUser.get_recent_tracks | (self, limit) | Get mock recent tracks. | Get mock recent tracks. | def get_recent_tracks(self, limit):
"""Get mock recent tracks."""
return [] | [
"def",
"get_recent_tracks",
"(",
"self",
",",
"limit",
")",
":",
"return",
"[",
"]"
] | [
26,
4
] | [
28,
17
] | python | en | ['en', 'da', 'en'] | True |
MockUser.get_top_tracks | (self, limit) | Get mock top tracks. | Get mock top tracks. | def get_top_tracks(self, limit):
"""Get mock top tracks."""
return [] | [
"def",
"get_top_tracks",
"(",
"self",
",",
"limit",
")",
":",
"return",
"[",
"]"
] | [
30,
4
] | [
32,
17
] | python | en | ['pl', 'nl', 'en'] | False |
MockUser.get_now_playing | (self) | Get mock now playing. | Get mock now playing. | def get_now_playing(self):
"""Get mock now playing."""
return self._now_playing_result | [
"def",
"get_now_playing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_now_playing_result"
] | [
34,
4
] | [
36,
39
] | python | en | ['en', 'en', 'en'] | True |
_generate_mock_feed_entry | (
external_id,
title,
distance_to_home,
coordinates,
attribution=None,
depth=None,
magnitude=None,
mmi=None,
locality=None,
quality=None,
time=None,
) | Construct a mock feed entry for testing purposes. | Construct a mock feed entry for testing purposes. | def _generate_mock_feed_entry(
external_id,
title,
distance_to_home,
coordinates,
attribution=None,
depth=None,
magnitude=None,
mmi=None,
locality=None,
quality=None,
time=None,
):
"""Construct a mock feed entry for testing purposes."""
feed_entry = MagicMock()
fe... | [
"def",
"_generate_mock_feed_entry",
"(",
"external_id",
",",
"title",
",",
"distance_to_home",
",",
"coordinates",
",",
"attribution",
"=",
"None",
",",
"depth",
"=",
"None",
",",
"magnitude",
"=",
"None",
",",
"mmi",
"=",
"None",
",",
"locality",
"=",
"None... | [
4,
0
] | [
30,
21
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up MQTT camera through configuration.yaml. | Set up MQTT camera through configuration.yaml. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up MQTT camera through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
await _async_setup_entity(config, async_add_entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATF... | [
47,
0
] | [
52,
57
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT camera dynamically through MQTT discovery. | Set up MQTT camera dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT camera dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add a MQTT camera."""
discovery_data = discovery_payload.discovery_data
try:
config ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add a MQTT camera.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
"."... | [
55,
0
] | [
72,
5
] | python | en | ['en', 'vi', 'en'] | True |
_async_setup_entity | (
config, async_add_entities, config_entry=None, discovery_data=None
) | Set up the MQTT Camera. | Set up the MQTT Camera. | async def _async_setup_entity(
config, async_add_entities, config_entry=None, discovery_data=None
):
"""Set up the MQTT Camera."""
async_add_entities([MqttCamera(config, config_entry, discovery_data)]) | [
"async",
"def",
"_async_setup_entity",
"(",
"config",
",",
"async_add_entities",
",",
"config_entry",
"=",
"None",
",",
"discovery_data",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"MqttCamera",
"(",
"config",
",",
"config_entry",
",",
"discovery_data"... | [
75,
0
] | [
79,
74
] | python | en | ['en', 'sv', 'en'] | True |
MqttCamera.__init__ | (self, config, config_entry, discovery_data) | Initialize the MQTT Camera. | Initialize the MQTT Camera. | def __init__(self, config, config_entry, discovery_data):
"""Initialize the MQTT Camera."""
self._config = config
self._unique_id = config.get(CONF_UNIQUE_ID)
self._sub_state = None
self._last_image = None
device_config = config.get(CONF_DEVICE)
Camera.__init__... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_unique_id",
"=",
"config",
".",
"get",
"(",
"CONF_UNIQUE_ID",
")",
"self",
".",
"_sub_state",
"=",
... | [
87,
4
] | [
101,
72
] | python | en | ['en', 'co', 'en'] | True |
MqttCamera.async_added_to_hass | (self) | Subscribe MQTT events. | Subscribe MQTT events. | async def async_added_to_hass(self):
"""Subscribe MQTT events."""
await super().async_added_to_hass()
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
103,
4
] | [
106,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttCamera.discovery_update | (self, discovery_payload) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, discovery_payload):
"""Handle updated discovery message."""
config = PLATFORM_SCHEMA(discovery_payload)
self._config = config
await self.attributes_discovery_update(config)
await self.availability_discovery_update(config)
await self.device... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"discovery_payload",
")",
":",
"config",
"=",
"PLATFORM_SCHEMA",
"(",
"discovery_payload",
")",
"self",
".",
"_config",
"=",
"config",
"await",
"self",
".",
"attributes_discovery_update",
"(",
"config",
")",
... | [
108,
4
] | [
116,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttCamera._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
@callback
@log_messages(self.hass, self.entity_id)
def message_received(msg):
"""Handle new MQTT messages."""
self._last_image = msg.payload
self._sub_state = await subscription.async_subs... | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"@",
"callback",
"@",
"log_messages",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity_id",
")",
"def",
"message_received",
"(",
"msg",
")",
":",
"\"\"\"Handle new MQTT messages.\"\"\"",
"self",
".... | [
118,
4
] | [
138,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttCamera.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state
)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_fro... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_sub_state",
"=",
"await",
"subscription",
".",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sub_state",
")",
"await",
"MqttAttributes",
".",
"async_... | [
140,
4
] | [
147,
67
] | python | en | ['en', 'en', 'en'] | True |
MqttCamera.async_camera_image | (self) | Return image response. | Return image response. | async def async_camera_image(self):
"""Return image response."""
return self._last_image | [
"async",
"def",
"async_camera_image",
"(",
"self",
")",
":",
"return",
"self",
".",
"_last_image"
] | [
149,
4
] | [
151,
31
] | python | en | ['en', 'jv', 'en'] | True |
MqttCamera.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
154,
4
] | [
156,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttCamera.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"
] | [
159,
4
] | [
161,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
require_fairscale | (test_case) |
Decorator marking a test that requires fairscale
|
Decorator marking a test that requires fairscale
| def require_fairscale(test_case):
"""
Decorator marking a test that requires fairscale
"""
if not is_fairscale_available():
return unittest.skip("test requires fairscale")(test_case)
else:
return test_case | [
"def",
"require_fairscale",
"(",
"test_case",
")",
":",
"if",
"not",
"is_fairscale_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires fairscale\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | [
46,
0
] | [
53,
24
] | python | en | ['en', 'error', 'th'] | False |
require_apex | (test_case) |
Decorator marking a test that requires apex
|
Decorator marking a test that requires apex
| def require_apex(test_case):
"""
Decorator marking a test that requires apex
"""
if not is_apex_available():
return unittest.skip("test requires apex")(test_case)
else:
return test_case | [
"def",
"require_apex",
"(",
"test_case",
")",
":",
"if",
"not",
"is_apex_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires apex\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | [
57,
0
] | [
64,
24
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the QR code image processing platform. | Set up the QR code image processing platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the QR code image processing platform."""
# pylint: disable=unused-argument
entities = []
for camera in config[CONF_SOURCE]:
entities.append(QrEntity(camera[CONF_ENTITY_ID], camera.get(CONF_NAME)))
add_entities(e... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# pylint: disable=unused-argument",
"entities",
"=",
"[",
"]",
"for",
"camera",
"in",
"config",
"[",
"CONF_SOURCE",
"]",
":",
"entities",
"... | [
15,
0
] | [
22,
26
] | python | en | ['en', 'da', 'en'] | True |
QrEntity.__init__ | (self, camera_entity, name) | Initialize QR image processing entity. | Initialize QR image processing entity. | def __init__(self, camera_entity, name):
"""Initialize QR image processing entity."""
super().__init__()
self._camera = camera_entity
if name:
self._name = name
else:
self._name = f"QR {split_entity_id(camera_entity)[1]}"
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"camera_entity",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_camera",
"=",
"camera_entity",
"if",
"name",
":",
"self",
".",
"_name",
"=",
"name",
"else",
":",
"self",
".",
... | [
28,
4
] | [
37,
26
] | python | en | ['en', 'en', 'en'] | True |
QrEntity.camera_entity | (self) | Return camera entity id from process pictures. | Return camera entity id from process pictures. | def camera_entity(self):
"""Return camera entity id from process pictures."""
return self._camera | [
"def",
"camera_entity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_camera"
] | [
40,
4
] | [
42,
27
] | python | en | ['en', 'en', 'en'] | True |
QrEntity.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
45,
4
] | [
47,
26
] | python | en | ['en', 'en', 'en'] | True |
QrEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
50,
4
] | [
52,
25
] | python | en | ['en', 'en', 'en'] | True |
QrEntity.process_image | (self, image) | Process image. | Process image. | def process_image(self, image):
"""Process image."""
stream = io.BytesIO(image)
img = Image.open(stream)
barcodes = pyzbar.decode(img)
if barcodes:
self._state = barcodes[0].data.decode("utf-8")
else:
self._state = None | [
"def",
"process_image",
"(",
"self",
",",
"image",
")",
":",
"stream",
"=",
"io",
".",
"BytesIO",
"(",
"image",
")",
"img",
"=",
"Image",
".",
"open",
"(",
"stream",
")",
"barcodes",
"=",
"pyzbar",
".",
"decode",
"(",
"img",
")",
"if",
"barcodes",
... | [
54,
4
] | [
63,
30
] | python | en | ['en', 'ny', 'en'] | False |
GRU.define_params | (self) |
Define parameters.
|
Define parameters.
| def define_params(self):
'''
Define parameters.
'''
input_dim = self.input_dim
hidden_dim = self.hidden_dim
prefix = self.name
self.w_matrix = tf.Variable(tf.random_normal([input_dim, 3 * hidden_dim], stddev=0.1),
name='/'.join(... | [
"def",
"define_params",
"(",
"self",
")",
":",
"input_dim",
"=",
"self",
".",
"input_dim",
"hidden_dim",
"=",
"self",
".",
"hidden_dim",
"prefix",
"=",
"self",
".",
"name",
"self",
".",
"w_matrix",
"=",
"tf",
".",
"Variable",
"(",
"tf",
".",
"random_norm... | [
37,
4
] | [
50,
19
] | python | en | ['en', 'error', 'th'] | False |
GRU.build | (self, x, h, mask=None) |
Build the GRU cell.
|
Build the GRU cell.
| def build(self, x, h, mask=None):
'''
Build the GRU cell.
'''
xw = tf.split(tf.matmul(x, self.w_matrix) + self.bias, 3, 1)
hu = tf.split(tf.matmul(h, self.U), 3, 1)
r = tf.sigmoid(xw[0] + hu[0])
z = tf.sigmoid(xw[1] + hu[1])
h1 = tf.tanh(xw[2] + r * hu[2])... | [
"def",
"build",
"(",
"self",
",",
"x",
",",
"h",
",",
"mask",
"=",
"None",
")",
":",
"xw",
"=",
"tf",
".",
"split",
"(",
"tf",
".",
"matmul",
"(",
"x",
",",
"self",
".",
"w_matrix",
")",
"+",
"self",
".",
"bias",
",",
"3",
",",
"1",
")",
... | [
52,
4
] | [
64,
21
] | python | en | ['en', 'error', 'th'] | False |
GRU.build_sequence | (self, xs, masks, init, is_left_to_right) |
Build GRU sequence.
|
Build GRU sequence.
| def build_sequence(self, xs, masks, init, is_left_to_right):
'''
Build GRU sequence.
'''
states = []
last = init
if is_left_to_right:
for i, xs_i in enumerate(xs):
h = self.build(xs_i, last, masks[i])
states.append(h)
... | [
"def",
"build_sequence",
"(",
"self",
",",
"xs",
",",
"masks",
",",
"init",
",",
"is_left_to_right",
")",
":",
"states",
"=",
"[",
"]",
"last",
"=",
"init",
"if",
"is_left_to_right",
":",
"for",
"i",
",",
"xs_i",
"in",
"enumerate",
"(",
"xs",
")",
":... | [
66,
4
] | [
82,
21
] | python | en | ['en', 'error', 'th'] | False |
DeopleteSourceTest.test_attributes | (self) |
Check all of the attributes we set.
|
Check all of the attributes we set.
| def test_attributes(self):
"""
Check all of the attributes we set.
"""
attributes = dict(
(key, getattr(self.source, key))
for key in
dir(self.source)
if not key.startswith('__')
and key != 'vim'
and not hasattr(geta... | [
"def",
"test_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"dict",
"(",
"(",
"key",
",",
"getattr",
"(",
"self",
".",
"source",
",",
"key",
")",
")",
"for",
"key",
"in",
"dir",
"(",
"self",
".",
"source",
")",
"if",
"not",
"key",
".",
"s... | [
36,
4
] | [
62,
10
] | python | en | ['en', 'error', 'th'] | False |
mock_shopping_list_io | () | Stub out the persistence. | Stub out the persistence. | def mock_shopping_list_io():
"""Stub out the persistence."""
with patch("homeassistant.components.shopping_list.ShoppingData.save"), patch(
"homeassistant.components.shopping_list.ShoppingData.async_load"
):
yield | [
"def",
"mock_shopping_list_io",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.shopping_list.ShoppingData.save\"",
")",
",",
"patch",
"(",
"\"homeassistant.components.shopping_list.ShoppingData.async_load\"",
")",
":",
"yield"
] | [
10,
0
] | [
15,
13
] | python | en | ['en', 'en', 'en'] | True |
sl_setup | (hass) | Set up the shopping list. | Set up the shopping list. | async def sl_setup(hass):
"""Set up the shopping list."""
entry = MockConfigEntry(domain="shopping_list")
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await sl_intent.async_setup_intents(hass) | [
"async",
"def",
"sl_setup",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"shopping_list\"",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"await",
"hass",
".",
"config_entries",
".",
"async_setup",
"(",
"entry... | [
19,
0
] | [
27,
45
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_already_setup | (hass) | Test we abort if ecobee is already setup. | Test we abort if ecobee is already setup. | async def test_abort_if_already_setup(hass):
"""Test we abort if ecobee is already setup."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABOR... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
")",
".",
"add_to_hass",
"(",
"hass",
")"... | [
18,
0
] | [
28,
56
] | python | en | ['en', 'sr', 'en'] | True |
test_user_step_without_user_input | (hass) | Test expected result if user step is called. | Test expected result if user step is called. | async def test_user_step_without_user_input(hass):
"""Test expected result if user step is called."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
... | [
"async",
"def",
"test_user_step_without_user_input",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{",
"}",
"... | [
31,
0
] | [
39,
38
] | python | en | ['en', 'en', 'en'] | True |
test_pin_request_succeeds | (hass) | Test expected result if pin request succeeds. | Test expected result if pin request succeeds. | async def test_pin_request_succeeds(hass):
"""Test expected result if pin request succeeds."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
with patch("homeassistant.components.ecobee.config_flow.Ecobee") as mock_ecobee:
mock_ecobee = mock_... | [
"async",
"def",
"test_pin_request_succeeds",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{",
"}",
"with",
... | [
42,
0
] | [
57,
72
] | python | en | ['de', 'en', 'en'] | True |
test_pin_request_fails | (hass) | Test expected result if pin request fails. | Test expected result if pin request fails. | async def test_pin_request_fails(hass):
"""Test expected result if pin request fails."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
with patch("homeassistant.components.ecobee.config_flow.Ecobee") as mock_ecobee:
mock_ecobee = mock_ecobee... | [
"async",
"def",
"test_pin_request_fails",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{",
"}",
"with",
"p... | [
60,
0
] | [
74,
63
] | python | en | ['fr', 'en', 'en'] | True |
test_token_request_succeeds | (hass) | Test expected result if token request succeeds. | Test expected result if token request succeeds. | async def test_token_request_succeeds(hass):
"""Test expected result if token request succeeds."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
with patch("homeassistant.components.ecobee.config_flow.Ecobee") as mock_ecobee:
mock_ecobee = m... | [
"async",
"def",
"test_token_request_succeeds",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{",
"}",
"with",... | [
77,
0
] | [
99,
9
] | python | en | ['nl', 'en', 'en'] | True |
test_token_request_fails | (hass) | Test expected result if token request fails. | Test expected result if token request fails. | async def test_token_request_fails(hass):
"""Test expected result if token request fails."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
with patch("homeassistant.components.ecobee.config_flow.Ecobee") as mock_ecobee:
mock_ecobee = mock_ec... | [
"async",
"def",
"test_token_request_fails",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{",
"}",
"with",
... | [
102,
0
] | [
121,
72
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_triggered_but_no_ecobee_conf | (hass) | Test expected result if import flow triggers but ecobee.conf doesn't exist. | Test expected result if import flow triggers but ecobee.conf doesn't exist. | async def test_import_flow_triggered_but_no_ecobee_conf(hass):
"""Test expected result if import flow triggers but ecobee.conf doesn't exist."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {}
result = await flow.async_step_import(import_data=None)
... | [
"async",
"def",
"test_import_flow_triggered_but_no_ecobee_conf",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]",
"=",
"{"... | [
125,
0
] | [
134,
38
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_valid_tokens | (
hass,
) | Test expected result if import flow triggers and ecobee.conf exists with valid tokens. | Test expected result if import flow triggers and ecobee.conf exists with valid tokens. | async def test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_valid_tokens(
hass,
):
"""Test expected result if import flow triggers and ecobee.conf exists with valid tokens."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
MOCK_ECOBEE_CONF = {ECOBEE_API_KEY: None, ECOBEE_REFRE... | [
"async",
"def",
"test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_valid_tokens",
"(",
"hass",
",",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"MOCK_ECOBEE_CONF",
"=",
"{",
"ECOBEE_API_KEY",
... | [
137,
0
] | [
162,
9
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_triggered_with_ecobee_conf_and_invalid_data | (hass) | Test expected result if import flow triggers and ecobee.conf exists with invalid data. | Test expected result if import flow triggers and ecobee.conf exists with invalid data. | async def test_import_flow_triggered_with_ecobee_conf_and_invalid_data(hass):
"""Test expected result if import flow triggers and ecobee.conf exists with invalid data."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {CONF_API_KEY: "test-api-key"}
MOCK... | [
"async",
"def",
"test_import_flow_triggered_with_ecobee_conf_and_invalid_data",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DATA_ECOBEE_CONFIG",
"]... | [
165,
0
] | [
184,
9
] | python | en | ['en', 'en', 'en'] | True |
test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_stale_tokens | (
hass,
) | Test expected result if import flow triggers and ecobee.conf exists with stale tokens. | Test expected result if import flow triggers and ecobee.conf exists with stale tokens. | async def test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_stale_tokens(
hass,
):
"""Test expected result if import flow triggers and ecobee.conf exists with stale tokens."""
flow = config_flow.EcobeeFlowHandler()
flow.hass = hass
flow.hass.data[DATA_ECOBEE_CONFIG] = {CONF_API_KEY: "te... | [
"async",
"def",
"test_import_flow_triggered_with_ecobee_conf_and_valid_data_and_stale_tokens",
"(",
"hass",
",",
")",
":",
"flow",
"=",
"config_flow",
".",
"EcobeeFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"hass",
".",
"data",
"[",
"DAT... | [
187,
0
] | [
212,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up a Point's alarm_control_panel based on a config entry. | Set up a Point's alarm_control_panel based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a Point's alarm_control_panel based on a config entry."""
async def async_discover_home(home_id):
"""Discover and add a discovered home."""
client = hass.data[POINT_DOMAIN][config_entry.entry_id]
async_add_en... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover_home",
"(",
"home_id",
")",
":",
"\"\"\"Discover and add a discovered home.\"\"\"",
"client",
"=",
"hass",
".",
"data",
"[",
"... | [
25,
0
] | [
35,
5
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.__init__ | (self, point_client, home_id) | Initialize the entity. | Initialize the entity. | def __init__(self, point_client, home_id):
"""Initialize the entity."""
self._client = point_client
self._home_id = home_id
self._async_unsub_hook_dispatcher_connect = None
self._changed_by = None | [
"def",
"__init__",
"(",
"self",
",",
"point_client",
",",
"home_id",
")",
":",
"self",
".",
"_client",
"=",
"point_client",
"self",
".",
"_home_id",
"=",
"home_id",
"self",
".",
"_async_unsub_hook_dispatcher_connect",
"=",
"None",
"self",
".",
"_changed_by",
"... | [
41,
4
] | [
46,
31
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.async_added_to_hass | (self) | Call when entity is added to HOme Assistant. | Call when entity is added to HOme Assistant. | async def async_added_to_hass(self):
"""Call when entity is added to HOme Assistant."""
await super().async_added_to_hass()
self._async_unsub_hook_dispatcher_connect = async_dispatcher_connect(
self.hass, SIGNAL_WEBHOOK, self._webhook_event
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_async_unsub_hook_dispatcher_connect",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_WEBHOOK",
"... | [
48,
4
] | [
53,
9
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.async_will_remove_from_hass | (self) | Disconnect dispatcher listener when removed. | Disconnect dispatcher listener when removed. | async def async_will_remove_from_hass(self):
"""Disconnect dispatcher listener when removed."""
await super().async_will_remove_from_hass()
if self._async_unsub_hook_dispatcher_connect:
self._async_unsub_hook_dispatcher_connect() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"if",
"self",
".",
"_async_unsub_hook_dispatcher_connect",
":",
"self",
".",
"_async_unsub_hook_dispatcher_connect",
"(",
")... | [
55,
4
] | [
59,
55
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl._webhook_event | (self, data, webhook) | Process new event from the webhook. | Process new event from the webhook. | def _webhook_event(self, data, webhook):
"""Process new event from the webhook."""
_type = data.get("event", {}).get("type")
_device_id = data.get("event", {}).get("device_id")
_changed_by = data.get("event", {}).get("user_id")
if (
_device_id not in self._home["devic... | [
"def",
"_webhook_event",
"(",
"self",
",",
"data",
",",
"webhook",
")",
":",
"_type",
"=",
"data",
".",
"get",
"(",
"\"event\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"type\"",
")",
"_device_id",
"=",
"data",
".",
"get",
"(",
"\"event\"",
",",
"{"... | [
62,
4
] | [
74,
35
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl._home | (self) | Return the home object. | Return the home object. | def _home(self):
"""Return the home object."""
return self._client.homes[self._home_id] | [
"def",
"_home",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client",
".",
"homes",
"[",
"self",
".",
"_home_id",
"]"
] | [
77,
4
] | [
79,
48
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.name | (self) | Return name of the device. | Return name of the device. | def name(self):
"""Return name of the device."""
return self._home["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_home",
"[",
"\"name\"",
"]"
] | [
82,
4
] | [
84,
33
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.state | (self) | Return state of the device. | Return state of the device. | def state(self):
"""Return state of the device."""
return EVENT_MAP.get(self._home["alarm_status"], STATE_ALARM_ARMED_AWAY) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"EVENT_MAP",
".",
"get",
"(",
"self",
".",
"_home",
"[",
"\"alarm_status\"",
"]",
",",
"STATE_ALARM_ARMED_AWAY",
")"
] | [
87,
4
] | [
89,
80
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_AWAY | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_AWAY"
] | [
92,
4
] | [
94,
37
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.changed_by | (self) | Return the user the last change was triggered by. | Return the user the last change was triggered by. | def changed_by(self):
"""Return the user the last change was triggered by."""
return self._changed_by | [
"def",
"changed_by",
"(",
"self",
")",
":",
"return",
"self",
".",
"_changed_by"
] | [
97,
4
] | [
99,
31
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
status = await self._client.async_alarm_disarm(self._home_id)
if status:
self._home["alarm_status"] = "off" | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"status",
"=",
"await",
"self",
".",
"_client",
".",
"async_alarm_disarm",
"(",
"self",
".",
"_home_id",
")",
"if",
"status",
":",
"self",
".",
"_home",
"[",
"\"alarm_... | [
101,
4
] | [
105,
46
] | python | en | ['en', 'pt', 'en'] | True |
MinutPointAlarmControl.async_alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
status = await self._client.async_alarm_arm(self._home_id)
if status:
self._home["alarm_status"] = "on" | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"status",
"=",
"await",
"self",
".",
"_client",
".",
"async_alarm_arm",
"(",
"self",
".",
"_home_id",
")",
"if",
"status",
":",
"self",
".",
"_home",
"[",
"\"alarm_s... | [
107,
4
] | [
111,
45
] | python | en | ['en', 'en', 'en'] | True |
MinutPointAlarmControl.unique_id | (self) | Return the unique id of the sensor. | Return the unique id of the sensor. | def unique_id(self):
"""Return the unique id of the sensor."""
return f"point.{self._home_id}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"point.{self._home_id}\""
] | [
114,
4
] | [
116,
39
] | python | en | ['en', 'la', 'en'] | True |
MinutPointAlarmControl.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return {
"identifiers": {(POINT_DOMAIN, self._home_id)},
"name": self.name,
"manufacturer": "Minut",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"POINT_DOMAIN",
",",
"self",
".",
"_home_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"Minut\"",
",",
"}"
] | [
119,
4
] | [
125,
9
] | python | en | ['ro', 'fr', 'en'] | False |
get_scanner | (hass, config) | Validate the configuration and return an Xfinity Gateway scanner. | Validate the configuration and return an Xfinity Gateway scanner. | def get_scanner(hass, config):
"""Validate the configuration and return an Xfinity Gateway scanner."""
_LOGGER.warning(
"The Xfinity Gateway has been deprecated and will be removed from "
"Home Assistant in version 0.109. Please remove it from your "
"configuration. "
)
gateway ... | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"The Xfinity Gateway has been deprecated and will be removed from \"",
"\"Home Assistant in version 0.109. Please remove it from your \"",
"\"configuration. \"",
")",
"gateway",
"=",
"Xf... | [
24,
0
] | [
42,
18
] | python | en | ['en', 'en', 'en'] | True |
XfinityDeviceScanner.__init__ | (self, gateway) | Initialize the scanner. | Initialize the scanner. | def __init__(self, gateway):
"""Initialize the scanner."""
self.gateway = gateway | [
"def",
"__init__",
"(",
"self",
",",
"gateway",
")",
":",
"self",
".",
"gateway",
"=",
"gateway"
] | [
48,
4
] | [
50,
30
] | python | en | ['en', 'en', 'en'] | True |
XfinityDeviceScanner.scan_devices | (self) | Scan for new devices and return a list of found MACs. | Scan for new devices and return a list of found MACs. | def scan_devices(self):
"""Scan for new devices and return a list of found MACs."""
connected_devices = []
try:
connected_devices = self.gateway.scan_devices()
except (RequestException, ValueError):
_LOGGER.error("Unable to scan devices. Check connection to gatewa... | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"connected_devices",
"=",
"[",
"]",
"try",
":",
"connected_devices",
"=",
"self",
".",
"gateway",
".",
"scan_devices",
"(",
")",
"except",
"(",
"RequestException",
",",
"ValueError",
")",
":",
"_LOGGER",
".",
"... | [
52,
4
] | [
59,
32
] | python | en | ['en', 'en', 'en'] | True |
XfinityDeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
return self.gateway.get_device_name(device) | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"return",
"self",
".",
"gateway",
".",
"get_device_name",
"(",
"device",
")"
] | [
61,
4
] | [
63,
51
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Add binary sensors for a config entry. | Add binary sensors for a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add binary sensors for a config entry."""
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
sensors = []
for device in broker.devices.values():
for capability in broker.get_assigned(device.device_id, "sensor"):... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"broker",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_BROKERS",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"sensors",
"=",
"[",
"]... | [
273,
0
] | [
296,
31
] | python | en | ['en', 'en', 'en'] | True |
get_capabilities | (capabilities: Sequence[str]) | Return all capabilities supported if minimum required are present. | Return all capabilities supported if minimum required are present. | def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
"""Return all capabilities supported if minimum required are present."""
return [
capability for capability in CAPABILITY_TO_SENSORS if capability in capabilities
] | [
"def",
"get_capabilities",
"(",
"capabilities",
":",
"Sequence",
"[",
"str",
"]",
")",
"->",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
":",
"return",
"[",
"capability",
"for",
"capability",
"in",
"CAPABILITY_TO_SENSORS",
"if",
"capability",
"in",
"c... | [
299,
0
] | [
303,
5
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsSensor.__init__ | (
self, device, attribute: str, name: str, default_unit: str, device_class: str
) | Init the class. | Init the class. | def __init__(
self, device, attribute: str, name: str, default_unit: str, device_class: str
):
"""Init the class."""
super().__init__(device)
self._attribute = attribute
self._name = name
self._device_class = device_class
self._default_unit = default_unit | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"attribute",
":",
"str",
",",
"name",
":",
"str",
",",
"default_unit",
":",
"str",
",",
"device_class",
":",
"str",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"... | [
309,
4
] | [
317,
41
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsSensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self) -> str:
"""Return the name of the binary sensor."""
return f"{self._device.label} {self._name}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.label} {self._name}\""
] | [
320,
4
] | [
322,
51
] | python | en | ['en', 'mi', 'en'] | True |
SmartThingsSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device.device_id}.{self._attribute}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.device_id}.{self._attribute}\""
] | [
325,
4
] | [
327,
60
] | python | ca | ['fr', 'ca', 'en'] | False |
SmartThingsSensor.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._device.status.attributes[self._attribute].value | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"status",
".",
"attributes",
"[",
"self",
".",
"_attribute",
"]",
".",
"value"
] | [
330,
4
] | [
332,
68
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsSensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self):
"""Return the device class of the sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
335,
4
] | [
337,
33
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
unit = self._device.status.attributes[self._attribute].unit
return UNITS.get(unit, unit) if unit else self._default_unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"unit",
"=",
"self",
".",
"_device",
".",
"status",
".",
"attributes",
"[",
"self",
".",
"_attribute",
"]",
".",
"unit",
"return",
"UNITS",
".",
"get",
"(",
"unit",
",",
"unit",
")",
"if",
"unit",
... | [
340,
4
] | [
343,
68
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsThreeAxisSensor.__init__ | (self, device, index) | Init the class. | Init the class. | def __init__(self, device, index):
"""Init the class."""
super().__init__(device)
self._index = index | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"index",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"_index",
"=",
"index"
] | [
349,
4
] | [
352,
27
] | python | en | ['en', 'en', 'en'] | True |
SmartThingsThreeAxisSensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self) -> str:
"""Return the name of the binary sensor."""
return "{} {}".format(self._device.label, THREE_AXIS_NAMES[self._index]) | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"{} {}\"",
".",
"format",
"(",
"self",
".",
"_device",
".",
"label",
",",
"THREE_AXIS_NAMES",
"[",
"self",
".",
"_index",
"]",
")"
] | [
355,
4
] | [
357,
80
] | python | en | ['en', 'mi', 'en'] | True |
SmartThingsThreeAxisSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return "{}.{}".format(self._device.device_id, THREE_AXIS_NAMES[self._index]) | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"{}.{}\"",
".",
"format",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"THREE_AXIS_NAMES",
"[",
"self",
".",
"_index",
"]",
")"
] | [
360,
4
] | [
362,
84
] | python | ca | ['fr', 'ca', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.