Skip to content

Commit a512640

Browse files
committed
Add support for SPPATTERN SWFR CNFG commands
1 parent 1be2ff1 commit a512640

5 files changed

Lines changed: 64 additions & 2 deletions

File tree

src/ynca/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
SpeakerA,
3737
SpeakerB,
3838
SpPattern,
39+
SpPatternSwfrCnfg,
3940
Straight,
4041
SurroundAI,
4142
ThreeDeeCinema,
@@ -122,6 +123,7 @@
122123
"Sleep",
123124
"SoundPrg",
124125
"SpPattern",
126+
"SpPatternSwfrCnfg",
125127
"SpeakerA",
126128
"SpeakerB",
127129
"Spotify",

src/ynca/enums.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,20 @@ def _missing_(cls, value: object) -> Self:
555555
"""Unknown values in the enum are mapped to UNKNOWN"""
556556

557557

558+
@unique
559+
class SpPatternSwfrCnfg(StrEnum):
560+
NONE = "None"
561+
USE = "Use"
562+
563+
@classmethod
564+
def _missing_(cls, value: object) -> Self:
565+
logger.warning("Unknown value '%s' in %s", value, cls.__name__)
566+
return cls(cls.UNKNOWN)
567+
568+
UNKNOWN = UNKNOWN_STRING
569+
"""Unknown values in the enum are mapped to UNKNOWN"""
570+
571+
558572
@unique
559573
class Straight(StrEnum):
560574
ON = "On"

src/ynca/subunits/system.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from ..constants import Subunit
44
from ..converters import StrConverter
5-
from ..enums import HdmiOutOnOff, Party, PartyMute, Pwr, SpPattern
5+
from ..enums import HdmiOutOnOff, Party, PartyMute, Pwr, SpPattern, SpPatternSwfrCnfg
66
from ..function import Cmd, EnumFunctionMixin, FunctionMixinBase, StrFunctionMixin
77
from ..subunit import SubunitBase
88

@@ -45,6 +45,10 @@ class System(SubunitBase):
4545
partymute = EnumFunctionMixin[PartyMute](PartyMute, Cmd.PUT)
4646
pwr = EnumFunctionMixin[Pwr](Pwr)
4747
sppattern = EnumFunctionMixin[SpPattern](SpPattern)
48+
sppattern1swfr1cnfg = EnumFunctionMixin[SpPatternSwfrCnfg](SpPatternSwfrCnfg)
49+
sppattern1swfr2cnfg = EnumFunctionMixin[SpPatternSwfrCnfg](SpPatternSwfrCnfg)
50+
sppattern2swfr1cnfg = EnumFunctionMixin[SpPatternSwfrCnfg](SpPatternSwfrCnfg)
51+
sppattern2swfr2cnfg = EnumFunctionMixin[SpPatternSwfrCnfg](SpPatternSwfrCnfg)
4852

4953
# No_initialize VERSION to avoid it being sent during initialization
5054
# It is also used behind the scenes for syncing and would interfere

tests/test_enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
SpeakerA,
3434
SpeakerB,
3535
SpPattern,
36+
SpPatternSwfrCnfg,
3637
Straight,
3738
SurroundAI,
3839
ThreeDeeCinema,
@@ -76,6 +77,7 @@ def test_invalid_values_on_enums() -> None:
7677
assert SpeakerA("x") is SpeakerA.UNKNOWN
7778
assert SpeakerB("x") is SpeakerB.UNKNOWN
7879
assert SpPattern("x") is SpPattern.UNKNOWN
80+
assert SpPatternSwfrCnfg("x") is SpPatternSwfrCnfg.UNKNOWN
7981
assert Straight("x") is Straight.UNKNOWN
8082
assert SurroundAI("x") is SurroundAI.UNKNOWN
8183
assert ThreeDeeCinema("x") is ThreeDeeCinema.UNKNOWN

tests/test_system.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
import pytest
66

77
from tests.mock_yncaconnection import YncaConnectionMock
8-
from ynca import HdmiOutOnOff, Party, PartyMute, Pwr, SpPattern, System
8+
from ynca import (
9+
HdmiOutOnOff,
10+
Party,
11+
PartyMute,
12+
Pwr,
13+
SpPattern,
14+
SpPatternSwfrCnfg,
15+
System,
16+
)
917

1018
SYS = "SYS"
1119

@@ -86,6 +94,30 @@
8694
(SYS, "SPPATTERN", "Pattern 2"),
8795
],
8896
),
97+
(
98+
(SYS, "SPPATTERN1SWFR1CNFG"),
99+
[
100+
(SYS, "SPPATTERN1SWFR1CNFG", "Use"),
101+
],
102+
),
103+
(
104+
(SYS, "SPPATTERN1SWFR2CNFG"),
105+
[
106+
(SYS, "SPPATTERN1SWFR2CNFG", "None"),
107+
],
108+
),
109+
(
110+
(SYS, "SPPATTERN2SWFR1CNFG"),
111+
[
112+
(SYS, "SPPATTERN2SWFR1CNFG", "Use"),
113+
],
114+
),
115+
(
116+
(SYS, "SPPATTERN2SWFR2CNFG"),
117+
[
118+
(SYS, "SPPATTERN2SWFR2CNFG", "None"),
119+
],
120+
),
89121
(
90122
(SYS, "VERSION"),
91123
[
@@ -164,6 +196,10 @@ def test_initialize_minimal(
164196
assert s.pwr is None
165197
assert s.party is None
166198
assert s.sppattern is None
199+
assert s.sppattern1swfr1cnfg is None
200+
assert s.sppattern1swfr2cnfg is None
201+
assert s.sppattern2swfr1cnfg is None
202+
assert s.sppattern2swfr2cnfg is None
167203

168204

169205
def test_initialize_full(
@@ -211,6 +247,10 @@ def test_initialize_full(
211247
assert s.party == Party.ON
212248
assert s.pwr == Pwr.STANDBY
213249
assert s.sppattern == SpPattern.PATTERN_2
250+
assert s.sppattern1swfr1cnfg == SpPatternSwfrCnfg.USE
251+
assert s.sppattern1swfr2cnfg == SpPatternSwfrCnfg.NONE
252+
assert s.sppattern2swfr1cnfg == SpPatternSwfrCnfg.USE
253+
assert s.sppattern2swfr2cnfg == SpPatternSwfrCnfg.NONE
214254

215255

216256
def test_hdmiout(connection: YncaConnectionMock, initialized_system: System) -> None:

0 commit comments

Comments
 (0)