|
3 | 3 | import logging |
4 | 4 | from typing import Awaitable, Callable |
5 | 5 |
|
| 6 | +from anthemav.device_error import DeviceError |
| 7 | + |
6 | 8 | __all__ = ["AVR"] |
7 | 9 |
|
8 | 10 | # These properties apply even when the AVR is powered off |
|
144 | 146 | } |
145 | 147 |
|
146 | 148 | # MRX 540, 740, 1140 |
| 149 | +LOOKUP["Z1PVOL"] = {"description": "Zone 1 Volume"} |
147 | 150 | LOOKUP["WMAC"] = {"description": "Wi-Fi MAC address"} |
148 | 151 | LOOKUP["EMAC"] = {"description": "Ethernet MAC address"} |
149 | 152 | LOOKUP["IS1ARC"] = {"description": "Zone 1 ARC", "0": "Off", "1": "On"} |
|
156 | 159 | } |
157 | 160 |
|
158 | 161 | COMMANDS_X20 = ["IDN", "ECH", "SIP", "Z1ARC", "FPB"] |
159 | | -COMMANDS_X40 = ["WMAC", "EMAC", "IS1ARC", "GCFPB", "GCTXS"] |
| 162 | +COMMANDS_X40 = ["Z1PVOL", "WMAC", "EMAC", "IS1ARC", "GCFPB", "GCTXS"] |
160 | 163 |
|
161 | 164 | EMPTY_MAC = "00:00:00:00:00:00" |
| 165 | +UNKNOWN_MODEL = "Unknown Model" |
162 | 166 |
|
163 | 167 |
|
164 | 168 | # pylint: disable=too-many-instance-attributes, too-many-public-methods |
@@ -212,7 +216,14 @@ def __init__( |
212 | 216 |
|
213 | 217 | async def wait_for_device_initialised(self, timeout: float): |
214 | 218 | """Wait to receive the model and mac address for the device""" |
215 | | - await asyncio.wait_for(self._deviceinfo_received.wait(), timeout) |
| 219 | + try: |
| 220 | + await asyncio.wait_for(self._deviceinfo_received.wait(), timeout) |
| 221 | + except asyncio.TimeoutError: |
| 222 | + raise DeviceError |
| 223 | + |
| 224 | + if self.macaddress == EMPTY_MAC or self.model == UNKNOWN_MODEL: |
| 225 | + raise DeviceError |
| 226 | + |
216 | 227 | self.log.debug("device is initialised") |
217 | 228 |
|
218 | 229 | def _set_device_initialised(self): |
@@ -648,12 +659,18 @@ def volume(self): |
648 | 659 | >>> volvalue = volume |
649 | 660 | >>> volume = 20 |
650 | 661 | """ |
651 | | - return self.attenuation_to_volume(self.attenuation) |
| 662 | + if self._model_series == "x40" and self._Z1PVOL: |
| 663 | + return int(self._Z1PVOL) |
| 664 | + else: |
| 665 | + return self.attenuation_to_volume(self.attenuation) |
652 | 666 |
|
653 | 667 | @volume.setter |
654 | 668 | def volume(self, value): |
655 | 669 | if isinstance(value, int) and 0 <= value <= 100: |
656 | | - self.attenuation = self.volume_to_attenuation(value) |
| 670 | + if self._model_series == "x40": |
| 671 | + self.command(f"Z1PVOL{value}") |
| 672 | + else: |
| 673 | + self.attenuation = self.volume_to_attenuation(value) |
657 | 674 |
|
658 | 675 | @property |
659 | 676 | def volume_as_percentage(self): |
@@ -782,7 +799,7 @@ def mute(self, value): |
782 | 799 | @property |
783 | 800 | def model(self): |
784 | 801 | """Device Model Name (read-only).""" |
785 | | - return self._IDM or "Unknown Model" |
| 802 | + return self._IDM or UNKNOWN_MODEL |
786 | 803 |
|
787 | 804 | @property |
788 | 805 | def swversion(self): |
|
0 commit comments