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
AppleTvDevice.playstatus_update
(self, updater, playing)
Print what is currently playing when it changes.
Print what is currently playing when it changes.
def playstatus_update(self, updater, playing): """Print what is currently playing when it changes.""" self._playing = playing self.async_write_ha_state()
[ "def", "playstatus_update", "(", "self", ",", "updater", ",", "playing", ")", ":", "self", ".", "_playing", "=", "playing", "self", ".", "async_write_ha_state", "(", ")" ]
[ 137, 4 ]
[ 140, 35 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.playstatus_error
(self, updater, exception)
Inform about an error and restart push updates.
Inform about an error and restart push updates.
def playstatus_error(self, updater, exception): """Inform about an error and restart push updates.""" _LOGGER.warning("A %s error occurred: %s", exception.__class__, exception) # This will wait 10 seconds before restarting push updates. If the # connection continues to fail, it will flo...
[ "def", "playstatus_error", "(", "self", ",", "updater", ",", "exception", ")", ":", "_LOGGER", ".", "warning", "(", "\"A %s error occurred: %s\"", ",", "exception", ".", "__class__", ",", "exception", ")", "# This will wait 10 seconds before restarting push updates. If th...
[ 143, 4 ]
[ 153, 35 ]
python
en
['en', 'lb', 'en']
True
AppleTvDevice.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.""" if self._playing: media_type = self._playing.media_type if media_type == atv_const.MEDIA_TYPE_VIDEO: return MEDIA_TYPE_VIDEO if media_type == atv_const.MEDIA_TYPE_MUSIC: ...
[ "def", "media_content_type", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "media_type", "=", "self", ".", "_playing", ".", "media_type", "if", "media_type", "==", "atv_const", ".", "MEDIA_TYPE_VIDEO", ":", "return", "MEDIA_TYPE_VIDEO", "if", "med...
[ 156, 4 ]
[ 166, 40 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.media_duration
(self)
Duration of current playing media in seconds.
Duration of current playing media in seconds.
def media_duration(self): """Duration of current playing media in seconds.""" if self._playing: return self._playing.total_time
[ "def", "media_duration", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "return", "self", ".", "_playing", ".", "total_time" ]
[ 169, 4 ]
[ 172, 43 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.media_position
(self)
Position of current playing media in seconds.
Position of current playing media in seconds.
def media_position(self): """Position of current playing media in seconds.""" if self._playing: return self._playing.position
[ "def", "media_position", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "return", "self", ".", "_playing", ".", "position" ]
[ 175, 4 ]
[ 178, 41 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.media_position_updated_at
(self)
Last valid time of media position.
Last valid time of media position.
def media_position_updated_at(self): """Last valid time of media position.""" state = self.state if state in (STATE_PLAYING, STATE_PAUSED): return dt_util.utcnow()
[ "def", "media_position_updated_at", "(", "self", ")", ":", "state", "=", "self", ".", "state", "if", "state", "in", "(", "STATE_PLAYING", ",", "STATE_PAUSED", ")", ":", "return", "dt_util", ".", "utcnow", "(", ")" ]
[ 181, 4 ]
[ 185, 35 ]
python
en
['en', 'et', 'en']
True
AppleTvDevice.async_play_media
(self, media_type, media_id, **kwargs)
Send the play_media command to the media player.
Send the play_media command to the media player.
async def async_play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the media player.""" await self.atv.airplay.play_url(media_id)
[ "async", "def", "async_play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "atv", ".", "airplay", ".", "play_url", "(", "media_id", ")" ]
[ 187, 4 ]
[ 189, 49 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.media_image_hash
(self)
Hash value for media image.
Hash value for media image.
def media_image_hash(self): """Hash value for media image.""" state = self.state if self._playing and state not in [STATE_OFF, STATE_IDLE]: return self._playing.hash
[ "def", "media_image_hash", "(", "self", ")", ":", "state", "=", "self", ".", "state", "if", "self", ".", "_playing", "and", "state", "not", "in", "[", "STATE_OFF", ",", "STATE_IDLE", "]", ":", "return", "self", ".", "_playing", ".", "hash" ]
[ 192, 4 ]
[ 196, 37 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_get_media_image
(self)
Fetch media image of current playing image.
Fetch media image of current playing image.
async def async_get_media_image(self): """Fetch media image of current playing image.""" state = self.state if self._playing and state not in [STATE_OFF, STATE_IDLE]: return (await self.atv.metadata.artwork()), "image/png" return None, None
[ "async", "def", "async_get_media_image", "(", "self", ")", ":", "state", "=", "self", ".", "state", "if", "self", ".", "_playing", "and", "state", "not", "in", "[", "STATE_OFF", ",", "STATE_IDLE", "]", ":", "return", "(", "await", "self", ".", "atv", "...
[ 198, 4 ]
[ 204, 25 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if self._playing: if self.state == STATE_IDLE: return "Nothing playing" title = self._playing.title return title if title else "No title" return f"Establishing a connection to {self....
[ "def", "media_title", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "if", "self", ".", "state", "==", "STATE_IDLE", ":", "return", "\"Nothing playing\"", "title", "=", "self", ".", "_playing", ".", "title", "return", "title", "if", "title", ...
[ 207, 4 ]
[ 215, 62 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.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.""" return SUPPORT_APPLE_TV
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_APPLE_TV" ]
[ 218, 4 ]
[ 220, 31 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.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.""" self._power.set_power_on(True)
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "self", ".", "_power", ".", "set_power_on", "(", "True", ")" ]
[ 222, 4 ]
[ 224, 38 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_turn_off
(self)
Turn the media player off.
Turn the media player off.
async def async_turn_off(self): """Turn the media player off.""" self._playing = None self._power.set_power_on(False)
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "self", ".", "_playing", "=", "None", "self", ".", "_power", ".", "set_power_on", "(", "False", ")" ]
[ 226, 4 ]
[ 229, 39 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_media_play_pause
(self)
Pause media on media player.
Pause media on media player.
async def async_media_play_pause(self): """Pause media on media player.""" if not self._playing: return state = self.state if state == STATE_PAUSED: await self.atv.remote_control.play() elif state == STATE_PLAYING: await self.atv.remote_control...
[ "async", "def", "async_media_play_pause", "(", "self", ")", ":", "if", "not", "self", ".", "_playing", ":", "return", "state", "=", "self", ".", "state", "if", "state", "==", "STATE_PAUSED", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "...
[ 231, 4 ]
[ 239, 49 ]
python
en
['en', 'et', 'en']
True
AppleTvDevice.async_media_play
(self)
Play media.
Play media.
async def async_media_play(self): """Play media.""" if self._playing: await self.atv.remote_control.play()
[ "async", "def", "async_media_play", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "play", "(", ")" ]
[ 241, 4 ]
[ 244, 48 ]
python
en
['en', 'sv', 'en']
False
AppleTvDevice.async_media_stop
(self)
Stop the media player.
Stop the media player.
async def async_media_stop(self): """Stop the media player.""" if self._playing: await self.atv.remote_control.stop()
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "stop", "(", ")" ]
[ 246, 4 ]
[ 249, 48 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_media_pause
(self)
Pause the media player.
Pause the media player.
async def async_media_pause(self): """Pause the media player.""" if self._playing: await self.atv.remote_control.pause()
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "pause", "(", ")" ]
[ 251, 4 ]
[ 254, 49 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_media_next_track
(self)
Send next track command.
Send next track command.
async def async_media_next_track(self): """Send next track command.""" if self._playing: await self.atv.remote_control.next()
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "next", "(", ")" ]
[ 256, 4 ]
[ 259, 48 ]
python
en
['en', 'pt', 'en']
True
AppleTvDevice.async_media_previous_track
(self)
Send previous track command.
Send previous track command.
async def async_media_previous_track(self): """Send previous track command.""" if self._playing: await self.atv.remote_control.previous()
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "previous", "(", ")" ]
[ 261, 4 ]
[ 264, 52 ]
python
en
['en', 'it', 'en']
True
AppleTvDevice.async_media_seek
(self, position)
Send seek command.
Send seek command.
async def async_media_seek(self, position): """Send seek command.""" if self._playing: await self.atv.remote_control.set_position(position)
[ "async", "def", "async_media_seek", "(", "self", ",", "position", ")", ":", "if", "self", ".", "_playing", ":", "await", "self", ".", "atv", ".", "remote_control", ".", "set_position", "(", "position", ")" ]
[ 266, 4 ]
[ 269, 64 ]
python
en
['en', 'ig', 'en']
True
AbodeFlowHandler.__init__
(self)
Initialize.
Initialize.
def __init__(self): """Initialize.""" self.data_schema = { vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str, }
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "data_schema", "=", "{", "vol", ".", "Required", "(", "CONF_USERNAME", ")", ":", "str", ",", "vol", ".", "Required", "(", "CONF_PASSWORD", ")", ":", "str", ",", "}" ]
[ 21, 4 ]
[ 26, 9 ]
python
en
['en', 'en', 'it']
False
AbodeFlowHandler.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.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if not user_input: return self._show_form() username = user_input[CONF_USER...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"single_instance_allowed\"", ")", "if", "not", "...
[ 28, 4 ]
[ 59, 9 ]
python
en
['en', 'en', 'en']
True
AbodeFlowHandler._show_form
(self, errors=None)
Show the form to the user.
Show the form to the user.
def _show_form(self, errors=None): """Show the form to the user.""" return self.async_show_form( step_id="user", data_schema=vol.Schema(self.data_schema), errors=errors if errors else {}, )
[ "def", "_show_form", "(", "self", ",", "errors", "=", "None", ")", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "vol", ".", "Schema", "(", "self", ".", "data_schema", ")", ",", "errors", "=", ...
[ 62, 4 ]
[ 68, 9 ]
python
en
['en', 'en', 'en']
True
AbodeFlowHandler.async_step_import
(self, import_config)
Import a config entry from configuration.yaml.
Import a config entry from configuration.yaml.
async def async_step_import(self, import_config): """Import a config entry from configuration.yaml.""" if self._async_current_entries(): LOGGER.warning("Only one configuration of abode is allowed.") return self.async_abort(reason="single_instance_allowed") return await s...
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "LOGGER", ".", "warning", "(", "\"Only one configuration of abode is allowed.\"", ")", "return", "self", ".", "async_abort",...
[ 70, 4 ]
[ 76, 56 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler.__init__
(self)
Initialize the UPnP/IGD config flow.
Initialize the UPnP/IGD config flow.
def __init__(self): """Initialize the UPnP/IGD config flow.""" self._discoveries: Mapping = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_discoveries", ":", "Mapping", "=", "None" ]
[ 39, 4 ]
[ 41, 41 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler.async_step_user
(self, user_input: Optional[Mapping] = None)
Handle a flow start.
Handle a flow start.
async def async_step_user(self, user_input: Optional[Mapping] = None): """Handle a flow start.""" _LOGGER.debug("async_step_user: user_input: %s", user_input) # This uses DISCOVERY_USN as the identifier for the device. if user_input is not None: # Ensure wanted device was di...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "Optional", "[", "Mapping", "]", "=", "None", ")", ":", "_LOGGER", ".", "debug", "(", "\"async_step_user: user_input: %s\"", ",", "user_input", ")", "# This uses DISCOVERY_USN as the identifier fo...
[ 43, 4 ]
[ 95, 9 ]
python
en
['en', 'lb', 'en']
True
UpnpFlowHandler.async_step_import
(self, import_info: Optional[Mapping])
Import a new UPnP/IGD device as a config entry. This flow is triggered by `async_setup`. If no device has been configured before, find any device and create a config_entry for it. Otherwise, do nothing.
Import a new UPnP/IGD device as a config entry.
async def async_step_import(self, import_info: Optional[Mapping]): """Import a new UPnP/IGD device as a config entry. This flow is triggered by `async_setup`. If no device has been configured before, find any device and create a config_entry for it. Otherwise, do nothing. """ ...
[ "async", "def", "async_step_import", "(", "self", ",", "import_info", ":", "Optional", "[", "Mapping", "]", ")", ":", "_LOGGER", ".", "debug", "(", "\"async_step_import: import_info: %s\"", ",", "import_info", ")", "# Landed here via configuration.yaml entry.", "# Any d...
[ 97, 4 ]
[ 130, 76 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler.async_step_ssdp
(self, discovery_info: Mapping)
Handle a discovered UPnP/IGD device. This flow is triggered by the SSDP component. It will check if the host is already configured and delegate to the import step if not.
Handle a discovered UPnP/IGD device.
async def async_step_ssdp(self, discovery_info: Mapping): """Handle a discovered UPnP/IGD device. This flow is triggered by the SSDP component. It will check if the host is already configured and delegate to the import step if not. """ _LOGGER.debug("async_step_ssdp: discovery_i...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ":", "Mapping", ")", ":", "_LOGGER", ".", "debug", "(", "\"async_step_ssdp: discovery_info: %s\"", ",", "discovery_info", ")", "# Ensure complete discovery.", "if", "(", "ssdp", ".", "ATTR_UPNP_UDN...
[ 132, 4 ]
[ 170, 51 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler.async_step_ssdp_confirm
(self, user_input: Optional[Mapping] = None)
Confirm integration via SSDP.
Confirm integration via SSDP.
async def async_step_ssdp_confirm(self, user_input: Optional[Mapping] = None): """Confirm integration via SSDP.""" _LOGGER.debug("async_step_ssdp_confirm: user_input: %s", user_input) if user_input is None: return self.async_show_form(step_id="ssdp_confirm") discovery = self...
[ "async", "def", "async_step_ssdp_confirm", "(", "self", ",", "user_input", ":", "Optional", "[", "Mapping", "]", "=", "None", ")", ":", "_LOGGER", ".", "debug", "(", "\"async_step_ssdp_confirm: user_input: %s\"", ",", "user_input", ")", "if", "user_input", "is", ...
[ 172, 4 ]
[ 179, 71 ]
python
en
['en', 'pt', 'en']
True
UpnpFlowHandler.async_get_options_flow
(config_entry)
Define the config flow to handle options.
Define the config flow to handle options.
def async_get_options_flow(config_entry): """Define the config flow to handle options.""" return UpnpOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "UpnpOptionsFlowHandler", "(", "config_entry", ")" ]
[ 183, 4 ]
[ 185, 51 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler._async_create_entry_from_discovery
( self, discovery: Mapping, )
Create an entry from discovery.
Create an entry from discovery.
async def _async_create_entry_from_discovery( self, discovery: Mapping, ): """Create an entry from discovery.""" _LOGGER.debug( "_async_create_entry_from_discovery: discovery: %s", discovery, ) # Get name from device, if not found already. ...
[ "async", "def", "_async_create_entry_from_discovery", "(", "self", ",", "discovery", ":", "Mapping", ",", ")", ":", "_LOGGER", ".", "debug", "(", "\"_async_create_entry_from_discovery: discovery: %s\"", ",", "discovery", ",", ")", "# Get name from device, if not found alrea...
[ 187, 4 ]
[ 207, 62 ]
python
en
['en', 'en', 'en']
True
UpnpFlowHandler._async_get_name_for_discovery
(self, discovery: Mapping)
Get the name of the device from a discovery.
Get the name of the device from a discovery.
async def _async_get_name_for_discovery(self, discovery: Mapping): """Get the name of the device from a discovery.""" _LOGGER.debug("_async_get_name_for_discovery: discovery: %s", discovery) device = await Device.async_create_device( self.hass, discovery[DISCOVERY_LOCATION] )...
[ "async", "def", "_async_get_name_for_discovery", "(", "self", ",", "discovery", ":", "Mapping", ")", ":", "_LOGGER", ".", "debug", "(", "\"_async_get_name_for_discovery: discovery: %s\"", ",", "discovery", ")", "device", "=", "await", "Device", ".", "async_create_devi...
[ 209, 4 ]
[ 215, 26 ]
python
en
['en', 'en', 'en']
True
UpnpOptionsFlowHandler.__init__
(self, config_entry)
Initialize.
Initialize.
def __init__(self, config_entry): """Initialize.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 221, 4 ]
[ 223, 40 ]
python
en
['en', 'en', 'it']
False
UpnpOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: udn = self.config_entry.data.get(CONFIG_ENTRY_UDN) coordinator = self.hass.data[DOMAIN][DOMAIN_COORDINATORS][udn] update_interval_sec = user_input.get( ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "udn", "=", "self", ".", "config_entry", ".", "data", ".", "get", "(", "CONFIG_ENTRY_UDN", ")", "coordinator", "=", "s...
[ 225, 4 ]
[ 251, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities )
Set up the HomematicIP switch from a config entry.
Set up the HomematicIP switch from a config entry.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the HomematicIP switch from a config entry.""" hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] entities = [] for device in hap.home.devices: if isinstance(device, As...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "hap", "=", "hass", ".", "data", "[", "HMIPC_DOMAIN", "]", "[", "config_entry", ".", "unique...
[ 27, 0 ]
[ 73, 36 ]
python
en
['en', 'en', 'en']
True
HomematicipMultiSwitch.__init__
(self, hap: HomematicipHAP, device, channel: int)
Initialize the multi switch device.
Initialize the multi switch device.
def __init__(self, hap: HomematicipHAP, device, channel: int) -> None: """Initialize the multi switch device.""" super().__init__(hap, device, channel=channel)
[ "def", "__init__", "(", "self", ",", "hap", ":", "HomematicipHAP", ",", "device", ",", "channel", ":", "int", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "hap", ",", "device", ",", "channel", "=", "channel", ")" ]
[ 79, 4 ]
[ 81, 54 ]
python
en
['en', 'en', 'en']
True
HomematicipMultiSwitch.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self) -> bool: """Return true if switch is on.""" return self._device.functionalChannels[self._channel].on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_device", ".", "functionalChannels", "[", "self", ".", "_channel", "]", ".", "on" ]
[ 84, 4 ]
[ 86, 64 ]
python
en
['en', 'fy', 'en']
True
HomematicipMultiSwitch.async_turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
async def async_turn_on(self, **kwargs) -> None: """Turn the switch on.""" await self._device.turn_on(self._channel)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_on", "(", "self", ".", "_channel", ")" ]
[ 88, 4 ]
[ 90, 49 ]
python
en
['en', 'en', 'en']
True
HomematicipMultiSwitch.async_turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
async def async_turn_off(self, **kwargs) -> None: """Turn the switch off.""" await self._device.turn_off(self._channel)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_off", "(", "self", ".", "_channel", ")" ]
[ 92, 4 ]
[ 94, 50 ]
python
en
['en', 'en', 'en']
True
HomematicipSwitch.__init__
(self, hap: HomematicipHAP, device)
Initialize the switch device.
Initialize the switch device.
def __init__(self, hap: HomematicipHAP, device) -> None: """Initialize the switch device.""" super().__init__(hap, device)
[ "def", "__init__", "(", "self", ",", "hap", ":", "HomematicipHAP", ",", "device", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "hap", ",", "device", ")" ]
[ 100, 4 ]
[ 102, 37 ]
python
en
['en', 'en', 'en']
True
HomematicipSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return self._device.on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_device", ".", "on" ]
[ 105, 4 ]
[ 107, 30 ]
python
en
['en', 'fy', 'en']
True
HomematicipSwitch.async_turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
async def async_turn_on(self, **kwargs) -> None: """Turn the device on.""" await self._device.turn_on()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_on", "(", ")" ]
[ 109, 4 ]
[ 111, 36 ]
python
en
['en', 'en', 'en']
True
HomematicipSwitch.async_turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
async def async_turn_off(self, **kwargs) -> None: """Turn the device off.""" await self._device.turn_off()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_off", "(", ")" ]
[ 113, 4 ]
[ 115, 37 ]
python
en
['en', 'en', 'en']
True
HomematicipGroupSwitch.__init__
(self, hap: HomematicipHAP, device, post: str = "Group")
Initialize switching group.
Initialize switching group.
def __init__(self, hap: HomematicipHAP, device, post: str = "Group") -> None: """Initialize switching group.""" device.modelType = f"HmIP-{post}" super().__init__(hap, device, post)
[ "def", "__init__", "(", "self", ",", "hap", ":", "HomematicipHAP", ",", "device", ",", "post", ":", "str", "=", "\"Group\"", ")", "->", "None", ":", "device", ".", "modelType", "=", "f\"HmIP-{post}\"", "super", "(", ")", ".", "__init__", "(", "hap", ",...
[ 121, 4 ]
[ 124, 43 ]
python
en
['en', 'en', 'en']
True
HomematicipGroupSwitch.is_on
(self)
Return true if group is on.
Return true if group is on.
def is_on(self) -> bool: """Return true if group is on.""" return self._device.on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_device", ".", "on" ]
[ 127, 4 ]
[ 129, 30 ]
python
en
['en', 'en', 'en']
True
HomematicipGroupSwitch.available
(self)
Switch-Group available.
Switch-Group available.
def available(self) -> bool: """Switch-Group available.""" # A switch-group must be available, and should not be affected by the # individual availability of group members. # This allows switching even when individual group members # are not available. return True
[ "def", "available", "(", "self", ")", "->", "bool", ":", "# A switch-group must be available, and should not be affected by the", "# individual availability of group members.", "# This allows switching even when individual group members", "# are not available.", "return", "True" ]
[ 132, 4 ]
[ 138, 19 ]
python
en
['en', 'en', 'en']
False
HomematicipGroupSwitch.device_state_attributes
(self)
Return the state attributes of the switch-group.
Return the state attributes of the switch-group.
def device_state_attributes(self) -> Dict[str, Any]: """Return the state attributes of the switch-group.""" state_attr = super().device_state_attributes if self._device.unreach: state_attr[ATTR_GROUP_MEMBER_UNREACHABLE] = True return state_attr
[ "def", "device_state_attributes", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "state_attr", "=", "super", "(", ")", ".", "device_state_attributes", "if", "self", ".", "_device", ".", "unreach", ":", "state_attr", "[", "ATTR_GROUP_MEMBER...
[ 141, 4 ]
[ 148, 25 ]
python
en
['en', 'en', 'en']
True
HomematicipGroupSwitch.async_turn_on
(self, **kwargs)
Turn the group on.
Turn the group on.
async def async_turn_on(self, **kwargs) -> None: """Turn the group on.""" await self._device.turn_on()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_on", "(", ")" ]
[ 150, 4 ]
[ 152, 36 ]
python
en
['en', 'en', 'en']
True
HomematicipGroupSwitch.async_turn_off
(self, **kwargs)
Turn the group off.
Turn the group off.
async def async_turn_off(self, **kwargs) -> None: """Turn the group off.""" await self._device.turn_off()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "turn_off", "(", ")" ]
[ 154, 4 ]
[ 156, 37 ]
python
en
['en', 'en', 'en']
True
HomematicipSwitchMeasuring.current_power_w
(self)
Return the current power usage in W.
Return the current power usage in W.
def current_power_w(self) -> float: """Return the current power usage in W.""" return self._device.currentPowerConsumption
[ "def", "current_power_w", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_device", ".", "currentPowerConsumption" ]
[ 163, 4 ]
[ 165, 51 ]
python
en
['en', 'en', 'en']
True
HomematicipSwitchMeasuring.today_energy_kwh
(self)
Return the today total energy usage in kWh.
Return the today total energy usage in kWh.
def today_energy_kwh(self) -> int: """Return the today total energy usage in kWh.""" if self._device.energyCounter is None: return 0 return round(self._device.energyCounter)
[ "def", "today_energy_kwh", "(", "self", ")", "->", "int", ":", "if", "self", ".", "_device", ".", "energyCounter", "is", "None", ":", "return", "0", "return", "round", "(", "self", ".", "_device", ".", "energyCounter", ")" ]
[ 168, 4 ]
[ 172, 48 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Register the API with the HTTP interface.
Register the API with the HTTP interface.
def setup(hass, config): """Register the API with the HTTP interface.""" hass.http.register_view(APIStatusView) hass.http.register_view(APIEventStream) hass.http.register_view(APIConfigView) hass.http.register_view(APIDiscoveryView) hass.http.register_view(APIStatesView) hass.http.register_v...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "http", ".", "register_view", "(", "APIStatusView", ")", "hass", ".", "http", ".", "register_view", "(", "APIEventStream", ")", "hass", ".", "http", ".", "register_view", "(", "APIConfigVie...
[ 58, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
async_services_json
(hass)
Generate services data to JSONify.
Generate services data to JSONify.
async def async_services_json(hass): """Generate services data to JSONify.""" descriptions = await async_get_all_descriptions(hass) return [{"domain": key, "services": value} for key, value in descriptions.items()]
[ "async", "def", "async_services_json", "(", "hass", ")", ":", "descriptions", "=", "await", "async_get_all_descriptions", "(", "hass", ")", "return", "[", "{", "\"domain\"", ":", "key", ",", "\"services\"", ":", "value", "}", "for", "key", ",", "value", "in"...
[ 432, 0 ]
[ 435, 86 ]
python
en
['pt', 'en', 'en']
True
async_events_json
(hass)
Generate event data to JSONify.
Generate event data to JSONify.
def async_events_json(hass): """Generate event data to JSONify.""" return [ {"event": key, "listener_count": value} for key, value in hass.bus.async_listeners().items() ]
[ "def", "async_events_json", "(", "hass", ")", ":", "return", "[", "{", "\"event\"", ":", "key", ",", "\"listener_count\"", ":", "value", "}", "for", "key", ",", "value", "in", "hass", ".", "bus", ".", "async_listeners", "(", ")", ".", "items", "(", ")"...
[ 439, 0 ]
[ 444, 5 ]
python
en
['en', 'en', 'it']
True
APIStatusView.get
(self, request)
Retrieve if API is running.
Retrieve if API is running.
def get(self, request): """Retrieve if API is running.""" return self.json_message("API running.")
[ "def", "get", "(", "self", ",", "request", ")", ":", "return", "self", ".", "json_message", "(", "\"API running.\"", ")" ]
[ 86, 4 ]
[ 88, 48 ]
python
en
['en', 'sn', 'en']
True
APIEventStream.get
(self, request)
Provide a streaming interface for the event bus.
Provide a streaming interface for the event bus.
async def get(self, request): """Provide a streaming interface for the event bus.""" if not request["hass_user"].is_admin: raise Unauthorized() hass = request.app["hass"] stop_obj = object() to_write = asyncio.Queue() restrict = request.query.get("restrict") ...
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", ")", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "stop_obj", "=", "object...
[ 97, 4 ]
[ 159, 23 ]
python
en
['en', 'en', 'en']
True
APIConfigView.get
(self, request)
Get current configuration.
Get current configuration.
def get(self, request): """Get current configuration.""" return self.json(request.app["hass"].config.as_dict())
[ "def", "get", "(", "self", ",", "request", ")", ":", "return", "self", ".", "json", "(", "request", ".", "app", "[", "\"hass\"", "]", ".", "config", ".", "as_dict", "(", ")", ")" ]
[ 169, 4 ]
[ 171, 62 ]
python
en
['en', 'la', 'en']
True
APIDiscoveryView.get
(self, request)
Get discovery information.
Get discovery information.
async def get(self, request): """Get discovery information.""" hass = request.app["hass"] uuid = await hass.helpers.instance_id.async_get() system_info = await async_get_system_info(hass) data = { ATTR_UUID: uuid, ATTR_BASE_URL: None, ATTR_EXT...
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "uuid", "=", "await", "hass", ".", "helpers", ".", "instance_id", ".", "async_get", "(", ")", "system_info", "=", "await", "async_ge...
[ 181, 4 ]
[ 212, 30 ]
python
en
['en', 'en', 'en']
True
APIStatesView.get
(self, request)
Get current states.
Get current states.
def get(self, request): """Get current states.""" user = request["hass_user"] entity_perm = user.permissions.check_entity states = [ state for state in request.app["hass"].states.async_all() if entity_perm(state.entity_id, "read") ] ret...
[ "def", "get", "(", "self", ",", "request", ")", ":", "user", "=", "request", "[", "\"hass_user\"", "]", "entity_perm", "=", "user", ".", "permissions", ".", "check_entity", "states", "=", "[", "state", "for", "state", "in", "request", ".", "app", "[", ...
[ 222, 4 ]
[ 231, 32 ]
python
en
['en', 'en', 'en']
True
APIEntityStateView.get
(self, request, entity_id)
Retrieve state of entity.
Retrieve state of entity.
def get(self, request, entity_id): """Retrieve state of entity.""" user = request["hass_user"] if not user.permissions.check_entity(entity_id, POLICY_READ): raise Unauthorized(entity_id=entity_id) state = request.app["hass"].states.get(entity_id) if state: ...
[ "def", "get", "(", "self", ",", "request", ",", "entity_id", ")", ":", "user", "=", "request", "[", "\"hass_user\"", "]", "if", "not", "user", ".", "permissions", ".", "check_entity", "(", "entity_id", ",", "POLICY_READ", ")", ":", "raise", "Unauthorized",...
[ 241, 4 ]
[ 250, 69 ]
python
en
['en', 'sk', 'en']
True
APIEntityStateView.post
(self, request, entity_id)
Update state of entity.
Update state of entity.
async def post(self, request, entity_id): """Update state of entity.""" if not request["hass_user"].is_admin: raise Unauthorized(entity_id=entity_id) hass = request.app["hass"] try: data = await request.json() except ValueError: return self.jso...
[ "async", "def", "post", "(", "self", ",", "request", ",", "entity_id", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", "entity_id", "=", "entity_id", ")", "hass", "=", "request", ".", "app"...
[ 252, 4 ]
[ 283, 19 ]
python
en
['en', 'en', 'en']
True
APIEntityStateView.delete
(self, request, entity_id)
Remove entity.
Remove entity.
def delete(self, request, entity_id): """Remove entity.""" if not request["hass_user"].is_admin: raise Unauthorized(entity_id=entity_id) if request.app["hass"].states.async_remove(entity_id): return self.json_message("Entity removed.") return self.json_message("En...
[ "def", "delete", "(", "self", ",", "request", ",", "entity_id", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", "entity_id", "=", "entity_id", ")", "if", "request", ".", "app", "[", "\"hass...
[ 286, 4 ]
[ 292, 69 ]
python
en
['es', 'it', 'en']
False
APIEventListenersView.get
(self, request)
Get event listeners.
Get event listeners.
def get(self, request): """Get event listeners.""" return self.json(async_events_json(request.app["hass"]))
[ "def", "get", "(", "self", ",", "request", ")", ":", "return", "self", ".", "json", "(", "async_events_json", "(", "request", ".", "app", "[", "\"hass\"", "]", ")", ")" ]
[ 302, 4 ]
[ 304, 64 ]
python
en
['fr', 'en', 'en']
True
APIEventView.post
(self, request, event_type)
Fire events.
Fire events.
async def post(self, request, event_type): """Fire events.""" if not request["hass_user"].is_admin: raise Unauthorized() body = await request.text() try: event_data = json.loads(body) if body else None except ValueError: return self.json_messag...
[ "async", "def", "post", "(", "self", ",", "request", ",", "event_type", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", ")", "body", "=", "await", "request", ".", "text", "(", ")", "try",...
[ 313, 4 ]
[ 343, 62 ]
python
en
['fr', 'en', 'en']
False
APIServicesView.get
(self, request)
Get registered services.
Get registered services.
async def get(self, request): """Get registered services.""" services = await async_services_json(request.app["hass"]) return self.json(services)
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "services", "=", "await", "async_services_json", "(", "request", ".", "app", "[", "\"hass\"", "]", ")", "return", "self", ".", "json", "(", "services", ")" ]
[ 352, 4 ]
[ 355, 34 ]
python
en
['en', 'da', 'en']
True
APIDomainServicesView.post
(self, request, domain, service)
Call a service. Returns a list of changed states.
Call a service.
async def post(self, request, domain, service): """Call a service. Returns a list of changed states. """ hass = request.app["hass"] body = await request.text() try: data = json.loads(body) if body else None except ValueError: return self.j...
[ "async", "def", "post", "(", "self", ",", "request", ",", "domain", ",", "service", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "body", "=", "await", "request", ".", "text", "(", ")", "try", ":", "data", "=", "json", ".", ...
[ 364, 4 ]
[ 384, 40 ]
python
en
['en', 'co', 'en']
True
APIComponentsView.get
(self, request)
Get current loaded components.
Get current loaded components.
def get(self, request): """Get current loaded components.""" return self.json(request.app["hass"].config.components)
[ "def", "get", "(", "self", ",", "request", ")", ":", "return", "self", ".", "json", "(", "request", ".", "app", "[", "\"hass\"", "]", ".", "config", ".", "components", ")" ]
[ 394, 4 ]
[ 396, 63 ]
python
en
['en', 'en', 'en']
True
APITemplateView.post
(self, request)
Render a template.
Render a template.
async def post(self, request): """Render a template.""" if not request["hass_user"].is_admin: raise Unauthorized() try: data = await request.json() tpl = template.Template(data["template"], request.app["hass"]) return tpl.async_render(variables=dat...
[ "async", "def", "post", "(", "self", ",", "request", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", ")", "try", ":", "data", "=", "await", "request", ".", "json", "(", ")", "tpl", "=",...
[ 405, 4 ]
[ 416, 13 ]
python
en
['en', 'en', 'en']
True
APIErrorLog.get
(self, request)
Retrieve API error log.
Retrieve API error log.
async def get(self, request): """Retrieve API error log.""" if not request["hass_user"].is_admin: raise Unauthorized() return web.FileResponse(request.app["hass"].data[DATA_LOGGING])
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "if", "not", "request", "[", "\"hass_user\"", "]", ".", "is_admin", ":", "raise", "Unauthorized", "(", ")", "return", "web", ".", "FileResponse", "(", "request", ".", "app", "[", "\"hass\"", ...
[ 425, 4 ]
[ 429, 71 ]
python
en
['es', 'pt', 'en']
False
async_setup
(hass, config)
Try to start embedded Lightwave broker.
Try to start embedded Lightwave broker.
async def async_setup(hass, config): """Try to start embedded Lightwave broker.""" host = config[DOMAIN][CONF_HOST] lwlink = LWLink(host) hass.data[LIGHTWAVE_LINK] = lwlink lights = config[DOMAIN][CONF_LIGHTS] if lights: hass.async_create_task( async_load_platform(hass, "lig...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "host", "=", "config", "[", "DOMAIN", "]", "[", "CONF_HOST", "]", "lwlink", "=", "LWLink", "(", "host", ")", "hass", ".", "data", "[", "LIGHTWAVE_LINK", "]", "=", "lwlink", "lights", ...
[ 60, 0 ]
[ 91, 15 ]
python
en
['en', 'no', 'en']
True
get_new_epoch
()
Get the latest epoch number. Returns: str: Epoch number.
Get the latest epoch number.
def get_new_epoch() -> str: """Get the latest epoch number. Returns: str: Epoch number. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] return get_new_port_number(cur_experiment_name)
[ "def", "get_new_epoch", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "return", "get_new_port_number", "(", "cur_experiment_name", ")" ]
[ 19, 0 ]
[ 28, 51 ]
python
en
['en', 'en', 'en']
True
get_existing_experiments
()
Get a list of existing experiments. Returns: str: Experiments information.
Get a list of existing experiments.
def get_existing_experiments() -> str: """Get a list of existing experiments. Returns: str: Experiments information. """ return get_experiments()
[ "def", "get_existing_experiments", "(", ")", "->", "str", ":", "return", "get_experiments", "(", ")" ]
[ 32, 0 ]
[ 39, 28 ]
python
en
['en', 'en', 'en']
True
add_experiment
()
Add a pending experiment. Returns: str: Experiment information.
Add a pending experiment.
def add_experiment() -> str: """Add a pending experiment. Returns: str: Experiment information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] return add_pending_experiment(cur_experiment_name)
[ "def", "add_experiment", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "return", "add_pending_experiment", "(", "cur_experiment_name", ")...
[ 43, 0 ]
[ 52, 54 ]
python
en
['en', 'en', 'en']
True
get_basic_experiment_info
()
Get basic experiment information. Returns: str: Experiment information.
Get basic experiment information.
def get_basic_experiment_info() -> str: """Get basic experiment information. Returns: str: Experiment information. """ return get_experiment_info()
[ "def", "get_basic_experiment_info", "(", ")", "->", "str", ":", "return", "get_experiment_info", "(", ")" ]
[ 56, 0 ]
[ 63, 32 ]
python
en
['en', 'da', 'en']
True
get_basic_vessel_info
()
Get vessel information within one tick. Returns: str: Vessel information.
Get vessel information within one tick.
def get_basic_vessel_info() -> str: """Get vessel information within one tick. Returns: str: Vessel information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] cur_snapshot_number = data["snapshot_number"] cur_epoch_number = data["epoch_numbe...
[ "def", "get_basic_vessel_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "cur_snapshot_number", "=", "data", "[", "\"snapshot_number...
[ 67, 0 ]
[ 81, 22 ]
python
en
['en', 'en', 'en']
True
get_acc_vessel_info
()
Get vessel information within a range. Returns: str: Vessel information.
Get vessel information within a range.
def get_acc_vessel_info() -> str: """Get vessel information within a range. Returns: str: Vessel information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] snapshot_start_number = data["snapshot_start_number"] snapshot_end_number = data["sna...
[ "def", "get_acc_vessel_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "snapshot_start_number", "=", "data", "[", "\"snapshot_start_...
[ 85, 0 ]
[ 100, 22 ]
python
en
['en', 'en', 'en']
True
get_basic_port_info
()
Get port information within one tick. Returns: str: Port information.
Get port information within one tick.
def get_basic_port_info() -> str: """Get port information within one tick. Returns: str: Port information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] cur_snapshot_number = data["snapshot_number"] cur_epoch_number = data["epoch_number"] ...
[ "def", "get_basic_port_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "cur_snapshot_number", "=", "data", "[", "\"snapshot_number\"...
[ 104, 0 ]
[ 116, 20 ]
python
en
['en', 'en', 'en']
True
get_acc_port_info
()
Get vessel information within a range. Returns: str: Port information.
Get vessel information within a range.
def get_acc_port_info() -> str: """Get vessel information within a range. Returns: str: Port information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] snapshot_start_number = data["snapshot_start_number"] snapshot_end_number = data["snapsho...
[ "def", "get_acc_port_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "snapshot_start_number", "=", "data", "[", "\"snapshot_start_nu...
[ 120, 0 ]
[ 135, 20 ]
python
en
['en', 'en', 'en']
True
get_basic_order_info
()
Get order information within one tick. Returns: str: Order information.
Get order information within one tick.
def get_basic_order_info() -> str: """Get order information within one tick. Returns: str: Order information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] cur_snapshot_number = data["snapshot_number"] cur_epoch_number = data["epoch_number"]...
[ "def", "get_basic_order_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "cur_snapshot_number", "=", "data", "[", "\"snapshot_number\...
[ 139, 0 ]
[ 151, 21 ]
python
en
['en', 'en', 'en']
True
get_acc_order_info
()
Get order information within a range. Returns: str: Order information.
Get order information within a range.
def get_acc_order_info() -> str: """Get order information within a range. Returns: str: Order information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] snapshot_start_number = data["snapshot_start_number"] snapshot_end_number = data["snapsh...
[ "def", "get_acc_order_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "snapshot_start_number", "=", "data", "[", "\"snapshot_start_n...
[ 155, 0 ]
[ 168, 30 ]
python
en
['en', 'en', 'en']
True
get_basic_attention_info
()
Get attention information within one tick. Returns: str: Attention information.
Get attention information within one tick.
def get_basic_attention_info() -> str: """Get attention information within one tick. Returns: str: Attention information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] cur_snapshot_number = data["snapshot_number"] cur_epoch_number = data["ep...
[ "def", "get_basic_attention_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "cur_snapshot_number", "=", "data", "[", "\"snapshot_num...
[ 172, 0 ]
[ 184, 25 ]
python
en
['en', 'en', 'en']
True
get_basic_decision_info
()
Get decision information within one tick. Returns: str: Decision information.
Get decision information within one tick.
def get_basic_decision_info() -> str: """Get decision information within one tick. Returns: str: Decision information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] cur_snapshot_number = data["snapshot_number"] cur_epoch_number = data["epoch...
[ "def", "get_basic_decision_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "cur_snapshot_number", "=", "data", "[", "\"snapshot_numb...
[ 188, 0 ]
[ 200, 24 ]
python
en
['en', 'en', 'en']
True
get_acc_decision_info
()
Get vessel information within a range. Returns: str: Decision information.
Get vessel information within a range.
def get_acc_decision_info() -> str: """Get vessel information within a range. Returns: str: Decision information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] snapshot_start_number = data["snapshot_start_number"] snapshot_end_number = data[...
[ "def", "get_acc_decision_info", "(", ")", "->", "str", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "snapshot_start_number", "=", "data", "[", "\"snapshot_star...
[ 204, 0 ]
[ 219, 33 ]
python
en
['en', 'en', 'en']
True
get_acc_attrs
()
Get decision and order information within a range. Returns: str: Decision and order information.
Get decision and order information within a range.
def get_acc_attrs(): """Get decision and order information within a range. Returns: str: Decision and order information. """ data = request.get_json(silent=True) cur_experiment_name = data["experiment_name"] snapshot_start_number = data["snapshot_start_number"] snapshot_end_number ...
[ "def", "get_acc_attrs", "(", ")", ":", "data", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "cur_experiment_name", "=", "data", "[", "\"experiment_name\"", "]", "snapshot_start_number", "=", "data", "[", "\"snapshot_start_number\"", "]", "sn...
[ 223, 0 ]
[ 240, 29 ]
python
en
['en', 'en', 'en']
True
accuracy
(preds, target)
Calculate the NME (Normalized Mean Error). Parameters ---------- preds : numpy array the predicted landmarks target : numpy array the ground truth of landmarks Returns ------- output: float32 the nme value output: list the list of l2 distances
Calculate the NME (Normalized Mean Error).
def accuracy(preds, target): """ Calculate the NME (Normalized Mean Error). Parameters ---------- preds : numpy array the predicted landmarks target : numpy array the ground truth of landmarks Returns ------- output: float32 the nme value output: list ...
[ "def", "accuracy", "(", "preds", ",", "target", ")", ":", "N", "=", "preds", ".", "shape", "[", "0", "]", "L", "=", "preds", ".", "shape", "[", "1", "]", "rmse", "=", "np", ".", "zeros", "(", "N", ")", ".", "astype", "(", "np", ".", "float32"...
[ 11, 0 ]
[ 59, 30 ]
python
en
['en', 'error', 'th']
False
bounded_regress_loss
( landmark_gt, landmarks_t, landmarks_s, reg_m=0.5, br_alpha=0.05 )
Calculate the Bounded Regression Loss for Knowledge Distillation. Parameters ---------- landmark_gt : tensor the ground truth of landmarks landmarks_t : tensor the predicted landmarks of teacher landmarks_s : tensor the predicted landmarks of student reg_m : float32...
Calculate the Bounded Regression Loss for Knowledge Distillation.
def bounded_regress_loss( landmark_gt, landmarks_t, landmarks_s, reg_m=0.5, br_alpha=0.05 ): """ Calculate the Bounded Regression Loss for Knowledge Distillation. Parameters ---------- landmark_gt : tensor the ground truth of landmarks landmarks_t : tensor the predicted land...
[ "def", "bounded_regress_loss", "(", "landmark_gt", ",", "landmarks_t", ",", "landmarks_s", ",", "reg_m", "=", "0.5", ",", "br_alpha", "=", "0.05", ")", ":", "l2_dis_s", "=", "(", "landmark_gt", "-", "landmarks_s", ")", ".", "pow", "(", "2", ")", ".", "su...
[ 96, 0 ]
[ 126, 29 ]
python
en
['en', 'error', 'th']
False
PFLDLoss.forward
(self, landmark_gt, euler_angle_gt, angle, landmarks)
Calculate weighted L2 loss for PFLD. Parameters ---------- landmark_gt : tensor the ground truth of landmarks euler_angle_gt : tensor the ground truth of pose angle angle : tensor the predicted pose angle landmarks : float32 ...
Calculate weighted L2 loss for PFLD.
def forward(self, landmark_gt, euler_angle_gt, angle, landmarks): """ Calculate weighted L2 loss for PFLD. Parameters ---------- landmark_gt : tensor the ground truth of landmarks euler_angle_gt : tensor the ground truth of pose angle angl...
[ "def", "forward", "(", "self", ",", "landmark_gt", ",", "euler_angle_gt", ",", "angle", ",", "landmarks", ")", ":", "weight_angle", "=", "torch", ".", "sum", "(", "1", "-", "torch", ".", "cos", "(", "angle", "-", "euler_angle_gt", ")", ",", "axis", "="...
[ 68, 4 ]
[ 93, 76 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass)
Enable the Entity Registry views.
Enable the Entity Registry views.
async def async_setup(hass): """Enable the Entity Registry views.""" hass.components.websocket_api.async_register_command(websocket_list_entities) hass.components.websocket_api.async_register_command(websocket_get_entity) hass.components.websocket_api.async_register_command(websocket_update_entity) ...
[ "async", "def", "async_setup", "(", "hass", ")", ":", "hass", ".", "components", ".", "websocket_api", ".", "async_register_command", "(", "websocket_list_entities", ")", "hass", ".", "components", ".", "websocket_api", ".", "async_register_command", "(", "websocket...
[ 15, 0 ]
[ 21, 15 ]
python
en
['en', 'en', 'en']
True
websocket_list_entities
(hass, connection, msg)
Handle list registry entries command. Async friendly.
Handle list registry entries command.
async def websocket_list_entities(hass, connection, msg): """Handle list registry entries command. Async friendly. """ registry = await async_get_registry(hass) connection.send_message( websocket_api.result_message( msg["id"], [_entry_dict(entry) for entry in registry.entities.v...
[ "async", "def", "websocket_list_entities", "(", "hass", ",", "connection", ",", "msg", ")", ":", "registry", "=", "await", "async_get_registry", "(", "hass", ")", "connection", ".", "send_message", "(", "websocket_api", ".", "result_message", "(", "msg", "[", ...
[ 26, 0 ]
[ 36, 5 ]
python
en
['en', 'en', 'en']
True
websocket_get_entity
(hass, connection, msg)
Handle get entity registry entry command. Async friendly.
Handle get entity registry entry command.
async def websocket_get_entity(hass, connection, msg): """Handle get entity registry entry command. Async friendly. """ registry = await async_get_registry(hass) entry = registry.entities.get(msg["entity_id"]) if entry is None: connection.send_message( websocket_api.error_m...
[ "async", "def", "websocket_get_entity", "(", "hass", ",", "connection", ",", "msg", ")", ":", "registry", "=", "await", "async_get_registry", "(", "hass", ")", "entry", "=", "registry", ".", "entities", ".", "get", "(", "msg", "[", "\"entity_id\"", "]", ")...
[ 46, 0 ]
[ 62, 5 ]
python
en
['en', 'en', 'en']
True
websocket_update_entity
(hass, connection, msg)
Handle update entity websocket command. Async friendly.
Handle update entity websocket command.
async def websocket_update_entity(hass, connection, msg): """Handle update entity websocket command. Async friendly. """ registry = await async_get_registry(hass) if msg["entity_id"] not in registry.entities: connection.send_message( websocket_api.error_message(msg["id"], ERR_N...
[ "async", "def", "websocket_update_entity", "(", "hass", ",", "connection", ",", "msg", ")", ":", "registry", "=", "await", "async_get_registry", "(", "hass", ")", "if", "msg", "[", "\"entity_id\"", "]", "not", "in", "registry", ".", "entities", ":", "connect...
[ 80, 0 ]
[ 124, 45 ]
python
en
['en', 'fy', 'en']
True
websocket_remove_entity
(hass, connection, msg)
Handle remove entity websocket command. Async friendly.
Handle remove entity websocket command.
async def websocket_remove_entity(hass, connection, msg): """Handle remove entity websocket command. Async friendly. """ registry = await async_get_registry(hass) if msg["entity_id"] not in registry.entities: connection.send_message( websocket_api.error_message(msg["id"], ERR_N...
[ "async", "def", "websocket_remove_entity", "(", "hass", ",", "connection", ",", "msg", ")", ":", "registry", "=", "await", "async_get_registry", "(", "hass", ")", "if", "msg", "[", "\"entity_id\"", "]", "not", "in", "registry", ".", "entities", ":", "connect...
[ 135, 0 ]
[ 149, 68 ]
python
en
['en', 'st', 'en']
True
_entry_dict
(entry)
Convert entry to API format.
Convert entry to API format.
def _entry_dict(entry): """Convert entry to API format.""" return { "config_entry_id": entry.config_entry_id, "device_id": entry.device_id, "area_id": entry.area_id, "disabled_by": entry.disabled_by, "entity_id": entry.entity_id, "name": entry.name, "icon"...
[ "def", "_entry_dict", "(", "entry", ")", ":", "return", "{", "\"config_entry_id\"", ":", "entry", ".", "config_entry_id", ",", "\"device_id\"", ":", "entry", ".", "device_id", ",", "\"area_id\"", ":", "entry", ".", "area_id", ",", "\"disabled_by\"", ":", "entr...
[ 153, 0 ]
[ 164, 5 ]
python
en
['en', 'en', 'en']
True
_entry_ext_dict
(entry)
Convert entry to API format.
Convert entry to API format.
def _entry_ext_dict(entry): """Convert entry to API format.""" data = _entry_dict(entry) data["original_name"] = entry.original_name data["original_icon"] = entry.original_icon data["unique_id"] = entry.unique_id data["capabilities"] = entry.capabilities return data
[ "def", "_entry_ext_dict", "(", "entry", ")", ":", "data", "=", "_entry_dict", "(", "entry", ")", "data", "[", "\"original_name\"", "]", "=", "entry", ".", "original_name", "data", "[", "\"original_icon\"", "]", "=", "entry", ".", "original_icon", "data", "["...
[ 168, 0 ]
[ 175, 15 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up Hive switches.
Set up Hive switches.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up Hive switches.""" if discovery_info is None: return session = hass.data.get(DATA_HIVE) devs = [] for dev in discovery_info: devs.append(HiveDevicePlug(session, dev)) add_entities(devs)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "session", "=", "hass", ".", "data", ".", "get", "(", "DATA_HIVE", ")", "devs", "...
[ 6, 0 ]
[ 15, 22 ]
python
en
['en', 'en', 'en']
True
HiveDevicePlug.unique_id
(self)
Return unique ID of entity.
Return unique ID of entity.
def unique_id(self): """Return unique ID of entity.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 22, 4 ]
[ 24, 30 ]
python
en
['en', 'cy', 'en']
True
HiveDevicePlug.device_info
(self)
Return device information.
Return device information.
def device_info(self): """Return device information.""" return {"identifiers": {(DOMAIN, self.unique_id)}, "name": self.name}
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "unique_id", ")", "}", ",", "\"name\"", ":", "self", ".", "name", "}" ]
[ 27, 4 ]
[ 29, 77 ]
python
da
['es', 'da', 'en']
False
HiveDevicePlug.name
(self)
Return the name of this Switch device if any.
Return the name of this Switch device if any.
def name(self): """Return the name of this Switch device if any.""" return self.node_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "node_name" ]
[ 32, 4 ]
[ 34, 29 ]
python
en
['en', 'en', 'en']
True
HiveDevicePlug.device_state_attributes
(self)
Show Device Attributes.
Show Device Attributes.
def device_state_attributes(self): """Show Device Attributes.""" return self.attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "attributes" ]
[ 37, 4 ]
[ 39, 30 ]
python
en
['en', 'en', 'en']
True
HiveDevicePlug.current_power_w
(self)
Return the current power usage in W.
Return the current power usage in W.
def current_power_w(self): """Return the current power usage in W.""" return self.session.switch.get_power_usage(self.node_id)
[ "def", "current_power_w", "(", "self", ")", ":", "return", "self", ".", "session", ".", "switch", ".", "get_power_usage", "(", "self", ".", "node_id", ")" ]
[ 42, 4 ]
[ 44, 64 ]
python
en
['en', 'en', 'en']
True