Skip to content

Commit

Permalink
Update from running pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Archibald committed Sep 26, 2024
1 parent 4490bdb commit 070a719
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions aiorussound/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .models import Source, RussoundMessage, Zone, Favorite
from .rio import Controller, RussoundClient


__all__ = [
"RussoundError",
"CommandError",
Expand Down
1 change: 1 addition & 0 deletions aiorussound/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from enum import Enum
import re


MINIMUM_API_SUPPORT = "1.05.00"

DEFAULT_PORT = 9621
Expand Down
3 changes: 2 additions & 1 deletion aiorussound/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Favorite:
provider_mode: str
album_cover_url: str
source_id: int



@dataclass
class Zone(DataClassORJSONMixin):
"""Data class representing Russound state."""
Expand Down
26 changes: 19 additions & 7 deletions aiorussound/rio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dataclasses import field, dataclass
from typing import Any, Coroutine, Optional


from aiorussound.connection import RussoundConnectionHandler
from aiorussound.const import (
FLAGS_BY_VERSION,
Expand Down Expand Up @@ -403,7 +404,6 @@ def supported_features(self) -> list[FeatureFlag]:
flags.append(flag)
return flags


async def enumerate_system_favorites(self) -> list[Favorite]:
"""Return a list of Favorite for this system."""
favorites = []
Expand Down Expand Up @@ -448,7 +448,7 @@ async def _get_system_favorite_variable(self, favorite_id, variable) -> str:
return await self.get_variable(
SYSTEM_KEY, f"favorite[{favorite_id}].{variable}"
)
except UncachedVariableError:
except RussoundError:
return "False"


Expand Down Expand Up @@ -532,13 +532,24 @@ async def enumerate_favorites(self) -> list[Favorite]:
if max_zone_favorites > 0:
for favorite_id in range(1, max_zone_favorites):
try:
valid = await self.client.get_variable(self.device_str, f"favorite[{favorite_id}].valid")
valid = await self.client.get_variable(
self.device_str, f"favorite[{favorite_id}].valid"
)
if valid == "TRUE":
try:
name = await self.client.get_variable(self.device_str, f"favorite[{favorite_id}].name")
providerMode = await self.client.get_variable(self.device_str, f"favorite[{favorite_id}].providerMode")
albumCoverURL = await self.client.get_variable(self.device_str, f"favorite[{favorite_id}].albumCoverURL")
source_id = await self.client.get_variable(self.device_str, f"favorite[{favorite_id}].source")
name = await self.client.get_variable(
self.device_str, f"favorite[{favorite_id}].name"
)
providerMode = await self.client.get_variable(
self.device_str, f"favorite[{favorite_id}].providerMode"
)
albumCoverURL = await self.client.get_variable(
self.device_str,
f"favorite[{favorite_id}].albumCoverURL",
)
source_id = await self.client.get_variable(
self.device_str, f"favorite[{favorite_id}].source"
)

favorites.append(
Favorite(
Expand All @@ -556,6 +567,7 @@ async def enumerate_favorites(self) -> list[Favorite]:
continue
return favorites


@dataclass
class Controller:
"""Data class representing a Russound controller."""
Expand Down
13 changes: 11 additions & 2 deletions aiorussound/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def is_fw_version_higher(fw_a: str, fw_b: str) -> bool:
or (a_major == b_major and a_minor == b_minor and a_patch >= b_patch)
)


def controller_device_str(controller_id: int) -> str:
"""Return a string representation of the specified controller device."""
return f"C[{controller_id}]"
Expand All @@ -72,13 +73,21 @@ def get_max_zones(model: str) -> int:

def get_max_zones_favorites(model: str) -> int:
"""Return a maximum number of zones favorites supported by a specific controller."""
if model in ("MCA-88", "MCA-88X", "MCA-C5", "MCA-66", "MCA-C3", "MBX-AMP", "MBX-PRE"):
if model in (
"MCA-88",
"MCA-88X",
"MCA-C5",
"MCA-66",
"MCA-C3",
"MBX-AMP",
"MBX-PRE",
):
return 4
if model in ("XSource", "XZone4", "XZone70V"):
return 2
return 0


def is_rnet_capable(model: str) -> bool:
"""Return whether a controller is rnet capable."""
return model in ("MCA-88X", "MCA-88", "MCA-66", "MCA-C5", "MCA-C3")
Expand Down

0 comments on commit 070a719

Please sign in to comment.