2019-05-13 08:16:55 +00:00
|
|
|
"""Const for Sonos."""
|
2021-04-25 17:20:21 +00:00
|
|
|
import datetime
|
|
|
|
|
2021-04-27 14:52:05 +00:00
|
|
|
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
2021-04-25 17:20:21 +00:00
|
|
|
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
2021-02-24 19:51:12 +00:00
|
|
|
from homeassistant.components.media_player.const import (
|
|
|
|
MEDIA_CLASS_ALBUM,
|
|
|
|
MEDIA_CLASS_ARTIST,
|
|
|
|
MEDIA_CLASS_COMPOSER,
|
|
|
|
MEDIA_CLASS_CONTRIBUTING_ARTIST,
|
|
|
|
MEDIA_CLASS_GENRE,
|
|
|
|
MEDIA_CLASS_PLAYLIST,
|
|
|
|
MEDIA_CLASS_TRACK,
|
|
|
|
MEDIA_TYPE_ALBUM,
|
|
|
|
MEDIA_TYPE_ARTIST,
|
|
|
|
MEDIA_TYPE_COMPOSER,
|
|
|
|
MEDIA_TYPE_CONTRIBUTING_ARTIST,
|
|
|
|
MEDIA_TYPE_GENRE,
|
|
|
|
MEDIA_TYPE_PLAYLIST,
|
|
|
|
MEDIA_TYPE_TRACK,
|
|
|
|
)
|
2021-04-25 17:20:21 +00:00
|
|
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
2021-05-25 16:32:25 +00:00
|
|
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
2019-05-13 08:16:55 +00:00
|
|
|
|
2021-05-29 13:31:22 +00:00
|
|
|
UPNP_ST = "urn:schemas-upnp-org:device:ZonePlayer:1"
|
|
|
|
|
2019-05-13 08:16:55 +00:00
|
|
|
DOMAIN = "sonos"
|
2020-05-27 22:36:08 +00:00
|
|
|
DATA_SONOS = "sonos_media_player"
|
2021-05-25 16:32:25 +00:00
|
|
|
PLATFORMS = {BINARY_SENSOR_DOMAIN, MP_DOMAIN, SENSOR_DOMAIN, SWITCH_DOMAIN}
|
2020-09-02 08:57:12 +00:00
|
|
|
|
|
|
|
SONOS_ARTIST = "artists"
|
|
|
|
SONOS_ALBUM = "albums"
|
|
|
|
SONOS_PLAYLISTS = "playlists"
|
|
|
|
SONOS_GENRE = "genres"
|
|
|
|
SONOS_ALBUM_ARTIST = "album_artists"
|
|
|
|
SONOS_TRACKS = "tracks"
|
|
|
|
SONOS_COMPOSER = "composers"
|
2021-02-24 19:51:12 +00:00
|
|
|
|
2021-05-11 21:06:51 +00:00
|
|
|
SONOS_STATE_PLAYING = "PLAYING"
|
|
|
|
SONOS_STATE_TRANSITIONING = "TRANSITIONING"
|
|
|
|
|
2021-02-24 19:51:12 +00:00
|
|
|
EXPANDABLE_MEDIA_TYPES = [
|
|
|
|
MEDIA_TYPE_ALBUM,
|
|
|
|
MEDIA_TYPE_ARTIST,
|
|
|
|
MEDIA_TYPE_COMPOSER,
|
|
|
|
MEDIA_TYPE_GENRE,
|
|
|
|
MEDIA_TYPE_PLAYLIST,
|
|
|
|
SONOS_ALBUM,
|
|
|
|
SONOS_ALBUM_ARTIST,
|
|
|
|
SONOS_ARTIST,
|
|
|
|
SONOS_GENRE,
|
|
|
|
SONOS_COMPOSER,
|
|
|
|
SONOS_PLAYLISTS,
|
|
|
|
]
|
|
|
|
|
|
|
|
SONOS_TO_MEDIA_CLASSES = {
|
|
|
|
SONOS_ALBUM: MEDIA_CLASS_ALBUM,
|
|
|
|
SONOS_ALBUM_ARTIST: MEDIA_CLASS_ARTIST,
|
|
|
|
SONOS_ARTIST: MEDIA_CLASS_CONTRIBUTING_ARTIST,
|
|
|
|
SONOS_COMPOSER: MEDIA_CLASS_COMPOSER,
|
|
|
|
SONOS_GENRE: MEDIA_CLASS_GENRE,
|
|
|
|
SONOS_PLAYLISTS: MEDIA_CLASS_PLAYLIST,
|
|
|
|
SONOS_TRACKS: MEDIA_CLASS_TRACK,
|
|
|
|
"object.container.album.musicAlbum": MEDIA_CLASS_ALBUM,
|
|
|
|
"object.container.genre.musicGenre": MEDIA_CLASS_PLAYLIST,
|
|
|
|
"object.container.person.composer": MEDIA_CLASS_PLAYLIST,
|
|
|
|
"object.container.person.musicArtist": MEDIA_CLASS_ARTIST,
|
|
|
|
"object.container.playlistContainer.sameArtist": MEDIA_CLASS_ARTIST,
|
|
|
|
"object.container.playlistContainer": MEDIA_CLASS_PLAYLIST,
|
|
|
|
"object.item.audioItem.musicTrack": MEDIA_CLASS_TRACK,
|
|
|
|
}
|
|
|
|
|
|
|
|
SONOS_TO_MEDIA_TYPES = {
|
|
|
|
SONOS_ALBUM: MEDIA_TYPE_ALBUM,
|
|
|
|
SONOS_ALBUM_ARTIST: MEDIA_TYPE_ARTIST,
|
|
|
|
SONOS_ARTIST: MEDIA_TYPE_CONTRIBUTING_ARTIST,
|
|
|
|
SONOS_COMPOSER: MEDIA_TYPE_COMPOSER,
|
|
|
|
SONOS_GENRE: MEDIA_TYPE_GENRE,
|
|
|
|
SONOS_PLAYLISTS: MEDIA_TYPE_PLAYLIST,
|
|
|
|
SONOS_TRACKS: MEDIA_TYPE_TRACK,
|
|
|
|
"object.container.album.musicAlbum": MEDIA_TYPE_ALBUM,
|
|
|
|
"object.container.genre.musicGenre": MEDIA_TYPE_PLAYLIST,
|
|
|
|
"object.container.person.composer": MEDIA_TYPE_PLAYLIST,
|
|
|
|
"object.container.person.musicArtist": MEDIA_TYPE_ARTIST,
|
|
|
|
"object.container.playlistContainer.sameArtist": MEDIA_TYPE_ARTIST,
|
|
|
|
"object.container.playlistContainer": MEDIA_TYPE_PLAYLIST,
|
|
|
|
"object.item.audioItem.musicTrack": MEDIA_TYPE_TRACK,
|
|
|
|
}
|
|
|
|
|
|
|
|
MEDIA_TYPES_TO_SONOS = {
|
|
|
|
MEDIA_TYPE_ALBUM: SONOS_ALBUM,
|
|
|
|
MEDIA_TYPE_ARTIST: SONOS_ALBUM_ARTIST,
|
|
|
|
MEDIA_TYPE_CONTRIBUTING_ARTIST: SONOS_ARTIST,
|
|
|
|
MEDIA_TYPE_COMPOSER: SONOS_COMPOSER,
|
|
|
|
MEDIA_TYPE_GENRE: SONOS_GENRE,
|
|
|
|
MEDIA_TYPE_PLAYLIST: SONOS_PLAYLISTS,
|
|
|
|
MEDIA_TYPE_TRACK: SONOS_TRACKS,
|
|
|
|
}
|
|
|
|
|
|
|
|
SONOS_TYPES_MAPPING = {
|
|
|
|
"A:ALBUM": SONOS_ALBUM,
|
|
|
|
"A:ALBUMARTIST": SONOS_ALBUM_ARTIST,
|
|
|
|
"A:ARTIST": SONOS_ARTIST,
|
|
|
|
"A:COMPOSER": SONOS_COMPOSER,
|
|
|
|
"A:GENRE": SONOS_GENRE,
|
|
|
|
"A:PLAYLISTS": SONOS_PLAYLISTS,
|
|
|
|
"A:TRACKS": SONOS_TRACKS,
|
|
|
|
"object.container.album.musicAlbum": SONOS_ALBUM,
|
|
|
|
"object.container.genre.musicGenre": SONOS_GENRE,
|
|
|
|
"object.container.person.composer": SONOS_COMPOSER,
|
|
|
|
"object.container.person.musicArtist": SONOS_ALBUM_ARTIST,
|
|
|
|
"object.container.playlistContainer.sameArtist": SONOS_ARTIST,
|
|
|
|
"object.container.playlistContainer": SONOS_PLAYLISTS,
|
|
|
|
"object.item.audioItem.musicTrack": SONOS_TRACKS,
|
|
|
|
}
|
|
|
|
|
|
|
|
LIBRARY_TITLES_MAPPING = {
|
|
|
|
"A:ALBUM": "Albums",
|
|
|
|
"A:ALBUMARTIST": "Artists",
|
|
|
|
"A:ARTIST": "Contributing Artists",
|
|
|
|
"A:COMPOSER": "Composers",
|
|
|
|
"A:GENRE": "Genres",
|
|
|
|
"A:PLAYLISTS": "Playlists",
|
|
|
|
"A:TRACKS": "Tracks",
|
|
|
|
}
|
|
|
|
|
|
|
|
PLAYABLE_MEDIA_TYPES = [
|
|
|
|
MEDIA_TYPE_ALBUM,
|
|
|
|
MEDIA_TYPE_ARTIST,
|
|
|
|
MEDIA_TYPE_COMPOSER,
|
|
|
|
MEDIA_TYPE_CONTRIBUTING_ARTIST,
|
|
|
|
MEDIA_TYPE_GENRE,
|
|
|
|
MEDIA_TYPE_PLAYLIST,
|
|
|
|
MEDIA_TYPE_TRACK,
|
|
|
|
]
|
2021-04-25 17:20:21 +00:00
|
|
|
|
2021-05-25 16:32:25 +00:00
|
|
|
SONOS_CREATE_ALARM = "sonos_create_alarm"
|
2021-04-27 14:52:05 +00:00
|
|
|
SONOS_CREATE_BATTERY = "sonos_create_battery"
|
|
|
|
SONOS_CREATE_MEDIA_PLAYER = "sonos_create_media_player"
|
2021-04-25 17:20:21 +00:00
|
|
|
SONOS_ENTITY_CREATED = "sonos_entity_created"
|
2021-05-28 10:07:58 +00:00
|
|
|
SONOS_POLL_UPDATE = "sonos_poll_update"
|
2021-04-25 17:20:21 +00:00
|
|
|
SONOS_GROUP_UPDATE = "sonos_group_update"
|
2021-06-16 15:30:05 +00:00
|
|
|
SONOS_ALARMS_UPDATED = "sonos_alarms_updated"
|
|
|
|
SONOS_FAVORITES_UPDATED = "sonos_favorites_updated"
|
2021-04-25 17:20:21 +00:00
|
|
|
SONOS_STATE_UPDATED = "sonos_state_updated"
|
2021-06-08 01:51:42 +00:00
|
|
|
SONOS_REBOOTED = "sonos_rebooted"
|
2021-04-25 17:20:21 +00:00
|
|
|
SONOS_SEEN = "sonos_seen"
|
|
|
|
|
2021-05-11 17:36:40 +00:00
|
|
|
SOURCE_LINEIN = "Line-in"
|
|
|
|
SOURCE_TV = "TV"
|
|
|
|
|
2021-04-25 17:20:21 +00:00
|
|
|
BATTERY_SCAN_INTERVAL = datetime.timedelta(minutes=15)
|
|
|
|
SCAN_INTERVAL = datetime.timedelta(seconds=10)
|
|
|
|
DISCOVERY_INTERVAL = datetime.timedelta(seconds=60)
|
|
|
|
SEEN_EXPIRE_TIME = 3.5 * DISCOVERY_INTERVAL
|
2021-05-17 22:26:48 +00:00
|
|
|
SUBSCRIPTION_TIMEOUT = 1200
|