miracle2k / onkyo-eiscp

Control Onkyo A/V receivers over the network; usuable as a script, or as a Python library.
MIT License
466 stars 110 forks source link

ValueError but it works #1

Closed djensen47 closed 11 years ago

djensen47 commented 11 years ago

I have an Onkyo TX-NR515 and whenever I issue a command it works and then returns a ValueError.

$ onkyo net-usb-artist-name-info=query

<eISCP(TX-NR515) 192.168.47.158:60128>: NATQSTN
Traceback (most recent call last):
  File "/usr/local/bin/onkyo", line 8, in <module>
    load_entry_point('onkyo-eiscp==0.9', 'console_scripts', 'onkyo')()
  File "build/bdist.macosx-10.8-intel/egg/eiscp/script.py", line 124, in run
  File "build/bdist.macosx-10.8-intel/egg/eiscp/script.py", line 119, in main
  File "build/bdist.macosx-10.8-intel/egg/eiscp/core.py", line 206, in iscp_to_command
ValueError: Cannot convert ISCP message to command: NATPeter Bjorn And John
moneytoo commented 11 years ago

I have the same mirror issue.

$ onkyo master-volume:level-up
<eISCP(TX-NR509) 192.168.1.20:60128>: MVLUP
Traceback (most recent call last):
  File "/usr/bin/onkyo", line 9, in <module>
    load_entry_point('onkyo-eiscp==0.9', 'console_scripts', 'onkyo')()
  File "/usr/lib/python2.7/site-packages/onkyo_eiscp-0.9-py2.7.egg/eiscp/script.py", line 124, in run
    sys.exit(main() or 0)
  File "/usr/lib/python2.7/site-packages/onkyo_eiscp-0.9-py2.7.egg/eiscp/script.py", line 119, in main
    response = iscp_to_command(response)
  File "/usr/lib/python2.7/site-packages/onkyo_eiscp-0.9-py2.7.egg/eiscp/core.py", line 206, in iscp_to_command
    'Cannot convert ISCP message to command: %s' % iscp_message)
ValueError: Cannot convert ISCP message to command: MVL1F
Dreded commented 11 years ago

same as above and also if I look up the volume command in help I get this error, which is quite obviously a unicode error as the windows console cannot display unicode characters natively.. I see no reason the character in question needs to be unicode and couldnt just be a '-'(dash)

PS C:\Users\Owner> onkyo --help-commands main master-volume Possible values for this command: Traceback (most recent call last): File "D:\Apps\Python27\Scripts\onkyo-script.py", line 8, in load_entry_point('onkyo-eiscp==0.9', 'console_scripts', 'onkyo')() File "build\bdist.win-amd64\egg\eiscp\script.py", line 124, in run File "build\bdist.win-amd64\egg\eiscp\script.py", line 80, in main File "d:\Apps\Python27\lib\encodings\cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character u'\u2013' in position 24: character maps to

also in addition to above error(posted by moneytoo) I cannot send specific volume numbers such as: onkyo-master-volume=20 it gives an error:

PS C:\Users\Owner> onkyo main master-volume=20 Error: Need at least command and argument PS C:\Users\Owner> onkyo master-volume=20 Error: "20" is not a valid argument for command "master-volume" in zone "main"

3s1d commented 11 years ago

Hi,

it seems to me that there is a problem regarding the commands.py. The value range is not properly defined. I am not a python guy, but (0, 100) does not work. I circumvented this by hacking the iscp_to_command function in core.py (see below). It is now possible to read out the values:

$ onkyo main.master-volume=query
<eISCP(TX-NR515) xxx.xxx.xxx.xxx:60128>: MVLQSTN
('master-volume', '15')

However for value input a more reliable solution should be implemented by a person which has more python knowledge than I. Note: It is important to distinguish between int and hex values

Just my two cent Juergen

def iscp_to_command(iscp_message):
    for zone, zone_cmds in commands.COMMANDS.iteritems():
        # For now, ISCP commands are always three characters, which
        # makes this easy.
        command, args = iscp_message[:3], iscp_message[3:]
        if command in zone_cmds:
            if args in zone_cmds[command]['values']:
                return zone_cmds[command]['name'], \
                       zone_cmds[command]['values'][args]['name']
            else:
            return zone_cmds[command]['name'], \
                   int(args, 16)
    else:
        raise ValueError(
            'Cannot convert ISCP message to command: %s' % iscp_message)
karora commented 11 years ago

I've implemented the solution posted by @3s1d above, on my own fork.

I changed it a little to correct the indentation (no doubt lost in the post) and to check for an actual hexadecimal string before converting to int, otherwise it just reports it as a string.

miracle2k commented 11 years ago

I think this might be fixed then.

icep87 commented 11 years ago

I'm experiencing similar issue:

onkyo -n 616 master-volume:query <eISCP(TX-NR616) 192.168.25.9:60128>: MVLQSTN Traceback (most recent call last): File "/usr/local/bin/onkyo", line 8, in load_entry_point('onkyo-eiscp==0.9', 'console_scripts', 'onkyo')() File "build/bdist.macosx-10.8-intel/egg/eiscp/script.py", line 129, in run File "build/bdist.macosx-10.8-intel/egg/eiscp/script.py", line 124, in main File "build/bdist.macosx-10.8-intel/egg/eiscp/core.py", line 206, in iscp_to_command ValueError: Cannot convert ISCP message to command: MVL31

Plus I'm having issue using command: onkyo -n 616 master-volume:55 or onkyo -n 616 master-volume=55

perimore commented 10 years ago

If it's of any use, Onkyo sent me the most recent v1.2.6 of the ISCP command XLS attached about 3 days ago:

http://www.filedropper.com/iscpavr126

miracle2k commented 10 years ago

That's great, thanks.