Skip to content

Commit 4971bda

Browse files
authored
Merge branch 'master' into receive_buffer_upstream
2 parents 8ae6068 + cc1e14b commit 4971bda

4 files changed

Lines changed: 41 additions & 30 deletions

File tree

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.2.10 (2024-03-09)
2+
- Retrieve zone from decoded commands
3+
4+
1.2.9 (2024-03-07)
5+
- Fix disconnected socket in async API
6+
17
1.2.8 (2019-11-09)
28
- Added HDMI-CEC TV control support via CTV command. See 'onkyo --help-commands main ctv' for possible values.
39

eiscp/core.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,27 @@ def command_to_iscp(command, arguments=None, zone=None):
244244
return '{}{}'.format(prefix, value)
245245

246246

247-
def iscp_to_command(iscp_message):
248-
for zone, zone_cmds in commands.COMMANDS.items():
249-
# For now, ISCP commands are always three characters, which
250-
# makes this easy.
251-
command, args = iscp_message[:3], iscp_message[3:]
252-
if command in zone_cmds:
253-
if args in zone_cmds[command]['values']:
254-
return zone_cmds[command]['name'], \
255-
zone_cmds[command]['values'][args]['name']
256-
else:
257-
match = re.match('[+-]?[0-9a-f]+$', args, re.IGNORECASE)
258-
if match:
259-
return zone_cmds[command]['name'], \
260-
int(args, 16)
247+
def iscp_to_command(iscp_message, with_zone=False):
248+
def __iscp_to_command(iscp_message):
249+
for zone, zone_cmds in commands.COMMANDS.items():
250+
# For now, ISCP commands are always three characters, which
251+
# makes this easy.
252+
command, args = iscp_message[:3], iscp_message[3:]
253+
if command in zone_cmds:
254+
if args in zone_cmds[command]['values']:
255+
return zone, zone_cmds[command]['name'], \
256+
zone_cmds[command]['values'][args]['name']
261257
else:
262-
return zone_cmds[command]['name'], args
263-
264-
else:
265-
raise ValueError(
266-
'Cannot convert ISCP message to command: {}'.format(iscp_message))
267-
258+
match = re.match('[+-]?[0-9a-f]+$', args, re.IGNORECASE)
259+
if match:
260+
return zone, zone_cmds[command]['name'], int(args, 16)
261+
else:
262+
return zone, zone_cmds[command]['name'], args
263+
else:
264+
raise ValueError(
265+
'Cannot convert ISCP message to command: {}'.format(iscp_message))
266+
zone, ret_cmd, args = __iscp_to_command(iscp_message)
267+
return (zone, ret_cmd, args) if with_zone else (ret_cmd, args)
268268

269269
def filter_for_message(getter_func, msg):
270270
"""Helper that calls ``getter_func`` until a matching message

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
f.close()
1212

1313
setup(
14-
name='onkyo-eiscp',
15-
version='1.2.8',
16-
url='https://github.com/miracle2k/onkyo-eiscp',
14+
name='dannytrigo-onkyo-eiscp',
15+
version='1.2.10',
16+
url='https://github.com/dannytrigo/onkyo-eiscp',
1717
license='MIT',
1818
author='Michael Elsdörfer',
1919
author_email='michael@elsdoerfer.com',
20-
description='Control Onkyo receivers over ethernet.',
20+
description='Control Onkyo receivers over ethernet. (dannytrigo fork for bugfix)',
2121
long_description=long_description,
2222
packages = find_packages(exclude=('tests*',)),
2323
entry_points="""[console_scripts]\nonkyo = eiscp.script:run\n""",

tests/test_core.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from eiscp.core import iscp_to_command, command_to_iscp
2+
from unittest import TestCase
23

3-
4-
class TestIscpToCommand:
4+
class TestIscpToCommand(TestCase):
55
def test(self):
6-
assert iscp_to_command('MVL') == ('master-volume', '')
6+
self.assertEqual(('master-volume', ''), iscp_to_command('MVL'))
77

8+
def test_with_zone(self):
9+
self.assertEqual(('main', 'audio-muting', ''), iscp_to_command('AMT', True))
10+
self.assertEqual(('zone2', 'muting', ''), iscp_to_command('ZMT', True))
11+
self.assertEqual(('zone3', 'muting', ''), iscp_to_command('MT3', True))
12+
self.assertEqual(('zone4', 'muting', ''), iscp_to_command('MT4', True))
813

9-
class TestCommandToIscp:
14+
class TestCommandToIscp(TestCase):
1015
def test(self):
11-
assert command_to_iscp('main.system-power=standby') == 'PWR00'
16+
self.assertEqual('PWR00', command_to_iscp('main.system-power=standby'))
1217

1318
def test_argument_aliases(self):
14-
assert command_to_iscp('main.system-power=off') == 'PWR00'
19+
self.assertEqual('PWR00', command_to_iscp('main.system-power=off'))

0 commit comments

Comments
 (0)