denonavr 0.11.3__py3-none-any.whl → 0.11.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
denonavr/tonecontrol.py CHANGED
@@ -9,7 +9,8 @@ This module implements the handler for state of Denon AVR receivers.
9
9
 
10
10
  import logging
11
11
  import time
12
- from typing import Hashable, Optional
12
+ from collections.abc import Hashable
13
+ from typing import Optional
13
14
 
14
15
  import attr
15
16
 
@@ -68,14 +69,14 @@ class DenonAVRToneControl(DenonAVRFoundation):
68
69
  return
69
70
 
70
71
  if parameter[0:3] == "BAS":
71
- self._bass = int(parameter[4:])
72
- self._bass_level = "{}dB".format(self._bass - 50)
72
+ self._bass = int(parameter[4:]) - 44
73
+ self._bass_level = f"{int(parameter[4:]) - 50}dB"
73
74
  elif parameter[0:3] == "TRE":
74
- self._treble = int(parameter[4:])
75
- self._treble_level = "{}dB".format(self._treble - 50)
75
+ self._treble = int(parameter[4:]) - 44
76
+ self._treble_level = f"{int(parameter[4:]) - 50}dB"
76
77
  elif parameter == "TONE CTRL OFF":
77
78
  self._tone_control_adjust = False
78
- self._tone_control_status = False
79
+ self._tone_control_status = True
79
80
  elif parameter == "TONE CTRL ON":
80
81
  self._tone_control_adjust = True
81
82
  self._tone_control_status = True
@@ -128,6 +129,16 @@ class DenonAVRToneControl(DenonAVRFoundation):
128
129
  ##############
129
130
  # Properties #
130
131
  ##############
132
+ @property
133
+ def tone_control_status(self) -> Optional[bool]:
134
+ """Return value of tone control status."""
135
+ return self._tone_control_status
136
+
137
+ @property
138
+ def tone_control_adjust(self) -> Optional[bool]:
139
+ """Return value of tone control adjust."""
140
+ return self._tone_control_adjust
141
+
131
142
  @property
132
143
  def bass(self) -> Optional[int]:
133
144
  """Return value of bass."""
@@ -153,21 +164,28 @@ class DenonAVRToneControl(DenonAVRFoundation):
153
164
  ##########
154
165
  async def async_enable_tone_control(self) -> None:
155
166
  """Enable tone control to change settings like bass or treble."""
156
- if not self._tone_control_status:
167
+ if self._tone_control_status is None:
157
168
  raise AvrCommandError(
158
169
  "Cannot enable tone control, Dynamic EQ must be deactivated"
159
170
  )
160
171
 
161
- await self.async_set_tone_control_command("adjust", 1)
172
+ if self._device.telnet_available:
173
+ telnet_command = self._device.telnet_commands.command_tonecontrol + "ON"
174
+ await self._device.telnet_api.async_send_commands(telnet_command)
175
+ else:
176
+ await self.async_set_tone_control_command("adjust", 1)
162
177
 
163
178
  async def async_disable_tone_control(self) -> None:
164
179
  """Disable tone control to change settings like bass or treble."""
165
- if not self._tone_control_status:
180
+ if self._tone_control_status is None:
166
181
  raise AvrCommandError(
167
182
  "Cannot disable tone control, Dynamic EQ must be deactivated"
168
183
  )
169
-
170
- await self.async_set_tone_control_command("adjust", 0)
184
+ if self._device.telnet_available:
185
+ telnet_command = self._device.telnet_commands.command_tonecontrol + "OFF"
186
+ await self._device.telnet_api.async_send_commands(telnet_command)
187
+ else:
188
+ await self.async_set_tone_control_command("adjust", 0)
171
189
 
172
190
  async def async_set_bass(self, value: int) -> None:
173
191
  """
@@ -180,8 +198,14 @@ class DenonAVRToneControl(DenonAVRFoundation):
180
198
  """
181
199
  if value < 0 or value > 12:
182
200
  raise AvrCommandError("Invalid value for bass")
183
- await self.async_enable_tone_control()
184
- await self.async_set_tone_control_command("bassvalue", value)
201
+ if self._device.telnet_available:
202
+ if not self.tone_control_adjust:
203
+ await self.async_enable_tone_control()
204
+ telnet_command = self._device.telnet_commands.command_bass + str(value + 44)
205
+ await self._device.telnet_api.async_send_commands(telnet_command)
206
+ else:
207
+ await self.async_enable_tone_control()
208
+ await self.async_set_tone_control_command("bassvalue", value)
185
209
 
