music-assistant-server

1.2 KBPY
constants.py
1.2 KB51 lines • python
1"""Constants for the Home Assistant provider."""
2
3from __future__ import annotations
4
5from enum import IntFlag
6
7from music_assistant_models.enums import PlaybackState
8
9
10class MediaPlayerEntityFeature(IntFlag):
11    """Supported features of the media player entity."""
12
13    PAUSE = 1
14    SEEK = 2
15    VOLUME_SET = 4
16    VOLUME_MUTE = 8
17    PREVIOUS_TRACK = 16
18    NEXT_TRACK = 32
19
20    TURN_ON = 128
21    TURN_OFF = 256
22    PLAY_MEDIA = 512
23    VOLUME_STEP = 1024
24    SELECT_SOURCE = 2048
25    STOP = 4096
26    CLEAR_PLAYLIST = 8192
27    PLAY = 16384
28    SHUFFLE_SET = 32768
29    SELECT_SOUND_MODE = 65536
30    BROWSE_MEDIA = 131072
31    REPEAT_SET = 262144
32    GROUPING = 524288
33    MEDIA_ANNOUNCE = 1048576
34    MEDIA_ENQUEUE = 2097152
35
36
37StateMap = {
38    "playing": PlaybackState.PLAYING,
39    "paused": PlaybackState.PAUSED,
40    "buffering": PlaybackState.PLAYING,
41    "idle": PlaybackState.IDLE,
42    "off": PlaybackState.IDLE,
43    "standby": PlaybackState.IDLE,
44    "unknown": PlaybackState.IDLE,
45    "unavailable": PlaybackState.IDLE,
46}
47
48# HA states that we consider as "powered off"
49OFF_STATES = ("unavailable", "unknown", "standby", "off")
50UNAVAILABLE_STATES = ("unavailable", "unknown")
51