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
RoonDevice.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" return self._media_image_url
[ "def", "media_image_url", "(", "self", ")", ":", "return", "self", ".", "_media_image_url" ]
[ 351, 4 ]
[ 353, 36 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_position
(self)
Return position currently playing.
Return position currently playing.
def media_position(self): """Return position currently playing.""" return self._media_position
[ "def", "media_position", "(", "self", ")", ":", "return", "self", ".", "_media_position" ]
[ 356, 4 ]
[ 358, 35 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_duration
(self)
Return total runtime length.
Return total runtime length.
def media_duration(self): """Return total runtime length.""" return self._media_duration
[ "def", "media_duration", "(", "self", ")", ":", "return", "self", ".", "_media_duration" ]
[ 361, 4 ]
[ 363, 35 ]
python
en
['fr', 'no', 'en']
False
RoonDevice.volume_level
(self)
Return current volume level.
Return current volume level.
def volume_level(self): """Return current volume level.""" return self._volume_level
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "_volume_level" ]
[ 366, 4 ]
[ 368, 33 ]
python
en
['fr', 'la', 'en']
False
RoonDevice.is_volume_muted
(self)
Return mute state.
Return mute state.
def is_volume_muted(self): """Return mute state.""" return self._is_volume_muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_is_volume_muted" ]
[ 371, 4 ]
[ 373, 36 ]
python
co
['ro', 'co', 'en']
False
RoonDevice.volume_step
(self)
.Return volume step size.
.Return volume step size.
def volume_step(self): """.Return volume step size.""" return self._volume_step
[ "def", "volume_step", "(", "self", ")", ":", "return", "self", ".", "_volume_step" ]
[ 376, 4 ]
[ 378, 32 ]
python
en
['nl', 'ko', 'en']
False
RoonDevice.supports_standby
(self)
Return power state of source controls.
Return power state of source controls.
def supports_standby(self): """Return power state of source controls.""" return self._supports_standby
[ "def", "supports_standby", "(", "self", ")", ":", "return", "self", ".", "_supports_standby" ]
[ 381, 4 ]
[ 383, 37 ]
python
en
['en', 'en', 'en']
True
RoonDevice.state
(self)
Return current playstate of the device.
Return current playstate of the device.
def state(self): """Return current playstate of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 386, 4 ]
[ 388, 26 ]
python
en
['en', 'en', 'en']
True
RoonDevice.shuffle
(self)
Boolean if shuffle is enabled.
Boolean if shuffle is enabled.
def shuffle(self): """Boolean if shuffle is enabled.""" return self._shuffle
[ "def", "shuffle", "(", "self", ")", ":", "return", "self", ".", "_shuffle" ]
[ 391, 4 ]
[ 393, 28 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_play
(self)
Send play command to device.
Send play command to device.
def media_play(self): """Send play command to device.""" self._server.roonapi.playback_control(self.output_id, "play")
[ "def", "media_play", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"play\"", ")" ]
[ 395, 4 ]
[ 397, 69 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_pause
(self)
Send pause command to device.
Send pause command to device.
def media_pause(self): """Send pause command to device.""" self._server.roonapi.playback_control(self.output_id, "pause")
[ "def", "media_pause", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"pause\"", ")" ]
[ 399, 4 ]
[ 401, 70 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_play_pause
(self)
Toggle play command to device.
Toggle play command to device.
def media_play_pause(self): """Toggle play command to device.""" self._server.roonapi.playback_control(self.output_id, "playpause")
[ "def", "media_play_pause", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"playpause\"", ")" ]
[ 403, 4 ]
[ 405, 74 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_stop
(self)
Send stop command to device.
Send stop command to device.
def media_stop(self): """Send stop command to device.""" self._server.roonapi.playback_control(self.output_id, "stop")
[ "def", "media_stop", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"stop\"", ")" ]
[ 407, 4 ]
[ 409, 69 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_next_track
(self)
Send next track command to device.
Send next track command to device.
def media_next_track(self): """Send next track command to device.""" self._server.roonapi.playback_control(self.output_id, "next")
[ "def", "media_next_track", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"next\"", ")" ]
[ 411, 4 ]
[ 413, 69 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_previous_track
(self)
Send previous track command to device.
Send previous track command to device.
def media_previous_track(self): """Send previous track command to device.""" self._server.roonapi.playback_control(self.output_id, "previous")
[ "def", "media_previous_track", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "playback_control", "(", "self", ".", "output_id", ",", "\"previous\"", ")" ]
[ 415, 4 ]
[ 417, 73 ]
python
en
['en', 'en', 'en']
True
RoonDevice.media_seek
(self, position)
Send seek command to device.
Send seek command to device.
def media_seek(self, position): """Send seek command to device.""" self._server.roonapi.seek(self.output_id, position) # Seek doesn't cause an async update - so force one self._media_position = position self.schedule_update_ha_state()
[ "def", "media_seek", "(", "self", ",", "position", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "seek", "(", "self", ".", "output_id", ",", "position", ")", "# Seek doesn't cause an async update - so force one", "self", ".", "_media_position", "=", "po...
[ 419, 4 ]
[ 424, 39 ]
python
en
['en', 'en', 'en']
True
RoonDevice.set_volume_level
(self, volume)
Send new volume_level to device.
Send new volume_level to device.
def set_volume_level(self, volume): """Send new volume_level to device.""" volume = int(volume * 100) self._server.roonapi.change_volume(self.output_id, volume)
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "volume", "=", "int", "(", "volume", "*", "100", ")", "self", ".", "_server", ".", "roonapi", ".", "change_volume", "(", "self", ".", "output_id", ",", "volume", ")" ]
[ 426, 4 ]
[ 429, 66 ]
python
en
['it', 'en', 'en']
True
RoonDevice.mute_volume
(self, mute=True)
Send mute/unmute to device.
Send mute/unmute to device.
def mute_volume(self, mute=True): """Send mute/unmute to device.""" self._server.roonapi.mute(self.output_id, mute)
[ "def", "mute_volume", "(", "self", ",", "mute", "=", "True", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "mute", "(", "self", ".", "output_id", ",", "mute", ")" ]
[ 431, 4 ]
[ 433, 55 ]
python
it
['it', 'it', 'en']
True
RoonDevice.volume_up
(self)
Send new volume_level to device.
Send new volume_level to device.
def volume_up(self): """Send new volume_level to device.""" self._server.roonapi.change_volume(self.output_id, 3, "relative")
[ "def", "volume_up", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "change_volume", "(", "self", ".", "output_id", ",", "3", ",", "\"relative\"", ")" ]
[ 435, 4 ]
[ 437, 73 ]
python
en
['it', 'en', 'en']
True
RoonDevice.volume_down
(self)
Send new volume_level to device.
Send new volume_level to device.
def volume_down(self): """Send new volume_level to device.""" self._server.roonapi.change_volume(self.output_id, -3, "relative")
[ "def", "volume_down", "(", "self", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "change_volume", "(", "self", ".", "output_id", ",", "-", "3", ",", "\"relative\"", ")" ]
[ 439, 4 ]
[ 441, 74 ]
python
en
['it', 'en', 'en']
True
RoonDevice.turn_on
(self)
Turn on device (if supported).
Turn on device (if supported).
def turn_on(self): """Turn on device (if supported).""" if not (self.supports_standby and "source_controls" in self.player_data): self.media_play() return for source in self.player_data["source_controls"]: if source["supports_standby"] and source["status"] != ...
[ "def", "turn_on", "(", "self", ")", ":", "if", "not", "(", "self", ".", "supports_standby", "and", "\"source_controls\"", "in", "self", ".", "player_data", ")", ":", "self", ".", "media_play", "(", ")", "return", "for", "source", "in", "self", ".", "play...
[ 443, 4 ]
[ 453, 22 ]
python
en
['fr', 'en', 'en']
True
RoonDevice.turn_off
(self)
Turn off device (if supported).
Turn off device (if supported).
def turn_off(self): """Turn off device (if supported).""" if not (self.supports_standby and "source_controls" in self.player_data): self.media_stop() return for source in self.player_data["source_controls"]: if source["supports_standby"] and source["status"] ...
[ "def", "turn_off", "(", "self", ")", ":", "if", "not", "(", "self", ".", "supports_standby", "and", "\"source_controls\"", "in", "self", ".", "player_data", ")", ":", "self", ".", "media_stop", "(", ")", "return", "for", "source", "in", "self", ".", "pla...
[ 455, 4 ]
[ 464, 22 ]
python
en
['en', 'en', 'en']
True
RoonDevice.set_shuffle
(self, shuffle)
Set shuffle state.
Set shuffle state.
def set_shuffle(self, shuffle): """Set shuffle state.""" self._server.roonapi.shuffle(self.output_id, shuffle)
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "self", ".", "_server", ".", "roonapi", ".", "shuffle", "(", "self", ".", "output_id", ",", "shuffle", ")" ]
[ 466, 4 ]
[ 468, 61 ]
python
de
['de', 'ny', 'en']
False
RoonDevice.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.
def play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the media player.""" _LOGGER.debug("Playback request for %s / %s", media_type, media_id) if media_type in ("library", "track"): # media_id is a roon browser id self._server.roonapi.pl...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Playback request for %s / %s\"", ",", "media_type", ",", "media_id", ")", "if", "media_type", "in", "(", "\"library\"", ...
[ 470, 4 ]
[ 486, 17 ]
python
en
['en', 'en', 'en']
True
RoonDevice.join_players
(self, group_members)
Join `group_members` as a player group with the current player.
Join `group_members` as a player group with the current player.
def join_players(self, group_members): """Join `group_members` as a player group with the current player.""" zone_data = self._server.roonapi.zone_by_output_id(self._output_id) if zone_data is None: _LOGGER.error("No zone data for %s", self.name) return sync_ava...
[ "def", "join_players", "(", "self", ",", "group_members", ")", ":", "zone_data", "=", "self", ".", "_server", ".", "roonapi", ".", "zone_by_output_id", "(", "self", ".", "_output_id", ")", "if", "zone_data", "is", "None", ":", "_LOGGER", ".", "error", "(",...
[ 488, 4 ]
[ 526, 9 ]
python
en
['en', 'en', 'en']
True
RoonDevice.unjoin_player
(self)
Remove this player from any group.
Remove this player from any group.
def unjoin_player(self): """Remove this player from any group.""" if not self._server.roonapi.is_grouped(self._output_id): _LOGGER.error( "Can't unjoin player %s because it's not in a group", self.name, ) return self._server.r...
[ "def", "unjoin_player", "(", "self", ")", ":", "if", "not", "self", ".", "_server", ".", "roonapi", ".", "is_grouped", "(", "self", ".", "_output_id", ")", ":", "_LOGGER", ".", "error", "(", "\"Can't unjoin player %s because it's not in a group\"", ",", "self", ...
[ 528, 4 ]
[ 538, 63 ]
python
en
['en', 'en', 'en']
True
RoonDevice.async_transfer
(self, transfer_id)
Transfer playback from this roon player to another.
Transfer playback from this roon player to another.
async def async_transfer(self, transfer_id): """Transfer playback from this roon player to another.""" name = self._server.roon_name(transfer_id) if name is None: _LOGGER.error("No roon player found for %s", transfer_id) return zone_ids = { output["d...
[ "async", "def", "async_transfer", "(", "self", ",", "transfer_id", ")", ":", "name", "=", "self", ".", "_server", ".", "roon_name", "(", "transfer_id", ")", "if", "name", "is", "None", ":", "_LOGGER", ".", "error", "(", "\"No roon player found for %s\"", ","...
[ 540, 4 ]
[ 566, 9 ]
python
en
['en', 'en', 'en']
True
RoonDevice.async_browse_media
(self, media_content_type=None, media_content_id=None)
Implement the websocket media browsing helper.
Implement the websocket media browsing helper.
async def async_browse_media(self, media_content_type=None, media_content_id=None): """Implement the websocket media browsing helper.""" return await self.hass.async_add_executor_job( browse_media, self.zone_id, self._server, media_content_type, ...
[ "async", "def", "async_browse_media", "(", "self", ",", "media_content_type", "=", "None", ",", "media_content_id", "=", "None", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "browse_media", ",", "self", ".", "zone_id", ...
[ 568, 4 ]
[ 576, 9 ]
python
en
['en', 'af', 'en']
True
async_setup_entry
(hass, config_entry)
Set up Met as config entry.
Set up Met as config entry.
async def async_setup_entry(hass, config_entry): """Set up Met as config entry.""" # Don't setup if tracking home location and latitude or longitude isn't set. # Also, filters out our onboarding default location. if config_entry.data.get(CONF_TRACK_HOME, False) and ( (not hass.config.latitude an...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "# Don't setup if tracking home location and latitude or longitude isn't set.", "# Also, filters out our onboarding default location.", "if", "config_entry", ".", "data", ".", "get", "(", "CONF_TRACK...
[ 34, 0 ]
[ 61, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, config_entry): """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms( config_entry, PLATFORMS ) hass.data[DOMAIN][config_entry.entry_id].untrack_home() hass.data[DOMAIN].pop(config_entry.entry_id) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "config_entry", ",", "PLATFORMS", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[",...
[ 64, 0 ]
[ 73, 20 ]
python
en
['en', 'es', 'en']
True
MetDataUpdateCoordinator.__init__
(self, hass, config_entry)
Initialize global Met data updater.
Initialize global Met data updater.
def __init__(self, hass, config_entry): """Initialize global Met data updater.""" self._unsub_track_home = None self.weather = MetWeatherData( hass, config_entry.data, hass.config.units.is_metric ) self.weather.set_coordinates() update_interval = timedelta(mi...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config_entry", ")", ":", "self", ".", "_unsub_track_home", "=", "None", "self", ".", "weather", "=", "MetWeatherData", "(", "hass", ",", "config_entry", ".", "data", ",", "hass", ".", "config", ".", "uni...
[ 79, 4 ]
[ 89, 85 ]
python
nl
['fr', 'nl', 'nl']
True
MetDataUpdateCoordinator._async_update_data
(self)
Fetch data from Met.
Fetch data from Met.
async def _async_update_data(self): """Fetch data from Met.""" try: return await self.weather.fetch_data() except Exception as err: raise UpdateFailed(f"Update failed: {err}") from err
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "try", ":", "return", "await", "self", ".", "weather", ".", "fetch_data", "(", ")", "except", "Exception", "as", "err", ":", "raise", "UpdateFailed", "(", "f\"Update failed: {err}\"", ")", "from", ...
[ 91, 4 ]
[ 96, 64 ]
python
en
['en', 'en', 'en']
True
MetDataUpdateCoordinator.track_home
(self)
Start tracking changes to HA home setting.
Start tracking changes to HA home setting.
def track_home(self): """Start tracking changes to HA home setting.""" if self._unsub_track_home: return async def _async_update_weather_data(_event=None): """Update weather data.""" if self.weather.set_coordinates(): await self.async_refresh(...
[ "def", "track_home", "(", "self", ")", ":", "if", "self", ".", "_unsub_track_home", ":", "return", "async", "def", "_async_update_weather_data", "(", "_event", "=", "None", ")", ":", "\"\"\"Update weather data.\"\"\"", "if", "self", ".", "weather", ".", "set_coo...
[ 98, 4 ]
[ 110, 9 ]
python
en
['en', 'en', 'en']
True
MetDataUpdateCoordinator.untrack_home
(self)
Stop tracking changes to HA home setting.
Stop tracking changes to HA home setting.
def untrack_home(self): """Stop tracking changes to HA home setting.""" if self._unsub_track_home: self._unsub_track_home() self._unsub_track_home = None
[ "def", "untrack_home", "(", "self", ")", ":", "if", "self", ".", "_unsub_track_home", ":", "self", ".", "_unsub_track_home", "(", ")", "self", ".", "_unsub_track_home", "=", "None" ]
[ 112, 4 ]
[ 116, 41 ]
python
en
['en', 'en', 'en']
True
MetWeatherData.__init__
(self, hass, config, is_metric)
Initialise the weather entity data.
Initialise the weather entity data.
def __init__(self, hass, config, is_metric): """Initialise the weather entity data.""" self.hass = hass self._config = config self._is_metric = is_metric self._weather_data = None self.current_weather_data = {} self.daily_forecast = None self.hourly_foreca...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "is_metric", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_config", "=", "config", "self", ".", "_is_metric", "=", "is_metric", "self", ".", "_weather_data", "=", "None", "se...
[ 122, 4 ]
[ 131, 32 ]
python
en
['en', 'zu', 'en']
True
MetWeatherData.set_coordinates
(self)
Weather data inialization - set the coordinates.
Weather data inialization - set the coordinates.
def set_coordinates(self): """Weather data inialization - set the coordinates.""" if self._config.get(CONF_TRACK_HOME, False): latitude = self.hass.config.latitude longitude = self.hass.config.longitude elevation = self.hass.config.elevation else: ...
[ "def", "set_coordinates", "(", "self", ")", ":", "if", "self", ".", "_config", ".", "get", "(", "CONF_TRACK_HOME", ",", "False", ")", ":", "latitude", "=", "self", ".", "hass", ".", "config", ".", "latitude", "longitude", "=", "self", ".", "hass", ".",...
[ 133, 4 ]
[ 161, 19 ]
python
en
['en', 'en', 'en']
True
MetWeatherData.fetch_data
(self)
Fetch data from API - (current weather and forecast).
Fetch data from API - (current weather and forecast).
async def fetch_data(self): """Fetch data from API - (current weather and forecast).""" await self._weather_data.fetching_data() self.current_weather_data = self._weather_data.get_current_weather() time_zone = dt_util.DEFAULT_TIME_ZONE self.daily_forecast = self._weather_data.get...
[ "async", "def", "fetch_data", "(", "self", ")", ":", "await", "self", ".", "_weather_data", ".", "fetching_data", "(", ")", "self", ".", "current_weather_data", "=", "self", ".", "_weather_data", ".", "get_current_weather", "(", ")", "time_zone", "=", "dt_util...
[ 163, 4 ]
[ 170, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None )
Read configuration and create Modbus lights.
Read configuration and create Modbus lights.
async def async_setup_platform( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ): """Read configuration and create Modbus lights.""" if discovery_info is None: # pragma: no cover return lights = [] for entry in discovery_info[CONF_LIGHTS]: hub: Mod...
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "# pragma: no cover", "return", "lights...
[ 18, 0 ]
[ 29, 30 ]
python
en
['en', 'en', 'en']
True
ModbusLight.async_turn_on
(self, **kwargs)
Set light on.
Set light on.
async def async_turn_on(self, **kwargs): """Set light on.""" await self.async_turn(self.command_on)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_turn", "(", "self", ".", "command_on", ")" ]
[ 35, 4 ]
[ 37, 46 ]
python
en
['fr', 'et', 'en']
False
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 19, 0 ]
[ 21, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 25, 0 ]
[ 27, 30 ]
python
en
['en', 'fy', 'en']
True
test_aid_generation
(hass, device_reg, entity_reg)
Test generating aids.
Test generating aids.
async def test_aid_generation(hass, device_reg, entity_reg): """Test generating aids.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connections={(device_regist...
[ "async", "def", "test_aid_generation", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")",...
[ 30, 0 ]
[ 97, 9 ]
python
en
['nl', 'en', 'it']
False
test_no_aid_collision
(hass, device_reg, entity_reg)
Test generating aids.
Test generating aids.
async def test_no_aid_collision(hass, device_reg, entity_reg): """Test generating aids.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connections={(device_regi...
[ "async", "def", "test_no_aid_collision", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")...
[ 100, 0 ]
[ 124, 26 ]
python
en
['nl', 'en', 'it']
False
test_aid_generation_no_unique_ids_handles_collision
( hass, device_reg, entity_reg )
Test colliding aids is stable.
Test colliding aids is stable.
async def test_aid_generation_no_unique_ids_handles_collision( hass, device_reg, entity_reg ): """Test colliding aids is stable.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_...
[ "async", "def", "test_aid_generation_no_unique_ids_handles_collision", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_t...
[ 127, 0 ]
[ 621, 70 ]
python
en
['en', 'en', 'en']
True
create_camera
(accessory)
Define camera characteristics.
Define camera characteristics.
def create_camera(accessory): """Define camera characteristics.""" accessory.add_service(ServicesTypes.CAMERA_RTP_STREAM_MANAGEMENT)
[ "def", "create_camera", "(", "accessory", ")", ":", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "CAMERA_RTP_STREAM_MANAGEMENT", ")" ]
[ 11, 0 ]
[ 13, 69 ]
python
ca
['it', 'ca', 'en']
False
test_read_state
(hass, utcnow)
Test reading the state of a HomeKit camera.
Test reading the state of a HomeKit camera.
async def test_read_state(hass, utcnow): """Test reading the state of a HomeKit camera.""" helper = await setup_test_component(hass, create_camera) state = await helper.poll_and_get_state() assert state.state == "idle"
[ "async", "def", "test_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_camera", ")", "state", "=", "await", "helper", ".", "poll_and_get_state", "(", ")", "assert", "state", ".", "st...
[ 16, 0 ]
[ 21, 32 ]
python
en
['en', 'en', 'en']
True
test_get_image
(hass, utcnow)
Test getting a JPEG from a camera.
Test getting a JPEG from a camera.
async def test_get_image(hass, utcnow): """Test getting a JPEG from a camera.""" helper = await setup_test_component(hass, create_camera) image = await camera.async_get_image(hass, helper.entity_id) assert image.content == base64.b64decode(FAKE_CAMERA_IMAGE)
[ "async", "def", "test_get_image", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_camera", ")", "image", "=", "await", "camera", ".", "async_get_image", "(", "hass", ",", "helper", ".", "entity_...
[ 24, 0 ]
[ 28, 63 ]
python
en
['en', 'en', 'en']
True
get_requirement_info
(dist)
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist().
def get_requirement_info(dist): # type: (Distribution) -> RequirementInfo """ Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist(). """ if not dist_is_editable(dist): return (None, False, []) location = os.path.normcase(os.path.abspath(dist.lo...
[ "def", "get_requirement_info", "(", "dist", ")", ":", "# type: (Distribution) -> RequirementInfo", "if", "not", "dist_is_editable", "(", "dist", ")", ":", "return", "(", "None", ",", "False", ",", "[", "]", ")", "location", "=", "os", ".", "path", ".", "norm...
[ 174, 0 ]
[ 233, 34 ]
python
en
['en', 'error', 'th']
False
test_reloadable
(hass)
Test that we can reload.
Test that we can reload.
async def test_reloadable(hass): """Test that we can reload.""" hass.states.async_set("sensor.test_sensor", "mytest") await async_setup_component( hass, "sensor", { "sensor": { "platform": DOMAIN, "sensors": { "state": ...
[ "async", "def", "test_reloadable", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"mytest\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sensor\"", ":", "{", "\"pla...
[ 14, 0 ]
[ 91, 66 ]
python
en
['en', 'en', 'en']
True
test_reloadable_can_remove
(hass)
Test that we can reload and remove all template sensors.
Test that we can reload and remove all template sensors.
async def test_reloadable_can_remove(hass): """Test that we can reload and remove all template sensors.""" hass.states.async_set("sensor.test_sensor", "mytest") await async_setup_component( hass, "sensor", { "sensor": { "platform": DOMAIN, ...
[ "async", "def", "test_reloadable_can_remove", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"mytest\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sensor\"", ":", "{...
[ 94, 0 ]
[ 145, 44 ]
python
en
['en', 'en', 'en']
True
test_reloadable_stops_on_invalid_config
(hass)
Test we stop the reload if configuration.yaml is completely broken.
Test we stop the reload if configuration.yaml is completely broken.
async def test_reloadable_stops_on_invalid_config(hass): """Test we stop the reload if configuration.yaml is completely broken.""" hass.states.async_set("sensor.test_sensor", "mytest") await async_setup_component( hass, "sensor", { "sensor": { "platform":...
[ "async", "def", "test_reloadable_stops_on_invalid_config", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"mytest\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sensor\""...
[ 148, 0 ]
[ 190, 44 ]
python
en
['en', 'en', 'en']
True
test_reloadable_handles_partial_valid_config
(hass)
Test we can still setup valid sensors when configuration.yaml has a broken entry.
Test we can still setup valid sensors when configuration.yaml has a broken entry.
async def test_reloadable_handles_partial_valid_config(hass): """Test we can still setup valid sensors when configuration.yaml has a broken entry.""" hass.states.async_set("sensor.test_sensor", "mytest") await async_setup_component( hass, "sensor", { "sensor": { ...
[ "async", "def", "test_reloadable_handles_partial_valid_config", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"mytest\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sens...
[ 193, 0 ]
[ 238, 83 ]
python
en
['en', 'en', 'en']
True
test_reloadable_multiple_platforms
(hass)
Test that we can reload.
Test that we can reload.
async def test_reloadable_multiple_platforms(hass): """Test that we can reload.""" hass.states.async_set("sensor.test_sensor", "mytest") await async_setup_component( hass, "sensor", { "sensor": { "platform": DOMAIN, "sensors": { ...
[ "async", "def", "test_reloadable_multiple_platforms", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"mytest\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sensor\"", "...
[ 241, 0 ]
[ 302, 60 ]
python
en
['en', 'en', 'en']
True
test_reload_sensors_that_reference_other_template_sensors
(hass)
Test that we can reload sensor that reference other template sensors.
Test that we can reload sensor that reference other template sensors.
async def test_reload_sensors_that_reference_other_template_sensors(hass): """Test that we can reload sensor that reference other template sensors.""" await async_setup_component( hass, "sensor", { "sensor": { "platform": DOMAIN, "sensors": { ...
[ "async", "def", "test_reload_sensors_that_reference_other_template_sensors", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"sensors\"", ":", "{", "\"st...
[ 305, 0 ]
[ 347, 55 ]
python
en
['en', 'en', 'en']
True
async_test_humidity
(hass, cluster, entity_id)
Test humidity sensor.
Test humidity sensor.
async def async_test_humidity(hass, cluster, entity_id): """Test humidity sensor.""" await send_attributes_report(hass, cluster, {1: 1, 0: 1000, 2: 100}) assert_state(hass, entity_id, "10.0", PERCENTAGE)
[ "async", "def", "async_test_humidity", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "1", ":", "1", ",", "0", ":", "1000", ",", "2", ":", "100", "}", ")", "assert_stat...
[ 39, 0 ]
[ 42, 53 ]
python
en
['en', 'et', 'en']
True
async_test_temperature
(hass, cluster, entity_id)
Test temperature sensor.
Test temperature sensor.
async def async_test_temperature(hass, cluster, entity_id): """Test temperature sensor.""" await send_attributes_report(hass, cluster, {1: 1, 0: 2900, 2: 100}) assert_state(hass, entity_id, "29.0", TEMP_CELSIUS)
[ "async", "def", "async_test_temperature", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "1", ":", "1", ",", "0", ":", "2900", ",", "2", ":", "100", "}", ")", "assert_s...
[ 45, 0 ]
[ 48, 55 ]
python
en
['en', 'la', 'en']
True
async_test_pressure
(hass, cluster, entity_id)
Test pressure sensor.
Test pressure sensor.
async def async_test_pressure(hass, cluster, entity_id): """Test pressure sensor.""" await send_attributes_report(hass, cluster, {1: 1, 0: 1000, 2: 10000}) assert_state(hass, entity_id, "1000", PRESSURE_HPA) await send_attributes_report(hass, cluster, {0: 1000, 20: -1, 16: 10000}) assert_state(hass...
[ "async", "def", "async_test_pressure", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "1", ":", "1", ",", "0", ":", "1000", ",", "2", ":", "10000", "}", ")", "assert_st...
[ 51, 0 ]
[ 57, 55 ]
python
en
['en', 'bs', 'en']
True
async_test_illuminance
(hass, cluster, entity_id)
Test illuminance sensor.
Test illuminance sensor.
async def async_test_illuminance(hass, cluster, entity_id): """Test illuminance sensor.""" await send_attributes_report(hass, cluster, {1: 1, 0: 10, 2: 20}) assert_state(hass, entity_id, "1.0", LIGHT_LUX)
[ "async", "def", "async_test_illuminance", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "1", ":", "1", ",", "0", ":", "10", ",", "2", ":", "20", "}", ")", "assert_stat...
[ 60, 0 ]
[ 63, 51 ]
python
fi
['fr', 'fi', 'it']
False
async_test_metering
(hass, cluster, entity_id)
Test metering sensor.
Test metering sensor.
async def async_test_metering(hass, cluster, entity_id): """Test metering sensor.""" await send_attributes_report(hass, cluster, {1025: 1, 1024: 12345, 1026: 100}) assert_state(hass, entity_id, "12345.0", "unknown")
[ "async", "def", "async_test_metering", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "1025", ":", "1", ",", "1024", ":", "12345", ",", "1026", ":", "100", "}", ")", "a...
[ 66, 0 ]
[ 69, 55 ]
python
af
['en', 'af', 'nl']
False
async_test_electrical_measurement
(hass, cluster, entity_id)
Test electrical measurement sensor.
Test electrical measurement sensor.
async def async_test_electrical_measurement(hass, cluster, entity_id): """Test electrical measurement sensor.""" with mock.patch( ( "homeassistant.components.zha.core.channels.homeautomation" ".ElectricalMeasurementChannel.divisor" ), new_callable=mock.PropertyMoc...
[ "async", "def", "async_test_electrical_measurement", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "with", "mock", ".", "patch", "(", "(", "\"homeassistant.components.zha.core.channels.homeautomation\"", "\".ElectricalMeasurementChannel.divisor\"", ")", ",", "new...
[ 72, 0 ]
[ 93, 56 ]
python
en
['en', 'da', 'en']
True
async_test_powerconfiguration
(hass, cluster, entity_id)
Test powerconfiguration/battery sensor.
Test powerconfiguration/battery sensor.
async def async_test_powerconfiguration(hass, cluster, entity_id): """Test powerconfiguration/battery sensor.""" await send_attributes_report(hass, cluster, {33: 98}) assert_state(hass, entity_id, "49", "%") assert hass.states.get(entity_id).attributes["battery_voltage"] == 2.9 assert hass.states.ge...
[ "async", "def", "async_test_powerconfiguration", "(", "hass", ",", "cluster", ",", "entity_id", ")", ":", "await", "send_attributes_report", "(", "hass", ",", "cluster", ",", "{", "33", ":", "98", "}", ")", "assert_state", "(", "hass", ",", "entity_id", ",",...
[ 96, 0 ]
[ 104, 74 ]
python
en
['en', 'no', 'en']
True
test_sensor
( hass, zigpy_device_mock, zha_device_joined_restored, cluster_id, test_func, report_count, read_plug, )
Test zha sensor platform.
Test zha sensor platform.
async def test_sensor( hass, zigpy_device_mock, zha_device_joined_restored, cluster_id, test_func, report_count, read_plug, ): """Test zha sensor platform.""" zigpy_device = zigpy_device_mock( { 1: { SIG_EP_INPUT: [cluster_id, general.Basic.cluste...
[ "async", "def", "test_sensor", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined_restored", ",", "cluster_id", ",", "test_func", ",", "report_count", ",", "read_plug", ",", ")", ":", "zigpy_device", "=", "zigpy_device_mock", "(", "{", "1", ":", "{",...
[ 152, 0 ]
[ 195, 75 ]
python
bg-Latn
['cs', 'bg-Latn', 'pl']
False
assert_state
(hass, entity_id, state, unit_of_measurement)
Check that the state is what is expected. This is used to ensure that the logic in each sensor class handled the attribute report it received correctly.
Check that the state is what is expected.
def assert_state(hass, entity_id, state, unit_of_measurement): """Check that the state is what is expected. This is used to ensure that the logic in each sensor class handled the attribute report it received correctly. """ hass_state = hass.states.get(entity_id) assert hass_state.state == state...
[ "def", "assert_state", "(", "hass", ",", "entity_id", ",", "state", ",", "unit_of_measurement", ")", ":", "hass_state", "=", "hass", ".", "states", ".", "get", "(", "entity_id", ")", "assert", "hass_state", ".", "state", "==", "state", "assert", "hass_state"...
[ 198, 0 ]
[ 206, 85 ]
python
en
['en', 'en', 'en']
True
hass_ms
(hass)
Hass instance with measurement system.
Hass instance with measurement system.
def hass_ms(hass): """Hass instance with measurement system.""" async def _hass_ms(meas_sys): await config_util.async_process_ha_core_config( hass, {CONF_UNIT_SYSTEM: meas_sys} ) await hass.async_block_till_done() return hass return _hass_ms
[ "def", "hass_ms", "(", "hass", ")", ":", "async", "def", "_hass_ms", "(", "meas_sys", ")", ":", "await", "config_util", ".", "async_process_ha_core_config", "(", "hass", ",", "{", "CONF_UNIT_SYSTEM", ":", "meas_sys", "}", ")", "await", "hass", ".", "async_bl...
[ 210, 0 ]
[ 220, 19 ]
python
en
['en', 'en', 'en']
True
core_rs
(hass_storage)
Core.restore_state fixture.
Core.restore_state fixture.
def core_rs(hass_storage): """Core.restore_state fixture.""" def _storage(entity_id, uom, state): now = dt_util.utcnow().isoformat() hass_storage[restore_state.STORAGE_KEY] = { "version": restore_state.STORAGE_VERSION, "key": restore_state.STORAGE_KEY, "data...
[ "def", "core_rs", "(", "hass_storage", ")", ":", "def", "_storage", "(", "entity_id", ",", "uom", ",", "state", ")", ":", "now", "=", "dt_util", ".", "utcnow", "(", ")", ".", "isoformat", "(", ")", "hass_storage", "[", "restore_state", ".", "STORAGE_KEY"...
[ 224, 0 ]
[ 252, 19 ]
python
en
['en', 'it', 'en']
False
test_temp_uom
( uom, raw_temp, expected, restore, hass_ms, core_rs, zigpy_device_mock, zha_device_restored, )
Test zha temperature sensor unit of measurement.
Test zha temperature sensor unit of measurement.
async def test_temp_uom( uom, raw_temp, expected, restore, hass_ms, core_rs, zigpy_device_mock, zha_device_restored, ): """Test zha temperature sensor unit of measurement.""" entity_id = "sensor.fake1026_fakemodel1026_004f3202_temperature" if restore: core_rs(entity_...
[ "async", "def", "test_temp_uom", "(", "uom", ",", "raw_temp", ",", "expected", ",", "restore", ",", "hass_ms", ",", "core_rs", ",", "zigpy_device_mock", ",", "zha_device_restored", ",", ")", ":", "entity_id", "=", "\"sensor.fake1026_fakemodel1026_004f3202_temperature\...
[ 264, 0 ]
[ 316, 60 ]
python
en
['en', 'fr', 'en']
True
test_electrical_measurement_init
( hass, zigpy_device_mock, zha_device_joined, )
Test proper initialization of the electrical measurement cluster.
Test proper initialization of the electrical measurement cluster.
async def test_electrical_measurement_init( hass, zigpy_device_mock, zha_device_joined, ): """Test proper initialization of the electrical measurement cluster.""" cluster_id = homeautomation.ElectricalMeasurement.cluster_id zigpy_device = zigpy_device_mock( { 1: { ...
[ "async", "def", "test_electrical_measurement_init", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ",", ")", ":", "cluster_id", "=", "homeautomation", ".", "ElectricalMeasurement", ".", "cluster_id", "zigpy_device", "=", "zigpy_device_mock", "(", "{", ...
[ 319, 0 ]
[ 373, 53 ]
python
en
['en', 'en', 'en']
True
test_no_fans
(hass, aioclient_mock)
Test that no fan entities are created.
Test that no fan entities are created.
async def test_no_fans(hass, aioclient_mock): """Test that no fan entities are created.""" await setup_deconz_integration(hass, aioclient_mock) assert len(hass.states.async_all()) == 0
[ "async", "def", "test_no_fans", "(", "hass", ",", "aioclient_mock", ")", ":", "await", "setup_deconz_integration", "(", "hass", ",", "aioclient_mock", ")", "assert", "len", "(", "hass", ".", "states", ".", "async_all", "(", ")", ")", "==", "0" ]
[ 28, 0 ]
[ 31, 44 ]
python
en
['en', 'en', 'en']
True
test_fans
(hass, aioclient_mock, mock_deconz_websocket)
Test that all supported fan entities are created.
Test that all supported fan entities are created.
async def test_fans(hass, aioclient_mock, mock_deconz_websocket): """Test that all supported fan entities are created.""" data = { "lights": { "1": { "etag": "432f3de28965052961a99e3c5494daf4", "hascolor": False, "manufacturername": "King Of Fa...
[ "async", "def", "test_fans", "(", "hass", ",", "aioclient_mock", ",", "mock_deconz_websocket", ")", ":", "data", "=", "{", "\"lights\"", ":", "{", "\"1\"", ":", "{", "\"etag\"", ":", "\"432f3de28965052961a99e3c5494daf4\"", ",", "\"hascolor\"", ":", "False", ",",...
[ 34, 0 ]
[ 240, 44 ]
python
en
['en', 'en', 'en']
True
test_fans_legacy_speed_modes
(hass, aioclient_mock, mock_deconz_websocket)
Test that all supported fan entities are created. Legacy fan support.
Test that all supported fan entities are created.
async def test_fans_legacy_speed_modes(hass, aioclient_mock, mock_deconz_websocket): """Test that all supported fan entities are created. Legacy fan support. """ data = { "lights": { "1": { "etag": "432f3de28965052961a99e3c5494daf4", "hascolor": False...
[ "async", "def", "test_fans_legacy_speed_modes", "(", "hass", ",", "aioclient_mock", ",", "mock_deconz_websocket", ")", ":", "data", "=", "{", "\"lights\"", ":", "{", "\"1\"", ":", "{", "\"etag\"", ":", "\"432f3de28965052961a99e3c5494daf4\"", ",", "\"hascolor\"", ":"...
[ 243, 0 ]
[ 489, 44 ]
python
en
['en', 'en', 'en']
True
TestComposedOneOfNumberWithValidations.testComposedOneOfNumberWithValidations
(self)
Test ComposedOneOfNumberWithValidations
Test ComposedOneOfNumberWithValidations
def testComposedOneOfNumberWithValidations(self): """Test ComposedOneOfNumberWithValidations""" # we can make an instance that stores float data inst = ComposedOneOfNumberWithValidations(10.0) from petstore_api.model import number_with_validations assert isinstance(inst, number_w...
[ "def", "testComposedOneOfNumberWithValidations", "(", "self", ")", ":", "# we can make an instance that stores float data", "inst", "=", "ComposedOneOfNumberWithValidations", "(", "10.0", ")", "from", "petstore_api", ".", "model", "import", "number_with_validations", "assert", ...
[ 33, 4 ]
[ 41, 67 ]
python
en
['en', 'en', 'en']
False
get_system_unique_id
(entity: RegistryEntry)
Determine the system wide unique_id for an entity.
Determine the system wide unique_id for an entity.
def get_system_unique_id(entity: RegistryEntry): """Determine the system wide unique_id for an entity.""" return f"{entity.platform}.{entity.domain}.{entity.unique_id}"
[ "def", "get_system_unique_id", "(", "entity", ":", "RegistryEntry", ")", ":", "return", "f\"{entity.platform}.{entity.domain}.{entity.unique_id}\"" ]
[ 34, 0 ]
[ 36, 66 ]
python
en
['en', 'en', 'en']
True
_generate_aids
(unique_id: str, entity_id: str)
Generate accessory aid.
Generate accessory aid.
def _generate_aids(unique_id: str, entity_id: str) -> int: """Generate accessory aid.""" if unique_id: # Use fnv1a_32 of the unique id as # fnv1a_32 has less collisions than # adler32 yield fnv1a_32(unique_id.encode("utf-8")) # If there is no unique id we use # fnv1a_32...
[ "def", "_generate_aids", "(", "unique_id", ":", "str", ",", "entity_id", ":", "str", ")", "->", "int", ":", "if", "unique_id", ":", "# Use fnv1a_32 of the unique id as", "# fnv1a_32 has less collisions than", "# adler32", "yield", "fnv1a_32", "(", "unique_id", ".", ...
[ 39, 0 ]
[ 56, 48 ]
python
co
['en', 'co', 'it']
False
AccessoryAidStorage.__init__
(self, hass: HomeAssistant, entry: ConfigEntry)
Create a new entity map store.
Create a new entity map store.
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: """Create a new entity map store.""" self.hass = hass self.allocations = {} self.allocated_aids = set() self._entry = entry self.store = None self._entity_registry = None
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "None", ":", "self", ".", "hass", "=", "hass", "self", ".", "allocations", "=", "{", "}", "self", ".", "allocated_aids", "=", "set", "(", ...
[ 67, 4 ]
[ 74, 36 ]
python
en
['en', 'en', 'en']
True
AccessoryAidStorage.async_initialize
(self)
Load the latest AID data.
Load the latest AID data.
async def async_initialize(self): """Load the latest AID data.""" self._entity_registry = ( await self.hass.helpers.entity_registry.async_get_registry() ) aidstore = get_aid_storage_filename_for_entry_id(self._entry) self.store = Store(self.hass, AID_MANAGER_STORAGE_V...
[ "async", "def", "async_initialize", "(", "self", ")", ":", "self", ".", "_entity_registry", "=", "(", "await", "self", ".", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", ")", "aidstore", "=", "get_aid_storage_filename_for_e...
[ 76, 4 ]
[ 90, 60 ]
python
en
['en', 'sm', 'en']
True
AccessoryAidStorage.get_or_allocate_aid_for_entity_id
(self, entity_id: str)
Generate a stable aid for an entity id.
Generate a stable aid for an entity id.
def get_or_allocate_aid_for_entity_id(self, entity_id: str): """Generate a stable aid for an entity id.""" entity = self._entity_registry.async_get(entity_id) if not entity: return self.get_or_allocate_aid(None, entity_id) sys_unique_id = get_system_unique_id(entity) ...
[ "def", "get_or_allocate_aid_for_entity_id", "(", "self", ",", "entity_id", ":", "str", ")", ":", "entity", "=", "self", ".", "_entity_registry", ".", "async_get", "(", "entity_id", ")", "if", "not", "entity", ":", "return", "self", ".", "get_or_allocate_aid", ...
[ 92, 4 ]
[ 99, 65 ]
python
en
['en', 'en', 'en']
True
AccessoryAidStorage.get_or_allocate_aid
(self, unique_id: str, entity_id: str)
Allocate (and return) a new aid for an accessory.
Allocate (and return) a new aid for an accessory.
def get_or_allocate_aid(self, unique_id: str, entity_id: str): """Allocate (and return) a new aid for an accessory.""" if unique_id and unique_id in self.allocations: return self.allocations[unique_id] if entity_id in self.allocations: return self.allocations[entity_id] ...
[ "def", "get_or_allocate_aid", "(", "self", ",", "unique_id", ":", "str", ",", "entity_id", ":", "str", ")", ":", "if", "unique_id", "and", "unique_id", "in", "self", ".", "allocations", ":", "return", "self", ".", "allocations", "[", "unique_id", "]", "if"...
[ 101, 4 ]
[ 121, 9 ]
python
en
['en', 'en', 'en']
True
AccessoryAidStorage.delete_aid
(self, storage_key: str)
Delete an aid allocation.
Delete an aid allocation.
def delete_aid(self, storage_key: str): """Delete an aid allocation.""" if storage_key not in self.allocations: return aid = self.allocations.pop(storage_key) self.allocated_aids.discard(aid) self.async_schedule_save()
[ "def", "delete_aid", "(", "self", ",", "storage_key", ":", "str", ")", ":", "if", "storage_key", "not", "in", "self", ".", "allocations", ":", "return", "aid", "=", "self", ".", "allocations", ".", "pop", "(", "storage_key", ")", "self", ".", "allocated_...
[ 123, 4 ]
[ 130, 34 ]
python
it
['en', 'it', 'it']
True
AccessoryAidStorage.async_schedule_save
(self)
Schedule saving the entity map cache.
Schedule saving the entity map cache.
def async_schedule_save(self): """Schedule saving the entity map cache.""" self.store.async_delay_save(self._data_to_save, AID_MANAGER_SAVE_DELAY)
[ "def", "async_schedule_save", "(", "self", ")", ":", "self", ".", "store", ".", "async_delay_save", "(", "self", ".", "_data_to_save", ",", "AID_MANAGER_SAVE_DELAY", ")" ]
[ 133, 4 ]
[ 135, 79 ]
python
en
['en', 'en', 'en']
True
AccessoryAidStorage.async_save
(self)
Save the entity map cache.
Save the entity map cache.
async def async_save(self): """Save the entity map cache.""" return await self.store.async_save(self._data_to_save())
[ "async", "def", "async_save", "(", "self", ")", ":", "return", "await", "self", ".", "store", ".", "async_save", "(", "self", ".", "_data_to_save", "(", ")", ")" ]
[ 137, 4 ]
[ 139, 64 ]
python
en
['en', 'en', 'en']
True
AccessoryAidStorage._data_to_save
(self)
Return data of entity map to store in a file.
Return data of entity map to store in a file.
def _data_to_save(self): """Return data of entity map to store in a file.""" return {ALLOCATIONS_KEY: self.allocations}
[ "def", "_data_to_save", "(", "self", ")", ":", "return", "{", "ALLOCATIONS_KEY", ":", "self", ".", "allocations", "}" ]
[ 142, 4 ]
[ 144, 50 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the ViaggiaTreno platform.
Set up the ViaggiaTreno platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the ViaggiaTreno platform.""" train_id = config.get(CONF_TRAIN_ID) station_id = config.get(CONF_STATION_ID) name = config.get(CONF_NAME) if not name: name = DEFAULT_NAME.format(train_id) asyn...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "train_id", "=", "config", ".", "get", "(", "CONF_TRAIN_ID", ")", "station_id", "=", "config", ".", "get", "(", "CONF...
[ 57, 0 ]
[ 64, 72 ]
python
en
['en', 'pt', 'en']
True
async_http_request
(hass, uri)
Perform actual request.
Perform actual request.
async def async_http_request(hass, uri): """Perform actual request.""" try: session = hass.helpers.aiohttp_client.async_get_clientsession(hass) with async_timeout.timeout(REQUEST_TIMEOUT): req = await session.get(uri) if req.status != HTTP_OK: return {"error": req...
[ "async", "def", "async_http_request", "(", "hass", ",", "uri", ")", ":", "try", ":", "session", "=", "hass", ".", "helpers", ".", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", "with", "async_timeout", ".", "timeout", "(", "REQUEST_TIMEOUT...
[ 67, 0 ]
[ 80, 78 ]
python
en
['en', 'la', 'en']
True
ViaggiaTrenoSensor.__init__
(self, train_id, station_id, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, train_id, station_id, name): """Initialize the sensor.""" self._state = None self._attributes = {} self._unit = "" self._icon = ICON self._station_id = station_id self._name = name self.uri = VIAGGIATRENO_ENDPOINT.format( st...
[ "def", "__init__", "(", "self", ",", "train_id", ",", "station_id", ",", "name", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_attributes", "=", "{", "}", "self", ".", "_unit", "=", "\"\"", "self", ".", "_icon", "=", "ICON", "self", ...
[ 86, 4 ]
[ 97, 9 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 100, 4 ]
[ 102, 25 ]
python
en
['en', 'mi', 'en']
True
ViaggiaTrenoSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 105, 4 ]
[ 107, 26 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 110, 4 ]
[ 112, 25 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.native_unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 115, 4 ]
[ 117, 25 ]
python
en
['en', 'la', 'en']
True
ViaggiaTrenoSensor.extra_state_attributes
(self)
Return extra attributes.
Return extra attributes.
def extra_state_attributes(self): """Return extra attributes.""" self._attributes[ATTR_ATTRIBUTION] = ATTRIBUTION return self._attributes
[ "def", "extra_state_attributes", "(", "self", ")", ":", "self", ".", "_attributes", "[", "ATTR_ATTRIBUTION", "]", "=", "ATTRIBUTION", "return", "self", ".", "_attributes" ]
[ 120, 4 ]
[ 123, 31 ]
python
en
['es', 'la', 'en']
False
ViaggiaTrenoSensor.has_departed
(data)
Check if the train has actually departed.
Check if the train has actually departed.
def has_departed(data): """Check if the train has actually departed.""" try: first_station = data["fermate"][0] if data["oraUltimoRilevamento"] or first_station["effettiva"]: return True except ValueError: _LOGGER.error("Cannot fetch first stat...
[ "def", "has_departed", "(", "data", ")", ":", "try", ":", "first_station", "=", "data", "[", "\"fermate\"", "]", "[", "0", "]", "if", "data", "[", "\"oraUltimoRilevamento\"", "]", "or", "first_station", "[", "\"effettiva\"", "]", ":", "return", "True", "ex...
[ 126, 4 ]
[ 134, 20 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.has_arrived
(data)
Check if the train has already arrived.
Check if the train has already arrived.
def has_arrived(data): """Check if the train has already arrived.""" last_station = data["fermate"][-1] if not last_station["effettiva"]: return False return True
[ "def", "has_arrived", "(", "data", ")", ":", "last_station", "=", "data", "[", "\"fermate\"", "]", "[", "-", "1", "]", "if", "not", "last_station", "[", "\"effettiva\"", "]", ":", "return", "False", "return", "True" ]
[ 137, 4 ]
[ 142, 19 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.is_cancelled
(data)
Check if the train is cancelled.
Check if the train is cancelled.
def is_cancelled(data): """Check if the train is cancelled.""" if data["tipoTreno"] == "ST" and data["provvedimento"] == 1: return True return False
[ "def", "is_cancelled", "(", "data", ")", ":", "if", "data", "[", "\"tipoTreno\"", "]", "==", "\"ST\"", "and", "data", "[", "\"provvedimento\"", "]", "==", "1", ":", "return", "True", "return", "False" ]
[ 145, 4 ]
[ 149, 20 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.async_update
(self)
Update state.
Update state.
async def async_update(self): """Update state.""" uri = self.uri res = await async_http_request(self.hass, uri) if res.get("error", ""): if res["error"] == 204: self._state = NO_INFORMATION_STRING self._unit = "" else: ...
[ "async", "def", "async_update", "(", "self", ")", ":", "uri", "=", "self", ".", "uri", "res", "=", "await", "async_http_request", "(", "self", ".", "hass", ",", "uri", ")", "if", "res", ".", "get", "(", "\"error\"", ",", "\"\"", ")", ":", "if", "re...
[ 151, 4 ]
[ 179, 33 ]
python
en
['en', 'co', 'en']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Platform setup.
Platform setup.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Platform setup.""" config_host = config[CONF_HOST] config_port = config[CONF_PORT] config_name = config[CONF_NAME] try: with async_timeout.timeout(PLATFORM_TIMEOUT): api = await real_time_ap...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "config_host", "=", "config", "[", "CONF_HOST", "]", "config_port", "=", "config", "[", "CONF_PORT", "]", "config_name", ...
[ 38, 0 ]
[ 73, 32 ]
python
en
['en', 'ru', 'en']
False
IamMeter.__init__
(self, coordinator, uid, sensor_name, unit, dev_name)
Initialize an iammeter sensor.
Initialize an iammeter sensor.
def __init__(self, coordinator, uid, sensor_name, unit, dev_name): """Initialize an iammeter sensor.""" super().__init__(coordinator) self.uid = uid self.sensor_name = sensor_name self.unit = unit self.dev_name = dev_name
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "uid", ",", "sensor_name", ",", "unit", ",", "dev_name", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "uid", "=", "uid", "self", ".", "sensor_name", "=", ...
[ 79, 4 ]
[ 85, 32 ]
python
en
['en', 'lb', 'it']
False
IamMeter.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self.coordinator.data.data[self.sensor_name]
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "coordinator", ".", "data", ".", "data", "[", "self", ".", "sensor_name", "]" ]
[ 88, 4 ]
[ 90, 59 ]
python
en
['en', 'en', 'en']
True
IamMeter.unique_id
(self)
Return unique id.
Return unique id.
def unique_id(self): """Return unique id.""" return self.uid
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "uid" ]
[ 93, 4 ]
[ 95, 23 ]
python
en
['fr', 'la', 'en']
False
IamMeter.name
(self)
Name of this iammeter attribute.
Name of this iammeter attribute.
def name(self): """Name of this iammeter attribute.""" return f"{self.dev_name} {self.sensor_name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.dev_name} {self.sensor_name}\"" ]
[ 98, 4 ]
[ 100, 52 ]
python
en
['en', 'en', 'en']
True
IamMeter.icon
(self)
Icon for each sensor.
Icon for each sensor.
def icon(self): """Icon for each sensor.""" return "mdi:flash"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:flash\"" ]
[ 103, 4 ]
[ 105, 26 ]
python
en
['en', 'gl', 'en']
True
IamMeter.native_unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def native_unit_of_measurement(self): """Return the unit of measurement.""" return self.unit
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "unit" ]
[ 108, 4 ]
[ 110, 24 ]
python
en
['en', 'la', 'en']
True