186
210
  async def async_bass_up(self) -> None:
187
211
  """
@@ -192,9 +216,15 @@ class DenonAVRToneControl(DenonAVRFoundation):
192
216
  """
193
217
  if self.bass == 12:
194
218
  return
195
- await self.async_enable_tone_control()
196
- await self.async_set_tone_control_command("bassvalue", self.bass + 1)
197
- await self.async_update()
219
+ if self._device.telnet_available:
220
+ if not self.tone_control_adjust:
221
+ await self.async_enable_tone_control()
222
+ telnet_command = self._device.telnet_commands.command_bass + "UP"
223
+ await self._device.telnet_api.async_send_commands(telnet_command)
224
+ else:
225
+ await self.async_enable_tone_control()
226
+ await self.async_set_tone_control_command("bassvalue", self.bass + 1)
227
+ await self.async_update()
198
228
 
199
229
  async def async_bass_down(self) -> None:
200
230
  """
@@ -205,9 +235,15 @@ class DenonAVRToneControl(DenonAVRFoundation):
205
235
  """
206
236
  if self.bass == 0:
207
237
  return
208
- await self.async_enable_tone_control()
209
- await self.async_set_tone_control_command("bassvalue", self.bass - 1)
210
- await self.async_update()
238
+ if self._device.telnet_available:
239
+ if not self.tone_control_adjust:
240
+ await self.async_enable_tone_control()
241
+ telnet_command = self._device.telnet_commands.command_bass + "DOWN"
242
+ await self._device.telnet_api.async_send_commands(telnet_command)
243
+ else:
244
+ await self.async_enable_tone_control()
245
+ await self.async_set_tone_control_command("bassvalue", self.bass - 1)
246
+ await self.async_update()
211
247
 
212
248
  async def async_set_treble(self, value: int) -> None:
213
249
  """
@@ -220,8 +256,16 @@ class DenonAVRToneControl(DenonAVRFoundation):
220
256
  """
221
257
  if value < 0 or value > 12:
222
258
  raise AvrCommandError("Invalid value for treble")
223
- await self.async_enable_tone_control()
224
- await self.async_set_tone_control_command("treblevalue", value)
259
+ if self._device.telnet_available:
260
+ if not self.tone_control_adjust:
261
+ await self.async_enable_tone_control()
262
+ telnet_command = self._device.telnet_commands.command_treble + str(
263
+ value + 44
264
+ )
265
+ await self._device.telnet_api.async_send_commands(telnet_command)
266
+ else:
267
+ await self.async_enable_tone_control()
268
+ await self.async_set_tone_control_command("treblevalue", value)
225
269
 
226
270
  async def async_treble_up(self) -> None:
227
271
  """
@@ -232,9 +276,15 @@ class DenonAVRToneControl(DenonAVRFoundation):
232
276
  """
233
277
  if self.treble == 12:
234
278
  return
235
- await self.async_enable_tone_control()
236
- await self.async_set_tone_control_command("treblevalue", self.treble + 1)
237
- await self.async_update()
279
+ if self._device.telnet_available:
280
+ if not self.tone_control_adjust:
281
+ await self.async_enable_tone_control()
282
+ telnet_command = self._device.telnet_commands.command_treble + "UP"
283
+ await self._device.telnet_api.async_send_commands(telnet_command)
284
+ else:
285
+ await self.async_enable_tone_control()
286
+ await self.async_set_tone_control_command("treblevalue", self.treble + 1)
287
+ await self.async_update()
238
288
 
239
289
  async def async_treble_down(self) -> None:
240
290
  """
@@ -245,9 +295,15 @@ class DenonAVRToneControl(DenonAVRFoundation):
245
295
  """
246
296
  if self.treble == 0:
247
297
  return
248
- await self.async_enable_tone_control()
249
- await self.async_set_tone_control_command("treblevalue", self.treble - 1)
250
- await self.async_update()
298
+ if self._device.telnet_available:
299
+ if not self.tone_control_adjust:
300
+ await self.async_enable_tone_control()
301
+ telnet_command = self._device.telnet_commands.command_treble + "DOWN"
302
+ await self._device.telnet_api.async_send_commands(telnet_command)
303
+ else:
304
+ await self.async_enable_tone_control()
305
+ await self.async_set_tone_control_command("treblevalue", self.treble - 1)
306
+ await self.async_update()
251
307
 
