OnkyoISCP plugin

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: OnkyoISCP plugin

Post by Mastiff » Tue Feb 28, 2017 8:34 am

I don't know if it was fired more then once by the plug-in (it wasn't fired more than once by my macro), since the error messages filled up my log file (from Log Redirector plug-in) completely. But I have set the timeout to 2 (I assume it's seconds) instead. I hope it won't happen again. But it would be nice with a limited reconnect, maybe five with one second pause between them.

justahotbag2
Experienced User
Posts: 68
Joined: Fri Jan 27, 2017 8:16 pm
Location: New York, NY

Re: OnkyoISCP plugin

Post by justahotbag2 » Tue May 02, 2017 9:05 am

Has anyone had success in converting the hex code that the volume is reported in, into the numbers on the receivers display, and displaying it on-screen, via Snarl or the OSD plugin? I have looked for months, I'm literally playing with myself, and mucking about with pasted together bits of code, and maybe someone has done this already.

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Tue May 02, 2017 10:54 am

That depends on how your Onkyo is configured. For most onkyos you can choose between Absolute and Relative volume.
The hex code should be convertible to a number between 0 and 200 where 200=100% (maximum volume) so 100 would be 50%. Or in hex: 0x64
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

justahotbag2
Experienced User
Posts: 68
Joined: Fri Jan 27, 2017 8:16 pm
Location: New York, NY

Re: OnkyoISCP plugin

Post by justahotbag2 » Tue May 02, 2017 5:30 pm

I believe it's set to absolute, it ranges from 0 to 88, my research is pointing to 0-87, where 88 says max, and the hex from 00 to 58. Thanks for any help in advance.

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Tue May 02, 2017 6:26 pm

In that case it's simple hex to decimal calculation actually :)
0x58 = 88
Most programming languages have a feature built-in for that but effectively it comes down to 16 * the first digit + the second digit.
In this case: 5*16 + 8

The total range in your case:

Code: Select all

0x00 =  0
0x01 =  1
0x02 =  2
0x03 =  3
0x04 =  4
0x05 =  5
0x06 =  6
0x07 =  7
0x08 =  8
0x09 =  9
0x0A = 10
0x0B = 11
0x0C = 12
0x0D = 13
0x0E = 14
0x0F = 15
0x10 = 16
0x11 = 17
0x12 = 18
0x13 = 19
0x14 = 20
0x15 = 21
0x16 = 22
0x17 = 23
0x18 = 24
0x19 = 25
0x1A = 26
0x1B = 27
0x1C = 28
0x1D = 29
0x1E = 30
0x1F = 31
0x20 = 32
0x21 = 33
0x22 = 34
0x23 = 35
0x24 = 36
0x25 = 37
0x26 = 38
0x27 = 39
0x28 = 40
0x29 = 41
0x2A = 42
0x2B = 43
0x2C = 44
0x2D = 45
0x2E = 46
0x2F = 47
0x30 = 48
0x31 = 49
0x32 = 50
0x33 = 51
0x34 = 52
0x35 = 53
0x36 = 54
0x37 = 55
0x38 = 56
0x39 = 57
0x3A = 58
0x3B = 59
0x3C = 60
0x3D = 61
0x3E = 62
0x3F = 63
0x40 = 64
0x41 = 65
0x42 = 66
0x43 = 67
0x44 = 68
0x45 = 69
0x46 = 70
0x47 = 71
0x48 = 72
0x49 = 73
0x4A = 74
0x4B = 75
0x4C = 76
0x4D = 77
0x4E = 78
0x4F = 79
0x50 = 80
0x51 = 81
0x52 = 82
0x53 = 83
0x54 = 84
0x55 = 85
0x56 = 86
0x57 = 87
0x58 = 88
The thing to keep in mind with hexadecimal is that it goes from 0-F instead of 0-9
So 10 in decimal is A in hexadecimal and 15 in decimal is F in hexadecimal.

Which means that if you want to set the volume to 50 we need to divide by 16 and add the remainder:
50 / 16 = 3.125 which means the first digit will be 3.
50 - (3 * 16) = 2 so the second digit will be 2.
Conclusion: 50 = 0x32
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

justahotbag2
Experienced User
Posts: 68
Joined: Fri Jan 27, 2017 8:16 pm
Location: New York, NY

Re: OnkyoISCP plugin

Post by justahotbag2 » Tue May 02, 2017 10:32 pm

Thank you. :D I'm trying it get it the other way around, the onkyo plugin spits out hex to start with, but at least now I understand the concept. I'll just have to learn a little coding to get it done.

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Tue May 02, 2017 10:42 pm

It depends on the programming language, but for Python you can do the following

Code: Select all

# Assuming x is a hexadecimal string:
x = '123'
# Convert to decimal from hexadecimal string
y = int(x, 16)
# Convert to decimal from decimal string
z = int(x, 10)
# Convert number to hex:
x = hex(123)
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

justahotbag2
Experienced User
Posts: 68
Joined: Fri Jan 27, 2017 8:16 pm
Location: New York, NY

Re: OnkyoISCP plugin

Post by justahotbag2 » Fri May 05, 2017 12:53 am

Sir... Dear Sir, (I assuming you're a sir) may I take a second to bromance you? If only you knew the lengthy crap I had pasted as code from others posts. The fact that it was built in, and such a short piece of code, I should stomp my own foot. Sir, I should spin, dance, and sway you around the room like a Disney princess that has just finished her dress for the ball. A simple thank you, just won't do.

Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: OnkyoISCP plugin

Post by Mastiff » Fri May 05, 2017 10:42 am

justahotbag2 wrote:Sir... Dear Sir, (I assuming you're a sir) may I take a second to bromance you? If only you knew the lengthy crap I had pasted as code from others posts. The fact that it was built in, and such a short piece of code, I should stomp my own foot. Sir, I should spin, dance, and sway you around the room like a Disney princess that has just finished her dress for the ball. A simple thank you, just won't do.
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :lol: :lol: :lol: :lol: :lol: :lol:

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Fri May 05, 2017 11:09 am

LOL :mrgreen:

You're welcome :)
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: OnkyoISCP plugin

Post by kgschlosser » Fri May 05, 2017 1:01 pm

ok that is friggin hysterical!
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: OnkyoISCP plugin

Post by kgschlosser » Fri May 05, 2017 1:04 pm

but Wolf.. you forgot about ordinal
If you like the work I have been doing then feel free to Image

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Fri May 05, 2017 3:24 pm

kgschlosser wrote:but Wolf.. you forgot about ordinal
Yes, but is it relevant here? (assuming you meant octal btw)
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: OnkyoISCP plugin

Post by kgschlosser » Sat May 06, 2017 2:42 am

ord()

chr() converts a int() to a str()
ord() converts a str() to an int()
hex() converts an int() to a str() of hex

so to convert a str() to hex() would be hex(ord(str()))


if i remember right it does.. this only works on a single char
If you like the work I have been doing then feel free to Image

WoLpH
Experienced User
Posts: 96
Joined: Mon Dec 10, 2012 3:57 am

Re: OnkyoISCP plugin

Post by WoLpH » Sat May 06, 2017 8:24 am

Ah, now I see what you mean. He probably won't need it here but it's useful to know indeed :)

Similarly, don't forget about unichr for the unicode version of that command :)
Author of the book Mastering Python. Got Python questions? Perhaps I can help :)

Post Reply