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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SamsungTVDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
157,
4
] | [
159,
25
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
162,
4
] | [
164,
26
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self):
"""Return device specific attributes."""
return {
"name": self.name,
"identifiers": {(DOMAIN, self.unique_id)},
"manufacturer": self._manufacturer,
"model": self._model,
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"manufacturer\"",
":",
"self",
".",
"_manufacturer",
",",
... | [
167,
4
] | [
174,
9
] | python | en | ['fr', 'it', 'en'] | False |
SamsungTVDevice.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self._muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_muted"
] | [
177,
4
] | [
179,
26
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return list(SOURCES) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"SOURCES",
")"
] | [
182,
4
] | [
184,
28
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
if self._on_script:
return SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON
return SUPPORT_SAMSUNGTV | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_on_script",
":",
"return",
"SUPPORT_SAMSUNGTV",
"|",
"SUPPORT_TURN_ON",
"return",
"SUPPORT_SAMSUNGTV"
] | [
187,
4
] | [
191,
32
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.device_class | (self) | Set the device class to TV. | Set the device class to TV. | def device_class(self):
"""Set the device class to TV."""
return DEVICE_CLASS_TV | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TV"
] | [
194,
4
] | [
196,
30
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)
self.send_key("KEY_POWEROFF")
# Force closing of remote session to provide instant UI feedback
self._bridge.close_remote() | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_end_of_power_off",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
"=",
"15",
")",
"self",
".",
"send_key",
"(",
"\"KEY_POWEROFF\"",
")",
"# Force closing of remote session to ... | [
198,
4
] | [
204,
35
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.volume_up | (self) | Volume up the media player. | Volume up the media player. | def volume_up(self):
"""Volume up the media player."""
self.send_key("KEY_VOLUP") | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"send_key",
"(",
"\"KEY_VOLUP\"",
")"
] | [
206,
4
] | [
208,
34
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.volume_down | (self) | Volume down media player. | Volume down media player. | def volume_down(self):
"""Volume down media player."""
self.send_key("KEY_VOLDOWN") | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"send_key",
"(",
"\"KEY_VOLDOWN\"",
")"
] | [
210,
4
] | [
212,
36
] | python | en | ['en', 'sl', 'en'] | True |
SamsungTVDevice.mute_volume | (self, mute) | Send mute command. | Send mute command. | def mute_volume(self, mute):
"""Send mute command."""
self.send_key("KEY_MUTE") | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"send_key",
"(",
"\"KEY_MUTE\"",
")"
] | [
214,
4
] | [
216,
33
] | python | en | ['en', 'co', 'en'] | True |
SamsungTVDevice.media_play_pause | (self) | Simulate play pause media player. | Simulate play pause media player. | def media_play_pause(self):
"""Simulate play pause media player."""
if self._playing:
self.media_pause()
else:
self.media_play() | [
"def",
"media_play_pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"_playing",
":",
"self",
".",
"media_pause",
"(",
")",
"else",
":",
"self",
".",
"media_play",
"(",
")"
] | [
218,
4
] | [
223,
29
] | python | en | ['en', 'en', 'it'] | True |
SamsungTVDevice.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
self._playing = True
self.send_key("KEY_PLAY") | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"_playing",
"=",
"True",
"self",
".",
"send_key",
"(",
"\"KEY_PLAY\"",
")"
] | [
225,
4
] | [
228,
33
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.media_pause | (self) | Send media pause command to media player. | Send media pause command to media player. | def media_pause(self):
"""Send media pause command to media player."""
self._playing = False
self.send_key("KEY_PAUSE") | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_playing",
"=",
"False",
"self",
".",
"send_key",
"(",
"\"KEY_PAUSE\"",
")"
] | [
230,
4
] | [
233,
34
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
self.send_key("KEY_CHUP") | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"send_key",
"(",
"\"KEY_CHUP\"",
")"
] | [
235,
4
] | [
237,
33
] | python | en | ['en', 'pt', 'en'] | True |
SamsungTVDevice.media_previous_track | (self) | Send the previous track command. | Send the previous track command. | def media_previous_track(self):
"""Send the previous track command."""
self.send_key("KEY_CHDOWN") | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"send_key",
"(",
"\"KEY_CHDOWN\"",
")"
] | [
239,
4
] | [
241,
35
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.async_play_media | (self, media_type, media_id, **kwargs) | Support changing a channel. | Support changing a channel. | async def async_play_media(self, media_type, media_id, **kwargs):
"""Support changing a channel."""
if media_type != MEDIA_TYPE_CHANNEL:
LOGGER.error("Unsupported media type")
return
# media_id should only be a channel number
try:
cv.positive_int(medi... | [
"async",
"def",
"async_play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"media_type",
"!=",
"MEDIA_TYPE_CHANNEL",
":",
"LOGGER",
".",
"error",
"(",
"\"Unsupported media type\"",
")",
"return",
"# media_id sho... | [
243,
4
] | [
259,
74
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.async_turn_on | (self) | Turn the media player on. | Turn the media player on. | async def async_turn_on(self):
"""Turn the media player on."""
if self._on_script:
await self._on_script.async_run(context=self._context) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_on_script",
":",
"await",
"self",
".",
"_on_script",
".",
"async_run",
"(",
"context",
"=",
"self",
".",
"_context",
")"
] | [
261,
4
] | [
264,
66
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVDevice.select_source | (self, source) | Select input source. | Select input source. | def select_source(self, source):
"""Select input source."""
if source not in SOURCES:
LOGGER.error("Unsupported source")
return
self.send_key(SOURCES[source]) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"source",
"not",
"in",
"SOURCES",
":",
"LOGGER",
".",
"error",
"(",
"\"Unsupported source\"",
")",
"return",
"self",
".",
"send_key",
"(",
"SOURCES",
"[",
"source",
"]",
")"
] | [
266,
4
] | [
272,
38
] | python | en | ['fr', 'su', 'en'] | False |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up the climate platform. | Set up the climate platform. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the climate platform."""
if DATA_SDM not in entry.data:
await async_setup_legacy_entry(hass, entry, async_add_entities)
return
await async_setup_sdm_entry(hass, entry, async_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"if",
"DATA_SDM",
"not",
"in",
"entry",
".",
"data",
":",
"await",
"async_setup_legacy_entry",
"(",
... | [
10,
0
] | [
17,
64
] | python | en | ['en', 'da', 'en'] | True |
validate_input | (hass: HomeAssistantType, data: Dict) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(hass: HomeAssistantType, data: Dict) -> Dict:
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
session = async_get_clientsession(hass)
roku = Roku(data[CONF_HOST], session=session)
device = await r... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"HomeAssistantType",
",",
"data",
":",
"Dict",
")",
"->",
"Dict",
":",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
"roku",
"=",
"Roku",
"(",
"data",
"[",
"CONF_HOST",
"]",
",",
"session",... | [
29,
0
] | [
41,
5
] | python | en | ['en', 'en', 'en'] | True |
RokuConfigFlow.__init__ | (self) | Set up the instance. | Set up the instance. | def __init__(self):
"""Set up the instance."""
self.discovery_info = {} | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"discovery_info",
"=",
"{",
"}"
] | [
50,
4
] | [
52,
32
] | python | en | ['en', 'en', 'en'] | True |
RokuConfigFlow._show_form | (self, errors: Optional[Dict] = None) | Show the form to the user. | Show the form to the user. | def _show_form(self, errors: Optional[Dict] = None) -> Dict[str, Any]:
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
data_schema=DATA_SCHEMA,
errors=errors or {},
) | [
"def",
"_show_form",
"(",
"self",
",",
"errors",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
... | [
55,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
RokuConfigFlow.async_step_user | (
self, user_input: Optional[Dict] = None
) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(
self, user_input: Optional[Dict] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by the user."""
if not user_input:
return self._show_form()
errors = {}
try:
info = await validate_input(self.hass, user_input)
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"not",
"user_input",
":",
"return",
"self",
".",
"_show_form",
"(",
")",
"er... | [
63,
4
] | [
85,
76
] | python | en | ['en', 'en', 'en'] | True |
RokuConfigFlow.async_step_ssdp | (
self, discovery_info: Optional[Dict] = None
) | Handle a flow initialized by discovery. | Handle a flow initialized by discovery. | async def async_step_ssdp(
self, discovery_info: Optional[Dict] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
name = discovery_info[ATTR_UPNP_FRIENDLY_NAME]
serial_number = discovery_info... | [
"async",
"def",
"async_step_ssdp",
"(",
"self",
",",
"discovery_info",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"host",
"=",
"urlparse",
"(",
"discovery_info",
"[",
"ATTR_SSDP_LOCATION",
"]",
")... | [
87,
4
] | [
112,
51
] | python | en | ['en', 'en', 'en'] | True |
RokuConfigFlow.async_step_ssdp_confirm | (
self, user_input: Optional[Dict] = None
) | Handle user-confirmation of discovered device. | Handle user-confirmation of discovered device. | async def async_step_ssdp_confirm(
self, user_input: Optional[Dict] = None
) -> Dict[str, Any]:
"""Handle user-confirmation of discovered device."""
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
if user_input is None:
return self.async_show_for... | [
"async",
"def",
"async_step_ssdp_confirm",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167",
"if",
"user_i... | [
114,
4
] | [
129,
9
] | python | en | ['en', 'en', 'en'] | True |
auth_mfa_module_from_config | (
hass: HomeAssistant, config: Dict[str, Any]
) | Initialize an auth module from a config. | Initialize an auth module from a config. | async def auth_mfa_module_from_config(
hass: HomeAssistant, config: Dict[str, Any]
) -> MultiFactorAuthModule:
"""Initialize an auth module from a config."""
module_name = config[CONF_TYPE]
module = await _load_mfa_module(hass, module_name)
try:
config = module.CONFIG_SCHEMA(config) # type... | [
"async",
"def",
"auth_mfa_module_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"MultiFactorAuthModule",
":",
"module_name",
"=",
"config",
"[",
"CONF_TYPE",
"]",
"module",
"=",
"await",
"... | [
124,
0
] | [
141,
63
] | python | en | ['en', 'en', 'en'] | True |
_load_mfa_module | (hass: HomeAssistant, module_name: str) | Load an mfa auth module. | Load an mfa auth module. | async def _load_mfa_module(hass: HomeAssistant, module_name: str) -> types.ModuleType:
"""Load an mfa auth module."""
module_path = f"homeassistant.auth.mfa_modules.{module_name}"
try:
module = importlib.import_module(module_path)
except ImportError as err:
_LOGGER.error("Unable to load... | [
"async",
"def",
"_load_mfa_module",
"(",
"hass",
":",
"HomeAssistant",
",",
"module_name",
":",
"str",
")",
"->",
"types",
".",
"ModuleType",
":",
"module_path",
"=",
"f\"homeassistant.auth.mfa_modules.{module_name}\"",
"try",
":",
"module",
"=",
"importlib",
".",
... | [
144,
0
] | [
171,
17
] | python | en | ['en', 'gd', 'sw'] | False |
MultiFactorAuthModule.__init__ | (self, hass: HomeAssistant, config: Dict[str, Any]) | Initialize an auth module. | Initialize an auth module. | def __init__(self, hass: HomeAssistant, config: Dict[str, Any]) -> None:
"""Initialize an auth module."""
self.hass = hass
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config",
"=",
"config"
] | [
38,
4
] | [
41,
28
] | python | de | ['de', 'en', 'nl'] | False |
MultiFactorAuthModule.id | (self) | Return id of the auth module.
Default is same as type
| Return id of the auth module. | def id(self) -> str:
"""Return id of the auth module.
Default is same as type
"""
return self.config.get(CONF_ID, self.type) | [
"def",
"id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config",
".",
"get",
"(",
"CONF_ID",
",",
"self",
".",
"type",
")"
] | [
44,
4
] | [
49,
50
] | python | en | ['en', 'en', 'en'] | True |
MultiFactorAuthModule.type | (self) | Return type of the module. | Return type of the module. | def type(self) -> str:
"""Return type of the module."""
return self.config[CONF_TYPE] | [
"def",
"type",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config",
"[",
"CONF_TYPE",
"]"
] | [
52,
4
] | [
54,
37
] | python | en | ['en', 'yo', 'en'] | True |
MultiFactorAuthModule.name | (self) | Return the name of the auth module. | Return the name of the auth module. | def name(self) -> str:
"""Return the name of the auth module."""
return self.config.get(CONF_NAME, self.DEFAULT_TITLE) | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config",
".",
"get",
"(",
"CONF_NAME",
",",
"self",
".",
"DEFAULT_TITLE",
")"
] | [
57,
4
] | [
59,
61
] | python | en | ['en', 'en', 'en'] | True |
MultiFactorAuthModule.input_schema | (self) | Return a voluptuous schema to define mfa auth module's input. | Return a voluptuous schema to define mfa auth module's input. | def input_schema(self) -> vol.Schema:
"""Return a voluptuous schema to define mfa auth module's input."""
raise NotImplementedError | [
"def",
"input_schema",
"(",
"self",
")",
"->",
"vol",
".",
"Schema",
":",
"raise",
"NotImplementedError"
] | [
64,
4
] | [
66,
33
] | python | en | ['en', 'de', 'en'] | True |
MultiFactorAuthModule.async_setup_flow | (self, user_id: str) | Return a data entry flow handler for setup module.
Mfa module should extend SetupFlow
| Return a data entry flow handler for setup module. | async def async_setup_flow(self, user_id: str) -> "SetupFlow":
"""Return a data entry flow handler for setup module.
Mfa module should extend SetupFlow
"""
raise NotImplementedError | [
"async",
"def",
"async_setup_flow",
"(",
"self",
",",
"user_id",
":",
"str",
")",
"->",
"\"SetupFlow\"",
":",
"raise",
"NotImplementedError"
] | [
68,
4
] | [
73,
33
] | python | en | ['en', 'da', 'en'] | True |
MultiFactorAuthModule.async_setup_user | (self, user_id: str, setup_data: Any) | Set up user for mfa auth module. | Set up user for mfa auth module. | async def async_setup_user(self, user_id: str, setup_data: Any) -> Any:
"""Set up user for mfa auth module."""
raise NotImplementedError | [
"async",
"def",
"async_setup_user",
"(",
"self",
",",
"user_id",
":",
"str",
",",
"setup_data",
":",
"Any",
")",
"->",
"Any",
":",
"raise",
"NotImplementedError"
] | [
75,
4
] | [
77,
33
] | python | en | ['en', 'en', 'en'] | True |
MultiFactorAuthModule.async_depose_user | (self, user_id: str) | Remove user from mfa module. | Remove user from mfa module. | async def async_depose_user(self, user_id: str) -> None:
"""Remove user from mfa module."""
raise NotImplementedError | [
"async",
"def",
"async_depose_user",
"(",
"self",
",",
"user_id",
":",
"str",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
79,
4
] | [
81,
33
] | python | en | ['en', 'it', 'en'] | True |
MultiFactorAuthModule.async_is_user_setup | (self, user_id: str) | Return whether user is setup. | Return whether user is setup. | async def async_is_user_setup(self, user_id: str) -> bool:
"""Return whether user is setup."""
raise NotImplementedError | [
"async",
"def",
"async_is_user_setup",
"(",
"self",
",",
"user_id",
":",
"str",
")",
"->",
"bool",
":",
"raise",
"NotImplementedError"
] | [
83,
4
] | [
85,
33
] | python | en | ['en', 'no', 'en'] | True |
MultiFactorAuthModule.async_validate | (self, user_id: str, user_input: Dict[str, Any]) | Return True if validation passed. | Return True if validation passed. | async def async_validate(self, user_id: str, user_input: Dict[str, Any]) -> bool:
"""Return True if validation passed."""
raise NotImplementedError | [
"async",
"def",
"async_validate",
"(",
"self",
",",
"user_id",
":",
"str",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"raise",
"NotImplementedError"
] | [
87,
4
] | [
89,
33
] | python | en | ['fr', 'ky', 'en'] | False |
SetupFlow.__init__ | (
self, auth_module: MultiFactorAuthModule, setup_schema: vol.Schema, user_id: str
) | Initialize the setup flow. | Initialize the setup flow. | def __init__(
self, auth_module: MultiFactorAuthModule, setup_schema: vol.Schema, user_id: str
) -> None:
"""Initialize the setup flow."""
self._auth_module = auth_module
self._setup_schema = setup_schema
self._user_id = user_id | [
"def",
"__init__",
"(",
"self",
",",
"auth_module",
":",
"MultiFactorAuthModule",
",",
"setup_schema",
":",
"vol",
".",
"Schema",
",",
"user_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_auth_module",
"=",
"auth_module",
"self",
".",
"_setup_schema... | [
95,
4
] | [
101,
31
] | python | en | ['en', 'en', 'en'] | True |
SetupFlow.async_step_init | (
self, user_input: Optional[Dict[str, str]] = None
) | Handle the first step of setup flow.
Return self.async_show_form(step_id='init') if user_input is None.
Return self.async_create_entry(data={'result': result}) if finish.
| Handle the first step of setup flow. | async def async_step_init(
self, user_input: Optional[Dict[str, str]] = None
) -> Dict[str, Any]:
"""Handle the first step of setup flow.
Return self.async_show_form(step_id='init') if user_input is None.
Return self.async_create_entry(data={'result': result}) if finish.
"""... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"errors",
":",
"Dict",
"[",
"str",
",",
"str",
"]... | [
103,
4
] | [
121,
9
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
24,
0
] | [
26,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
30,
0
] | [
32,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
36,
0
] | [
38,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_conditions | (hass, device_reg, entity_reg) | Test we get the expected conditions from a switch. | Test we get the expected conditions from a switch. | async def test_get_conditions(hass, device_reg, entity_reg):
"""Test we get the expected conditions from a switch."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
... | [
"async",
"def",
"test_get_conditions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",... | [
41,
0
] | [
67,
44
] | python | en | ['en', 'en', 'en'] | True |
test_get_condition_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a switch condition. | Test we get the expected capabilities from a switch condition. | async def test_get_condition_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a switch condition."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=confi... | [
"async",
"def",
"test_get_condition_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"h... | [
70,
0
] | [
89,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_state | (hass, calls) | Test for turn_on and turn_off conditions. | Test for turn_on and turn_off conditions. | async def test_if_state(hass, calls):
"""Test for turn_on and turn_off conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
ent1, ent2, ent3 = ... | [
"async",
"def",
"test_if_state",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",... | [
92,
0
] | [
163,
64
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_for_condition | (hass, calls) | Test for firing if condition is on with delay. | Test for firing if condition is on with delay. | async def test_if_fires_on_for_condition(hass, calls):
"""Test for firing if condition is on with delay."""
point1 = dt_util.utcnow()
point2 = point1 + timedelta(seconds=10)
point3 = point2 + timedelta(seconds=10)
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert... | [
"async",
"def",
"test_if_fires_on_for_condition",
"(",
"hass",
",",
"calls",
")",
":",
"point1",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"point2",
"=",
"point1",
"+",
"timedelta",
"(",
"seconds",
"=",
"10",
")",
"point3",
"=",
"point2",
"+",
"timedelta",
... | [
166,
0
] | [
234,
68
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the Netatmo camera platform. | Set up the Netatmo camera platform. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the Netatmo camera platform."""
if "access_camera" not in entry.data["token"]["scope"]:
_LOGGER.info(
"Cameras are currently not supported with this authentication method"
)
return
data_handler = has... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"if",
"\"access_camera\"",
"not",
"in",
"entry",
".",
"data",
"[",
"\"token\"",
"]",
"[",
"\"scope\"",
"]",
":",
"_LOGGER",
".",
"info",
"(",
"\"Cameras are ... | [
41,
0
] | [
113,
9
] | python | en | ['en', 'pt', 'en'] | True |
NetatmoCamera.__init__ | (
self,
data_handler,
camera_id,
camera_type,
home_id,
quality,
) | Set up for access to the Netatmo camera images. | Set up for access to the Netatmo camera images. | def __init__(
self,
data_handler,
camera_id,
camera_type,
home_id,
quality,
):
"""Set up for access to the Netatmo camera images."""
Camera.__init__(self)
super().__init__(data_handler)
self._data_classes.append(
{"name": C... | [
"def",
"__init__",
"(",
"self",
",",
"data_handler",
",",
"camera_id",
",",
"camera_type",
",",
"home_id",
",",
"quality",
",",
")",
":",
"Camera",
".",
"__init__",
"(",
"self",
")",
"super",
"(",
")",
".",
"__init__",
"(",
"data_handler",
")",
"self",
... | [
119,
4
] | [
148,
32
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.async_added_to_hass | (self) | Entity created. | Entity created. | async def async_added_to_hass(self) -> None:
"""Entity created."""
await super().async_added_to_hass()
for event_type in (EVENT_TYPE_LIGHT_MODE, EVENT_TYPE_OFF, EVENT_TYPE_ON):
self._listeners.append(
async_dispatcher_connect(
self.hass,
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"for",
"event_type",
"in",
"(",
"EVENT_TYPE_LIGHT_MODE",
",",
"EVENT_TYPE_OFF",
",",
"EVENT_TYPE_ON",
")",
":",
"self"... | [
150,
4
] | [
163,
74
] | python | en | ['en', 'sm', 'en'] | False |
NetatmoCamera.handle_event | (self, event) | Handle webhook events. | Handle webhook events. | def handle_event(self, event):
"""Handle webhook events."""
data = event["data"]
if not data.get("camera_id"):
return
if data["home_id"] == self._home_id and data["camera_id"] == self._id:
if data["push_type"] in ["NACamera-off", "NACamera-disconnection"]:
... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"data",
"=",
"event",
"[",
"\"data\"",
"]",
"if",
"not",
"data",
".",
"get",
"(",
"\"camera_id\"",
")",
":",
"return",
"if",
"data",
"[",
"\"home_id\"",
"]",
"==",
"self",
".",
"_home_id",
"... | [
166,
4
] | [
184,
18
] | python | en | ['eu', 'xh', 'en'] | False |
NetatmoCamera.camera_image | (self) | Return a still image response from the camera. | Return a still image response from the camera. | def camera_image(self):
"""Return a still image response from the camera."""
try:
if self._localurl:
response = requests.get(
f"{self._localurl}/live/snapshot_720.jpg", timeout=10
)
elif self._vpnurl:
response = ... | [
"def",
"camera_image",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_localurl",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"f\"{self._localurl}/live/snapshot_720.jpg\"",
",",
"timeout",
"=",
"10",
")",
"elif",
"self",
".",
"_vpnurl",
":",
... | [
186,
4
] | [
212,
31
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.device_state_attributes | (self) | Return the Netatmo-specific camera state attributes. | Return the Netatmo-specific camera state attributes. | def device_state_attributes(self):
"""Return the Netatmo-specific camera state attributes."""
return {
"id": self._id,
"status": self._status,
"sd_status": self._sd_status,
"alim_status": self._alim_status,
"is_local": self._is_local,
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"id\"",
":",
"self",
".",
"_id",
",",
"\"status\"",
":",
"self",
".",
"_status",
",",
"\"sd_status\"",
":",
"self",
".",
"_sd_status",
",",
"\"alim_status\"",
":",
"self",
".",
"_ali... | [
215,
4
] | [
226,
9
] | python | en | ['en', 'it', 'en'] | True |
NetatmoCamera.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return bool(self._alim_status == "on" or self._status == "disconnected") | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_alim_status",
"==",
"\"on\"",
"or",
"self",
".",
"_status",
"==",
"\"disconnected\"",
")"
] | [
229,
4
] | [
231,
80
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
return SUPPORT_STREAM | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_STREAM"
] | [
234,
4
] | [
236,
29
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.brand | (self) | Return the camera brand. | Return the camera brand. | def brand(self):
"""Return the camera brand."""
return MANUFACTURER | [
"def",
"brand",
"(",
"self",
")",
":",
"return",
"MANUFACTURER"
] | [
239,
4
] | [
241,
27
] | python | en | ['en', 'bs', 'en'] | True |
NetatmoCamera.motion_detection_enabled | (self) | Return the camera motion detection status. | Return the camera motion detection status. | def motion_detection_enabled(self):
"""Return the camera motion detection status."""
return bool(self._status == "on") | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_status",
"==",
"\"on\"",
")"
] | [
244,
4
] | [
246,
41
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.is_on | (self) | Return true if on. | Return true if on. | def is_on(self):
"""Return true if on."""
return self.is_streaming | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"is_streaming"
] | [
249,
4
] | [
251,
32
] | python | en | ['en', 'mt', 'en'] | True |
NetatmoCamera.turn_off | (self) | Turn off camera. | Turn off camera. | def turn_off(self):
"""Turn off camera."""
self._data.set_state(
home_id=self._home_id, camera_id=self._id, monitoring="off"
) | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_data",
".",
"set_state",
"(",
"home_id",
"=",
"self",
".",
"_home_id",
",",
"camera_id",
"=",
"self",
".",
"_id",
",",
"monitoring",
"=",
"\"off\"",
")"
] | [
253,
4
] | [
257,
9
] | python | en | ['en', 'ja', 'en'] | True |
NetatmoCamera.turn_on | (self) | Turn on camera. | Turn on camera. | def turn_on(self):
"""Turn on camera."""
self._data.set_state(home_id=self._home_id, camera_id=self._id, monitoring="on") | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"_data",
".",
"set_state",
"(",
"home_id",
"=",
"self",
".",
"_home_id",
",",
"camera_id",
"=",
"self",
".",
"_id",
",",
"monitoring",
"=",
"\"on\"",
")"
] | [
259,
4
] | [
261,
88
] | python | en | ['en', 'et', 'en'] | True |
NetatmoCamera.stream_source | (self) | Return the stream source. | Return the stream source. | async def stream_source(self):
"""Return the stream source."""
url = "{0}/live/files/{1}/index.m3u8"
if self._localurl:
return url.format(self._localurl, self._quality)
return url.format(self._vpnurl, self._quality) | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"url",
"=",
"\"{0}/live/files/{1}/index.m3u8\"",
"if",
"self",
".",
"_localurl",
":",
"return",
"url",
".",
"format",
"(",
"self",
".",
"_localurl",
",",
"self",
".",
"_quality",
")",
"return",
"url",
... | [
263,
4
] | [
268,
54
] | python | en | ['en', 'ig', 'en'] | True |
NetatmoCamera.model | (self) | Return the camera model. | Return the camera model. | def model(self):
"""Return the camera model."""
return MODELS[self._model] | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"MODELS",
"[",
"self",
".",
"_model",
"]"
] | [
271,
4
] | [
273,
34
] | python | en | ['en', 'co', 'en'] | True |
NetatmoCamera.async_update_callback | (self) | Update the entity's state. | Update the entity's state. | def async_update_callback(self):
"""Update the entity's state."""
camera = self._data.get_camera(self._id)
self._vpnurl, self._localurl = self._data.camera_urls(self._id)
self._status = camera.get("status")
self._sd_status = camera.get("sd_status")
self._alim_status = cam... | [
"def",
"async_update_callback",
"(",
"self",
")",
":",
"camera",
"=",
"self",
".",
"_data",
".",
"get_camera",
"(",
"self",
".",
"_id",
")",
"self",
".",
"_vpnurl",
",",
"self",
".",
"_localurl",
"=",
"self",
".",
"_data",
".",
"camera_urls",
"(",
"sel... | [
276,
4
] | [
293,
13
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera.process_events | (self, events) | Add meta data to events. | Add meta data to events. | def process_events(self, events):
"""Add meta data to events."""
for event in events.values():
if "video_id" not in event:
continue
if self._is_local:
event[
"media_url"
] = f"{self._localurl}/vod/{event['video_i... | [
"def",
"process_events",
"(",
"self",
",",
"events",
")",
":",
"for",
"event",
"in",
"events",
".",
"values",
"(",
")",
":",
"if",
"\"video_id\"",
"not",
"in",
"event",
":",
"continue",
"if",
"self",
".",
"_is_local",
":",
"event",
"[",
"\"media_url\"",
... | [
295,
4
] | [
308,
21
] | python | en | ['it', 'en', 'en'] | True |
NetatmoCamera._service_set_persons_home | (self, **kwargs) | Service to change current home schedule. | Service to change current home schedule. | def _service_set_persons_home(self, **kwargs):
"""Service to change current home schedule."""
persons = kwargs.get(ATTR_PERSONS)
person_ids = []
for person in persons:
for pid, data in self._data.persons.items():
if data.get("pseudo") == person:
... | [
"def",
"_service_set_persons_home",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"persons",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_PERSONS",
")",
"person_ids",
"=",
"[",
"]",
"for",
"person",
"in",
"persons",
":",
"for",
"pid",
",",
"data",
"in",
"se... | [
310,
4
] | [
320,
51
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera._service_set_person_away | (self, **kwargs) | Service to mark a person as away or set the home as empty. | Service to mark a person as away or set the home as empty. | def _service_set_person_away(self, **kwargs):
"""Service to mark a person as away or set the home as empty."""
person = kwargs.get(ATTR_PERSON)
person_id = None
if person:
for pid, data in self._data.persons.items():
if data.get("pseudo") == person:
... | [
"def",
"_service_set_person_away",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"person",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_PERSON",
")",
"person_id",
"=",
"None",
"if",
"person",
":",
"for",
"pid",
",",
"data",
"in",
"self",
".",
"_data",
".",
... | [
322,
4
] | [
343,
46
] | python | en | ['en', 'en', 'en'] | True |
NetatmoCamera._service_set_camera_light | (self, **kwargs) | Service to set light mode. | Service to set light mode. | def _service_set_camera_light(self, **kwargs):
"""Service to set light mode."""
mode = kwargs.get(ATTR_CAMERA_LIGHT_MODE)
_LOGGER.debug("Turn camera '%s' %s", self._name, mode)
self._data.set_state(
home_id=self._home_id,
camera_id=self._id,
floodlight... | [
"def",
"_service_set_camera_light",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"mode",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_CAMERA_LIGHT_MODE",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Turn camera '%s' %s\"",
",",
"self",
".",
"_name",
",",
"mode",
")",
... | [
345,
4
] | [
353,
9
] | python | en | ['en', 'pt', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Perform the setup for Xiaomi devices. | Perform the setup for Xiaomi devices. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Perform the setup for Xiaomi devices."""
entities = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
for device in gateway.devices["switch"]:
model = device["model"]
if model == "plug":
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"gateway",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"GATEWAYS_KEY",
"]",
"[",
"config_entry",
".",
"entry_id",
... | [
23,
0
] | [
123,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.__init__ | (
self,
device,
name,
data_key,
supports_power_consumption,
xiaomi_hub,
config_entry,
) | Initialize the XiaomiPlug. | Initialize the XiaomiPlug. | def __init__(
self,
device,
name,
data_key,
supports_power_consumption,
xiaomi_hub,
config_entry,
):
"""Initialize the XiaomiPlug."""
self._data_key = data_key
self._in_use = None
self._load_power = None
self._power_cons... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"name",
",",
"data_key",
",",
"supports_power_consumption",
",",
"xiaomi_hub",
",",
"config_entry",
",",
")",
":",
"self",
".",
"_data_key",
"=",
"data_key",
"self",
".",
"_in_use",
"=",
"None",
"self",
"... | [
129,
4
] | [
144,
64
] | python | en | ['en', 'pl', 'en'] | True |
XiaomiGenericSwitch.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
if self._data_key == "status":
return "mdi:power-plug"
return "mdi:power-socket" | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data_key",
"==",
"\"status\"",
":",
"return",
"\"mdi:power-plug\"",
"return",
"\"mdi:power-socket\""
] | [
147,
4
] | [
151,
33
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.is_on | (self) | Return true if it is on. | Return true if it is on. | def is_on(self):
"""Return true if it is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
154,
4
] | [
156,
26
] | python | en | ['en', 'fy', 'en'] | True |
XiaomiGenericSwitch.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if self._supports_power_consumption:
attrs = {
ATTR_IN_USE: self._in_use,
ATTR_LOAD_POWER: self._load_power,
ATTR_POWER_CONSUMED: self._power_consumed,
}
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_supports_power_consumption",
":",
"attrs",
"=",
"{",
"ATTR_IN_USE",
":",
"self",
".",
"_in_use",
",",
"ATTR_LOAD_POWER",
":",
"self",
".",
"_load_power",
",",
"ATTR_POWER_CONSUMED",
":... | [
159,
4
] | [
170,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.should_poll | (self) | Return the polling state. Polling needed for Zigbee plug only. | Return the polling state. Polling needed for Zigbee plug only. | def should_poll(self):
"""Return the polling state. Polling needed for Zigbee plug only."""
return self._supports_power_consumption | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supports_power_consumption"
] | [
173,
4
] | [
175,
47
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
if self._write_to_hub(self._sid, **{self._data_key: "on"}):
self._state = True
self.schedule_update_ha_state() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_write_to_hub",
"(",
"self",
".",
"_sid",
",",
"*",
"*",
"{",
"self",
".",
"_data_key",
":",
"\"on\"",
"}",
")",
":",
"self",
".",
"_state",
"=",
"True",
"self"... | [
177,
4
] | [
181,
43
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
if self._write_to_hub(self._sid, **{self._data_key: "off"}):
self._state = False
self.schedule_update_ha_state() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_write_to_hub",
"(",
"self",
".",
"_sid",
",",
"*",
"*",
"{",
"self",
".",
"_data_key",
":",
"\"off\"",
"}",
")",
":",
"self",
".",
"_state",
"=",
"False",
"se... | [
183,
4
] | [
187,
43
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGenericSwitch.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if IN_USE in data:
self._in_use = int(data[IN_USE])
if not self._in_use:
self._load_power = 0
for key in [POWER_CONSUMED, ENERGY_CONSUMED]:
if key in data:
... | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"if",
"IN_USE",
"in",
"data",
":",
"self",
".",
"_in_use",
"=",
"int",
"(",
"data",
"[",
"IN_USE",
"]",
")",
"if",
"not",
"self",
".",
"_in_use",
":",
"self",
".",
"_load_pow... | [
189,
4
] | [
212,
19
] | python | en | ['en', 'de', 'en'] | True |
XiaomiGenericSwitch.update | (self) | Get data from hub. | Get data from hub. | def update(self):
"""Get data from hub."""
_LOGGER.debug("Update data from hub: %s", self._name)
self._get_from_hub(self._sid) | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Update data from hub: %s\"",
",",
"self",
".",
"_name",
")",
"self",
".",
"_get_from_hub",
"(",
"self",
".",
"_sid",
")"
] | [
214,
4
] | [
217,
37
] | python | en | ['en', 'en', 'en'] | True |
test_uuid_util_random_uuid_hex | () | Verify we can generate a random uuid. | Verify we can generate a random uuid. | async def test_uuid_util_random_uuid_hex():
"""Verify we can generate a random uuid."""
assert len(uuid_util.random_uuid_hex()) == 32
assert uuid.UUID(uuid_util.random_uuid_hex()) | [
"async",
"def",
"test_uuid_util_random_uuid_hex",
"(",
")",
":",
"assert",
"len",
"(",
"uuid_util",
".",
"random_uuid_hex",
"(",
")",
")",
"==",
"32",
"assert",
"uuid",
".",
"UUID",
"(",
"uuid_util",
".",
"random_uuid_hex",
"(",
")",
")"
] | [
7,
0
] | [
10,
49
] | python | en | ['en', 'cy', 'en'] | True |
async_setup | (hass, config) | Set up the LIFX component. | Set up the LIFX component. | async def async_setup(hass, config):
"""Set up the LIFX component."""
conf = config.get(DOMAIN)
hass.data[DOMAIN] = conf or {}
if conf is not None:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"conf",
"or",
"{",
"}",
"if",
"conf",
"is",
"not",
"None",
":",
"hass",
".",... | [
29,
0
] | [
42,
15
] | python | en | ['en', 'fr', 'en'] | True |
async_setup_entry | (hass, entry) | Set up LIFX from a config entry. | Set up LIFX from a config entry. | async def async_setup_entry(hass, entry):
"""Set up LIFX from a config entry."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, LIGHT_DOMAIN)
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"entry",
",",
"LIGHT_DOMAIN",
")",
")",
"return",
"True"
] | [
45,
0
] | [
51,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
hass.data.pop(DATA_LIFX_MANAGER).cleanup()
await hass.config_entries.async_forward_entry_unload(entry, LIGHT_DOMAIN)
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"data",
".",
"pop",
"(",
"DATA_LIFX_MANAGER",
")",
".",
"cleanup",
"(",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",... | [
54,
0
] | [
60,
15
] | python | en | ['en', 'es', 'en'] | True |
RingEntityMixin.__init__ | (self, config_entry_id, device) | Initialize a sensor for Ring device. | Initialize a sensor for Ring device. | def __init__(self, config_entry_id, device):
"""Initialize a sensor for Ring device."""
super().__init__()
self._config_entry_id = config_entry_id
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"config_entry_id",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_config_entry_id",
"=",
"config_entry_id",
"self",
".",
"_device",
"=",
"device"
] | [
10,
4
] | [
14,
29
] | python | en | ['en', 'en', 'en'] | True |
RingEntityMixin.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.ring_objects["device_data"].async_add_listener(self._update_callback) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"ring_objects",
"[",
"\"device_data\"",
"]",
".",
"async_add_listener",
"(",
"self",
".",
"_update_callback",
")"
] | [
16,
4
] | [
18,
82
] | python | en | ['en', 'no', 'en'] | False |
RingEntityMixin.async_will_remove_from_hass | (self) | Disconnect callbacks. | Disconnect callbacks. | async def async_will_remove_from_hass(self):
"""Disconnect callbacks."""
self.ring_objects["device_data"].async_remove_listener(self._update_callback) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"ring_objects",
"[",
"\"device_data\"",
"]",
".",
"async_remove_listener",
"(",
"self",
".",
"_update_callback",
")"
] | [
20,
4
] | [
22,
85
] | python | en | ['en', 'ja', 'en'] | False |
RingEntityMixin._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
25,
4
] | [
27,
35
] | python | en | ['en', 'sn', 'en'] | True |
RingEntityMixin.ring_objects | (self) | Return the Ring API objects. | Return the Ring API objects. | def ring_objects(self):
"""Return the Ring API objects."""
return self.hass.data[DOMAIN][self._config_entry_id] | [
"def",
"ring_objects",
"(",
"self",
")",
":",
"return",
"self",
".",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"self",
".",
"_config_entry_id",
"]"
] | [
30,
4
] | [
32,
60
] | python | en | ['en', 'en', 'en'] | True |
RingEntityMixin.should_poll | (self) | Return False, updates are controlled via the hub. | Return False, updates are controlled via the hub. | def should_poll(self):
"""Return False, updates are controlled via the hub."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
35,
4
] | [
37,
20
] | python | en | ['en', 'sm', 'en'] | True |
RingEntityMixin.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
40,
4
] | [
42,
46
] | python | en | ['en', 'en', 'en'] | True |
RingEntityMixin.device_info | (self) | Return device info. | Return device info. | def device_info(self):
"""Return device info."""
return {
"identifiers": {(DOMAIN, self._device.device_id)},
"name": self._device.name,
"model": self._device.model,
"manufacturer": "Ring",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"device_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device",
".",
"name",
",",
"\"model\"",
":",
"self",
... | [
45,
4
] | [
52,
9
] | python | en | ['es', 'hr', 'en'] | False |
XiaomiMiioFlowHandler.__init__ | (self) | Initialize. | Initialize. | def __init__(self):
"""Initialize."""
self.host = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"host",
"=",
"None"
] | [
36,
4
] | [
38,
24
] | python | en | ['en', 'en', 'it'] | False |
XiaomiMiioFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
# Check which device needs to be connected.
if user_input[CONF_GATEWAY]:
return await self.async_step_gateway()
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"# Check which device needs to be connected.",
"if",
"user_input",
"[",
"CONF_GATEWAY",
"]",
":",
"... | [
40,
4
] | [
52,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiMiioFlowHandler.async_step_zeroconf | (self, discovery_info) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(self, discovery_info):
"""Handle zeroconf discovery."""
name = discovery_info.get("name")
self.host = discovery_info.get("host")
mac_address = discovery_info.get("properties", {}).get("mac")
if not name or not self.host or not mac_address:
... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
")",
":",
"name",
"=",
"discovery_info",
".",
"get",
"(",
"\"name\"",
")",
"self",
".",
"host",
"=",
"discovery_info",
".",
"get",
"(",
"\"host\"",
")",
"mac_address",
"=",
"discovery... | [
54,
4
] | [
82,
57
] | python | de | ['de', 'sr', 'en'] | False |
XiaomiMiioFlowHandler.async_step_gateway | (self, user_input=None) | Handle a flow initialized by the user to configure a gateway. | Handle a flow initialized by the user to configure a gateway. | async def async_step_gateway(self, user_input=None):
"""Handle a flow initialized by the user to configure a gateway."""
errors = {}
if user_input is not None:
token = user_input[CONF_TOKEN]
if user_input.get(CONF_HOST):
self.host = user_input[CONF_HOST]
... | [
"async",
"def",
"async_step_gateway",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"token",
"=",
"user_input",
"[",
"CONF_TOKEN",
"]",
"if",
"user_input",
".",
"get",
"(",
... | [
84,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
Poster.get_data | (self) |
Gets every snapshots from main and subfolders.
Data looks like this:
{'1.1.1.1': [{'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}, {}]}
|
Gets every snapshots from main and subfolders.
Data looks like this:
{'1.1.1.1': [{'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}, {}]}
| def get_data(self):
'''
Gets every snapshots from main and subfolders.
Data looks like this:
{'1.1.1.1': [{'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}, {}]}
'''
self.prep_files_to_post = defaultdict(list)
#TODO: grab al... | [
"def",
"get_data",
"(",
"self",
")",
":",
"self",
".",
"prep_files_to_post",
"=",
"defaultdict",
"(",
"list",
")",
"#TODO: grab all channels to an album\r",
"for",
"d",
",",
"dirs",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"fdir",
")",
... | [
34,
1
] | [
60,
32
] | python | en | ['en', 'ja', 'th'] | False |
Poster.prep_data | (self, folder, host) |
Gets folder where is snapshots and its name.
From 1.1.1.1_37777_admin_admin_1.jpg returns: '1.1.1.1', {'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}
|
Gets folder where is snapshots and its name.
From 1.1.1.1_37777_admin_admin_1.jpg returns: '1.1.1.1', {'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}
| def prep_data(self, folder, host):
'''
Gets folder where is snapshots and its name.
From 1.1.1.1_37777_admin_admin_1.jpg returns: '1.1.1.1', {'Port': '37777', 'Login': 'admin', 'Password': 'admin', 'Channel': '1', 'Path': '/.../1.1.1.1_37777_admin_admin_1.jpg'}
'''
self.data = host.split("_")
return s... | [
"def",
"prep_data",
"(",
"self",
",",
"folder",
",",
"host",
")",
":",
"self",
".",
"data",
"=",
"host",
".",
"split",
"(",
"\"_\"",
")",
"return",
"self",
".",
"data",
"[",
"0",
"]",
",",
"{",
"\"Port\"",
":",
"self",
".",
"data",
"[",
"1",
"]... | [
63,
1
] | [
69,
180
] | python | en | ['en', 'ja', 'th'] | False |
Poster.sort_list | (self, files_to_sort) |
Sorts list for each host by channel.
|
Sorts list for each host by channel.
| def sort_list(self, files_to_sort):
'''
Sorts list for each host by channel.
'''
def ckey(data):
return int(data["Channel"])
self.files_to_post_sorted = dict(files_to_sort) #convert from defaultdict object to normal dict
for i in range(len(self.files_to_post_sorted)):
self.files_to_post_sort... | [
"def",
"sort_list",
"(",
"self",
",",
"files_to_sort",
")",
":",
"def",
"ckey",
"(",
"data",
")",
":",
"return",
"int",
"(",
"data",
"[",
"\"Channel\"",
"]",
")",
"self",
".",
"files_to_post_sorted",
"=",
"dict",
"(",
"files_to_sort",
")",
"#convert from d... | [
72,
1
] | [
83,
34
] | python | en | ['en', 'ja', 'th'] | False |
test_calendar | () | Return a test calendar. | Return a test calendar. | def test_calendar():
"""Return a test calendar."""
return TEST_CALENDAR | [
"def",
"test_calendar",
"(",
")",
":",
"return",
"TEST_CALENDAR"
] | [
23,
0
] | [
25,
24
] | python | en | ['en', 'is', 'en'] | True |
mock_next_event | () | Mock the google calendar data. | Mock the google calendar data. | def mock_next_event():
"""Mock the google calendar data."""
patch_google_cal = patch(
"homeassistant.components.google.calendar.GoogleCalendarData"
)
with patch_google_cal as google_cal_data:
yield google_cal_data | [
"def",
"mock_next_event",
"(",
")",
":",
"patch_google_cal",
"=",
"patch",
"(",
"\"homeassistant.components.google.calendar.GoogleCalendarData\"",
")",
"with",
"patch_google_cal",
"as",
"google_cal_data",
":",
"yield",
"google_cal_data"
] | [
29,
0
] | [
35,
29
] | python | en | ['en', 'tr', 'en'] | True |
GaussianProcess_QuasiPeriodicActivity_Alternative.lnlk_compute | (self, variable_value, dataset) | 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to GP input parameters
| 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to GP input parameters
| def lnlk_compute(self, variable_value, dataset):
""" 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to GP input parameters
"""
env = dataset.e ** 2.0 + dataset.jitter ** 2.0
... | [
"def",
"lnlk_compute",
"(",
"self",
",",
"variable_value",
",",
"dataset",
")",
":",
"env",
"=",
"dataset",
".",
"e",
"**",
"2.0",
"+",
"dataset",
".",
"jitter",
"**",
"2.0",
"cov_matrix",
"=",
"self",
".",
"_compute_cov_matrix",
"(",
"variable_value",
","... | [
68,
4
] | [
84,
26
] | python | en | ['en', 'sk', 'en'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Abode sensor devices. | Set up Abode sensor devices. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode sensor devices."""
data = hass.data[DOMAIN]
entities = []
for device in data.abode.get_devices(generic_type=CONST.TYPE_SENSOR):
for sensor_type in SENSOR_TYPES:
if sensor_type not in device.get_val... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"data",
".",
"abode",
".",
"get_devices",
... | [
20,
0
] | [
32,
32
] | python | da | ['es', 'da', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.