252
308
 
253
309
  def tone_control_factory(instance: DenonAVRFoundation) -> DenonAVRToneControl:
denonavr/volume.py CHANGED
@@ -8,7 +8,8 @@ This module implements the handler for volume of Denon AVR receivers.
8
8
  """
9
9
 
10
10
  import logging
11
- from typing import Hashable, Optional, Union
11
+ from collections.abc import Hashable
12
+ from typing import Optional, Union
12
13
 
13
14
  import attr
14
15
 
@@ -143,20 +144,22 @@ class DenonAVRVolume(DenonAVRFoundation):
143
144
  ##########
144
145
  async def async_volume_up(self) -> None:
145
146
  """Volume up receiver via HTTP get command."""
146
- success = self._device.telnet_api.send_commands(
147
- self._device.telnet_commands.command_volume_up
148
- )
149
- if not success:
147
+ if self._device.telnet_available:
148
+ await self._device.telnet_api.async_send_commands(
149
+ self._device.telnet_commands.command_volume_up
150
+ )
151
+ else:
150
152
  await self._device.api.async_get_command(
151
153
  self._device.urls.command_volume_up
152
154
  )
153
155
 
154
156
  async def async_volume_down(self) -> None:
155
157
  """Volume down receiver via HTTP get command."""
156
- success = self._device.telnet_api.send_commands(
157
- self._device.telnet_commands.command_volume_down
158
- )
159
- if not success:
158
+ if self._device.telnet_available:
159
+ await self._device.telnet_api.async_send_commands(
160
+ self._device.telnet_commands.command_volume_down
161
+ )
162
+ else:
160
163
  await self._device.api.async_get_command(
161
164
  self._device.urls.command_volume_down
162
165
  )
@@ -169,16 +172,17 @@ class DenonAVRVolume(DenonAVRFoundation):
169
172
  Minimum is -80.0, maximum at 18.0
170
173
  """
171
174
  if volume < -80 or volume > 18:
172
- raise AvrCommandError("Invalid volume: {}".format(volume))
175
+ raise AvrCommandError(f"Invalid volume: {volume}")
173
176
 
174
177
  # Round volume because only values which are a multi of 0.5 are working
175
178
  volume = round(volume * 2) / 2.0
