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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
LcnOutputsCover.assumed_state | (self) | Return True if unable to access real state of the entity. | Return True if unable to access real state of the entity. | def assumed_state(self):
"""Return True if unable to access real state of the entity."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
82,
4
] | [
84,
19
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputsCover.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs):
"""Close the cover."""
self._is_opening = False
self._is_closing = True
state = pypck.lcn_defs.MotorStateModifier.DOWN
self.address_connection.control_motors_outputs(state, self.reverse_time)
self.async_write_ha_state() | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_opening",
"=",
"False",
"self",
".",
"_is_closing",
"=",
"True",
"state",
"=",
"pypck",
".",
"lcn_defs",
".",
"MotorStateModifier",
".",
"DOWN",
"self",
... | [
86,
4
] | [
92,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputsCover.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
self._is_closed = False
self._is_opening = True
self._is_closing = False
state = pypck.lcn_defs.MotorStateModifier.UP
self.address_connection.control_motors_outputs(state, self.reverse_time)
self.as... | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_closed",
"=",
"False",
"self",
".",
"_is_opening",
"=",
"True",
"self",
".",
"_is_closing",
"=",
"False",
"state",
"=",
"pypck",
".",
"lcn_defs",
".",
... | [
94,
4
] | [
101,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputsCover.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
self._is_closing = False
self._is_opening = False
state = pypck.lcn_defs.MotorStateModifier.STOP
self.address_connection.control_motors_outputs(state)
self.async_write_ha_state() | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_closing",
"=",
"False",
"self",
".",
"_is_opening",
"=",
"False",
"state",
"=",
"pypck",
".",
"lcn_defs",
".",
"MotorStateModifier",
".",
"STOP",
"self",
... | [
103,
4
] | [
109,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnOutputsCover.input_received | (self, input_obj) | Set cover states when LCN input object (command) is received. | Set cover states when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set cover states when LCN input object (command) is received."""
if (
not isinstance(input_obj, pypck.inputs.ModStatusOutput)
or input_obj.get_output_id() not in self.output_ids
):
return
if input_obj.get_percen... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusOutput",
")",
"or",
"input_obj",
".",
"get_output_id",
"(",
")",
"not",
"in",
"self",
".",
"ou... | [
111,
4
] | [
133,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.__init__ | (self, config, address_connection) | Initialize the LCN cover. | Initialize the LCN cover. | def __init__(self, config, address_connection):
"""Initialize the LCN cover."""
super().__init__(config, address_connection)
self.motor = pypck.lcn_defs.MotorPort[config[CONF_MOTOR]]
self.motor_port_onoff = self.motor.value * 2
self.motor_port_updown = self.motor_port_onoff + 1
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"motor",
"=",
"pypck",
".",
"lcn_defs",
".",
"MotorPort",
"[",
"config",
"... | [
139,
4
] | [
149,
32
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.motor) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"motor",
")"
] | [
151,
4
] | [
154,
81
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.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._is_closed | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_closed"
] | [
157,
4
] | [
159,
30
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return self._is_opening | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_opening"
] | [
162,
4
] | [
164,
31
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return self._is_closing | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_closing"
] | [
167,
4
] | [
169,
31
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.assumed_state | (self) | Return True if unable to access real state of the entity. | Return True if unable to access real state of the entity. | def assumed_state(self):
"""Return True if unable to access real state of the entity."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
172,
4
] | [
174,
19
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs):
"""Close the cover."""
self._is_opening = False
self._is_closing = True
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.DOWN
self.address_connection.control... | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_opening",
"=",
"False",
"self",
".",
"_is_closing",
"=",
"True",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"MotorStateModifier",
".",
"NOCHANGE"... | [
176,
4
] | [
183,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
self._is_closed = False
self._is_opening = True
self._is_closing = False
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.UP
sel... | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_closed",
"=",
"False",
"self",
".",
"_is_opening",
"=",
"True",
"self",
".",
"_is_closing",
"=",
"False",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
... | [
185,
4
] | [
193,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
self._is_closing = False
self._is_opening = False
states = [pypck.lcn_defs.MotorStateModifier.NOCHANGE] * 4
states[self.motor.value] = pypck.lcn_defs.MotorStateModifier.STOP
self.address_connection.control_... | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_is_closing",
"=",
"False",
"self",
".",
"_is_opening",
"=",
"False",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"MotorStateModifier",
".",
"NOCHANGE"... | [
195,
4
] | [
202,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnRelayCover.input_received | (self, input_obj) | Set cover states when LCN input object (command) is received. | Set cover states when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set cover states when LCN input object (command) is received."""
if not isinstance(input_obj, pypck.inputs.ModStatusRelays):
return
states = input_obj.states # list of boolean values (relay on/off)
if states[self.motor_port_onoff]: #... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusRelays",
")",
":",
"return",
"states",
"=",
"input_obj",
".",
"states",
"# list of boolean values (relay on... | [
204,
4
] | [
218,
35
] | python | en | ['en', 'en', 'en'] | True |
_discovery | (config_info) | Discover receivers from configuration in the network. | Discover receivers from configuration in the network. | def _discovery(config_info):
"""Discover receivers from configuration in the network."""
if config_info.from_discovery:
receivers = rxv.RXV(
config_info.ctrl_url,
model_name=config_info.model,
friendly_name=config_info.name,
unit_desc_url=config_info.desc_... | [
"def",
"_discovery",
"(",
"config_info",
")",
":",
"if",
"config_info",
".",
"from_discovery",
":",
"receivers",
"=",
"rxv",
".",
"RXV",
"(",
"config_info",
".",
"ctrl_url",
",",
"model_name",
"=",
"config_info",
".",
"model",
",",
"friendly_name",
"=",
"con... | [
98,
0
] | [
115,
20
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Yamaha platform. | Set up the Yamaha platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Yamaha platform."""
# Keep track of configured receivers so that we don't end up
# discovering a receiver dynamically that we have static config
# for. Map each device from its zone_id .
known_zones... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# Keep track of configured receivers so that we don't end up",
"# discovering a receiver dynamically that we have static config",
"# for. Ma... | [
118,
0
] | [
165,
5
] | python | en | ['en', 'su', 'en'] | True |
YamahaConfigInfo.__init__ | (self, config: None, discovery_info: None) | Initialize the Configuration Info for Yamaha Receiver. | Initialize the Configuration Info for Yamaha Receiver. | def __init__(self, config: None, discovery_info: None):
"""Initialize the Configuration Info for Yamaha Receiver."""
self.name = config.get(CONF_NAME)
self.host = config.get(CONF_HOST)
self.ctrl_url = f"http://{self.host}:80/YamahaRemoteControl/ctrl"
self.source_ignore = config.g... | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"None",
",",
"discovery_info",
":",
"None",
")",
":",
"self",
".",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"self",
".",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
... | [
79,
4
] | [
95,
38
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.__init__ | (self, name, receiver, source_ignore, source_names, zone_names) | Initialize the Yamaha Receiver. | Initialize the Yamaha Receiver. | def __init__(self, name, receiver, source_ignore, source_names, zone_names):
"""Initialize the Yamaha Receiver."""
self.receiver = receiver
self._muted = False
self._volume = 0
self._pwstate = STATE_OFF
self._current_source = None
self._sound_mode = None
s... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"receiver",
",",
"source_ignore",
",",
"source_names",
",",
"zone_names",
")",
":",
"self",
".",
"receiver",
"=",
"receiver",
"self",
".",
"_muted",
"=",
"False",
"self",
".",
"_volume",
"=",
"0",
"self",... | [
171,
4
] | [
189,
34
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.update | (self) | Get the latest details from the device. | Get the latest details from the device. | def update(self):
"""Get the latest details from the device."""
try:
self._play_status = self.receiver.play_status()
except requests.exceptions.ConnectionError:
_LOGGER.info("Receiver is offline: %s", self._name)
return
if self.receiver.on:
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_play_status",
"=",
"self",
".",
"receiver",
".",
"play_status",
"(",
")",
"except",
"requests",
".",
"exceptions",
".",
"ConnectionError",
":",
"_LOGGER",
".",
"info",
"(",
"\"Receiver is o... | [
191,
4
] | [
227,
40
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.build_source_list | (self) | Build the source list. | Build the source list. | def build_source_list(self):
"""Build the source list."""
self._reverse_mapping = {
alias: source for source, alias in self._source_names.items()
}
self._source_list = sorted(
self._source_names.get(source, source)
for source in self.receiver.inputs()... | [
"def",
"build_source_list",
"(",
"self",
")",
":",
"self",
".",
"_reverse_mapping",
"=",
"{",
"alias",
":",
"source",
"for",
"source",
",",
"alias",
"in",
"self",
".",
"_source_names",
".",
"items",
"(",
")",
"}",
"self",
".",
"_source_list",
"=",
"sorte... | [
229,
4
] | [
239,
9
] | python | en | ['en', 'fr', 'en'] | True |
YamahaDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
name = self._name
zone_name = self._zone_names.get(self._zone, self._zone)
if zone_name != "Main_Zone":
# Zone will be one of Main_Zone, Zone_2, Zone_3
name += f" {zone_name.replace('_', ' ')}"
return na... | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"_name",
"zone_name",
"=",
"self",
".",
"_zone_names",
".",
"get",
"(",
"self",
".",
"_zone",
",",
"self",
".",
"_zone",
")",
"if",
"zone_name",
"!=",
"\"Main_Zone\"",
":",
"# Zone will be... | [
242,
4
] | [
249,
19
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.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._pwstate | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pwstate"
] | [
252,
4
] | [
254,
28
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
return self._volume | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_volume"
] | [
257,
4
] | [
259,
27
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.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"
] | [
262,
4
] | [
264,
26
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.source | (self) | Return the current input source. | Return the current input source. | def source(self):
"""Return the current input source."""
return self._current_source | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_source"
] | [
267,
4
] | [
269,
35
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.sound_mode | (self) | Return the current sound mode. | Return the current sound mode. | def sound_mode(self):
"""Return the current sound mode."""
return self._sound_mode | [
"def",
"sound_mode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sound_mode"
] | [
272,
4
] | [
274,
31
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.sound_mode_list | (self) | Return the current sound mode. | Return the current sound mode. | def sound_mode_list(self):
"""Return the current sound mode."""
return self._sound_mode_list | [
"def",
"sound_mode_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sound_mode_list"
] | [
277,
4
] | [
279,
36
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return self._source_list | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source_list"
] | [
282,
4
] | [
284,
32
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.zone_id | (self) | Return a zone_id to ensure 1 media player per zone. | Return a zone_id to ensure 1 media player per zone. | def zone_id(self):
"""Return a zone_id to ensure 1 media player per zone."""
return f"{self.receiver.ctrl_url}:{self._zone}" | [
"def",
"zone_id",
"(",
"self",
")",
":",
"return",
"f\"{self.receiver.ctrl_url}:{self._zone}\""
] | [
287,
4
] | [
289,
55
] | python | en | ['en', 'co', 'en'] | True |
YamahaDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
supported_features = SUPPORT_YAMAHA
supports = self._playback_support
mapping = {
"play": (SUPPORT_PLAY | SUPPORT_PLAY_MEDIA),
"pause": SUPPORT_PAUSE,
"stop": SUPPORT_S... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"SUPPORT_YAMAHA",
"supports",
"=",
"self",
".",
"_playback_support",
"mapping",
"=",
"{",
"\"play\"",
":",
"(",
"SUPPORT_PLAY",
"|",
"SUPPORT_PLAY_MEDIA",
")",
",",
"\"pause\"",
":",
... | [
292,
4
] | [
307,
33
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self.receiver.on = False | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"receiver",
".",
"on",
"=",
"False"
] | [
309,
4
] | [
311,
32
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
receiver_vol = 100 - (volume * 100)
negative_receiver_vol = -receiver_vol
self.receiver.volume = negative_receiver_vol | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"receiver_vol",
"=",
"100",
"-",
"(",
"volume",
"*",
"100",
")",
"negative_receiver_vol",
"=",
"-",
"receiver_vol",
"self",
".",
"receiver",
".",
"volume",
"=",
"negative_receiver_vol"
] | [
313,
4
] | [
317,
52
] | python | en | ['fr', 'zu', 'en'] | False |
YamahaDevice.mute_volume | (self, mute) | Mute (true) or unmute (false) media player. | Mute (true) or unmute (false) media player. | def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
self.receiver.mute = mute | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"receiver",
".",
"mute",
"=",
"mute"
] | [
319,
4
] | [
321,
33
] | python | en | ['en', 'la', 'it'] | False |
YamahaDevice.turn_on | (self) | Turn the media player on. | Turn the media player on. | def turn_on(self):
"""Turn the media player on."""
self.receiver.on = True
self._volume = (self.receiver.volume / 100) + 1 | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"receiver",
".",
"on",
"=",
"True",
"self",
".",
"_volume",
"=",
"(",
"self",
".",
"receiver",
".",
"volume",
"/",
"100",
")",
"+",
"1"
] | [
323,
4
] | [
326,
55
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
self._call_playback_function(self.receiver.play, "play") | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"_call_playback_function",
"(",
"self",
".",
"receiver",
".",
"play",
",",
"\"play\"",
")"
] | [
328,
4
] | [
330,
64
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_pause | (self) | Send pause command. | Send pause command. | def media_pause(self):
"""Send pause command."""
self._call_playback_function(self.receiver.pause, "pause") | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_call_playback_function",
"(",
"self",
".",
"receiver",
".",
"pause",
",",
"\"pause\"",
")"
] | [
332,
4
] | [
334,
66
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_stop | (self) | Send stop command. | Send stop command. | def media_stop(self):
"""Send stop command."""
self._call_playback_function(self.receiver.stop, "stop") | [
"def",
"media_stop",
"(",
"self",
")",
":",
"self",
".",
"_call_playback_function",
"(",
"self",
".",
"receiver",
".",
"stop",
",",
"\"stop\"",
")"
] | [
336,
4
] | [
338,
64
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_previous_track | (self) | Send previous track command. | Send previous track command. | def media_previous_track(self):
"""Send previous track command."""
self._call_playback_function(self.receiver.previous, "previous track") | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"_call_playback_function",
"(",
"self",
".",
"receiver",
".",
"previous",
",",
"\"previous track\"",
")"
] | [
340,
4
] | [
342,
78
] | python | en | ['en', 'it', 'en'] | True |
YamahaDevice.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
self._call_playback_function(self.receiver.next, "next track") | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"_call_playback_function",
"(",
"self",
".",
"receiver",
".",
"next",
",",
"\"next track\"",
")"
] | [
344,
4
] | [
346,
70
] | python | en | ['en', 'pt', 'en'] | True |
YamahaDevice.select_source | (self, source) | Select input source. | Select input source. | def select_source(self, source):
"""Select input source."""
self.receiver.input = self._reverse_mapping.get(source, source) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"receiver",
".",
"input",
"=",
"self",
".",
"_reverse_mapping",
".",
"get",
"(",
"source",
",",
"source",
")"
] | [
354,
4
] | [
356,
71
] | python | en | ['fr', 'su', 'en'] | False |
YamahaDevice.play_media | (self, media_type, media_id, **kwargs) | Play media from an ID.
This exposes a pass through for various input sources in the
Yamaha to direct play certain kinds of media. media_type is
treated as the input type that we are setting, and media id is
specific to it.
For the NET RADIO mediatype the format for ``media_id`` ... | Play media from an ID. | def play_media(self, media_type, media_id, **kwargs):
"""Play media from an ID.
This exposes a pass through for various input sources in the
Yamaha to direct play certain kinds of media. media_type is
treated as the input type that we are setting, and media id is
specific to it.... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"media_type",
"==",
"\"NET RADIO\"",
":",
"self",
".",
"receiver",
".",
"net_radio",
"(",
"media_id",
")"
] | [
358,
4
] | [
378,
45
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.enable_output | (self, port, enabled) | Enable or disable an output port.. | Enable or disable an output port.. | def enable_output(self, port, enabled):
"""Enable or disable an output port.."""
self.receiver.enable_output(port, enabled) | [
"def",
"enable_output",
"(",
"self",
",",
"port",
",",
"enabled",
")",
":",
"self",
".",
"receiver",
".",
"enable_output",
"(",
"port",
",",
"enabled",
")"
] | [
380,
4
] | [
382,
50
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.set_scene | (self, scene) | Set the current scene. | Set the current scene. | def set_scene(self, scene):
"""Set the current scene."""
try:
self.receiver.scene = scene
except AssertionError:
_LOGGER.warning("Scene '%s' does not exist!", scene) | [
"def",
"set_scene",
"(",
"self",
",",
"scene",
")",
":",
"try",
":",
"self",
".",
"receiver",
".",
"scene",
"=",
"scene",
"except",
"AssertionError",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Scene '%s' does not exist!\"",
",",
"scene",
")"
] | [
384,
4
] | [
389,
64
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.select_sound_mode | (self, sound_mode) | Set Sound Mode for Receiver.. | Set Sound Mode for Receiver.. | def select_sound_mode(self, sound_mode):
"""Set Sound Mode for Receiver.."""
self.receiver.surround_program = sound_mode | [
"def",
"select_sound_mode",
"(",
"self",
",",
"sound_mode",
")",
":",
"self",
".",
"receiver",
".",
"surround_program",
"=",
"sound_mode"
] | [
391,
4
] | [
393,
51
] | python | en | ['en', 'pt', 'en'] | True |
YamahaDevice.media_artist | (self) | Artist of current playing media. | Artist of current playing media. | def media_artist(self):
"""Artist of current playing media."""
if self._play_status is not None:
return self._play_status.artist | [
"def",
"media_artist",
"(",
"self",
")",
":",
"if",
"self",
".",
"_play_status",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_play_status",
".",
"artist"
] | [
396,
4
] | [
399,
43
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_album_name | (self) | Album of current playing media. | Album of current playing media. | def media_album_name(self):
"""Album of current playing media."""
if self._play_status is not None:
return self._play_status.album | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_play_status",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_play_status",
".",
"album"
] | [
402,
4
] | [
405,
42
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_content_type | (self) | Content type of current playing media. | Content type of current playing media. | def media_content_type(self):
"""Content type of current playing media."""
# Loose assumption that if playback is supported, we are playing music
if self._is_playback_supported:
return MEDIA_TYPE_MUSIC
return None | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"# Loose assumption that if playback is supported, we are playing music",
"if",
"self",
".",
"_is_playback_supported",
":",
"return",
"MEDIA_TYPE_MUSIC",
"return",
"None"
] | [
408,
4
] | [
413,
19
] | python | en | ['en', 'en', 'en'] | True |
YamahaDevice.media_title | (self) | Artist of current playing media. | Artist of current playing media. | def media_title(self):
"""Artist of current playing media."""
if self._play_status is not None:
song = self._play_status.song
station = self._play_status.station
# If both song and station is available, print both, otherwise
# just the one we have.
... | [
"def",
"media_title",
"(",
"self",
")",
":",
"if",
"self",
".",
"_play_status",
"is",
"not",
"None",
":",
"song",
"=",
"self",
".",
"_play_status",
".",
"song",
"station",
"=",
"self",
".",
"_play_status",
".",
"station",
"# If both song and station is availab... | [
416,
4
] | [
427,
34
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_base_schema | (schema) | Test base schema validation. | Test base schema validation. | def test_invalid_base_schema(schema):
"""Test base schema validation."""
with pytest.raises(vol.Invalid):
selector.validate_selector(schema) | [
"def",
"test_invalid_base_schema",
"(",
"schema",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"selector",
".",
"validate_selector",
"(",
"schema",
")"
] | [
10,
0
] | [
13,
42
] | python | de | ['de', 'de', 'en'] | True |
test_validate_selector | () | Test return is the same as input. | Test return is the same as input. | def test_validate_selector():
"""Test return is the same as input."""
schema = {"device": {"manufacturer": "mock-manuf", "model": "mock-model"}}
assert schema == selector.validate_selector(schema) | [
"def",
"test_validate_selector",
"(",
")",
":",
"schema",
"=",
"{",
"\"device\"",
":",
"{",
"\"manufacturer\"",
":",
"\"mock-manuf\"",
",",
"\"model\"",
":",
"\"mock-model\"",
"}",
"}",
"assert",
"schema",
"==",
"selector",
".",
"validate_selector",
"(",
"schema... | [
16,
0
] | [
19,
55
] | python | en | ['en', 'en', 'en'] | True |
test_device_selector_schema | (schema) | Test device selector. | Test device selector. | def test_device_selector_schema(schema):
"""Test device selector."""
selector.validate_selector({"device": schema}) | [
"def",
"test_device_selector_schema",
"(",
"schema",
")",
":",
"selector",
".",
"validate_selector",
"(",
"{",
"\"device\"",
":",
"schema",
"}",
")"
] | [
33,
0
] | [
35,
50
] | python | en | ['fr', 'en', 'en'] | True |
test_entity_selector_schema | (schema) | Test entity selector. | Test entity selector. | def test_entity_selector_schema(schema):
"""Test entity selector."""
selector.validate_selector({"entity": schema}) | [
"def",
"test_entity_selector_schema",
"(",
"schema",
")",
":",
"selector",
".",
"validate_selector",
"(",
"{",
"\"entity\"",
":",
"schema",
"}",
")"
] | [
47,
0
] | [
49,
50
] | python | en | ['en', 'en', 'en'] | True |
get_entity_state | (config, entity) | Retrieve and convert state and brightness values for an entity. | Retrieve and convert state and brightness values for an entity. | def get_entity_state(config, entity):
"""Retrieve and convert state and brightness values for an entity."""
cached_state_entry = config.cached_states.get(entity.entity_id, None)
cached_state = None
# Check if we have a cached entry, and if so if it hasn't expired.
if cached_state_entry is not None:... | [
"def",
"get_entity_state",
"(",
"config",
",",
"entity",
")",
":",
"cached_state_entry",
"=",
"config",
".",
"cached_states",
".",
"get",
"(",
"entity",
".",
"entity_id",
",",
"None",
")",
"cached_state",
"=",
"None",
"# Check if we have a cached entry, and if so if... | [
578,
0
] | [
691,
15
] | python | en | ['en', 'en', 'en'] | True |
entity_to_json | (config, entity) | Convert an entity to its Hue bridge JSON representation. | Convert an entity to its Hue bridge JSON representation. | def entity_to_json(config, entity):
"""Convert an entity to its Hue bridge JSON representation."""
entity_features = entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
unique_id = hashlib.md5(entity.entity_id.encode()).hexdigest()
unique_id = f"00:{unique_id[0:2]}:{unique_id[2:4]}:{unique_id[4:6]}:{uniqu... | [
"def",
"entity_to_json",
"(",
"config",
",",
"entity",
")",
":",
"entity_features",
"=",
"entity",
".",
"attributes",
".",
"get",
"(",
"ATTR_SUPPORTED_FEATURES",
",",
"0",
")",
"unique_id",
"=",
"hashlib",
".",
"md5",
"(",
"entity",
".",
"entity_id",
".",
... | [
694,
0
] | [
790,
17
] | python | en | ['en', 'ht', 'en'] | True |
create_hue_success_response | (entity_number, attr, value) | Create a success response for an attribute set on a light. | Create a success response for an attribute set on a light. | def create_hue_success_response(entity_number, attr, value):
"""Create a success response for an attribute set on a light."""
success_key = f"/lights/{entity_number}/state/{attr}"
return {"success": {success_key: value}} | [
"def",
"create_hue_success_response",
"(",
"entity_number",
",",
"attr",
",",
"value",
")",
":",
"success_key",
"=",
"f\"/lights/{entity_number}/state/{attr}\"",
"return",
"{",
"\"success\"",
":",
"{",
"success_key",
":",
"value",
"}",
"}"
] | [
793,
0
] | [
796,
44
] | python | en | ['en', 'en', 'en'] | True |
create_config_model | (config, request) | Create a config resource. | Create a config resource. | def create_config_model(config, request):
"""Create a config resource."""
return {
"mac": "00:00:00:00:00:00",
"swversion": "01003542",
"apiversion": "1.17.0",
"whitelist": {HUE_API_USERNAME: {"name": "HASS BRIDGE"}},
"ipaddress": f"{config.advertise_ip}:{config.advertise... | [
"def",
"create_config_model",
"(",
"config",
",",
"request",
")",
":",
"return",
"{",
"\"mac\"",
":",
"\"00:00:00:00:00:00\"",
",",
"\"swversion\"",
":",
"\"01003542\"",
",",
"\"apiversion\"",
":",
"\"1.17.0\"",
",",
"\"whitelist\"",
":",
"{",
"HUE_API_USERNAME",
... | [
799,
0
] | [
808,
5
] | python | en | ['en', 'en', 'en'] | True |
create_list_of_entities | (config, request) | Create a list of all entities. | Create a list of all entities. | def create_list_of_entities(config, request):
"""Create a list of all entities."""
hass = request.app["hass"]
json_response = {}
for entity in config.filter_exposed_entities(hass.states.async_all()):
number = config.entity_id_to_number(entity.entity_id)
json_response[number] = entity_to... | [
"def",
"create_list_of_entities",
"(",
"config",
",",
"request",
")",
":",
"hass",
"=",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
"json_response",
"=",
"{",
"}",
"for",
"entity",
"in",
"config",
".",
"filter_exposed_entities",
"(",
"hass",
".",
"states",
... | [
811,
0
] | [
820,
24
] | python | en | ['en', 'en', 'en'] | True |
hue_brightness_to_hass | (value) | Convert hue brightness 1..254 to hass format 0..255. | Convert hue brightness 1..254 to hass format 0..255. | def hue_brightness_to_hass(value):
"""Convert hue brightness 1..254 to hass format 0..255."""
return min(255, round((value / HUE_API_STATE_BRI_MAX) * 255)) | [
"def",
"hue_brightness_to_hass",
"(",
"value",
")",
":",
"return",
"min",
"(",
"255",
",",
"round",
"(",
"(",
"value",
"/",
"HUE_API_STATE_BRI_MAX",
")",
"*",
"255",
")",
")"
] | [
823,
0
] | [
825,
65
] | python | en | ['en', 'en', 'en'] | True |
hass_to_hue_brightness | (value) | Convert hass brightness 0..255 to hue 1..254 scale. | Convert hass brightness 0..255 to hue 1..254 scale. | def hass_to_hue_brightness(value):
"""Convert hass brightness 0..255 to hue 1..254 scale."""
return max(1, round((value / 255) * HUE_API_STATE_BRI_MAX)) | [
"def",
"hass_to_hue_brightness",
"(",
"value",
")",
":",
"return",
"max",
"(",
"1",
",",
"round",
"(",
"(",
"value",
"/",
"255",
")",
"*",
"HUE_API_STATE_BRI_MAX",
")",
")"
] | [
828,
0
] | [
830,
63
] | python | en | ['en', 'en', 'en'] | True |
wait_for_state_change_or_timeout | (hass, entity_id, timeout) | Wait for an entity to change state. | Wait for an entity to change state. | async def wait_for_state_change_or_timeout(hass, entity_id, timeout):
"""Wait for an entity to change state."""
ev = asyncio.Event()
@core.callback
def _async_event_changed(_):
ev.set()
unsub = async_track_state_change_event(hass, [entity_id], _async_event_changed)
try:
await ... | [
"async",
"def",
"wait_for_state_change_or_timeout",
"(",
"hass",
",",
"entity_id",
",",
"timeout",
")",
":",
"ev",
"=",
"asyncio",
".",
"Event",
"(",
")",
"@",
"core",
".",
"callback",
"def",
"_async_event_changed",
"(",
"_",
")",
":",
"ev",
".",
"set",
... | [
833,
0
] | [
848,
15
] | python | en | ['en', 'en', 'en'] | True |
HueUnauthorizedUser.get | (self, request) | Handle a GET request. | Handle a GET request. | async def get(self, request):
"""Handle a GET request."""
return self.json(UNAUTHORIZED_USER) | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"json",
"(",
"UNAUTHORIZED_USER",
")"
] | [
118,
4
] | [
120,
43
] | python | en | ['en', 'en', 'en'] | True |
HueUsernameView.post | (self, request) | Handle a POST request. | Handle a POST request. | async def post(self, request):
"""Handle a POST request."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
try:
data = await request.json()
except ValueError:
return self.json_message... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs allowed\"",
",",
"HTTP_UNAUTHORIZED",
")",
... | [
131,
4
] | [
144,
71
] | python | en | ['en', 'en', 'en'] | True |
HueAllGroupsStateView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
154,
4
] | [
156,
28
] | python | en | ['en', 'en', 'en'] | True |
HueAllGroupsStateView.get | (self, request, username) | Process a request to make the Brilliant Lightpad work. | Process a request to make the Brilliant Lightpad work. | def get(self, request, username):
"""Process a request to make the Brilliant Lightpad work."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
return self.json({}) | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"username",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs allowed\"",
",",
"HTTP_UNAUTHORIZED"... | [
159,
4
] | [
164,
28
] | python | en | ['en', 'en', 'en'] | True |
HueGroupView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
174,
4
] | [
176,
28
] | python | en | ['en', 'en', 'en'] | True |
HueGroupView.put | (self, request, username) | Process a request to make the Logitech Pop working. | Process a request to make the Logitech Pop working. | def put(self, request, username):
"""Process a request to make the Logitech Pop working."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
return self.json(
[
{
"error... | [
"def",
"put",
"(",
"self",
",",
"request",
",",
"username",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs allowed\"",
",",
"HTTP_UNAUTHORIZED"... | [
179,
4
] | [
194,
9
] | python | en | ['en', 'en', 'en'] | True |
HueAllLightsStateView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
204,
4
] | [
206,
28
] | python | en | ['en', 'en', 'en'] | True |
HueAllLightsStateView.get | (self, request, username) | Process a request to get the list of available lights. | Process a request to get the list of available lights. | def get(self, request, username):
"""Process a request to get the list of available lights."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
return self.json(create_list_of_entities(self.config, request)) | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"username",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs allowed\"",
",",
"HTTP_UNAUTHORIZED"... | [
209,
4
] | [
214,
71
] | python | en | ['en', 'en', 'en'] | True |
HueFullStateView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
224,
4
] | [
226,
28
] | python | en | ['en', 'en', 'en'] | True |
HueFullStateView.get | (self, request, username) | Process a request to get the list of available lights. | Process a request to get the list of available lights. | def get(self, request, username):
"""Process a request to get the list of available lights."""
if not is_local(ip_address(request.remote)):
return self.json_message("only local IPs allowed", HTTP_UNAUTHORIZED)
if username != HUE_API_USERNAME:
return self.json(UNAUTHORIZED... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"username",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"only local IPs allowed\"",
",",
"HTTP_UNAUTHORIZED"... | [
229,
4
] | [
241,
39
] | python | en | ['en', 'en', 'en'] | True |
HueConfigView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
252,
4
] | [
254,
28
] | python | en | ['en', 'en', 'en'] | True |
HueConfigView.get | (self, request, username="") | Process a request to get the configuration. | Process a request to get the configuration. | def get(self, request, username=""):
"""Process a request to get the configuration."""
if not is_local(ip_address(request.remote)):
return self.json_message("only local IPs allowed", HTTP_UNAUTHORIZED)
json_response = create_config_model(self.config, request)
return self.js... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"username",
"=",
"\"\"",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"only local IPs allowed\"",
",",
"H... | [
257,
4
] | [
264,
39
] | python | en | ['en', 'en', 'en'] | True |
HueOneLightStateView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
274,
4
] | [
276,
28
] | python | en | ['en', 'en', 'en'] | True |
HueOneLightStateView.get | (self, request, username, entity_id) | Process a request to get the state of an individual light. | Process a request to get the state of an individual light. | def get(self, request, username, entity_id):
"""Process a request to get the state of an individual light."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
hass = request.app["hass"]
hass_entity_id = self.c... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"username",
",",
"entity_id",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs allowed\"",
",",... | [
279,
4
] | [
306,
39
] | python | en | ['en', 'en', 'en'] | True |
HueOneLightChangeView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
316,
4
] | [
318,
28
] | python | en | ['en', 'en', 'en'] | True |
HueOneLightChangeView.put | (self, request, username, entity_number) | Process a request to set the state of an individual light. | Process a request to set the state of an individual light. | async def put(self, request, username, entity_number):
"""Process a request to set the state of an individual light."""
if not is_local(ip_address(request.remote)):
return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
config = self.config
hass = request.app[... | [
"async",
"def",
"put",
"(",
"self",
",",
"request",
",",
"username",
",",
"entity_number",
")",
":",
"if",
"not",
"is_local",
"(",
"ip_address",
"(",
"request",
".",
"remote",
")",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Only local IPs all... | [
320,
4
] | [
575,
39
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the OpenUV component. | Set up the OpenUV component. | async def async_setup(hass, config):
"""Set up the OpenUV component."""
hass.data[DOMAIN] = {DATA_OPENUV_CLIENT: {}, DATA_OPENUV_LISTENER: {}}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_OPENUV_CLIENT",
":",
"{",
"}",
",",
"DATA_OPENUV_LISTENER",
":",
"{",
"}",
"}",
"return",
"True"
] | [
57,
0
] | [
60,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up OpenUV as config entry. | Set up OpenUV as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up OpenUV as config entry."""
_verify_domain_control = verify_domain_control(hass, DOMAIN)
try:
websession = aiohttp_client.async_get_clientsession(hass)
openuv = OpenUV(
Client(
config_entry.data[CONF_API_K... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"_verify_domain_control",
"=",
"verify_domain_control",
"(",
"hass",
",",
"DOMAIN",
")",
"try",
":",
"websession",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
... | [
63,
0
] | [
117,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload an OpenUV config entry. | Unload an OpenUV config entry. | async def async_unload_entry(hass, config_entry):
"""Unload an OpenUV config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in PLATFORMS
]
)
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"config_entry",
",",
"compo... | [
120,
0
] | [
133,
20
] | python | en | ['en', 'en', 'en'] | True |
async_migrate_entry | (hass, config_entry) | Migrate the config entry upon new versions. | Migrate the config entry upon new versions. | async def async_migrate_entry(hass, config_entry):
"""Migrate the config entry upon new versions."""
version = config_entry.version
data = {**config_entry.data}
_LOGGER.debug("Migrating from version %s", version)
# 1 -> 2: Remove unused condition data:
if version == 1:
data.pop(CONF_BI... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"version",
"=",
"config_entry",
".",
"version",
"data",
"=",
"{",
"*",
"*",
"config_entry",
".",
"data",
"}",
"_LOGGER",
".",
"debug",
"(",
"\"Migrating from version %s\"",
",",... | [
136,
0
] | [
151,
15
] | python | en | ['en', 'en', 'en'] | True |
OpenUV.__init__ | (self, client) | Initialize. | Initialize. | def __init__(self, client):
"""Initialize."""
self.client = client
self.data = {} | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"client",
"=",
"client",
"self",
".",
"data",
"=",
"{",
"}"
] | [
157,
4
] | [
160,
22
] | python | en | ['en', 'en', 'it'] | False |
OpenUV.async_update_protection_data | (self) | Update binary sensor (protection window) data. | Update binary sensor (protection window) data. | async def async_update_protection_data(self):
"""Update binary sensor (protection window) data."""
try:
resp = await self.client.uv_protection_window()
self.data[DATA_PROTECTION_WINDOW] = resp["result"]
except OpenUvError as err:
_LOGGER.error("Error during pr... | [
"async",
"def",
"async_update_protection_data",
"(",
"self",
")",
":",
"try",
":",
"resp",
"=",
"await",
"self",
".",
"client",
".",
"uv_protection_window",
"(",
")",
"self",
".",
"data",
"[",
"DATA_PROTECTION_WINDOW",
"]",
"=",
"resp",
"[",
"\"result\"",
"]... | [
162,
4
] | [
169,
50
] | python | en | ['en', 'sn', 'en'] | True |
OpenUV.async_update_uv_index_data | (self) | Update sensor (uv index, etc) data. | Update sensor (uv index, etc) data. | async def async_update_uv_index_data(self):
"""Update sensor (uv index, etc) data."""
try:
data = await self.client.uv_index()
self.data[DATA_UV] = data
except OpenUvError as err:
_LOGGER.error("Error during uv index data update: %s", err)
self.dat... | [
"async",
"def",
"async_update_uv_index_data",
"(",
"self",
")",
":",
"try",
":",
"data",
"=",
"await",
"self",
".",
"client",
".",
"uv_index",
"(",
")",
"self",
".",
"data",
"[",
"DATA_UV",
"]",
"=",
"data",
"except",
"OpenUvError",
"as",
"err",
":",
"... | [
171,
4
] | [
178,
35
] | python | en | ['et', 'la', 'en'] | False |
OpenUV.async_update | (self) | Update sensor/binary sensor data. | Update sensor/binary sensor data. | async def async_update(self):
"""Update sensor/binary sensor data."""
tasks = [self.async_update_protection_data(), self.async_update_uv_index_data()]
await asyncio.gather(*tasks) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"tasks",
"=",
"[",
"self",
".",
"async_update_protection_data",
"(",
")",
",",
"self",
".",
"async_update_uv_index_data",
"(",
")",
"]",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"tasks",
")"
] | [
180,
4
] | [
183,
36
] | python | en | ['en', 'bs', 'en'] | True |
OpenUvEntity.__init__ | (self, openuv) | Initialize. | Initialize. | def __init__(self, openuv):
"""Initialize."""
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._available = True
self._name = None
self.openuv = openuv | [
"def",
"__init__",
"(",
"self",
",",
"openuv",
")",
":",
"self",
".",
"_attrs",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"DEFAULT_ATTRIBUTION",
"}",
"self",
".",
"_available",
"=",
"True",
"self",
".",
"_name",
"=",
"None",
"self",
".",
"openuv",
"=",
"openuv"... | [
189,
4
] | [
194,
28
] | python | en | ['en', 'en', 'it'] | False |
OpenUvEntity.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
197,
4
] | [
199,
30
] | python | en | ['en', 'en', 'en'] | True |
OpenUvEntity.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attrs"
] | [
202,
4
] | [
204,
26
] | python | en | ['en', 'en', 'en'] | True |
OpenUvEntity.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"
] | [
207,
4
] | [
209,
25
] | python | en | ['en', 'en', 'en'] | True |
OpenUvEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
@callback
def update():
"""Update the state."""
self.update_from_latest_data()
self.async_write_ha_state()
self.async_on_remove(async_dispatcher_connect(self.hass, TOPIC_UPDATE, update))
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"update",
"(",
")",
":",
"\"\"\"Update the state.\"\"\"",
"self",
".",
"update_from_latest_data",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")",
"self",
".",
"async_o... | [
211,
4
] | [
222,
38
] | python | en | ['en', 'no', 'en'] | False |
OpenUvEntity.update_from_latest_data | (self) | Update the sensor using the latest data. | Update the sensor using the latest data. | def update_from_latest_data(self):
"""Update the sensor using the latest data."""
raise NotImplementedError | [
"def",
"update_from_latest_data",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
224,
4
] | [
226,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Activate the Alexa component. | Activate the Alexa component. | async def async_setup(hass, config):
"""Activate the Alexa component."""
if DOMAIN not in config:
return True
config = config[DOMAIN]
flash_briefings_config = config.get(CONF_FLASH_BRIEFINGS)
intent.async_setup(hass)
if flash_briefings_config:
flash_briefings.async_setup(hass... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"config",
"=",
"config",
"[",
"DOMAIN",
"]",
"flash_briefings_config",
"=",
"config",
".",
"get",
"(",
"CONF_FLASH_BRIEFINGS",
... | [
76,
0
] | [
98,
15
] | python | en | ['en', 'en', 'en'] | True |
conv3x3 | (in_planes, out_planes, stride=1, dilation=1, padding=1) | 3x3 convolution with padding | 3x3 convolution with padding | def conv3x3(in_planes, out_planes, stride=1, dilation=1, padding=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, dilation=dilation,
padding=padding, bias=False) | [
"def",
"conv3x3",
"(",
"in_planes",
",",
"out_planes",
",",
"stride",
"=",
"1",
",",
"dilation",
"=",
"1",
",",
"padding",
"=",
"1",
")",
":",
"return",
"nn",
".",
"Conv2d",
"(",
"in_planes",
",",
"out_planes",
",",
"kernel_size",
"=",
"3",
",",
"str... | [
29,
0
] | [
32,
49
] | python | en | ['en', 'ja', 'en'] | True |
resnet18 | (pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, **kwargs) | Constructs a ResNet-18 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | Constructs a ResNet-18 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | def resnet18(pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, **kwargs):
"""Constructs a ResNet-18 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretraine... | [
"def",
"resnet18",
"(",
"pretrained",
"=",
"False",
",",
"pretrained_model_path",
"=",
"None",
",",
"num_classes",
"=",
"None",
",",
"expose_stages",
"=",
"None",
",",
"dilations",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"num_classes",
"is",
... | [
243,
0
] | [
274,
16
] | python | en | ['en', 'en', 'en'] | True |
resnet34 | (pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, **kwargs) | Constructs a ResNet-34 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | Constructs a ResNet-34 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | def resnet34(pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, **kwargs):
"""Constructs a ResNet-34 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretraine... | [
"def",
"resnet34",
"(",
"pretrained",
"=",
"False",
",",
"pretrained_model_path",
"=",
"None",
",",
"num_classes",
"=",
"None",
",",
"expose_stages",
"=",
"None",
",",
"dilations",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"num_classes",
"is",
... | [
277,
0
] | [
309,
16
] | python | en | ['en', 'en', 'en'] | True |
resnet50 | (pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False) | Constructs a ResNet-50 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | Constructs a ResNet-50 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (int... | def resnet50(pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False):
"""Constructs a ResNet-50 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective whe... | [
"def",
"resnet50",
"(",
"pretrained",
"=",
"False",
",",
"pretrained_model_path",
"=",
"None",
",",
"num_classes",
"=",
"None",
",",
"expose_stages",
"=",
"None",
",",
"dilations",
"=",
"None",
",",
"stride_in_1x1",
"=",
"False",
")",
":",
"if",
"num_classes... | [
312,
0
] | [
344,
16
] | python | en | ['en', 'en', 'en'] | True |
resnet101 | (pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False) | Constructs a ResNet-101 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (in... | Constructs a ResNet-101 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (in... | def resnet101(pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False):
"""Constructs a ResNet-101 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective w... | [
"def",
"resnet101",
"(",
"pretrained",
"=",
"False",
",",
"pretrained_model_path",
"=",
"None",
",",
"num_classes",
"=",
"None",
",",
"expose_stages",
"=",
"None",
",",
"dilations",
"=",
"None",
",",
"stride_in_1x1",
"=",
"False",
")",
":",
"if",
"num_classe... | [
347,
0
] | [
379,
16
] | python | en | ['en', 'en', 'en'] | True |
resnet152 | (pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False) | Constructs a ResNet-152 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (in... | Constructs a ResNet-152 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective when pretrained=True,
if not specified, use pretrained model from model_zoo.
num_classes (in... | def resnet152(pretrained=False, pretrained_model_path=None, num_classes=None, expose_stages=None, dilations=None, stride_in_1x1=False):
"""Constructs a ResNet-152 model
Args:
pretrained (bool): if True, load pretrained model. Default: False
pretrained_model_path (str, optional): only effective w... | [
"def",
"resnet152",
"(",
"pretrained",
"=",
"False",
",",
"pretrained_model_path",
"=",
"None",
",",
"num_classes",
"=",
"None",
",",
"expose_stages",
"=",
"None",
",",
"dilations",
"=",
"None",
",",
"stride_in_1x1",
"=",
"False",
")",
":",
"if",
"num_classe... | [
382,
0
] | [
414,
16
] | python | en | ['en', 'en', 'en'] | True |
ResNet.load_pretrained_state_dict | (self, state_dict) | Load state dict of pretrained model
Args:
state_dict (dict): state dict to load
| Load state dict of pretrained model
Args:
state_dict (dict): state dict to load
| def load_pretrained_state_dict(self, state_dict):
"""Load state dict of pretrained model
Args:
state_dict (dict): state dict to load
"""
new_state_dict = self.state_dict()
miss_keys = []
for k in new_state_dict.keys():
if k in state_dict.keys():
... | [
"def",
"load_pretrained_state_dict",
"(",
"self",
",",
"state_dict",
")",
":",
"new_state_dict",
"=",
"self",
".",
"state_dict",
"(",
")",
"miss_keys",
"=",
"[",
"]",
"for",
"k",
"in",
"new_state_dict",
".",
"keys",
"(",
")",
":",
"if",
"k",
"in",
"state... | [
200,
4
] | [
214,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_fritzbox | (hass: HomeAssistantType, config: dict) | Set up mock AVM Fritz!Box. | Set up mock AVM Fritz!Box. | async def setup_fritzbox(hass: HomeAssistantType, config: dict):
"""Set up mock AVM Fritz!Box."""
assert await async_setup_component(hass, FB_DOMAIN, config) is True
await hass.async_block_till_done() | [
"async",
"def",
"setup_fritzbox",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"dict",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"FB_DOMAIN",
",",
"config",
")",
"is",
"True",
"await",
"hass",
".",
"async_block_till_... | [
49,
0
] | [
52,
38
] | python | en | ['en', 'zu', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.