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
SpotifyMediaPlayer.device_info
(self)
Return device information about this entity.
Return device information about this entity.
def device_info(self) -> DeviceInfo: """Return device information about this entity.""" model = "Spotify Free" if self._me is not None: product = self._me["product"] model = f"Spotify {product}" return { "identifiers": {(DOMAIN, self._id)}, ...
[ "def", "device_info", "(", "self", ")", "->", "DeviceInfo", ":", "model", "=", "\"Spotify Free\"", "if", "self", ".", "_me", "is", "not", "None", ":", "product", "=", "self", ".", "_me", "[", "\"product\"", "]", "model", "=", "f\"Spotify {product}\"", "ret...
[ 256, 4 ]
[ 269, 9 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.state
(self)
Return the playback state.
Return the playback state.
def state(self) -> str | None: """Return the playback state.""" if not self._currently_playing: return STATE_IDLE if self._currently_playing["is_playing"]: return STATE_PLAYING return STATE_PAUSED
[ "def", "state", "(", "self", ")", "->", "str", "|", "None", ":", "if", "not", "self", ".", "_currently_playing", ":", "return", "STATE_IDLE", "if", "self", ".", "_currently_playing", "[", "\"is_playing\"", "]", ":", "return", "STATE_PLAYING", "return", "STAT...
[ 272, 4 ]
[ 278, 27 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.volume_level
(self)
Return the device volume.
Return the device volume.
def volume_level(self) -> float | None: """Return the device volume.""" return self._currently_playing.get("device", {}).get("volume_percent", 0) / 100
[ "def", "volume_level", "(", "self", ")", "->", "float", "|", "None", ":", "return", "self", ".", "_currently_playing", ".", "get", "(", "\"device\"", ",", "{", "}", ")", ".", "get", "(", "\"volume_percent\"", ",", "0", ")", "/", "100" ]
[ 281, 4 ]
[ 283, 87 ]
python
en
['en', 'ko', 'en']
True
SpotifyMediaPlayer.media_content_id
(self)
Return the media URL.
Return the media URL.
def media_content_id(self) -> str | None: """Return the media URL.""" item = self._currently_playing.get("item") or {} return item.get("uri")
[ "def", "media_content_id", "(", "self", ")", "->", "str", "|", "None", ":", "item", "=", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "or", "{", "}", "return", "item", ".", "get", "(", "\"uri\"", ")" ]
[ 286, 4 ]
[ 289, 30 ]
python
en
['en', 'no', 'en']
True
SpotifyMediaPlayer.media_duration
(self)
Duration of current playing media in seconds.
Duration of current playing media in seconds.
def media_duration(self) -> int | None: """Duration of current playing media in seconds.""" if self._currently_playing.get("item") is None: return None return self._currently_playing["item"]["duration_ms"] / 1000
[ "def", "media_duration", "(", "self", ")", "->", "int", "|", "None", ":", "if", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "is", "None", ":", "return", "None", "return", "self", ".", "_currently_playing", "[", "\"item\"", "]", "...
[ 292, 4 ]
[ 296, 68 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.media_position
(self)
Position of current playing media in seconds.
Position of current playing media in seconds.
def media_position(self) -> str | None: """Position of current playing media in seconds.""" if not self._currently_playing: return None return self._currently_playing["progress_ms"] / 1000
[ "def", "media_position", "(", "self", ")", "->", "str", "|", "None", ":", "if", "not", "self", ".", "_currently_playing", ":", "return", "None", "return", "self", ".", "_currently_playing", "[", "\"progress_ms\"", "]", "/", "1000" ]
[ 299, 4 ]
[ 303, 60 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.media_position_updated_at
(self)
When was the position of the current playing media valid.
When was the position of the current playing media valid.
def media_position_updated_at(self) -> dt.datetime | None: """When was the position of the current playing media valid.""" if not self._currently_playing: return None return utc_from_timestamp(self._currently_playing["timestamp"] / 1000)
[ "def", "media_position_updated_at", "(", "self", ")", "->", "dt", ".", "datetime", "|", "None", ":", "if", "not", "self", ".", "_currently_playing", ":", "return", "None", "return", "utc_from_timestamp", "(", "self", ".", "_currently_playing", "[", "\"timestamp\...
[ 306, 4 ]
[ 310, 78 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.media_image_url
(self)
Return the media image URL.
Return the media image URL.
def media_image_url(self) -> str | None: """Return the media image URL.""" if ( self._currently_playing.get("item") is None or not self._currently_playing["item"]["album"]["images"] ): return None return fetch_image_url(self._currently_playing["item"][...
[ "def", "media_image_url", "(", "self", ")", "->", "str", "|", "None", ":", "if", "(", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "is", "None", "or", "not", "self", ".", "_currently_playing", "[", "\"item\"", "]", "[", "\"album\"...
[ 313, 4 ]
[ 320, 72 ]
python
en
['en', 'et', 'en']
True
SpotifyMediaPlayer.media_title
(self)
Return the media title.
Return the media title.
def media_title(self) -> str | None: """Return the media title.""" item = self._currently_playing.get("item") or {} return item.get("name")
[ "def", "media_title", "(", "self", ")", "->", "str", "|", "None", ":", "item", "=", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "or", "{", "}", "return", "item", ".", "get", "(", "\"name\"", ")" ]
[ 323, 4 ]
[ 326, 31 ]
python
en
['en', 'sq', 'en']
True
SpotifyMediaPlayer.media_artist
(self)
Return the media artist.
Return the media artist.
def media_artist(self) -> str | None: """Return the media artist.""" if self._currently_playing.get("item") is None: return None return ", ".join( artist["name"] for artist in self._currently_playing["item"]["artists"] )
[ "def", "media_artist", "(", "self", ")", "->", "str", "|", "None", ":", "if", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "is", "None", ":", "return", "None", "return", "\", \"", ".", "join", "(", "artist", "[", "\"name\"", "]"...
[ 329, 4 ]
[ 335, 9 ]
python
en
['en', 'no', 'en']
True
SpotifyMediaPlayer.media_album_name
(self)
Return the media album.
Return the media album.
def media_album_name(self) -> str | None: """Return the media album.""" if self._currently_playing.get("item") is None: return None return self._currently_playing["item"]["album"]["name"]
[ "def", "media_album_name", "(", "self", ")", "->", "str", "|", "None", ":", "if", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "is", "None", ":", "return", "None", "return", "self", ".", "_currently_playing", "[", "\"item\"", "]", ...
[ 338, 4 ]
[ 342, 63 ]
python
en
['en', 'la', 'en']
True
SpotifyMediaPlayer.media_track
(self)
Track number of current playing media, music track only.
Track number of current playing media, music track only.
def media_track(self) -> int | None: """Track number of current playing media, music track only.""" item = self._currently_playing.get("item") or {} return item.get("track_number")
[ "def", "media_track", "(", "self", ")", "->", "int", "|", "None", ":", "item", "=", "self", ".", "_currently_playing", ".", "get", "(", "\"item\"", ")", "or", "{", "}", "return", "item", ".", "get", "(", "\"track_number\"", ")" ]
[ 345, 4 ]
[ 348, 39 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.media_playlist
(self)
Title of Playlist currently playing.
Title of Playlist currently playing.
def media_playlist(self): """Title of Playlist currently playing.""" if self._playlist is None: return None return self._playlist["name"]
[ "def", "media_playlist", "(", "self", ")", ":", "if", "self", ".", "_playlist", "is", "None", ":", "return", "None", "return", "self", ".", "_playlist", "[", "\"name\"", "]" ]
[ 351, 4 ]
[ 355, 37 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.source
(self)
Return the current playback device.
Return the current playback device.
def source(self) -> str | None: """Return the current playback device.""" return self._currently_playing.get("device", {}).get("name")
[ "def", "source", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_currently_playing", ".", "get", "(", "\"device\"", ",", "{", "}", ")", ".", "get", "(", "\"name\"", ")" ]
[ 358, 4 ]
[ 360, 68 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.source_list
(self)
Return a list of source devices.
Return a list of source devices.
def source_list(self) -> list[str] | None: """Return a list of source devices.""" if not self._devices: return None return [device["name"] for device in self._devices]
[ "def", "source_list", "(", "self", ")", "->", "list", "[", "str", "]", "|", "None", ":", "if", "not", "self", ".", "_devices", ":", "return", "None", "return", "[", "device", "[", "\"name\"", "]", "for", "device", "in", "self", ".", "_devices", "]" ]
[ 363, 4 ]
[ 367, 59 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.shuffle
(self)
Shuffling state.
Shuffling state.
def shuffle(self) -> bool: """Shuffling state.""" return bool(self._currently_playing.get("shuffle_state"))
[ "def", "shuffle", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_currently_playing", ".", "get", "(", "\"shuffle_state\"", ")", ")" ]
[ 370, 4 ]
[ 372, 65 ]
python
de
['de', 'jv', 'en']
False
SpotifyMediaPlayer.repeat
(self)
Return current repeat mode.
Return current repeat mode.
def repeat(self) -> str | None: """Return current repeat mode.""" repeat_state = self._currently_playing.get("repeat_state") return REPEAT_MODE_MAPPING_TO_HA.get(repeat_state)
[ "def", "repeat", "(", "self", ")", "->", "str", "|", "None", ":", "repeat_state", "=", "self", ".", "_currently_playing", ".", "get", "(", "\"repeat_state\"", ")", "return", "REPEAT_MODE_MAPPING_TO_HA", ".", "get", "(", "repeat_state", ")" ]
[ 375, 4 ]
[ 378, 58 ]
python
en
['en', 'la', 'en']
True
SpotifyMediaPlayer.supported_features
(self)
Return the media player features that are supported.
Return the media player features that are supported.
def supported_features(self) -> int: """Return the media player features that are supported.""" if self._me["product"] != "premium": return 0 return SUPPORT_SPOTIFY
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "if", "self", ".", "_me", "[", "\"product\"", "]", "!=", "\"premium\"", ":", "return", "0", "return", "SUPPORT_SPOTIFY" ]
[ 381, 4 ]
[ 385, 30 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.set_volume_level
(self, volume: int)
Set the volume level.
Set the volume level.
def set_volume_level(self, volume: int) -> None: """Set the volume level.""" self._spotify.volume(int(volume * 100))
[ "def", "set_volume_level", "(", "self", ",", "volume", ":", "int", ")", "->", "None", ":", "self", ".", "_spotify", ".", "volume", "(", "int", "(", "volume", "*", "100", ")", ")" ]
[ 388, 4 ]
[ 390, 47 ]
python
en
['en', 'sr', 'en']
True
SpotifyMediaPlayer.media_play
(self)
Start or resume playback.
Start or resume playback.
def media_play(self) -> None: """Start or resume playback.""" self._spotify.start_playback()
[ "def", "media_play", "(", "self", ")", "->", "None", ":", "self", ".", "_spotify", ".", "start_playback", "(", ")" ]
[ 393, 4 ]
[ 395, 38 ]
python
en
['en', 'jv', 'en']
True
SpotifyMediaPlayer.media_pause
(self)
Pause playback.
Pause playback.
def media_pause(self) -> None: """Pause playback.""" self._spotify.pause_playback()
[ "def", "media_pause", "(", "self", ")", "->", "None", ":", "self", ".", "_spotify", ".", "pause_playback", "(", ")" ]
[ 398, 4 ]
[ 400, 38 ]
python
de
['de', 'lt', 'en']
False
SpotifyMediaPlayer.media_previous_track
(self)
Skip to previous track.
Skip to previous track.
def media_previous_track(self) -> None: """Skip to previous track.""" self._spotify.previous_track()
[ "def", "media_previous_track", "(", "self", ")", "->", "None", ":", "self", ".", "_spotify", ".", "previous_track", "(", ")" ]
[ 403, 4 ]
[ 405, 38 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.media_next_track
(self)
Skip to next track.
Skip to next track.
def media_next_track(self) -> None: """Skip to next track.""" self._spotify.next_track()
[ "def", "media_next_track", "(", "self", ")", "->", "None", ":", "self", ".", "_spotify", ".", "next_track", "(", ")" ]
[ 408, 4 ]
[ 410, 34 ]
python
en
['en', 'bg-Latn', 'en']
True
SpotifyMediaPlayer.media_seek
(self, position)
Send seek command.
Send seek command.
def media_seek(self, position): """Send seek command.""" self._spotify.seek_track(int(position * 1000))
[ "def", "media_seek", "(", "self", ",", "position", ")", ":", "self", ".", "_spotify", ".", "seek_track", "(", "int", "(", "position", "*", "1000", ")", ")" ]
[ 413, 4 ]
[ 415, 54 ]
python
en
['en', 'ig', 'en']
True
SpotifyMediaPlayer.play_media
(self, media_type: str, media_id: str, **kwargs)
Play media.
Play media.
def play_media(self, media_type: str, media_id: str, **kwargs) -> None: """Play media.""" kwargs = {} # Spotify can't handle URI's with query strings or anchors # Yet, they do generate those types of URI in their official clients. media_id = str(URL(media_id).with_query(None).wi...
[ "def", "play_media", "(", "self", ",", "media_type", ":", "str", ",", "media_id", ":", "str", ",", "*", "*", "kwargs", ")", "->", "None", ":", "kwargs", "=", "{", "}", "# Spotify can't handle URI's with query strings or anchors", "# Yet, they do generate those types...
[ 418, 4 ]
[ 437, 46 ]
python
en
['en', 'sv', 'en']
False
SpotifyMediaPlayer.select_source
(self, source: str)
Select playback device.
Select playback device.
def select_source(self, source: str) -> None: """Select playback device.""" for device in self._devices: if device["name"] == source: self._spotify.transfer_playback( device["id"], self.state == STATE_PLAYING ) return
[ "def", "select_source", "(", "self", ",", "source", ":", "str", ")", "->", "None", ":", "for", "device", "in", "self", ".", "_devices", ":", "if", "device", "[", "\"name\"", "]", "==", "source", ":", "self", ".", "_spotify", ".", "transfer_playback", "...
[ 440, 4 ]
[ 447, 22 ]
python
en
['es', 'en', 'en']
True
SpotifyMediaPlayer.set_shuffle
(self, shuffle: bool)
Enable/Disable shuffle mode.
Enable/Disable shuffle mode.
def set_shuffle(self, shuffle: bool) -> None: """Enable/Disable shuffle mode.""" self._spotify.shuffle(shuffle)
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ":", "bool", ")", "->", "None", ":", "self", ".", "_spotify", ".", "shuffle", "(", "shuffle", ")" ]
[ 450, 4 ]
[ 452, 38 ]
python
en
['en', 'st', 'en']
True
SpotifyMediaPlayer.set_repeat
(self, repeat: str)
Set repeat mode.
Set repeat mode.
def set_repeat(self, repeat: str) -> None: """Set repeat mode.""" if repeat not in REPEAT_MODE_MAPPING_TO_SPOTIFY: raise ValueError(f"Unsupported repeat mode: {repeat}") self._spotify.repeat(REPEAT_MODE_MAPPING_TO_SPOTIFY[repeat])
[ "def", "set_repeat", "(", "self", ",", "repeat", ":", "str", ")", "->", "None", ":", "if", "repeat", "not", "in", "REPEAT_MODE_MAPPING_TO_SPOTIFY", ":", "raise", "ValueError", "(", "f\"Unsupported repeat mode: {repeat}\"", ")", "self", ".", "_spotify", ".", "rep...
[ 455, 4 ]
[ 459, 68 ]
python
en
['en', 'id', 'en']
True
SpotifyMediaPlayer.update
(self)
Update state and attributes.
Update state and attributes.
def update(self) -> None: """Update state and attributes.""" if not self.enabled: return if not self._session.valid_token or self._spotify is None: run_coroutine_threadsafe( self._session.async_ensure_token_valid(), self.hass.loop ).result() ...
[ "def", "update", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "enabled", ":", "return", "if", "not", "self", ".", "_session", ".", "valid_token", "or", "self", ".", "_spotify", "is", "None", ":", "run_coroutine_threadsafe", "(", "self",...
[ 462, 4 ]
[ 482, 50 ]
python
en
['en', 'en', 'en']
True
SpotifyMediaPlayer.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.""" if not self._scope_ok: _LOGGER.debug( "Spotify scopes are not set correctly, this can impact features such as media browsing" ...
[ "async", "def", "async_browse_media", "(", "self", ",", "media_content_type", "=", "None", ",", "media_content_id", "=", "None", ")", ":", "if", "not", "self", ".", "_scope_ok", ":", "_LOGGER", ".", "debug", "(", "\"Spotify scopes are not set correctly, this can imp...
[ 484, 4 ]
[ 507, 23 ]
python
en
['en', 'af', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Initialize the SmartThings platform.
Initialize the SmartThings platform.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the SmartThings platform.""" await setup_smartapp_endpoint(hass) return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "await", "setup_smartapp_endpoint", "(", "hass", ")", "return", "True" ]
[ 59, 0 ]
[ 62, 15 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
(hass: HomeAssistant, entry: ConfigEntry)
Handle migration of a previous version config entry. A config entry created under a previous version must go through the integration setup again so we can properly retrieve the needed data elements. Force this by removing the entry and triggering a new flow.
Handle migration of a previous version config entry.
async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Handle migration of a previous version config entry. A config entry created under a previous version must go through the integration setup again so we can properly retrieve the needed data elements. Force this by removin...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "# Remove the entry which will invoke the callback to delete the app.", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries"...
[ 65, 0 ]
[ 84, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Initialize config entry which represents an installed SmartApp.
Initialize config entry which represents an installed SmartApp.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Initialize config entry which represents an installed SmartApp.""" # For backwards compat if entry.unique_id is None: hass.config_entries.async_update_entry( entry, unique_id=format_unique_id( ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "# For backwards compat", "if", "entry", ".", "unique_id", "is", "None", ":", "hass", ".", "config_entries", ".", "async_update_entr...
[ 87, 0 ]
[ 193, 15 ]
python
en
['en', 'en', 'en']
True
async_get_entry_scenes
(entry: ConfigEntry, api)
Get the scenes within an integration.
Get the scenes within an integration.
async def async_get_entry_scenes(entry: ConfigEntry, api): """Get the scenes within an integration.""" try: return await api.scenes(location_id=entry.data[CONF_LOCATION_ID]) except ClientResponseError as ex: if ex.status == HTTP_FORBIDDEN: _LOGGER.exception( "Unab...
[ "async", "def", "async_get_entry_scenes", "(", "entry", ":", "ConfigEntry", ",", "api", ")", ":", "try", ":", "return", "await", "api", ".", "scenes", "(", "location_id", "=", "entry", ".", "data", "[", "CONF_LOCATION_ID", "]", ")", "except", "ClientResponse...
[ 196, 0 ]
[ 208, 13 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" broker = hass.data[DOMAIN][DATA_BROKERS].pop(entry.entry_id, None) if broker: broker.disconnect() return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "broker", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BROKERS", "]", ".", "pop", "(", "entry", ".", "entry_id", ",", "None",...
[ 211, 0 ]
[ 217, 77 ]
python
en
['en', 'es', 'en']
True
async_remove_entry
(hass: HomeAssistant, entry: ConfigEntry)
Perform clean-up when entry is being removed.
Perform clean-up when entry is being removed.
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: """Perform clean-up when entry is being removed.""" api = SmartThings(async_get_clientsession(hass), entry.data[CONF_ACCESS_TOKEN]) # Remove the installed_app, which if already removed raises a HTTP_FORBIDDEN error. installe...
[ "async", "def", "async_remove_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "None", ":", "api", "=", "SmartThings", "(", "async_get_clientsession", "(", "hass", ")", ",", "entry", ".", "data", "[", "CONF_ACCESS_TOKEN",...
[ 220, 0 ]
[ 261, 44 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.__init__
( self, hass: HomeAssistant, entry: ConfigEntry, token, smart_app, devices: Iterable, scenes: Iterable, )
Create a new instance of the DeviceBroker.
Create a new instance of the DeviceBroker.
def __init__( self, hass: HomeAssistant, entry: ConfigEntry, token, smart_app, devices: Iterable, scenes: Iterable, ): """Create a new instance of the DeviceBroker.""" self._hass = hass self._entry = entry self._installed_app_id...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "token", ",", "smart_app", ",", "devices", ":", "Iterable", ",", "scenes", ":", "Iterable", ",", ")", ":", "self", ".", "_hass", "=", "hass", "sel...
[ 267, 4 ]
[ 286, 65 ]
python
en
['en', 'en', 'en']
True
DeviceBroker._assign_capabilities
(self, devices: Iterable)
Assign platforms to capabilities.
Assign platforms to capabilities.
def _assign_capabilities(self, devices: Iterable): """Assign platforms to capabilities.""" assignments = {} for device in devices: capabilities = device.capabilities.copy() slots = {} for platform in PLATFORMS: platform_module = importlib.impor...
[ "def", "_assign_capabilities", "(", "self", ",", "devices", ":", "Iterable", ")", ":", "assignments", "=", "{", "}", "for", "device", "in", "devices", ":", "capabilities", "=", "device", ".", "capabilities", ".", "copy", "(", ")", "slots", "=", "{", "}",...
[ 288, 4 ]
[ 310, 26 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.connect
(self)
Connect handlers/listeners for device/lifecycle events.
Connect handlers/listeners for device/lifecycle events.
def connect(self): """Connect handlers/listeners for device/lifecycle events.""" # Setup interval to regenerate the refresh token on a periodic basis. # Tokens expire in 30 days and once expired, cannot be recovered. async def regenerate_refresh_token(now): """Generate a new ...
[ "def", "connect", "(", "self", ")", ":", "# Setup interval to regenerate the refresh token on a periodic basis.", "# Tokens expire in 30 days and once expired, cannot be recovered.", "async", "def", "regenerate_refresh_token", "(", "now", ")", ":", "\"\"\"Generate a new refresh token a...
[ 312, 4 ]
[ 339, 83 ]
python
en
['da', 'en', 'en']
True
DeviceBroker.disconnect
(self)
Disconnects handlers/listeners for device/lifecycle events.
Disconnects handlers/listeners for device/lifecycle events.
def disconnect(self): """Disconnects handlers/listeners for device/lifecycle events.""" if self._regenerate_token_remove: self._regenerate_token_remove() if self._event_disconnect: self._event_disconnect()
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "_regenerate_token_remove", ":", "self", ".", "_regenerate_token_remove", "(", ")", "if", "self", ".", "_event_disconnect", ":", "self", ".", "_event_disconnect", "(", ")" ]
[ 341, 4 ]
[ 346, 36 ]
python
en
['da', 'en', 'en']
True
DeviceBroker.get_assigned
(self, device_id: str, platform: str)
Get the capabilities assigned to the platform.
Get the capabilities assigned to the platform.
def get_assigned(self, device_id: str, platform: str): """Get the capabilities assigned to the platform.""" slots = self._assignments.get(device_id, {}) return [key for key, value in slots.items() if value == platform]
[ "def", "get_assigned", "(", "self", ",", "device_id", ":", "str", ",", "platform", ":", "str", ")", ":", "slots", "=", "self", ".", "_assignments", ".", "get", "(", "device_id", ",", "{", "}", ")", "return", "[", "key", "for", "key", ",", "value", ...
[ 348, 4 ]
[ 351, 73 ]
python
en
['en', 'en', 'en']
True
DeviceBroker.any_assigned
(self, device_id: str, platform: str)
Return True if the platform has any assigned capabilities.
Return True if the platform has any assigned capabilities.
def any_assigned(self, device_id: str, platform: str): """Return True if the platform has any assigned capabilities.""" slots = self._assignments.get(device_id, {}) return any(value for value in slots.values() if value == platform)
[ "def", "any_assigned", "(", "self", ",", "device_id", ":", "str", ",", "platform", ":", "str", ")", ":", "slots", "=", "self", ".", "_assignments", ".", "get", "(", "device_id", ",", "{", "}", ")", "return", "any", "(", "value", "for", "value", "in",...
[ 353, 4 ]
[ 356, 74 ]
python
en
['en', 'en', 'en']
True
DeviceBroker._event_handler
(self, req, resp, app)
Broker for incoming events.
Broker for incoming events.
async def _event_handler(self, req, resp, app): """Broker for incoming events.""" # Do not process events received from a different installed app # under the same parent SmartApp (valid use-scenario) if req.installed_app_id != self._installed_app_id: return updated_d...
[ "async", "def", "_event_handler", "(", "self", ",", "req", ",", "resp", ",", "app", ")", ":", "# Do not process events received from a different installed app", "# under the same parent SmartApp (valid use-scenario)", "if", "req", ".", "installed_app_id", "!=", "self", ".",...
[ 358, 4 ]
[ 409, 85 ]
python
en
['da', 'en', 'en']
True
SmartThingsEntity.__init__
(self, device: DeviceEntity)
Initialize the instance.
Initialize the instance.
def __init__(self, device: DeviceEntity) -> None: """Initialize the instance.""" self._device = device self._dispatcher_remove = None
[ "def", "__init__", "(", "self", ",", "device", ":", "DeviceEntity", ")", "->", "None", ":", "self", ".", "_device", "=", "device", "self", ".", "_dispatcher_remove", "=", "None" ]
[ 415, 4 ]
[ 418, 38 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.async_added_to_hass
(self)
Device added to hass.
Device added to hass.
async def async_added_to_hass(self): """Device added to hass.""" async def async_update_state(devices): """Update device state.""" if self._device.device_id in devices: await self.async_update_ha_state(True) self._dispatcher_remove = async_dispatcher_con...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async", "def", "async_update_state", "(", "devices", ")", ":", "\"\"\"Update device state.\"\"\"", "if", "self", ".", "_device", ".", "device_id", "in", "devices", ":", "await", "self", ".", "async_u...
[ 420, 4 ]
[ 430, 9 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.async_will_remove_from_hass
(self)
Disconnect the device when removed.
Disconnect the device when removed.
async def async_will_remove_from_hass(self) -> None: """Disconnect the device when removed.""" if self._dispatcher_remove: self._dispatcher_remove()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_dispatcher_remove", ":", "self", ".", "_dispatcher_remove", "(", ")" ]
[ 432, 4 ]
[ 435, 37 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.device_info
(self)
Get attributes about the device.
Get attributes about the device.
def device_info(self): """Get attributes about the device.""" return { "identifiers": {(DOMAIN, self._device.device_id)}, "name": self._device.label, "model": self._device.device_type_name, "manufacturer": "Unavailable", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_device", ".", "device_id", ")", "}", ",", "\"name\"", ":", "self", ".", "_device", ".", "label", ",", "\"model\"", ":", "self", ...
[ 438, 4 ]
[ 445, 9 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.name
(self)
Return the name of the device.
Return the name of the device.
def name(self) -> str: """Return the name of the device.""" return self._device.label
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device", ".", "label" ]
[ 448, 4 ]
[ 450, 33 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.should_poll
(self)
No polling needed for this device.
No polling needed for this device.
def should_poll(self) -> bool: """No polling needed for this device.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 453, 4 ]
[ 455, 20 ]
python
en
['en', 'en', 'en']
True
SmartThingsEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self._device.device_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device", ".", "device_id" ]
[ 458, 4 ]
[ 460, 37 ]
python
ca
['fr', 'ca', 'en']
False
test_thermostat_v2
( hass, client, climate_radio_thermostat_ct100_plus, integration )
Test a thermostat v2 command class entity.
Test a thermostat v2 command class entity.
async def test_thermostat_v2( hass, client, climate_radio_thermostat_ct100_plus, integration ): """Test a thermostat v2 command class entity.""" node = climate_radio_thermostat_ct100_plus state = hass.states.get(CLIMATE_RADIO_THERMOSTAT_ENTITY) assert state assert state.state == HVAC_MODE_HEAT ...
[ "async", "def", "test_thermostat_v2", "(", "hass", ",", "client", ",", "climate_radio_thermostat_ct100_plus", ",", "integration", ")", ":", "node", "=", "climate_radio_thermostat_ct100_plus", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_RADIO_THERMOS...
[ 50, 0 ]
[ 345, 9 ]
python
en
['en', 'en', 'en']
True
test_thermostat_different_endpoints
( hass, client, climate_radio_thermostat_ct100_plus_different_endpoints, integration )
Test an entity with values on a different endpoint from the primary value.
Test an entity with values on a different endpoint from the primary value.
async def test_thermostat_different_endpoints( hass, client, climate_radio_thermostat_ct100_plus_different_endpoints, integration ): """Test an entity with values on a different endpoint from the primary value.""" state = hass.states.get(CLIMATE_RADIO_THERMOSTAT_ENTITY) assert state.attributes[ATTR_CUR...
[ "async", "def", "test_thermostat_different_endpoints", "(", "hass", ",", "client", ",", "climate_radio_thermostat_ct100_plus_different_endpoints", ",", "integration", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_RADIO_THERMOSTAT_ENTITY", ")", ...
[ 348, 0 ]
[ 357, 66 ]
python
en
['en', 'en', 'en']
True
test_setpoint_thermostat
(hass, client, climate_danfoss_lc_13, integration)
Test a setpoint thermostat command class entity.
Test a setpoint thermostat command class entity.
async def test_setpoint_thermostat(hass, client, climate_danfoss_lc_13, integration): """Test a setpoint thermostat command class entity.""" node = climate_danfoss_lc_13 state = hass.states.get(CLIMATE_DANFOSS_LC13_ENTITY) assert state assert state.state == HVAC_MODE_HEAT assert state.attribute...
[ "async", "def", "test_setpoint_thermostat", "(", "hass", ",", "client", ",", "climate_danfoss_lc_13", ",", "integration", ")", ":", "node", "=", "climate_danfoss_lc_13", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_DANFOSS_LC13_ENTITY", ")", "ass...
[ 360, 0 ]
[ 460, 50 ]
python
en
['en', 'en', 'en']
True
test_thermostat_heatit_z_trm3_no_value
( hass, client, climate_heatit_z_trm3_no_value, integration )
Test a heatit Z-TRM3 entity that is missing a value.
Test a heatit Z-TRM3 entity that is missing a value.
async def test_thermostat_heatit_z_trm3_no_value( hass, client, climate_heatit_z_trm3_no_value, integration ): """Test a heatit Z-TRM3 entity that is missing a value.""" # When the config parameter that specifies what sensor to use has no value, we fall # back to the first temperature sensor found on th...
[ "async", "def", "test_thermostat_heatit_z_trm3_no_value", "(", "hass", ",", "client", ",", "climate_heatit_z_trm3_no_value", ",", "integration", ")", ":", "# When the config parameter that specifies what sensor to use has no value, we fall", "# back to the first temperature sensor found ...
[ 463, 0 ]
[ 470, 61 ]
python
en
['en', 'en', 'en']
True
test_thermostat_heatit_z_trm3
( hass, client, climate_heatit_z_trm3, integration )
Test a heatit Z-TRM3 entity.
Test a heatit Z-TRM3 entity.
async def test_thermostat_heatit_z_trm3( hass, client, climate_heatit_z_trm3, integration ): """Test a heatit Z-TRM3 entity.""" node = climate_heatit_z_trm3 state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY) assert state assert state.state == HVAC_MODE_HEAT assert state.attributes[ATT...
[ "async", "def", "test_thermostat_heatit_z_trm3", "(", "hass", ",", "client", ",", "climate_heatit_z_trm3", ",", "integration", ")", ":", "node", "=", "climate_heatit_z_trm3", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_FLOOR_THERMOSTAT_ENTITY", ")...
[ 473, 0 ]
[ 537, 61 ]
python
en
['en', 'pl', 'en']
True
test_thermostat_heatit_z_trm2fx
( hass, client, climate_heatit_z_trm2fx, integration )
Test a heatit Z-TRM2fx entity.
Test a heatit Z-TRM2fx entity.
async def test_thermostat_heatit_z_trm2fx( hass, client, climate_heatit_z_trm2fx, integration ): """Test a heatit Z-TRM2fx entity.""" node = climate_heatit_z_trm2fx state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY) assert state assert state.state == HVAC_MODE_HEAT assert state.attrib...
[ "async", "def", "test_thermostat_heatit_z_trm2fx", "(", "hass", ",", "client", ",", "climate_heatit_z_trm2fx", ",", "integration", ")", ":", "node", "=", "climate_heatit_z_trm2fx", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_FLOOR_THERMOSTAT_ENTITY"...
[ 540, 0 ]
[ 584, 58 ]
python
ca
['ca', 'pl', 'en']
False
test_thermostat_srt321_hrt4_zw
(hass, client, srt321_hrt4_zw, integration)
Test a climate entity from a HRT4-ZW / SRT321 thermostat device. This device currently has no setpoint values.
Test a climate entity from a HRT4-ZW / SRT321 thermostat device.
async def test_thermostat_srt321_hrt4_zw(hass, client, srt321_hrt4_zw, integration): """Test a climate entity from a HRT4-ZW / SRT321 thermostat device. This device currently has no setpoint values. """ state = hass.states.get(CLIMATE_MAIN_HEAT_ACTIONNER) assert state assert state.state == HVA...
[ "async", "def", "test_thermostat_srt321_hrt4_zw", "(", "hass", ",", "client", ",", "srt321_hrt4_zw", ",", "integration", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_MAIN_HEAT_ACTIONNER", ")", "assert", "state", "assert", "state", "."...
[ 587, 0 ]
[ 601, 57 ]
python
en
['en', 'cs', 'en']
True
test_preset_and_no_setpoint
( hass, client, climate_eurotronic_spirit_z, integration )
Test preset without setpoint value.
Test preset without setpoint value.
async def test_preset_and_no_setpoint( hass, client, climate_eurotronic_spirit_z, integration ): """Test preset without setpoint value.""" node = climate_eurotronic_spirit_z state = hass.states.get(CLIMATE_EUROTRONICS_SPIRIT_Z_ENTITY) assert state assert state.state == HVAC_MODE_HEAT assert...
[ "async", "def", "test_preset_and_no_setpoint", "(", "hass", ",", "client", ",", "climate_eurotronic_spirit_z", ",", "integration", ")", ":", "node", "=", "climate_eurotronic_spirit_z", "state", "=", "hass", ".", "states", ".", "get", "(", "CLIMATE_EUROTRONICS_SPIRIT_Z...
[ 604, 0 ]
[ 718, 42 ]
python
en
['en', 'en', 'en']
True
test_temp_unit_fix
( hass, client, climate_radio_thermostat_ct101_multiple_temp_units, climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints, integration, )
Test temperaturee unit fix.
Test temperaturee unit fix.
async def test_temp_unit_fix( hass, client, climate_radio_thermostat_ct101_multiple_temp_units, climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints, integration, ): """Test temperaturee unit fix.""" state = hass.states.get("climate.thermostat") assert state assert...
[ "async", "def", "test_temp_unit_fix", "(", "hass", ",", "client", ",", "climate_radio_thermostat_ct101_multiple_temp_units", ",", "climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints", ",", "integration", ",", ")", ":", "state", "=", "hass", ".", "states",...
[ 721, 0 ]
[ 735, 58 ]
python
en
['en', 'la', 'en']
True
transform_hits
(hits)
The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use.
The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use.
def transform_hits(hits): # type: (List[Dict[str, str]]) -> List[TransformedHit] """ The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use. """ packages = OrderedDict() # type...
[ "def", "transform_hits", "(", "hits", ")", ":", "# type: (List[Dict[str, str]]) -> List[TransformedHit]", "packages", "=", "OrderedDict", "(", ")", "# type: OrderedDict[str, TransformedHit]", "for", "hit", "in", "hits", ":", "name", "=", "hit", "[", "'name'", "]", "su...
[ 83, 0 ]
[ 109, 34 ]
python
en
['en', 'error', 'th']
False
service_signal
(service: str, *args: str)
Encode signal.
Encode signal.
def service_signal(service: str, *args: str) -> str: """Encode signal.""" return "_".join([DOMAIN, service, *args])
[ "def", "service_signal", "(", "service", ":", "str", ",", "*", "args", ":", "str", ")", "->", "str", ":", "return", "\"_\"", ".", "join", "(", "[", "DOMAIN", ",", "service", ",", "*", "args", "]", ")" ]
[ 8, 0 ]
[ 10, 45 ]
python
en
['en', 'cy', 'en']
False
log_update_error
( logger: logging.Logger, action: str, name: str | None, entity_type: str, error: Exception, level: int = logging.ERROR, )
Log an update error.
Log an update error.
def log_update_error( logger: logging.Logger, action: str, name: str | None, entity_type: str, error: Exception, level: int = logging.ERROR, ) -> None: """Log an update error.""" logger.log( level, "Could not %s %s %s due to error: %s", action, name, ...
[ "def", "log_update_error", "(", "logger", ":", "logging", ".", "Logger", ",", "action", ":", "str", ",", "name", ":", "str", "|", "None", ",", "entity_type", ":", "str", ",", "error", ":", "Exception", ",", "level", ":", "int", "=", "logging", ".", "...
[ 13, 0 ]
[ 29, 5 ]
python
da
['da', 'lb', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Zabbix sensor platform.
Set up the Zabbix sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Zabbix sensor platform.""" sensors = [] zapi = hass.data[zabbix.DOMAIN] if not zapi: _LOGGER.error("Zabbix integration hasn't been loaded? zapi is None") return False _LOGGER.info("Connected to Zabbi...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "[", "]", "zapi", "=", "hass", ".", "data", "[", "zabbix", ".", "DOMAIN", "]", "if", "not", "zapi", ":", "_LOGGER", ...
[ 32, 0 ]
[ 77, 25 ]
python
en
['en', 'cs', 'en']
True
ZabbixTriggerCountSensor.__init__
(self, zApi, name="Zabbix")
Initialize Zabbix sensor.
Initialize Zabbix sensor.
def __init__(self, zApi, name="Zabbix"): """Initialize Zabbix sensor.""" self._name = name self._zapi = zApi self._state = None self._attributes = {}
[ "def", "__init__", "(", "self", ",", "zApi", ",", "name", "=", "\"Zabbix\"", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_zapi", "=", "zApi", "self", ".", "_state", "=", "None", "self", ".", "_attributes", "=", "{", "}" ]
[ 83, 4 ]
[ 88, 29 ]
python
it
['mt', 'pl', 'it']
False
ZabbixTriggerCountSensor.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" ]
[ 91, 4 ]
[ 93, 25 ]
python
en
['en', 'mi', 'en']
True
ZabbixTriggerCountSensor.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" ]
[ 96, 4 ]
[ 98, 26 ]
python
en
['en', 'en', 'en']
True
ZabbixTriggerCountSensor.native_unit_of_measurement
(self)
Return the units of measurement.
Return the units of measurement.
def native_unit_of_measurement(self): """Return the units of measurement.""" return "issues"
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "\"issues\"" ]
[ 101, 4 ]
[ 103, 23 ]
python
en
['en', 'bg', 'en']
True
ZabbixTriggerCountSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" _LOGGER.debug("Updating ZabbixTriggerCountSensor: %s", str(self._name)) triggers = self._call_zabbix_api() self._state = len(triggers)
[ "def", "update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating ZabbixTriggerCountSensor: %s\"", ",", "str", "(", "self", ".", "_name", ")", ")", "triggers", "=", "self", ".", "_call_zabbix_api", "(", ")", "self", ".", "_state", "=", "len...
[ 110, 4 ]
[ 114, 35 ]
python
en
['en', 'nl', 'en']
True
ZabbixTriggerCountSensor.extra_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def extra_state_attributes(self): """Return the state attributes of the device.""" return self._attributes
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 117, 4 ]
[ 119, 31 ]
python
en
['en', 'en', 'en']
True
ZabbixSingleHostTriggerCountSensor.__init__
(self, zApi, hostid, name=None)
Initialize Zabbix sensor.
Initialize Zabbix sensor.
def __init__(self, zApi, hostid, name=None): """Initialize Zabbix sensor.""" super().__init__(zApi, name) self._hostid = hostid if not name: self._name = self._zapi.host.get(hostids=self._hostid, output="extend")[0][ "name" ] self._attribu...
[ "def", "__init__", "(", "self", ",", "zApi", ",", "hostid", ",", "name", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "zApi", ",", "name", ")", "self", ".", "_hostid", "=", "hostid", "if", "not", "name", ":", "self", ".", "_nam...
[ 125, 4 ]
[ 134, 50 ]
python
it
['mt', 'pl', 'it']
False
ZabbixMultipleHostTriggerCountSensor.__init__
(self, zApi, hostids, name=None)
Initialize Zabbix sensor.
Initialize Zabbix sensor.
def __init__(self, zApi, hostids, name=None): """Initialize Zabbix sensor.""" super().__init__(zApi, name) self._hostids = hostids if not name: host_names = self._zapi.host.get(hostids=self._hostids, output="extend") self._name = " ".join(name["name"] for name in ...
[ "def", "__init__", "(", "self", ",", "zApi", ",", "hostids", ",", "name", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "zApi", ",", "name", ")", "self", ".", "_hostids", "=", "hostids", "if", "not", "name", ":", "host_names", "="...
[ 149, 4 ]
[ 156, 52 ]
python
it
['mt', 'pl', 'it']
False
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, )
Set up 1-Wire platform.
Set up 1-Wire platform.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up 1-Wire platform.""" # Only OWServer implementation works with binary sensors if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER: onewirehub = hass...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ",", ")", "->", "None", ":", "# Only OWServer implementation works with binary sensors", "if", "config_e...
[ 102, 0 ]
[ 113, 42 ]
python
en
['en', 'de', 'en']
True
get_entities
(onewirehub: OneWireHub)
Get a list of entities.
Get a list of entities.
def get_entities(onewirehub: OneWireHub) -> list[BinarySensorEntity]: """Get a list of entities.""" if not onewirehub.devices: return [] entities: list[BinarySensorEntity] = [] for device in onewirehub.devices: family = device["family"] device_type = device["type"] devi...
[ "def", "get_entities", "(", "onewirehub", ":", "OneWireHub", ")", "->", "list", "[", "BinarySensorEntity", "]", ":", "if", "not", "onewirehub", ".", "devices", ":", "return", "[", "]", "entities", ":", "list", "[", "BinarySensorEntity", "]", "=", "[", "]",...
[ 116, 0 ]
[ 152, 19 ]
python
en
['en', 'en', 'en']
True
OneWireProxyBinarySensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self) -> bool: """Return true if sensor is on.""" return bool(self._state)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_state", ")" ]
[ 161, 4 ]
[ 163, 32 ]
python
en
['en', 'et', 'en']
True
alter_time
(retval)
Manage multiple time mocks.
Manage multiple time mocks.
def alter_time(retval): """Manage multiple time mocks.""" patch1 = patch("homeassistant.util.dt.utcnow", return_value=retval) patch2 = patch("homeassistant.util.dt.now", return_value=retval) with patch1, patch2: yield
[ "def", "alter_time", "(", "retval", ")", ":", "patch1", "=", "patch", "(", "\"homeassistant.util.dt.utcnow\"", ",", "return_value", "=", "retval", ")", "patch2", "=", "patch", "(", "\"homeassistant.util.dt.now\"", ",", "return_value", "=", "retval", ")", "with", ...
[ 42, 0 ]
[ 48, 13 ]
python
da
['pl', 'da', 'en']
False
test_state
(hass)
Test utility sensor state.
Test utility sensor state.
async def test_state(hass): """Test utility sensor state.""" config = { "utility_meter": { "energy_bill": { "source": "sensor.energy", "tariffs": ["onpeak", "midpeak", "offpeak"], } } } assert await async_setup_component(hass, DOMA...
[ "async", "def", "test_state", "(", "hass", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"tariffs\"", ":", "[", "\"onpeak\"", ",", "\"midpeak\"", ",", "\"offpeak\"", "]"...
[ 51, 0 ]
[ 186, 33 ]
python
en
['en', 'el-Latn', 'en']
True
test_device_class
(hass)
Test utility device_class.
Test utility device_class.
async def test_device_class(hass): """Test utility device_class.""" config = { "utility_meter": { "energy_meter": { "source": "sensor.energy", "net_consumption": True, }, "gas_meter": { "source": "sensor.gas", ...
[ "async", "def", "test_device_class", "(", "hass", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_meter\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"net_consumption\"", ":", "True", ",", "}", ",", "\"gas_meter\"", ":", "...
[ 189, 0 ]
[ 251, 80 ]
python
en
['en', 'pl', 'en']
True
test_restore_state
(hass)
Test utility sensor restore state.
Test utility sensor restore state.
async def test_restore_state(hass): """Test utility sensor restore state.""" last_reset = "2020-12-21T00:00:00.013073+00:00" config = { "utility_meter": { "energy_bill": { "source": "sensor.energy", "tariffs": ["onpeak", "midpeak", "offpeak"], ...
[ "async", "def", "test_restore_state", "(", "hass", ")", ":", "last_reset", "=", "\"2020-12-21T00:00:00.013073+00:00\"", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"tariffs\"", ":", "...
[ 254, 0 ]
[ 312, 51 ]
python
en
['en', 'da', 'en']
True
test_net_consumption
(hass)
Test utility sensor state.
Test utility sensor state.
async def test_net_consumption(hass): """Test utility sensor state.""" config = { "utility_meter": { "energy_bill": {"source": "sensor.energy", "net_consumption": True} } } assert await async_setup_component(hass, DOMAIN, config) await hass.async_block_till_done() h...
[ "async", "def", "test_net_consumption", "(", "hass", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"net_consumption\"", ":", "True", "}", "}", "}", "assert", "await", "a...
[ 315, 0 ]
[ 346, 30 ]
python
en
['en', 'el-Latn', 'en']
True
test_non_net_consumption
(hass)
Test utility sensor state.
Test utility sensor state.
async def test_non_net_consumption(hass): """Test utility sensor state.""" config = { "utility_meter": { "energy_bill": {"source": "sensor.energy", "net_consumption": False} } } assert await async_setup_component(hass, DOMAIN, config) await hass.async_block_till_done() ...
[ "async", "def", "test_non_net_consumption", "(", "hass", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"net_consumption\"", ":", "False", "}", "}", "}", "assert", "await",...
[ 349, 0 ]
[ 380, 29 ]
python
en
['en', 'el-Latn', 'en']
True
gen_config
(cycle, offset=None)
Generate configuration.
Generate configuration.
def gen_config(cycle, offset=None): """Generate configuration.""" config = { "utility_meter": {"energy_bill": {"source": "sensor.energy", "cycle": cycle}} } if offset: config["utility_meter"]["energy_bill"]["offset"] = { "days": offset.days, "seconds": offset.sec...
[ "def", "gen_config", "(", "cycle", ",", "offset", "=", "None", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"cycle\"", ":", "cycle", "}", "}", "}", "if", "offset", ...
[ 383, 0 ]
[ 394, 17 ]
python
en
['en', 'la', 'en']
False
_test_self_reset
(hass, config, start_time, expect_reset=True)
Test energy sensor self reset.
Test energy sensor self reset.
async def _test_self_reset(hass, config, start_time, expect_reset=True): """Test energy sensor self reset.""" now = dt_util.parse_datetime(start_time) with alter_time(now): assert await async_setup_component(hass, DOMAIN, config) await hass.async_block_till_done() hass.bus.async_fir...
[ "async", "def", "_test_self_reset", "(", "hass", ",", "config", ",", "start_time", ",", "expect_reset", "=", "True", ")", ":", "now", "=", "dt_util", ".", "parse_datetime", "(", "start_time", ")", "with", "alter_time", "(", "now", ")", ":", "assert", "awai...
[ 397, 0 ]
[ 472, 33 ]
python
be
['hu', 'be', 'en']
False
test_self_reset_cron_pattern
(hass, legacy_patchable_time)
Test cron pattern reset of meter.
Test cron pattern reset of meter.
async def test_self_reset_cron_pattern(hass, legacy_patchable_time): """Test cron pattern reset of meter.""" config = { "utility_meter": { "energy_bill": {"source": "sensor.energy", "cron": "0 0 1 * *"} } } await _test_self_reset(hass, config, "2017-01-31T23:59:00.000000+00:...
[ "async", "def", "test_self_reset_cron_pattern", "(", "hass", ",", "legacy_patchable_time", ")", ":", "config", "=", "{", "\"utility_meter\"", ":", "{", "\"energy_bill\"", ":", "{", "\"source\"", ":", "\"sensor.energy\"", ",", "\"cron\"", ":", "\"0 0 1 * *\"", "}", ...
[ 475, 0 ]
[ 483, 76 ]
python
en
['en', 'jv', 'en']
True
test_self_reset_quarter_hourly
(hass, legacy_patchable_time)
Test quarter-hourly reset of meter.
Test quarter-hourly reset of meter.
async def test_self_reset_quarter_hourly(hass, legacy_patchable_time): """Test quarter-hourly reset of meter.""" await _test_self_reset( hass, gen_config("quarter-hourly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_quarter_hourly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"quarter-hourly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 486, 0 ]
[ 490, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_quarter_hourly_first_quarter
(hass, legacy_patchable_time)
Test quarter-hourly reset of meter.
Test quarter-hourly reset of meter.
async def test_self_reset_quarter_hourly_first_quarter(hass, legacy_patchable_time): """Test quarter-hourly reset of meter.""" await _test_self_reset( hass, gen_config("quarter-hourly"), "2017-12-31T23:14:00.000000+00:00" )
[ "async", "def", "test_self_reset_quarter_hourly_first_quarter", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"quarter-hourly\"", ")", ",", "\"2017-12-31T23:14:00.000000+00:00\"", ")" ]
[ 493, 0 ]
[ 497, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_quarter_hourly_second_quarter
(hass, legacy_patchable_time)
Test quarter-hourly reset of meter.
Test quarter-hourly reset of meter.
async def test_self_reset_quarter_hourly_second_quarter(hass, legacy_patchable_time): """Test quarter-hourly reset of meter.""" await _test_self_reset( hass, gen_config("quarter-hourly"), "2017-12-31T23:29:00.000000+00:00" )
[ "async", "def", "test_self_reset_quarter_hourly_second_quarter", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"quarter-hourly\"", ")", ",", "\"2017-12-31T23:29:00.000000+00:00\"", ")" ]
[ 500, 0 ]
[ 504, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_quarter_hourly_third_quarter
(hass, legacy_patchable_time)
Test quarter-hourly reset of meter.
Test quarter-hourly reset of meter.
async def test_self_reset_quarter_hourly_third_quarter(hass, legacy_patchable_time): """Test quarter-hourly reset of meter.""" await _test_self_reset( hass, gen_config("quarter-hourly"), "2017-12-31T23:44:00.000000+00:00" )
[ "async", "def", "test_self_reset_quarter_hourly_third_quarter", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"quarter-hourly\"", ")", ",", "\"2017-12-31T23:44:00.000000+00:00\"", ")" ]
[ 507, 0 ]
[ 511, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_hourly
(hass, legacy_patchable_time)
Test hourly reset of meter.
Test hourly reset of meter.
async def test_self_reset_hourly(hass, legacy_patchable_time): """Test hourly reset of meter.""" await _test_self_reset( hass, gen_config("hourly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_hourly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"hourly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 514, 0 ]
[ 518, 5 ]
python
en
['en', 'nl', 'en']
True
test_self_reset_daily
(hass, legacy_patchable_time)
Test daily reset of meter.
Test daily reset of meter.
async def test_self_reset_daily(hass, legacy_patchable_time): """Test daily reset of meter.""" await _test_self_reset( hass, gen_config("daily"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_daily", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"daily\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 521, 0 ]
[ 525, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_weekly
(hass, legacy_patchable_time)
Test weekly reset of meter.
Test weekly reset of meter.
async def test_self_reset_weekly(hass, legacy_patchable_time): """Test weekly reset of meter.""" await _test_self_reset( hass, gen_config("weekly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_weekly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"weekly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 528, 0 ]
[ 532, 5 ]
python
en
['en', 'af', 'en']
True
test_self_reset_monthly
(hass, legacy_patchable_time)
Test monthly reset of meter.
Test monthly reset of meter.
async def test_self_reset_monthly(hass, legacy_patchable_time): """Test monthly reset of meter.""" await _test_self_reset( hass, gen_config("monthly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_monthly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"monthly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 535, 0 ]
[ 539, 5 ]
python
en
['en', 'nl', 'en']
True
test_self_reset_bimonthly
(hass, legacy_patchable_time)
Test bimonthly reset of meter occurs on even months.
Test bimonthly reset of meter occurs on even months.
async def test_self_reset_bimonthly(hass, legacy_patchable_time): """Test bimonthly reset of meter occurs on even months.""" await _test_self_reset( hass, gen_config("bimonthly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_bimonthly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"bimonthly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 542, 0 ]
[ 546, 5 ]
python
en
['en', 'en', 'en']
True
test_self_no_reset_bimonthly
(hass, legacy_patchable_time)
Test bimonthly reset of meter does not occur on odd months.
Test bimonthly reset of meter does not occur on odd months.
async def test_self_no_reset_bimonthly(hass, legacy_patchable_time): """Test bimonthly reset of meter does not occur on odd months.""" await _test_self_reset( hass, gen_config("bimonthly"), "2018-01-01T23:59:00.000000+00:00", expect_reset=False, )
[ "async", "def", "test_self_no_reset_bimonthly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"bimonthly\"", ")", ",", "\"2018-01-01T23:59:00.000000+00:00\"", ",", "expect_reset", "=", "False", ...
[ 549, 0 ]
[ 556, 5 ]
python
en
['en', 'en', 'en']
True
test_self_reset_quarterly
(hass, legacy_patchable_time)
Test quarterly reset of meter.
Test quarterly reset of meter.
async def test_self_reset_quarterly(hass, legacy_patchable_time): """Test quarterly reset of meter.""" await _test_self_reset( hass, gen_config("quarterly"), "2017-03-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_quarterly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"quarterly\"", ")", ",", "\"2017-03-31T23:59:00.000000+00:00\"", ")" ]
[ 559, 0 ]
[ 563, 5 ]
python
en
['en', 'la', 'en']
True
test_self_reset_yearly
(hass, legacy_patchable_time)
Test yearly reset of meter.
Test yearly reset of meter.
async def test_self_reset_yearly(hass, legacy_patchable_time): """Test yearly reset of meter.""" await _test_self_reset( hass, gen_config("yearly"), "2017-12-31T23:59:00.000000+00:00" )
[ "async", "def", "test_self_reset_yearly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"yearly\"", ")", ",", "\"2017-12-31T23:59:00.000000+00:00\"", ")" ]
[ 566, 0 ]
[ 570, 5 ]
python
en
['en', 'en', 'en']
True
test_self_no_reset_yearly
(hass, legacy_patchable_time)
Test yearly reset of meter does not occur after 1st January.
Test yearly reset of meter does not occur after 1st January.
async def test_self_no_reset_yearly(hass, legacy_patchable_time): """Test yearly reset of meter does not occur after 1st January.""" await _test_self_reset( hass, gen_config("yearly"), "2018-01-01T23:59:00.000000+00:00", expect_reset=False, )
[ "async", "def", "test_self_no_reset_yearly", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"yearly\"", ")", ",", "\"2018-01-01T23:59:00.000000+00:00\"", ",", "expect_reset", "=", "False", ",", ...
[ 573, 0 ]
[ 580, 5 ]
python
en
['en', 'en', 'en']
True
test_reset_yearly_offset
(hass, legacy_patchable_time)
Test yearly reset of meter.
Test yearly reset of meter.
async def test_reset_yearly_offset(hass, legacy_patchable_time): """Test yearly reset of meter.""" await _test_self_reset( hass, gen_config("yearly", timedelta(days=1, minutes=10)), "2018-01-02T00:09:00.000000+00:00", )
[ "async", "def", "test_reset_yearly_offset", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"yearly\"", ",", "timedelta", "(", "days", "=", "1", ",", "minutes", "=", "10", ")", ")", ","...
[ 583, 0 ]
[ 589, 5 ]
python
en
['en', 'en', 'en']
True
test_no_reset_yearly_offset
(hass, legacy_patchable_time)
Test yearly reset of meter.
Test yearly reset of meter.
async def test_no_reset_yearly_offset(hass, legacy_patchable_time): """Test yearly reset of meter.""" await _test_self_reset( hass, gen_config("yearly", timedelta(31)), "2018-01-30T23:59:00.000000+00:00", expect_reset=False, )
[ "async", "def", "test_no_reset_yearly_offset", "(", "hass", ",", "legacy_patchable_time", ")", ":", "await", "_test_self_reset", "(", "hass", ",", "gen_config", "(", "\"yearly\"", ",", "timedelta", "(", "31", ")", ")", ",", "\"2018-01-30T23:59:00.000000+00:00\"", ",...
[ 592, 0 ]
[ 599, 5 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up Nest components with dispatch between old/new flows.
Set up Nest components with dispatch between old/new flows.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up Nest components with dispatch between old/new flows.""" hass.data[DOMAIN] = {} if DOMAIN not in config: return True if CONF_PROJECT_ID not in config[DOMAIN]: return await async_setup_legacy(hass, config) ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "if", "C...
[ 72, 0 ]
[ 102, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Nest from a config entry with dispatch between old/new flows.
Set up Nest from a config entry with dispatch between old/new flows.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Nest from a config entry with dispatch between old/new flows.""" if DATA_SDM not in entry.data: return await async_setup_legacy_entry(hass, entry) implementation = ( await config_entry_oauth2_flow.async...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "if", "DATA_SDM", "not", "in", "entry", ".", "data", ":", "return", "await", "async_setup_legacy_entry", "(", "hass", ",", "entr...
[ 137, 0 ]
[ 194, 15 ]
python
en
['en', 'en', 'en']
True