176
- success = self._device.telnet_api.send_commands(
177
- self._device.telnet_commands.command_set_volume.format(
178
- volume=int(volume + 80)
179
+ if self._device.telnet_available:
180
+ await self._device.telnet_api.async_send_commands(
181
+ self._device.telnet_commands.command_set_volume.format(
182
+ volume=int(volume + 80)
183
+ )
179
184
  )
180
- )
181
- if not success:
185
+ else:
182
186
  await self._device.api.async_get_command(
183
187
  self._device.urls.command_set_volume.format(volume=volume)
184
188
  )
@@ -186,18 +190,20 @@ class DenonAVRVolume(DenonAVRFoundation):
186
190
  async def async_mute(self, mute: bool) -> None:
187
191
  """Mute receiver via HTTP get command."""
188
192
  if mute:
189
- success = self._device.telnet_api.send_commands(
190
- self._device.telnet_commands.command_mute_on
191
- )
192
- if not success:
193
+ if self._device.telnet_available:
194
+ await self._device.telnet_api.async_send_commands(
195
+ self._device.telnet_commands.command_mute_on
196
+ )
197
+ else:
193
198
  await self._device.api.async_get_command(
194
199
  self._device.urls.command_mute_on
195
200
  )
196
201
  else:
197
- success = self._device.telnet_api.send_commands(
198
- self._device.telnet_commands.command_mute_off
199
- )
200
- if not success:
202
+ if self._device.telnet_available:
203
+ await self._device.telnet_api.async_send_commands(
204
+ self._device.telnet_commands.command_mute_off
205
+ )
206
+ else:
201
207
  await self._device.api.async_get_command(
202
208
  self._device.urls.command_mute_off
203
209
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: denonavr
3
- Version: 0.11.3
3
+ Version: 0.11.6
4
4
  Summary: Automation Library for Denon AVR receivers
5
5
  Author-email: Oliver Goetz <scarface@mywoh.de>
6
6
  License: MIT
@@ -19,15 +19,17 @@ Classifier: Programming Language :: Python :: 3.8
19
19
  Classifier: Programming Language :: Python :: 3.9
20
20
  Classifier: Programming Language :: Python :: 3.10
21
21
  Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
22
23
  Requires-Python: >=3.7
23
24
  Description-Content-Type: text/markdown; charset=UTF-8
24
25
  License-File: LICENSE
25
- Requires-Dist: asyncstdlib (>=3.10.2)
26
- Requires-Dist: attrs (>=21.2.0)
27
- Requires-Dist: defusedxml (>=0.7.1)
28
- Requires-Dist: httpx (>=0.23.1)
29
- Requires-Dist: netifaces (>=0.11.0)
30
- Requires-Dist: async-timeout (>=4.0.2) ; python_version < "3.11"
26
+ Requires-Dist: asyncstdlib >=3.10.2
27
+ Requires-Dist: attrs >=21.2.0
28
+ Requires-Dist: defusedxml >=0.7.1
29
+ Requires-Dist: ftfy >=6.1.1
30
+ Requires-Dist: httpx >=0.23.1
31
+ Requires-Dist: netifaces >=0.11.0
32
+ Requires-Dist: async-timeout >=4.0.2 ; python_version < "3.11"
31
33
  Provides-Extra: testing
32
34
  Requires-Dist: pydocstyle ; extra == 'testing'
33
35
  Requires-Dist: pylint ; extra == 'testing'
@@ -58,7 +60,7 @@ In addition to retrieving the current device status via HTTP calls, this version
58
60
 
59
61
  As of version 0.10.0 and newer, the `denonavr` library has switched to using`async` methods to interact with Denon receivers.
60
62
 
61
- Legacy synchronous methods are still availlable to avoid breaking existing implementations, but may be deprecated in the future. Switching to `async` methods is recommended. The existing sync methods are inefficient because they use the corresponding async methods by starting and stopping its own `asyncio` loop for each command.
63
+ Legacy synchronous methods are still available to avoid breaking existing implementations, but may be deprecated in the future. Switching to `async` methods is recommended. The existing sync methods are inefficient because they use the corresponding async methods by starting and stopping its own `asyncio` loop for each command.
62
64
 
63
65
  ### Other changes:
64
66
 
@@ -129,8 +131,8 @@ The `asyncio` library should automatically be imported in the REPL. Import the
129
131
  ```
130
132
  ### Sound
131
133
  ```
132
- >>> await d.async_mute_on(True)
133
- >>> await d.async_mute_off(False)
134
+ >>> await d.async_mute(True)
135
+ >>> await d.async_mute(False)
134
136
  ```
135
137
 
136
138
  ### Other methods
@@ -0,0 +1,19 @@
1
+ denonavr/__init__.py,sha256=-divkN4DxZpILQgRgqab1PE7GszFDjdkCdy7aCI63nw,2035
2
+ denonavr/api.py,sha256=8s_TXeUidCDh4wzgbibOaJjZ1Nba5pcbGmKyLhL1m9s,28671
3
+ denonavr/appcommand.py,sha256=H37VK4n-yW0ISvR1hfX8G4udQtGASoY44QNaXtLSidE,7784
4
+ denonavr/audyssey.py,sha256=tbfOerXxjv6l3TAJ4zMBn08UPNqx-tVJEpDhwyYZ3iw,10797
5
+ denonavr/const.py,sha256=7jXrdTrqSrRJsYf_twqersNtdGx6odiMSsCajIHfsPA,17458
6
+ denonavr/decorators.py,sha256=j1Icyfw64LPLD67H2yd9nbREbTvicqG-kAxawfgvXuE,5062
7
+ denonavr/denonavr.py,sha256=hnsYJiVSXD9qaYr6mjlwkQL3I8NrbXXfAo8uWT35HBU,28159
8
+ denonavr/exceptions.py,sha256=naP7MCuNH98rv7y_lDdO7ayyvQGywnsfpHhW-o9tKeo,1725
9
+ denonavr/foundation.py,sha256=lCPxcbpbjbUCSNquNjaW5RXHQXdSR7Q0O8og2hcPXOY,27911
10
+ denonavr/input.py,sha256=kkswPrMiys1Qq7YWfwrveB-w2aaTgXAkkBa05rolbOA,41085
11
+ denonavr/soundmode.py,sha256=G36Nmf6lTe8Ku6sQ-2nDYHjmSjrnNr9l4wq3-B45I1g,11737
12
+ denonavr/ssdp.py,sha256=4gyvN0yo9qSnJ7l6iJmSC_5qW45Fq2Tt2RACpxFMSqg,7839
13
+ denonavr/tonecontrol.py,sha256=jg3d_OnnXKR5mq7S3mtKHyYhg7Y_qmDloqIm7WRJ71U,11093
14
+ denonavr/volume.py,sha256=bGEOyeNGaI4X-7C7hjEBBH4RlFCYngf4Dl2IM8ooxOo,7197
15
+ denonavr-0.11.6.dist-info/LICENSE,sha256=hcKXAoZnRee1NRWnxTpKyjKCz4aHhw76sZUZoB3qPTw,1068
16
+ denonavr-0.11.6.dist-info/METADATA,sha256=0He0qq32YZidhfW5a5K0NjPhojr5Ul1Q5zXip2SeCDs,10361
17
+ denonavr-0.11.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
18
+ denonavr-0.11.6.dist-info/top_level.txt,sha256=GKwe6bOaw_R68BR7x-C7VD3bDFKKNBf0pRkWywUZWIs,9
19
+ denonavr-0.11.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,19 +0,0 @@
1
- denonavr/__init__.py,sha256=FAX6_LNl1FO5fkg2AdKOSbm-tIq9H33B16jNgWMbn1s,2035
2
- denonavr/api.py,sha256=E7b6f6EFM0d2Gx2HWf2LoQfgcFLbZrbOEzr6l8zZEUo,24850
3
- denonavr/appcommand.py,sha256=H37VK4n-yW0ISvR1hfX8G4udQtGASoY44QNaXtLSidE,7784
4
- denonavr/audyssey.py,sha256=imsjVxjvqjil9ohMDiQdhEbaS84p4xNynSGn6VRh6uo,8679
5
- denonavr/const.py,sha256=xWcqrGuyE0wy3MoDK-Libl8C0lHxKR7QmQQfQxanYm4,15150
6
- denonavr/decorators.py,sha256=0V3PAM2ZNZr911f1W1CXXeTJvOWxqs1S5EjEJkkB53o,5323
7
- denonavr/denonavr.py,sha256=0okvy4KGcHI5K513eopny6TkSuANkIsFzk94Qw_gCNk,26570
8
- denonavr/exceptions.py,sha256=naP7MCuNH98rv7y_lDdO7ayyvQGywnsfpHhW-o9tKeo,1725
9
- denonavr/foundation.py,sha256=YTACGvm7rpwN48AkguiMoCQ1AKHG2ZxLGuN_WmxBBBU,27679
10
- denonavr/input.py,sha256=zV-VYrbHROSV_GiX1uuDQmM6OCNLkuqPFR2Z59vp0Ew,40962
11
- denonavr/soundmode.py,sha256=OAGPK0-jp6xDYyutpDrOqvAKkwXXTptYxAWwPfmfVf4,11483
12
- denonavr/ssdp.py,sha256=7r8DVb9voIlH09IDNY5iSjhmpyJKf6MlZZanEO7Uqos,8011
13
- denonavr/tonecontrol.py,sha256=3Fc-ivHnAPUEEx15XWxyXFAetlhHnK9tz2WxxobwShE,8287
14
- denonavr/volume.py,sha256=JJG7_dSWUnAEeKZ9z9AbBWGI0jz_mJ5NG_mMppU3HGE,6932
15
- denonavr-0.11.3.dist-info/LICENSE,sha256=hcKXAoZnRee1NRWnxTpKyjKCz4aHhw76sZUZoB3qPTw,1068
16
- denonavr-0.11.3.dist-info/METADATA,sha256=f8Gn2XQjl1DR-1cpVPadZQwHcTuw5SLkS8Ve2ENU1SI,10302
17
- denonavr-0.11.3.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
18
- denonavr-0.11.3.dist-info/top_level.txt,sha256=GKwe6bOaw_R68BR7x-C7VD3bDFKKNBf0pRkWywUZWIs,9
19
- denonavr-0.11.3.dist-info/RECORD,,