Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@ repos:
- id: black
language_version: python3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort

#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.740
# hooks:
# - id: mypy
# args: [--no-strict-optional, --ignore-missing-imports]
4,016 changes: 2,100 additions & 1,916 deletions devinfos/HT-XT3.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ aiohttp
click
async_upnp_client
attrs
pre-commit
1 change: 1 addition & 0 deletions songpal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# flake8: noqa
from songpal.common import SongpalException
from songpal.discovery import Discover
from songpal.device import Device
from songpal.notification import (
Notification,
Expand Down
26 changes: 18 additions & 8 deletions songpal/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class Scheme:
make = classmethod(make)

scheme = attr.ib()
sources_getter = attr.ib()

async def get_sources(self):
return [Source.make(**x) for x in self.sources_getter(scheme=self.scheme)]

@attr.s
class PlaybackFunction:
Expand Down Expand Up @@ -230,6 +233,11 @@ class SoftwareUpdateInfo:
target = attr.ib()
updatableVersion = attr.ib()
forcedUpdate = attr.ib(converter=convert_to_bool)
service = attr.ib()

async def update(self):
return await self.service["actSWUpdate"]()



@attr.s
Expand Down Expand Up @@ -259,7 +267,7 @@ class Volume:
"""Volume information."""
make = classmethod(make)

services = attr.ib(repr=False)
service = attr.ib(repr=False)
maxVolume = attr.ib()
minVolume = attr.ib()
mute = attr.ib()
Expand Down Expand Up @@ -287,19 +295,19 @@ async def set_mute(self, activate: bool):
if activate:
enabled = "on"

return await self.services["audio"]["setAudioMute"](
return await self.service["setAudioMute"](
mute=enabled, output=self.output
)

async def toggle_mute(self):
"""Toggle mute."""
return await self.services["audio"]["setAudioMute"](
return await self.service["setAudioMute"](
mute="toggle", output=self.output
)

async def set_volume(self, volume: int):
"""Set volume level."""
return await self.services["audio"]["setAudioVolume"](
return await self.service["setAudioVolume"](
volume=str(volume), output=self.output
)

Expand Down Expand Up @@ -338,7 +346,7 @@ class Zone:
title = attr.ib(converter=convert_title)
uri = attr.ib()

services = attr.ib(repr=False)
service = attr.ib(repr=False)
active = attr.ib(converter=convert_is_active)
label = attr.ib()
iconUrl = attr.ib()
Expand All @@ -351,7 +359,7 @@ def __str__(self):

async def activate(self, activate):
"""Activate this zone."""
return await self.services["avContent"]["setActiveTerminal"](active='active' if activate else 'inactive', uri=self.uri)
return await self["setActiveTerminal"](active='active' if activate else 'inactive', uri=self.uri)


@attr.s
Expand All @@ -364,7 +372,7 @@ class Input:
title = attr.ib(converter=convert_title)
uri = attr.ib()

services = attr.ib(repr=False)
service = attr.ib(repr=False)
active = attr.ib(converter=convert_is_active)
label = attr.ib()
iconUrl = attr.ib()
Expand All @@ -379,7 +387,7 @@ def __str__(self):
async def activate(self, output: Zone=None):
"""Activate this input."""
output_uri = output.uri if output else ""
return await self.services["avContent"]["setPlayContent"](uri=self.uri, output=output_uri)
return await self["setPlayContent"](uri=self.uri, output=output_uri)


@attr.s
Expand Down Expand Up @@ -509,3 +517,5 @@ def _create_candidates(x):
titleTextID = attr.ib()
deviceUIInfo = attr.ib()
uri = attr.ib()
setter = attr.ib()
value = attr.ib()
Loading