ha-core/homeassistant/components/forked_daapd/const.py

86 lines
2.6 KiB
Python
Raw Normal View History

Add forked_daapd integration (#31953) * New forked_daapd component * Bunch of changes Add config flow and zeroconf Add zones on callback when added by server Add password auth Add async_play_media for TTS Add media_image_url Add support for pipe control/input from librespot-java Improve update callbacks * Refactor as per code review suggestions Move config_flow connection testing to pypi library (v0.1.4) Remove use of ForkedDaapdData class Decouple Master and Zone data and functions Add updater class to manage websocket and entity updates * More changes as per code review Avoid direct access to entities in tests Bump pypi version Mark entities unavailable when websocket disconnected Move config tests to test_config_flow Move full url creation from media_image_url to library Move updater entity from master to hass.data Remove default unmute volume option Remove name from config_flow Remove storage of entities in hass.data Use async_write_ha_state Use signal to trigger update_options Use unittest.mock instead of asynctest.mock * Yet more changes as per code review Add more assertions in tests Avoid patching asyncio Make off state require player state stopped Only send update to existing zones Split up some tests Use events instead of async_block_till_done Use sets instead of lists where applicable Wait for pause callback before continuing TTS * Remove unnecessary use of Future() * Add pipes and playlists as sources * Add support for multiple servers Change config options to add max_playlists+remove use_pipe_control Create Machine ID in test_connection and also get from zeroconf Modify hass.data storage Update host for known configurations Use Machine ID in unique_ids, entity names, config title, signals * Use entry_id as basis for multiple entries * Use f-strings and str.format, abort for same host * Clean up check for same host
2020-05-13 15:13:41 +02:00
"""Const for forked-daapd."""
from homeassistant.components.media_player.const import (
SUPPORT_CLEAR_PLAYLIST,
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SEEK,
SUPPORT_SELECT_SOURCE,
SUPPORT_SHUFFLE_SET,
SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
)
CALLBACK_TIMEOUT = 8 # max time between command and callback from forked-daapd server
CONF_LIBRESPOT_JAVA_PORT = "librespot_java_port"
CONF_MAX_PLAYLISTS = "max_playlists"
CONF_TTS_PAUSE_TIME = "tts_pause_time"
CONF_TTS_VOLUME = "tts_volume"
DEFAULT_PORT = 3689
DEFAULT_SERVER_NAME = "My Server"
DEFAULT_TTS_PAUSE_TIME = 1.2
DEFAULT_TTS_VOLUME = 0.8
DEFAULT_UNMUTE_VOLUME = 0.6
DOMAIN = "forked_daapd" # key for hass.data
FD_NAME = "forked-daapd"
HASS_DATA_REMOVE_LISTENERS_KEY = "REMOVE_LISTENERS"
HASS_DATA_UPDATER_KEY = "UPDATER"
KNOWN_PIPES = {"librespot-java"}
PIPE_FUNCTION_MAP = {
"librespot-java": {
"async_media_play": "player_resume",
"async_media_pause": "player_pause",
"async_media_stop": "player_pause",
"async_media_previous_track": "player_prev",
"async_media_next_track": "player_next",
}
}
SIGNAL_ADD_ZONES = "forked-daapd_add_zones {}"
SIGNAL_CONFIG_OPTIONS_UPDATE = "forked-daapd_config_options_update {}"
SIGNAL_UPDATE_DATABASE = "forked-daapd_update_database {}"
SIGNAL_UPDATE_MASTER = "forked-daapd_update_master {}"
SIGNAL_UPDATE_OUTPUTS = "forked-daapd_update_outputs {}"
SIGNAL_UPDATE_PLAYER = "forked-daapd_update_player {}"
SIGNAL_UPDATE_QUEUE = "forked-daapd_update_queue {}"
SOURCE_NAME_CLEAR = "Clear queue"
SOURCE_NAME_DEFAULT = "Default (no pipe)"
STARTUP_DATA = {
"player": {
"state": "stop",
"repeat": "off",
"consume": False,
"shuffle": False,
"volume": 0,
"item_id": 0,
"item_length_ms": 0,
"item_progress_ms": 0,
},
"queue": {"version": 0, "count": 0, "items": []},
"outputs": [],
}
SUPPORTED_FEATURES = (
SUPPORT_PLAY
| SUPPORT_PAUSE
| SUPPORT_STOP
| SUPPORT_SEEK
| SUPPORT_VOLUME_SET
| SUPPORT_VOLUME_MUTE
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK
| SUPPORT_CLEAR_PLAYLIST
| SUPPORT_SELECT_SOURCE
| SUPPORT_SHUFFLE_SET
| SUPPORT_TURN_ON
| SUPPORT_TURN_OFF
| SUPPORT_PLAY_MEDIA
)
SUPPORTED_FEATURES_ZONE = (
SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | SUPPORT_TURN_ON | SUPPORT_TURN_OFF
)
TTS_TIMEOUT = 20 # max time to wait between TTS getting sent and starting to play