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
test_form_addr_in_use
(hass, addr_in_use)
Test how we handle addr_in_use error.
Test how we handle addr_in_use error.
async def test_form_addr_in_use(hass, addr_in_use): """Test how we handle addr_in_use error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) result2 = await hass.config_entries.flow.async_configure( result["flow_id"], ...
[ "async", "def", "test_form_addr_in_use", "(", "hass", ",", "addr_in_use", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOU...
[ 90, 0 ]
[ 101, 45 ]
python
en
['en', 'en', 'en']
True
test_form_start_server_failed
(hass, start_server_failed)
Test how we handle start_server_failed error.
Test how we handle start_server_failed error.
async def test_form_start_server_failed(hass, start_server_failed): """Test how we handle start_server_failed error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) result2 = await hass.config_entries.flow.async_configure( ...
[ "async", "def", "test_form_start_server_failed", "(", "hass", ",", "start_server_failed", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries...
[ 104, 0 ]
[ 115, 53 ]
python
en
['en', 'no', 'en']
True
test_option_flow
(hass)
Test option flow.
Test option flow.
async def test_option_flow(hass): """Test option flow.""" entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG) entry.add_to_hass(hass) assert not entry.options result = await hass.config_entries.options.async_init(entry.entry_id, data=None) assert result["type"] == data_entry_flow.RESULT_...
[ "async", "def", "test_option_flow", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "MOCK_CONFIG", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "assert", "not", "entry", ".", "options", "result...
[ 118, 0 ]
[ 136, 44 ]
python
da
['nl', 'da', 'en']
False
auth_header
(hass_access_token)
Generate an HTTP header with bearer token authorization.
Generate an HTTP header with bearer token authorization.
def auth_header(hass_access_token): """Generate an HTTP header with bearer token authorization.""" return {AUTHORIZATION: f"Bearer {hass_access_token}"}
[ "def", "auth_header", "(", "hass_access_token", ")", ":", "return", "{", "AUTHORIZATION", ":", "f\"Bearer {hass_access_token}\"", "}" ]
[ 32, 0 ]
[ 34, 57 ]
python
en
['en', 'lb', 'en']
True
assistant_client
(loop, hass, aiohttp_client)
Create web client for the Google Assistant API.
Create web client for the Google Assistant API.
def assistant_client(loop, hass, aiohttp_client): """Create web client for the Google Assistant API.""" loop.run_until_complete( setup.async_setup_component( hass, "google_assistant", { "google_assistant": { "project_id": PROJECT_ID...
[ "def", "assistant_client", "(", "loop", ",", "hass", ",", "aiohttp_client", ")", ":", "loop", ".", "run_until_complete", "(", "setup", ".", "async_setup_component", "(", "hass", ",", "\"google_assistant\"", ",", "{", "\"google_assistant\"", ":", "{", "\"project_id...
[ 38, 0 ]
[ 58, 65 ]
python
en
['en', 'en', 'en']
True
hass_fixture
(loop, hass)
Set up a Home Assistant instance for these tests.
Set up a Home Assistant instance for these tests.
def hass_fixture(loop, hass): """Set up a Home Assistant instance for these tests.""" # We need to do this to get access to homeassistant/turn_(on,off) loop.run_until_complete(setup.async_setup_component(hass, core.DOMAIN, {})) loop.run_until_complete( setup.async_setup_component( h...
[ "def", "hass_fixture", "(", "loop", ",", "hass", ")", ":", "# We need to do this to get access to homeassistant/turn_(on,off)", "loop", ".", "run_until_complete", "(", "setup", ".", "async_setup_component", "(", "hass", ",", "core", ".", "DOMAIN", ",", "{", "}", ")"...
[ 62, 0 ]
[ 117, 15 ]
python
en
['en', 'en', 'en']
True
test_sync_request
(hass_fixture, assistant_client, auth_header)
Test a sync request.
Test a sync request.
async def test_sync_request(hass_fixture, assistant_client, auth_header): """Test a sync request.""" reqid = "5711642932632160983" data = {"requestId": reqid, "inputs": [{"intent": "action.devices.SYNC"}]} result = await assistant_client.post( ga.const.GOOGLE_ASSISTANT_API_ENDPOINT, data...
[ "async", "def", "test_sync_request", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "reqid", "=", "\"5711642932632160983\"", "data", "=", "{", "\"requestId\"", ":", "reqid", ",", "\"inputs\"", ":", "[", "{", "\"intent\"", ":", "\"act...
[ 123, 0 ]
[ 149, 42 ]
python
en
['en', 'en', 'en']
True
test_query_request
(hass_fixture, assistant_client, auth_header)
Test a query request.
Test a query request.
async def test_query_request(hass_fixture, assistant_client, auth_header): """Test a query request.""" reqid = "5711642932632160984" data = { "requestId": reqid, "inputs": [ { "intent": "action.devices.QUERY", "payload": { "devi...
[ "async", "def", "test_query_request", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "reqid", "=", "\"5711642932632160984\"", "data", "=", "{", "\"requestId\"", ":", "reqid", ",", "\"inputs\"", ":", "[", "{", "\"intent\"", ":", "\"ac...
[ 152, 0 ]
[ 190, 60 ]
python
en
['es', 'en', 'en']
True
test_query_climate_request
(hass_fixture, assistant_client, auth_header)
Test a query request.
Test a query request.
async def test_query_climate_request(hass_fixture, assistant_client, auth_header): """Test a query request.""" reqid = "5711642932632160984" data = { "requestId": reqid, "inputs": [ { "intent": "action.devices.QUERY", "payload": { ...
[ "async", "def", "test_query_climate_request", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "reqid", "=", "\"5711642932632160984\"", "data", "=", "{", "\"requestId\"", ":", "reqid", ",", "\"inputs\"", ":", "[", "{", "\"intent\"", ":",...
[ 193, 0 ]
[ 242, 5 ]
python
en
['es', 'en', 'en']
True
test_query_climate_request_f
(hass_fixture, assistant_client, auth_header)
Test a query request.
Test a query request.
async def test_query_climate_request_f(hass_fixture, assistant_client, auth_header): """Test a query request.""" # Mock demo devices as fahrenheit to see if we convert to celsius hass_fixture.config.units.temperature_unit = const.TEMP_FAHRENHEIT for entity_id in ("climate.hvac", "climate.heatpump", "cli...
[ "async", "def", "test_query_climate_request_f", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "# Mock demo devices as fahrenheit to see if we convert to celsius", "hass_fixture", ".", "config", ".", "units", ".", "temperature_unit", "=", "const",...
[ 245, 0 ]
[ 302, 67 ]
python
en
['es', 'en', 'en']
True
test_query_humidifier_request
(hass_fixture, assistant_client, auth_header)
Test a query request.
Test a query request.
async def test_query_humidifier_request(hass_fixture, assistant_client, auth_header): """Test a query request.""" reqid = "5711642932632160984" data = { "requestId": reqid, "inputs": [ { "intent": "action.devices.QUERY", "payload": { ...
[ "async", "def", "test_query_humidifier_request", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "reqid", "=", "\"5711642932632160984\"", "data", "=", "{", "\"requestId\"", ":", "reqid", ",", "\"inputs\"", ":", "[", "{", "\"intent\"", "...
[ 305, 0 ]
[ 348, 5 ]
python
en
['es', 'en', 'en']
True
test_execute_request
(hass_fixture, assistant_client, auth_header)
Test an execute request.
Test an execute request.
async def test_execute_request(hass_fixture, assistant_client, auth_header): """Test an execute request.""" reqid = "5711642932632160985" data = { "requestId": reqid, "inputs": [ { "intent": "action.devices.EXECUTE", "payload": { ...
[ "async", "def", "test_execute_request", "(", "hass_fixture", ",", "assistant_client", ",", "auth_header", ")", ":", "reqid", "=", "\"5711642932632160985\"", "data", "=", "{", "\"requestId\"", ":", "reqid", ",", "\"inputs\"", ":", "[", "{", "\"intent\"", ":", "\"...
[ 351, 0 ]
[ 475, 66 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Sonos platform. Obsolete.
Set up the Sonos platform. Obsolete.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Sonos platform. Obsolete.""" _LOGGER.error( "Loading Sonos by media_player platform configuration is no longer supported" )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "_LOGGER", ".", "error", "(", "\"Loading Sonos by media_player platform configuration is no longer supported\"", ")" ]
[ 254, 0 ]
[ 258, 5 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Sonos from a config entry.
Set up Sonos from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Sonos from a config entry.""" if DATA_SONOS not in hass.data: hass.data[DATA_SONOS] = SonosData() config = hass.data[SONOS_DOMAIN].get("media_player", {}) _LOGGER.debug("Reached async_setup_entry, config=%s", config)...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "if", "DATA_SONOS", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DATA_SONOS", "]", "=", "SonosData", "(", ")", "config", "=", ...
[ 261, 0 ]
[ 435, 5 ]
python
en
['en', 'en', 'en']
True
_get_entity_from_soco_uid
(hass, uid)
Return SonosEntity from SoCo uid.
Return SonosEntity from SoCo uid.
def _get_entity_from_soco_uid(hass, uid): """Return SonosEntity from SoCo uid.""" for entity in hass.data[DATA_SONOS].entities: if uid == entity.unique_id: return entity return None
[ "def", "_get_entity_from_soco_uid", "(", "hass", ",", "uid", ")", ":", "for", "entity", "in", "hass", ".", "data", "[", "DATA_SONOS", "]", ".", "entities", ":", "if", "uid", "==", "entity", ".", "unique_id", ":", "return", "entity", "return", "None" ]
[ 453, 0 ]
[ 458, 15 ]
python
en
['en', 'cy', 'en']
True
soco_error
(errorcodes=None)
Filter out specified UPnP errors from logs and avoid exceptions.
Filter out specified UPnP errors from logs and avoid exceptions.
def soco_error(errorcodes=None): """Filter out specified UPnP errors from logs and avoid exceptions.""" def decorator(funct): """Decorate functions.""" @ft.wraps(funct) def wrapper(*args, **kwargs): """Wrap for all soco UPnP exception.""" try: re...
[ "def", "soco_error", "(", "errorcodes", "=", "None", ")", ":", "def", "decorator", "(", "funct", ")", ":", "\"\"\"Decorate functions.\"\"\"", "@", "ft", ".", "wraps", "(", "funct", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ...
[ 461, 0 ]
[ 480, 20 ]
python
en
['en', 'en', 'en']
True
soco_coordinator
(funct)
Call function on coordinator.
Call function on coordinator.
def soco_coordinator(funct): """Call function on coordinator.""" @ft.wraps(funct) def wrapper(entity, *args, **kwargs): """Wrap for call to coordinator.""" if entity.is_coordinator: return funct(entity, *args, **kwargs) return funct(entity.coordinator, *args, **kwargs) ...
[ "def", "soco_coordinator", "(", "funct", ")", ":", "@", "ft", ".", "wraps", "(", "funct", ")", "def", "wrapper", "(", "entity", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap for call to coordinator.\"\"\"", "if", "entity", ".", "is_coord...
[ 483, 0 ]
[ 493, 18 ]
python
en
['en', 'en', 'en']
True
_timespan_secs
(timespan)
Parse a time-span into number of seconds.
Parse a time-span into number of seconds.
def _timespan_secs(timespan): """Parse a time-span into number of seconds.""" if timespan in UNAVAILABLE_VALUES: return None return sum(60 ** x[0] * int(x[1]) for x in enumerate(reversed(timespan.split(":"))))
[ "def", "_timespan_secs", "(", "timespan", ")", ":", "if", "timespan", "in", "UNAVAILABLE_VALUES", ":", "return", "None", "return", "sum", "(", "60", "**", "x", "[", "0", "]", "*", "int", "(", "x", "[", "1", "]", ")", "for", "x", "in", "enumerate", ...
[ 496, 0 ]
[ 501, 88 ]
python
en
['en', 'en', 'en']
True
build_item_response
(media_library, payload)
Create response payload for the provided media query.
Create response payload for the provided media query.
def build_item_response(media_library, payload): """Create response payload for the provided media query.""" if payload["search_type"] == MEDIA_TYPE_ALBUM and payload["idstring"].startswith( ("A:GENRE", "A:COMPOSER") ): payload["idstring"] = "A:ALBUMARTIST/" + "/".join( payload["...
[ "def", "build_item_response", "(", "media_library", ",", "payload", ")", ":", "if", "payload", "[", "\"search_type\"", "]", "==", "MEDIA_TYPE_ALBUM", "and", "payload", "[", "\"idstring\"", "]", ".", "startswith", "(", "(", "\"A:GENRE\"", ",", "\"A:COMPOSER\"", "...
[ 1494, 0 ]
[ 1556, 5 ]
python
en
['en', 'en', 'en']
True
item_payload
(item)
Create response payload for a single media item. Used by async_browse_media.
Create response payload for a single media item.
def item_payload(item): """ Create response payload for a single media item. Used by async_browse_media. """ media_type = get_media_type(item) try: media_class = SONOS_TO_MEDIA_CLASSES[media_type] except KeyError as err: _LOGGER.debug("Unknown media type received %s", media_...
[ "def", "item_payload", "(", "item", ")", ":", "media_type", "=", "get_media_type", "(", "item", ")", "try", ":", "media_class", "=", "SONOS_TO_MEDIA_CLASSES", "[", "media_type", "]", "except", "KeyError", "as", "err", ":", "_LOGGER", ".", "debug", "(", "\"Un...
[ 1559, 0 ]
[ 1579, 5 ]
python
en
['en', 'error', 'th']
False
library_payload
(media_library)
Create response payload to describe contents of a specific library. Used by async_browse_media.
Create response payload to describe contents of a specific library.
def library_payload(media_library): """ Create response payload to describe contents of a specific library. Used by async_browse_media. """ if not media_library.browse_by_idstring( "tracks", "", max_items=1, ): raise BrowseError("Local library not found") ch...
[ "def", "library_payload", "(", "media_library", ")", ":", "if", "not", "media_library", ".", "browse_by_idstring", "(", "\"tracks\"", ",", "\"\"", ",", "max_items", "=", "1", ",", ")", ":", "raise", "BrowseError", "(", "\"Local library not found\"", ")", "childr...
[ 1582, 0 ]
[ 1610, 5 ]
python
en
['en', 'error', 'th']
False
get_media_type
(item)
Extract media type of item.
Extract media type of item.
def get_media_type(item): """Extract media type of item.""" if item.item_class == "object.item.audioItem.musicTrack": return SONOS_TRACKS if ( item.item_class == "object.container.album.musicAlbum" and SONOS_TYPES_MAPPING.get(item.item_id.split("/")[0]) in [ SONO...
[ "def", "get_media_type", "(", "item", ")", ":", "if", "item", ".", "item_class", "==", "\"object.item.audioItem.musicTrack\"", ":", "return", "SONOS_TRACKS", "if", "(", "item", ".", "item_class", "==", "\"object.container.album.musicAlbum\"", "and", "SONOS_TYPES_MAPPING...
[ 1613, 0 ]
[ 1628, 79 ]
python
en
['en', 'sr', 'en']
True
can_play
(item)
Test if playable. Used by async_browse_media.
Test if playable.
def can_play(item): """ Test if playable. Used by async_browse_media. """ return SONOS_TO_MEDIA_TYPES.get(item) in PLAYABLE_MEDIA_TYPES
[ "def", "can_play", "(", "item", ")", ":", "return", "SONOS_TO_MEDIA_TYPES", ".", "get", "(", "item", ")", "in", "PLAYABLE_MEDIA_TYPES" ]
[ 1631, 0 ]
[ 1637, 65 ]
python
en
['en', 'error', 'th']
False
can_expand
(item)
Test if expandable. Used by async_browse_media.
Test if expandable.
def can_expand(item): """ Test if expandable. Used by async_browse_media. """ if isinstance(item, str): return SONOS_TYPES_MAPPING.get(item) in EXPANDABLE_MEDIA_TYPES if SONOS_TO_MEDIA_TYPES.get(item.item_class) in EXPANDABLE_MEDIA_TYPES: return True return SONOS_TYPES_MAP...
[ "def", "can_expand", "(", "item", ")", ":", "if", "isinstance", "(", "item", ",", "str", ")", ":", "return", "SONOS_TYPES_MAPPING", ".", "get", "(", "item", ")", "in", "EXPANDABLE_MEDIA_TYPES", "if", "SONOS_TO_MEDIA_TYPES", ".", "get", "(", "item", ".", "i...
[ 1640, 0 ]
[ 1652, 74 ]
python
en
['en', 'error', 'th']
False
get_content_id
(item)
Extract content id or uri.
Extract content id or uri.
def get_content_id(item): """Extract content id or uri.""" if item.item_class == "object.item.audioItem.musicTrack": return item.get_uri() return item.item_id
[ "def", "get_content_id", "(", "item", ")", ":", "if", "item", ".", "item_class", "==", "\"object.item.audioItem.musicTrack\"", ":", "return", "item", ".", "get_uri", "(", ")", "return", "item", ".", "item_id" ]
[ 1655, 0 ]
[ 1659, 23 ]
python
en
['en', 'en', 'en']
True
get_media
(media_library, item_id, search_type)
Fetch media/album.
Fetch media/album.
def get_media(media_library, item_id, search_type): """Fetch media/album.""" search_type = MEDIA_TYPES_TO_SONOS.get(search_type, search_type) if not item_id.startswith("A:ALBUM") and search_type == SONOS_ALBUM: item_id = "A:ALBUMARTIST/" + "/".join(item_id.split("/")[2:]) for item in media_lib...
[ "def", "get_media", "(", "media_library", ",", "item_id", ",", "search_type", ")", ":", "search_type", "=", "MEDIA_TYPES_TO_SONOS", ".", "get", "(", "search_type", ",", "search_type", ")", "if", "not", "item_id", ".", "startswith", "(", "\"A:ALBUM\"", ")", "an...
[ 1662, 0 ]
[ 1676, 23 ]
python
en
['en', 'cy', 'en']
False
SonosData.__init__
(self)
Initialize the data.
Initialize the data.
def __init__(self): """Initialize the data.""" self.entities = [] self.discovered = [] self.topology_condition = asyncio.Condition() self.discovery_thread = None self.hosts_heartbeat = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "entities", "=", "[", "]", "self", ".", "discovered", "=", "[", "]", "self", ".", "topology_condition", "=", "asyncio", ".", "Condition", "(", ")", "self", ".", "discovery_thread", "=", "None", "se...
[ 245, 4 ]
[ 251, 35 ]
python
en
['en', 'en', 'en']
True
_ProcessSonosEventQueue.__init__
(self, handler)
Initialize Sonos event queue.
Initialize Sonos event queue.
def __init__(self, handler): """Initialize Sonos event queue.""" self._handler = handler
[ "def", "__init__", "(", "self", ",", "handler", ")", ":", "self", ".", "_handler", "=", "handler" ]
[ 441, 4 ]
[ 443, 31 ]
python
es
['es', 'la', 'it']
False
_ProcessSonosEventQueue.put
(self, item, block=True, timeout=None)
Process event.
Process event.
def put(self, item, block=True, timeout=None): """Process event.""" try: self._handler(item) except SoCoException as ex: _LOGGER.warning("Error calling %s: %s", self._handler, ex)
[ "def", "put", "(", "self", ",", "item", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "try", ":", "self", ".", "_handler", "(", "item", ")", "except", "SoCoException", "as", "ex", ":", "_LOGGER", ".", "warning", "(", "\"Error call...
[ 445, 4 ]
[ 450, 70 ]
python
en
['en', 'zh', 'en']
False
SonosEntity.__init__
(self, player)
Initialize the Sonos entity.
Initialize the Sonos entity.
def __init__(self, player): """Initialize the Sonos entity.""" self._subscriptions = [] self._poll_timer = None self._seen_timer = None self._volume_increment = 2 self._unique_id = player.uid self._player = player self._player_volume = None self._p...
[ "def", "__init__", "(", "self", ",", "player", ")", ":", "self", ".", "_subscriptions", "=", "[", "]", "self", ".", "_poll_timer", "=", "None", "self", ".", "_seen_timer", "=", "None", "self", ".", "_volume_increment", "=", "2", "self", ".", "_unique_id"...
[ 507, 4 ]
[ 545, 55 ]
python
en
['en', 'en', 'en']
True
SonosEntity.async_added_to_hass
(self)
Subscribe sonos events.
Subscribe sonos events.
async def async_added_to_hass(self): """Subscribe sonos events.""" await self.async_seen(self.soco) self.hass.data[DATA_SONOS].entities.append(self) def _rebuild_groups(): """Build the current group topology.""" for entity in self.hass.data[DATA_SONOS].entities:...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "self", ".", "async_seen", "(", "self", ".", "soco", ")", "self", ".", "hass", ".", "data", "[", "DATA_SONOS", "]", ".", "entities", ".", "append", "(", "self", ")", "def", "_rebuil...
[ 547, 4 ]
[ 558, 57 ]
python
es
['es', 'es', 'it']
True
SonosEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 561, 4 ]
[ 563, 30 ]
python
ca
['fr', 'ca', 'en']
False
SonosEntity.__hash__
(self)
Return a hash of self.
Return a hash of self.
def __hash__(self): """Return a hash of self.""" return hash(self.unique_id)
[ "def", "__hash__", "(", "self", ")", ":", "return", "hash", "(", "self", ".", "unique_id", ")" ]
[ 565, 4 ]
[ 567, 35 ]
python
en
['en', 'ig', 'en']
True
SonosEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 570, 4 ]
[ 572, 25 ]
python
en
['en', 'en', 'en']
True
SonosEntity.device_info
(self)
Return information about the device.
Return information about the device.
def device_info(self): """Return information about the device.""" return { "identifiers": {(SONOS_DOMAIN, self._unique_id)}, "name": self._name, "model": self._model.replace("Sonos ", ""), "sw_version": self._sw_version, "connections": {(dr.CON...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "SONOS_DOMAIN", ",", "self", ".", "_unique_id", ")", "}", ",", "\"name\"", ":", "self", ".", "_name", ",", "\"model\"", ":", "self", ".", "_model", ".", "repl...
[ 575, 4 ]
[ 584, 9 ]
python
en
['en', 'en', 'en']
True
SonosEntity.state
(self)
Return the state of the entity.
Return the state of the entity.
def state(self): """Return the state of the entity.""" if self._status in ( "PAUSED_PLAYBACK", "STOPPED", ): # Sonos can consider itself "paused" but without having media loaded # (happens if playing Spotify and via Spotify app you pick another dev...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_status", "in", "(", "\"PAUSED_PLAYBACK\"", ",", "\"STOPPED\"", ",", ")", ":", "# Sonos can consider itself \"paused\" but without having media loaded", "# (happens if playing Spotify and via Spotify app you pick anothe...
[ 588, 4 ]
[ 601, 25 ]
python
en
['en', 'en', 'en']
True
SonosEntity.is_coordinator
(self)
Return true if player is a coordinator.
Return true if player is a coordinator.
def is_coordinator(self): """Return true if player is a coordinator.""" return self._coordinator is None
[ "def", "is_coordinator", "(", "self", ")", ":", "return", "self", ".", "_coordinator", "is", "None" ]
[ 604, 4 ]
[ 606, 40 ]
python
en
['en', 'lb', 'en']
True
SonosEntity.soco
(self)
Return soco object.
Return soco object.
def soco(self): """Return soco object.""" return self._player
[ "def", "soco", "(", "self", ")", ":", "return", "self", ".", "_player" ]
[ 609, 4 ]
[ 611, 27 ]
python
bg
['es', 'ig', 'bg']
False
SonosEntity.coordinator
(self)
Return coordinator of this player.
Return coordinator of this player.
def coordinator(self): """Return coordinator of this player.""" return self._coordinator
[ "def", "coordinator", "(", "self", ")", ":", "return", "self", ".", "_coordinator" ]
[ 614, 4 ]
[ 616, 32 ]
python
en
['en', 'en', 'en']
True
SonosEntity.async_seen
(self, player)
Record that this player was seen right now.
Record that this player was seen right now.
async def async_seen(self, player): """Record that this player was seen right now.""" was_available = self.available self._player = player if self._seen_timer: self._seen_timer() self._seen_timer = self.hass.helpers.event.async_call_later( 2.5 * DISCOVE...
[ "async", "def", "async_seen", "(", "self", ",", "player", ")", ":", "was_available", "=", "self", ".", "available", "self", ".", "_player", "=", "player", "if", "self", ".", "_seen_timer", ":", "self", ".", "_seen_timer", "(", ")", "self", ".", "_seen_ti...
[ 618, 4 ]
[ 643, 35 ]
python
en
['en', 'en', 'en']
True
SonosEntity.async_unseen
(self, now=None)
Make this player unavailable when it was not seen recently.
Make this player unavailable when it was not seen recently.
def async_unseen(self, now=None): """Make this player unavailable when it was not seen recently.""" self._seen_timer = None if self._poll_timer: self._poll_timer() self._poll_timer = None def _unsub(subscriptions): for subscription in subscriptions: ...
[ "def", "async_unseen", "(", "self", ",", "now", "=", "None", ")", ":", "self", ".", "_seen_timer", "=", "None", "if", "self", ".", "_poll_timer", ":", "self", ".", "_poll_timer", "(", ")", "self", ".", "_poll_timer", "=", "None", "def", "_unsub", "(", ...
[ 646, 4 ]
[ 662, 35 ]
python
en
['en', 'en', 'en']
True
SonosEntity.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._seen_timer is not None
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_seen_timer", "is", "not", "None" ]
[ 665, 4 ]
[ 667, 43 ]
python
en
['en', 'en', 'en']
True
SonosEntity._clear_media_position
(self)
Clear the media_position.
Clear the media_position.
def _clear_media_position(self): """Clear the media_position.""" self._media_position = None self._media_position_updated_at = None
[ "def", "_clear_media_position", "(", "self", ")", ":", "self", ".", "_media_position", "=", "None", "self", ".", "_media_position_updated_at", "=", "None" ]
[ 669, 4 ]
[ 672, 46 ]
python
en
['en', 'en', 'en']
True
SonosEntity._set_favorites
(self)
Set available favorites.
Set available favorites.
def _set_favorites(self): """Set available favorites.""" self._favorites = [] for fav in self.soco.music_library.get_sonos_favorites(): try: # Exclude non-playable favorites with no linked resources if fav.reference.resources: self....
[ "def", "_set_favorites", "(", "self", ")", ":", "self", ".", "_favorites", "=", "[", "]", "for", "fav", "in", "self", ".", "soco", ".", "music_library", ".", "get_sonos_favorites", "(", ")", ":", "try", ":", "# Exclude non-playable favorites with no linked resou...
[ 674, 4 ]
[ 684, 75 ]
python
en
['fr', 'en', 'en']
True
SonosEntity._attach_player
(self)
Get basic information and add event subscriptions.
Get basic information and add event subscriptions.
def _attach_player(self): """Get basic information and add event subscriptions.""" try: self._play_mode = self.soco.play_mode self.update_volume() self._set_favorites() player = self.soco def subscribe(sonos_service, action): ...
[ "def", "_attach_player", "(", "self", ")", ":", "try", ":", "self", ".", "_play_mode", "=", "self", ".", "soco", ".", "play_mode", "self", ".", "update_volume", "(", ")", "self", ".", "_set_favorites", "(", ")", "player", "=", "self", ".", "soco", "def...
[ 686, 4 ]
[ 708, 24 ]
python
en
['en', 'en', 'en']
True
SonosEntity.should_poll
(self)
Return that we should not be polled (we handle that internally).
Return that we should not be polled (we handle that internally).
def should_poll(self): """Return that we should not be polled (we handle that internally).""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 711, 4 ]
[ 713, 20 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update
(self, now=None)
Retrieve latest state.
Retrieve latest state.
def update(self, now=None): """Retrieve latest state.""" try: self.update_groups() self.update_volume() if self.is_coordinator: self.update_media() except SoCoException: pass
[ "def", "update", "(", "self", ",", "now", "=", "None", ")", ":", "try", ":", "self", ".", "update_groups", "(", ")", "self", ".", "update_volume", "(", ")", "if", "self", ".", "is_coordinator", ":", "self", ".", "update_media", "(", ")", "except", "S...
[ 715, 4 ]
[ 723, 16 ]
python
en
['es', 'sk', 'en']
False
SonosEntity.update_media
(self, event=None)
Update information about currently playing media.
Update information about currently playing media.
def update_media(self, event=None): """Update information about currently playing media.""" transport_info = self.soco.get_current_transport_info() new_status = transport_info.get("current_transport_state") # Ignore transitions, we should get the target state soon if new_status ...
[ "def", "update_media", "(", "self", ",", "event", "=", "None", ")", ":", "transport_info", "=", "self", ".", "soco", ".", "get_current_transport_info", "(", ")", "new_status", "=", "transport_info", ".", "get", "(", "\"current_transport_state\"", ")", "# Ignore ...
[ 725, 4 ]
[ 775, 49 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_media_linein
(self, source)
Update state when playing from line-in/tv.
Update state when playing from line-in/tv.
def update_media_linein(self, source): """Update state when playing from line-in/tv.""" self._clear_media_position() self._media_title = source self._source_name = source
[ "def", "update_media_linein", "(", "self", ",", "source", ")", ":", "self", ".", "_clear_media_position", "(", ")", "self", ".", "_media_title", "=", "source", "self", ".", "_source_name", "=", "source" ]
[ 777, 4 ]
[ 782, 34 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_media_radio
(self, variables, track_info)
Update state when streaming radio.
Update state when streaming radio.
def update_media_radio(self, variables, track_info): """Update state when streaming radio.""" self._clear_media_position() try: album_art_uri = variables["current_track_meta_data"].album_art_uri self._media_image_url = self._media_library.build_album_art_full_uri( ...
[ "def", "update_media_radio", "(", "self", ",", "variables", ",", "track_info", ")", ":", "self", ".", "_clear_media_position", "(", ")", "try", ":", "album_art_uri", "=", "variables", "[", "\"current_track_meta_data\"", "]", ".", "album_art_uri", "self", ".", "_...
[ 784, 4 ]
[ 819, 45 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_media_music
(self, update_media_position, track_info)
Update state when playing music tracks.
Update state when playing music tracks.
def update_media_music(self, update_media_position, track_info): """Update state when playing music tracks.""" self._media_duration = _timespan_secs(track_info.get("duration")) current_position = _timespan_secs(track_info.get("position")) # player started reporting position? if ...
[ "def", "update_media_music", "(", "self", ",", "update_media_position", ",", "track_info", ")", ":", "self", ".", "_media_duration", "=", "_timespan_secs", "(", "track_info", ".", "get", "(", "\"duration\"", ")", ")", "current_position", "=", "_timespan_secs", "("...
[ 821, 4 ]
[ 851, 75 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_volume
(self, event=None)
Update information about currently volume settings.
Update information about currently volume settings.
def update_volume(self, event=None): """Update information about currently volume settings.""" if event: variables = event.variables if "volume" in variables: self._player_volume = int(variables["volume"]["Master"]) if "mute" in variables: ...
[ "def", "update_volume", "(", "self", ",", "event", "=", "None", ")", ":", "if", "event", ":", "variables", "=", "event", ".", "variables", "if", "\"volume\"", "in", "variables", ":", "self", ".", "_player_volume", "=", "int", "(", "variables", "[", "\"vo...
[ 853, 4 ]
[ 875, 56 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_groups
(self, event=None)
Handle callback for topology change event.
Handle callback for topology change event.
def update_groups(self, event=None): """Handle callback for topology change event.""" def _get_soco_group(): """Ask SoCo cache for existing topology.""" coordinator_uid = self.unique_id slave_uids = [] try: if self.soco.group and self.soc...
[ "def", "update_groups", "(", "self", ",", "event", "=", "None", ")", ":", "def", "_get_soco_group", "(", ")", ":", "\"\"\"Ask SoCo cache for existing topology.\"\"\"", "coordinator_uid", "=", "self", ".", "unique_id", "slave_uids", "=", "[", "]", "try", ":", "if...
[ 877, 4 ]
[ 945, 59 ]
python
en
['en', 'en', 'en']
True
SonosEntity.update_content
(self, event=None)
Update information about available content.
Update information about available content.
def update_content(self, event=None): """Update information about available content.""" self._set_favorites() self.schedule_update_ha_state()
[ "def", "update_content", "(", "self", ",", "event", "=", "None", ")", ":", "self", ".", "_set_favorites", "(", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 947, 4 ]
[ 950, 39 ]
python
en
['fr', 'en', 'en']
True
SonosEntity.volume_level
(self)
Volume level of the media player (0..1).
Volume level of the media player (0..1).
def volume_level(self): """Volume level of the media player (0..1).""" if self._player_volume is None: return None return self._player_volume / 100
[ "def", "volume_level", "(", "self", ")", ":", "if", "self", ".", "_player_volume", "is", "None", ":", "return", "None", "return", "self", ".", "_player_volume", "/", "100" ]
[ 953, 4 ]
[ 957, 40 ]
python
en
['en', 'en', 'en']
True
SonosEntity.is_volume_muted
(self)
Return true if volume is muted.
Return true if volume is muted.
def is_volume_muted(self): """Return true if volume is muted.""" return self._player_muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_player_muted" ]
[ 960, 4 ]
[ 962, 33 ]
python
de
['nl', 'de', 'en']
False
SonosEntity.shuffle
(self)
Shuffling state.
Shuffling state.
def shuffle(self): """Shuffling state.""" return PLAY_MODES[self._play_mode][0]
[ "def", "shuffle", "(", "self", ")", ":", "return", "PLAY_MODES", "[", "self", ".", "_play_mode", "]", "[", "0", "]" ]
[ 966, 4 ]
[ 968, 45 ]
python
de
['de', 'jv', 'en']
False
SonosEntity.repeat
(self)
Return current repeat mode.
Return current repeat mode.
def repeat(self): """Return current repeat mode.""" sonos_repeat = PLAY_MODES[self._play_mode][1] return SONOS_TO_REPEAT[sonos_repeat]
[ "def", "repeat", "(", "self", ")", ":", "sonos_repeat", "=", "PLAY_MODES", "[", "self", ".", "_play_mode", "]", "[", "1", "]", "return", "SONOS_TO_REPEAT", "[", "sonos_repeat", "]" ]
[ 972, 4 ]
[ 975, 44 ]
python
en
['en', 'la', 'en']
True
SonosEntity.media_content_id
(self)
Content id of current playing media.
Content id of current playing media.
def media_content_id(self): """Content id of current playing media.""" return self._uri
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "_uri" ]
[ 979, 4 ]
[ 981, 24 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_content_type
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media.""" return MEDIA_TYPE_MUSIC
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_MUSIC" ]
[ 984, 4 ]
[ 986, 31 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_duration
(self)
Duration of current playing media in seconds.
Duration of current playing media in seconds.
def media_duration(self): """Duration of current playing media in seconds.""" return self._media_duration
[ "def", "media_duration", "(", "self", ")", ":", "return", "self", ".", "_media_duration" ]
[ 990, 4 ]
[ 992, 35 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_position
(self)
Position of current playing media in seconds.
Position of current playing media in seconds.
def media_position(self): """Position of current playing media in seconds.""" return self._media_position
[ "def", "media_position", "(", "self", ")", ":", "return", "self", ".", "_media_position" ]
[ 996, 4 ]
[ 998, 35 ]
python
en
['en', 'en', 'en']
True
SonosEntity.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): """When was the position of the current playing media valid.""" return self._media_position_updated_at
[ "def", "media_position_updated_at", "(", "self", ")", ":", "return", "self", ".", "_media_position_updated_at" ]
[ 1002, 4 ]
[ 1004, 46 ]
python
en
['en', 'en', 'en']
True
SonosEntity.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 or None
[ "def", "media_image_url", "(", "self", ")", ":", "return", "self", ".", "_media_image_url", "or", "None" ]
[ 1008, 4 ]
[ 1010, 44 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_channel
(self)
Channel currently playing.
Channel currently playing.
def media_channel(self): """Channel currently playing.""" return self._media_channel or None
[ "def", "media_channel", "(", "self", ")", ":", "return", "self", ".", "_media_channel", "or", "None" ]
[ 1014, 4 ]
[ 1016, 42 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_artist
(self)
Artist of current playing media, music track only.
Artist of current playing media, music track only.
def media_artist(self): """Artist of current playing media, music track only.""" return self._media_artist or None
[ "def", "media_artist", "(", "self", ")", ":", "return", "self", ".", "_media_artist", "or", "None" ]
[ 1020, 4 ]
[ 1022, 41 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_album_name
(self)
Album name of current playing media, music track only.
Album name of current playing media, music track only.
def media_album_name(self): """Album name of current playing media, music track only.""" return self._media_album_name or None
[ "def", "media_album_name", "(", "self", ")", ":", "return", "self", ".", "_media_album_name", "or", "None" ]
[ 1026, 4 ]
[ 1028, 45 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" return self._media_title or None
[ "def", "media_title", "(", "self", ")", ":", "return", "self", ".", "_media_title", "or", "None" ]
[ 1032, 4 ]
[ 1034, 40 ]
python
en
['en', 'en', 'en']
True
SonosEntity.queue_position
(self)
If playing local queue return the position in the queue else None.
If playing local queue return the position in the queue else None.
def queue_position(self): """If playing local queue return the position in the queue else None.""" if self._is_playing_local_queue: return self._queue_position return None
[ "def", "queue_position", "(", "self", ")", ":", "if", "self", ".", "_is_playing_local_queue", ":", "return", "self", ".", "_queue_position", "return", "None" ]
[ 1038, 4 ]
[ 1043, 19 ]
python
en
['en', 'en', 'en']
True
SonosEntity.source
(self)
Name of the current input source.
Name of the current input source.
def source(self): """Name of the current input source.""" return self._source_name or None
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_source_name", "or", "None" ]
[ 1047, 4 ]
[ 1049, 40 ]
python
en
['en', 'en', 'en']
True
SonosEntity.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_SONOS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_SONOS" ]
[ 1053, 4 ]
[ 1055, 28 ]
python
en
['en', 'en', 'en']
True
SonosEntity.volume_up
(self)
Volume up media player.
Volume up media player.
def volume_up(self): """Volume up media player.""" self._player.volume += self._volume_increment
[ "def", "volume_up", "(", "self", ")", ":", "self", ".", "_player", ".", "volume", "+=", "self", ".", "_volume_increment" ]
[ 1058, 4 ]
[ 1060, 53 ]
python
en
['en', 'no', 'en']
True
SonosEntity.volume_down
(self)
Volume down media player.
Volume down media player.
def volume_down(self): """Volume down media player.""" self._player.volume -= self._volume_increment
[ "def", "volume_down", "(", "self", ")", ":", "self", ".", "_player", ".", "volume", "-=", "self", ".", "_volume_increment" ]
[ 1063, 4 ]
[ 1065, 53 ]
python
en
['en', 'sl', 'en']
True
SonosEntity.set_volume_level
(self, volume)
Set volume level, range 0..1.
Set volume level, range 0..1.
def set_volume_level(self, volume): """Set volume level, range 0..1.""" self.soco.volume = str(int(volume * 100))
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "self", ".", "soco", ".", "volume", "=", "str", "(", "int", "(", "volume", "*", "100", ")", ")" ]
[ 1068, 4 ]
[ 1070, 49 ]
python
en
['fr', 'zu', 'en']
False
SonosEntity.set_shuffle
(self, shuffle)
Enable/Disable shuffle mode.
Enable/Disable shuffle mode.
def set_shuffle(self, shuffle): """Enable/Disable shuffle mode.""" sonos_shuffle = shuffle sonos_repeat = PLAY_MODES[self._play_mode][1] self.soco.play_mode = PLAY_MODE_BY_MEANING[(sonos_shuffle, sonos_repeat)]
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "sonos_shuffle", "=", "shuffle", "sonos_repeat", "=", "PLAY_MODES", "[", "self", ".", "_play_mode", "]", "[", "1", "]", "self", ".", "soco", ".", "play_mode", "=", "PLAY_MODE_BY_MEANING", "[", "(...
[ 1074, 4 ]
[ 1078, 81 ]
python
en
['en', 'st', 'en']
True
SonosEntity.set_repeat
(self, repeat)
Set repeat mode.
Set repeat mode.
def set_repeat(self, repeat): """Set repeat mode.""" sonos_shuffle = PLAY_MODES[self._play_mode][0] sonos_repeat = REPEAT_TO_SONOS[repeat] self.soco.play_mode = PLAY_MODE_BY_MEANING[(sonos_shuffle, sonos_repeat)]
[ "def", "set_repeat", "(", "self", ",", "repeat", ")", ":", "sonos_shuffle", "=", "PLAY_MODES", "[", "self", ".", "_play_mode", "]", "[", "0", "]", "sonos_repeat", "=", "REPEAT_TO_SONOS", "[", "repeat", "]", "self", ".", "soco", ".", "play_mode", "=", "PL...
[ 1082, 4 ]
[ 1086, 81 ]
python
en
['en', 'id', 'en']
True
SonosEntity.mute_volume
(self, mute)
Mute (true) or unmute (false) media player.
Mute (true) or unmute (false) media player.
def mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" self.soco.mute = mute
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "self", ".", "soco", ".", "mute", "=", "mute" ]
[ 1089, 4 ]
[ 1091, 29 ]
python
en
['en', 'la', 'it']
False
SonosEntity.select_source
(self, source)
Select input source.
Select input source.
def select_source(self, source): """Select input source.""" if source == SOURCE_LINEIN: self.soco.switch_to_line_in() elif source == SOURCE_TV: self.soco.switch_to_tv() else: fav = [fav for fav in self._favorites if fav.title == source] if ...
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "if", "source", "==", "SOURCE_LINEIN", ":", "self", ".", "soco", ".", "switch_to_line_in", "(", ")", "elif", "source", "==", "SOURCE_TV", ":", "self", ".", "soco", ".", "switch_to_tv", "(", ")...
[ 1095, 4 ]
[ 1111, 48 ]
python
en
['fr', 'su', 'en']
False
SonosEntity.source_list
(self)
List of available input sources.
List of available input sources.
def source_list(self): """List of available input sources.""" sources = [fav.title for fav in self._favorites] model = self._model.upper() if "PLAY:5" in model or "CONNECT" in model: sources += [SOURCE_LINEIN] elif "PLAYBAR" in model: sources += [SOURCE_L...
[ "def", "source_list", "(", "self", ")", ":", "sources", "=", "[", "fav", ".", "title", "for", "fav", "in", "self", ".", "_favorites", "]", "model", "=", "self", ".", "_model", ".", "upper", "(", ")", "if", "\"PLAY:5\"", "in", "model", "or", "\"CONNEC...
[ 1115, 4 ]
[ 1127, 22 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_play
(self)
Send play command.
Send play command.
def media_play(self): """Send play command.""" self.soco.play()
[ "def", "media_play", "(", "self", ")", ":", "self", ".", "soco", ".", "play", "(", ")" ]
[ 1131, 4 ]
[ 1133, 24 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_stop
(self)
Send stop command.
Send stop command.
def media_stop(self): """Send stop command.""" self.soco.stop()
[ "def", "media_stop", "(", "self", ")", ":", "self", ".", "soco", ".", "stop", "(", ")" ]
[ 1137, 4 ]
[ 1139, 24 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_pause
(self)
Send pause command.
Send pause command.
def media_pause(self): """Send pause command.""" self.soco.pause()
[ "def", "media_pause", "(", "self", ")", ":", "self", ".", "soco", ".", "pause", "(", ")" ]
[ 1143, 4 ]
[ 1145, 25 ]
python
en
['en', 'en', 'en']
True
SonosEntity.media_next_track
(self)
Send next track command.
Send next track command.
def media_next_track(self): """Send next track command.""" self.soco.next()
[ "def", "media_next_track", "(", "self", ")", ":", "self", ".", "soco", ".", "next", "(", ")" ]
[ 1149, 4 ]
[ 1151, 24 ]
python
en
['en', 'pt', 'en']
True
SonosEntity.media_previous_track
(self)
Send next track command.
Send next track command.
def media_previous_track(self): """Send next track command.""" self.soco.previous()
[ "def", "media_previous_track", "(", "self", ")", ":", "self", ".", "soco", ".", "previous", "(", ")" ]
[ 1155, 4 ]
[ 1157, 28 ]
python
en
['en', 'pt', 'en']
True
SonosEntity.media_seek
(self, position)
Send seek command.
Send seek command.
def media_seek(self, position): """Send seek command.""" self.soco.seek(str(datetime.timedelta(seconds=int(position))))
[ "def", "media_seek", "(", "self", ",", "position", ")", ":", "self", ".", "soco", ".", "seek", "(", "str", "(", "datetime", ".", "timedelta", "(", "seconds", "=", "int", "(", "position", ")", ")", ")", ")" ]
[ 1161, 4 ]
[ 1163, 70 ]
python
en
['en', 'ig', 'en']
True
SonosEntity.clear_playlist
(self)
Clear players playlist.
Clear players playlist.
def clear_playlist(self): """Clear players playlist.""" self.soco.clear_queue()
[ "def", "clear_playlist", "(", "self", ")", ":", "self", ".", "soco", ".", "clear_queue", "(", ")" ]
[ 1167, 4 ]
[ 1169, 31 ]
python
en
['fr', 'en', 'en']
True
SonosEntity.play_media
(self, media_type, media_id, **kwargs)
Send the play_media command to the media player. If media_type is "playlist", media_id should be a Sonos Playlist name. Otherwise, media_id should be a URI. If ATTR_MEDIA_ENQUEUE is True, add `media_id` to the queue.
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. If media_type is "playlist", media_id should be a Sonos Playlist name. Otherwise, media_id should be a URI. If ATTR_MEDIA_ENQUEUE is True, add `media_id` to the queue. ...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "if", "media_type", "in", "(", "MEDIA_TYPE_MUSIC", ",", "MEDIA_TYPE_TRACK", ")", ":", "if", "kwargs", ".", "get", "(", "ATTR_MEDIA_ENQUEUE", ")", ":", ...
[ 1173, 4 ]
[ 1225, 84 ]
python
en
['en', 'error', 'th']
False
SonosEntity.join
(self, slaves)
Form a group with other players.
Form a group with other players.
def join(self, slaves): """Form a group with other players.""" if self._coordinator: self.unjoin() group = [self] else: group = self._sonos_group.copy() for slave in slaves: if slave.unique_id != self.unique_id: slave.soco....
[ "def", "join", "(", "self", ",", "slaves", ")", ":", "if", "self", ".", "_coordinator", ":", "self", ".", "unjoin", "(", ")", "group", "=", "[", "self", "]", "else", ":", "group", "=", "self", ".", "_sonos_group", ".", "copy", "(", ")", "for", "s...
[ 1228, 4 ]
[ 1244, 20 ]
python
en
['en', 'en', 'en']
True
SonosEntity.join_multi
(hass, master, entities)
Form a group with other players.
Form a group with other players.
async def join_multi(hass, master, entities): """Form a group with other players.""" async with hass.data[DATA_SONOS].topology_condition: group = await hass.async_add_executor_job(master.join, entities) await SonosEntity.wait_for_groups(hass, [group])
[ "async", "def", "join_multi", "(", "hass", ",", "master", ",", "entities", ")", ":", "async", "with", "hass", ".", "data", "[", "DATA_SONOS", "]", ".", "topology_condition", ":", "group", "=", "await", "hass", ".", "async_add_executor_job", "(", "master", ...
[ 1247, 4 ]
[ 1251, 60 ]
python
en
['en', 'en', 'en']
True
SonosEntity.unjoin
(self)
Unjoin the player from a group.
Unjoin the player from a group.
def unjoin(self): """Unjoin the player from a group.""" self.soco.unjoin() self._coordinator = None
[ "def", "unjoin", "(", "self", ")", ":", "self", ".", "soco", ".", "unjoin", "(", ")", "self", ".", "_coordinator", "=", "None" ]
[ 1254, 4 ]
[ 1257, 32 ]
python
en
['en', 'en', 'en']
True
SonosEntity.unjoin_multi
(hass, entities)
Unjoin several players from their group.
Unjoin several players from their group.
async def unjoin_multi(hass, entities): """Unjoin several players from their group.""" def _unjoin_all(entities): """Sync helper.""" # Unjoin slaves first to prevent inheritance of queues coordinators = [e for e in entities if e.is_coordinator] slaves = [...
[ "async", "def", "unjoin_multi", "(", "hass", ",", "entities", ")", ":", "def", "_unjoin_all", "(", "entities", ")", ":", "\"\"\"Sync helper.\"\"\"", "# Unjoin slaves first to prevent inheritance of queues", "coordinators", "=", "[", "e", "for", "e", "in", "entities", ...
[ 1260, 4 ]
[ 1274, 76 ]
python
en
['en', 'en', 'en']
True
SonosEntity.snapshot
(self, with_group)
Snapshot the state of a player.
Snapshot the state of a player.
def snapshot(self, with_group): """Snapshot the state of a player.""" self._soco_snapshot = pysonos.snapshot.Snapshot(self.soco) self._soco_snapshot.snapshot() if with_group: self._snapshot_group = self._sonos_group.copy() else: self._snapshot_group = None
[ "def", "snapshot", "(", "self", ",", "with_group", ")", ":", "self", ".", "_soco_snapshot", "=", "pysonos", ".", "snapshot", ".", "Snapshot", "(", "self", ".", "soco", ")", "self", ".", "_soco_snapshot", ".", "snapshot", "(", ")", "if", "with_group", ":"...
[ 1277, 4 ]
[ 1284, 39 ]
python
en
['en', 'en', 'en']
True
SonosEntity.snapshot_multi
(hass, entities, with_group)
Snapshot all the entities and optionally their groups.
Snapshot all the entities and optionally their groups.
async def snapshot_multi(hass, entities, with_group): """Snapshot all the entities and optionally their groups.""" # pylint: disable=protected-access def _snapshot_all(entities): """Sync helper.""" for entity in entities: entity.snapshot(with_group) ...
[ "async", "def", "snapshot_multi", "(", "hass", ",", "entities", ",", "with_group", ")", ":", "# pylint: disable=protected-access", "def", "_snapshot_all", "(", "entities", ")", ":", "\"\"\"Sync helper.\"\"\"", "for", "entity", "in", "entities", ":", "entity", ".", ...
[ 1287, 4 ]
[ 1303, 70 ]
python
en
['en', 'en', 'en']
True
SonosEntity.restore
(self)
Restore a snapshotted state to a player.
Restore a snapshotted state to a player.
def restore(self): """Restore a snapshotted state to a player.""" try: self._soco_snapshot.restore() except (TypeError, AttributeError, SoCoException) as ex: # Can happen if restoring a coordinator onto a current slave _LOGGER.warning("Error on restore %s: %s"...
[ "def", "restore", "(", "self", ")", ":", "try", ":", "self", ".", "_soco_snapshot", ".", "restore", "(", ")", "except", "(", "TypeError", ",", "AttributeError", ",", "SoCoException", ")", "as", "ex", ":", "# Can happen if restoring a coordinator onto a current sla...
[ 1306, 4 ]
[ 1315, 35 ]
python
en
['en', 'en', 'en']
True
SonosEntity.restore_multi
(hass, entities, with_group)
Restore snapshots for all the entities.
Restore snapshots for all the entities.
async def restore_multi(hass, entities, with_group): """Restore snapshots for all the entities.""" # pylint: disable=protected-access def _restore_groups(entities, with_group): """Pause all current coordinators and restore groups.""" for entity in (e for e in entities if...
[ "async", "def", "restore_multi", "(", "hass", ",", "entities", ",", "with_group", ")", ":", "# pylint: disable=protected-access", "def", "_restore_groups", "(", "entities", ",", "with_group", ")", ":", "\"\"\"Pause all current coordinators and restore groups.\"\"\"", "for",...
[ 1318, 4 ]
[ 1365, 73 ]
python
en
['en', 'en', 'en']
True
SonosEntity.wait_for_groups
(hass, groups)
Wait until all groups are present, or timeout.
Wait until all groups are present, or timeout.
async def wait_for_groups(hass, groups): """Wait until all groups are present, or timeout.""" # pylint: disable=protected-access def _test_groups(groups): """Return whether all groups exist now.""" for group in groups: coordinator = group[0] ...
[ "async", "def", "wait_for_groups", "(", "hass", ",", "groups", ")", ":", "# pylint: disable=protected-access", "def", "_test_groups", "(", "groups", ")", ":", "\"\"\"Return whether all groups exist now.\"\"\"", "for", "group", "in", "groups", ":", "coordinator", "=", ...
[ 1368, 4 ]
[ 1396, 42 ]
python
en
['en', 'en', 'en']
True
SonosEntity.set_sleep_timer
(self, sleep_time)
Set the timer on the player.
Set the timer on the player.
def set_sleep_timer(self, sleep_time): """Set the timer on the player.""" self.soco.set_sleep_timer(sleep_time)
[ "def", "set_sleep_timer", "(", "self", ",", "sleep_time", ")", ":", "self", ".", "soco", ".", "set_sleep_timer", "(", "sleep_time", ")" ]
[ 1400, 4 ]
[ 1402, 45 ]
python
en
['en', 'en', 'en']
True
SonosEntity.clear_sleep_timer
(self)
Clear the timer on the player.
Clear the timer on the player.
def clear_sleep_timer(self): """Clear the timer on the player.""" self.soco.set_sleep_timer(None)
[ "def", "clear_sleep_timer", "(", "self", ")", ":", "self", ".", "soco", ".", "set_sleep_timer", "(", "None", ")" ]
[ 1406, 4 ]
[ 1408, 39 ]
python
en
['en', 'en', 'en']
True
SonosEntity.set_alarm
( self, alarm_id, time=None, volume=None, enabled=None, include_linked_zones=None )
Set the alarm clock on the player.
Set the alarm clock on the player.
def set_alarm( self, alarm_id, time=None, volume=None, enabled=None, include_linked_zones=None ): """Set the alarm clock on the player.""" alarm = None for one_alarm in alarms.get_alarms(self.soco): # pylint: disable=protected-access if one_alarm._alarm_id == ...
[ "def", "set_alarm", "(", "self", ",", "alarm_id", ",", "time", "=", "None", ",", "volume", "=", "None", ",", "enabled", "=", "None", ",", "include_linked_zones", "=", "None", ")", ":", "alarm", "=", "None", "for", "one_alarm", "in", "alarms", ".", "get...
[ 1412, 4 ]
[ 1432, 20 ]
python
en
['en', 'en', 'en']
True
SonosEntity.set_option
(self, night_sound=None, speech_enhance=None, status_light=None)
Modify playback options.
Modify playback options.
def set_option(self, night_sound=None, speech_enhance=None, status_light=None): """Modify playback options.""" if night_sound is not None and self._night_sound is not None: self.soco.night_mode = night_sound if speech_enhance is not None and self._speech_enhance is not None: ...
[ "def", "set_option", "(", "self", ",", "night_sound", "=", "None", ",", "speech_enhance", "=", "None", ",", "status_light", "=", "None", ")", ":", "if", "night_sound", "is", "not", "None", "and", "self", ".", "_night_sound", "is", "not", "None", ":", "se...
[ 1435, 4 ]
[ 1444, 49 ]
python
en
['en', 'ny', 'en']
True