Skip to content

Commit

Permalink
feat: change to websocket method
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhusby committed Sep 9, 2024
1 parent 3c34f18 commit 8a38f38
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 134 deletions.
3 changes: 3 additions & 0 deletions aiostreammagic/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import logging

_LOGGER = logging.getLogger(__package__)
9 changes: 9 additions & 0 deletions aiostreammagic/endpoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""List of endpoints for the StreamMagic API."""

INFO = "/system/info"
SOURCES = "/system/sources"
ZONE_STATE = "/zone/state"
PLAY_STATE = "/zone/play_state"
UPDATE = "/system/update"
POSITION = "/zone/play_state/position"
NOW_PLAYING = "/zone/now_playing"
23 changes: 12 additions & 11 deletions aiostreammagic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ class State(DataClassORJSONMixin):
volume_percent: int = field(metadata=field_options(alias="volume_percent"), default=None)
mute: bool = field(metadata=field_options(alias="mute"), default=False)

@dataclass
class PlayState(DataClassORJSONMixin):
"""Data class representing StreamMagic play state."""

state: str = field(metadata=field_options(alias="state"))
presettable: bool = field(metadata=field_options(alias="presettable"))
metadata: PlayStateMetadata = field(metadata=field_options(alias="metadata"))
position: int = field(metadata=field_options(alias="position"), default=None)
mode_repeat: str = field(metadata=field_options(alias="mode_repeat"), default="off")
mode_shuffle: str = field(metadata=field_options(alias="mode_shuffle"), default="off")


@dataclass
class PlayStateMetadata(DataClassORJSONMixin):
Expand All @@ -80,3 +69,15 @@ class PlayStateMetadata(DataClassORJSONMixin):
artist: str | None = field(metadata=field_options(alias="artist"), default=None)
station: str | None = field(metadata=field_options(alias="station"), default=None)
album: str | None = field(metadata=field_options(alias="album"), default=None)


@dataclass
class PlayState(DataClassORJSONMixin):
"""Data class representing StreamMagic play state."""

state: str = field(metadata=field_options(alias="state"), default="not_ready")
metadata: PlayStateMetadata = field(metadata=field_options(alias="metadata"), default=PlayStateMetadata())
presettable: bool = field(metadata=field_options(alias="presettable"), default=False)
position: int = field(metadata=field_options(alias="position"), default=None)
mode_repeat: str = field(metadata=field_options(alias="mode_repeat"), default="off")
mode_shuffle: str = field(metadata=field_options(alias="mode_shuffle"), default="off")
Loading

0 comments on commit 8a38f38

Please sign in to comment.