Page 3 of 14

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 22 March 2017 22:18
by jorgh
@swevm,

Good to hear it works.
Just an idea, on the issue you have.
If the receiver stops responding, does it only not send a response, or is the receiver also not executing the command?

I think that if network stand-by is disabled, the controller is actually turned off when you power off the reciever (thus, only cycling the controller inside the receiver). Just for the sake of it, next time, try to disable network standby, power-off the receiver and then power it on. Try if it responds again in that case. If this also works to get the receiver to respond, the following might work:

Create a script that checks if the receiver still responds.
If not, disable network stand-by and power off the receiver (or wait for the user to do this, whatever is more convenient).
If you power on the receiver again (using IR or the power button) the internal controller will boot up.
The script will then enable network standby again.

Although this will not completely get rid of the issue, it might be easier as pulling the plug. If there are a lot of receivers that have this issue, I could try to create such a script (stand-alone, independent of the plugin). But first we need to figure out, if this procedure will work.

On your observations:
* All devices are created as type: Light/Switch
Well, there are only the following device types as far as I know: light, weather, temp, utility. Where light is for controlling things, the others are for measurements only.
* Master volume is in % (mine say MasterVolume is set to 56% while receiver show a value of 45 in its display
I calculate the percentage from the maxvolume the receiver returns in its configuration. The absolute max volume differs per receiver, hence I calculate the percentage based on the max volume. This obviously leads to a difference between the percentage number and the number on the receiver display. As far as I know, all sliders in Domoticz are in percentages, but correct me if I'm wrong.
* MasterVolume in Domoticz UI showed 56% but slider was at far left indicating 0%. Adjusting volume work and if manually adjusted using UI slider it stay at defined level and receiver MasterVolume is changed too. Not sure if this is a bug in the plugin or Domoticz UI.
I Noticed this too, but am not sure why this happens, In my case this only happens once, after it is synchronized I've not seen any issues yet.

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 22 March 2017 23:27
by jake
@jorgh

Thanks, thanks, thanks! Now for the 1st time I have direct feedback from the receiver, so automatic 'pull' instead of manual 'pull'

Devices for my Onkyo TX-NR535 were created immediately and I added all 'Main' devices.

- Switch On/Off works very, very direct both ways, not comparable at all with the Onkyo commandline action response
- Input source switch works both ways, although response in Domoticz seems to depend on the source: switching to 'PC' took longer then to FM or BD/DVD. I than switched to 'Net' by the local remote, but Domoticz hasn't changed for minutes and remains on 'PC'. The input list seems complete, but also has a lot of empty spaces in between the source names. Can I delete the empty lines, by editing the selector switch?
- Volume responds both ways, although percentage is not matching with receiver. I checked at one setting (PC, I think) where the receiver display shows 'PC --' instead of 'PC 29', seemed like the volume was not shown, only when I increased/decreased the volume.
- Tuner window remains empty and switch in 'off' state, even while 'Source' is FM
- Mode: I find hard to find out what it does. I usually use 5-channel stereo for audio and 'digital theater' for video, but that is not on the selector option list

All in all, this plugin first trial exeeds my expectations by miles, well done! and keep up the good work!

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Thursday 23 March 2017 8:39
by jorgh
@jake,

Thanks for the compliment :D
- Input source switch works both ways, although response in Domoticz seems to depend on the source: switching to 'PC' took longer then to FM or BD/DVD.
The switching to PC taking longer, is probably something specific to your receiver. There is no difference in how the inputs are switched depending on the selected input.
I than switched to 'Net' by the local remote, but Domoticz hasn't changed for minutes and remains on 'PC'.
If you change the input with the remote to NET, does Domotics display the correct input if you refresh the browser (F5)? If so, it's probably an Domoticz issue.
If not, could you enable debug in the plugin and send me (or post) the log entries that appear when switching to NET?
The input list seems complete, but also has a lot of empty spaces in between the source names.
I create the input list, from what the receiver states it has. Multiple things could play a role here:
The receiver has more inputs that you don't use, maybe you can disable them on the receiver. They should not appear in that case. If you use inputs without a name, give them a name in the receiver, they now should appear correctly in the plugin (requires you to delete the device and restart the plugin).
The receiver has a different response from the one I use, indicating a input does not exist by delivering an empty name. In that case I could change the code to skip inputs without a name.
Can I delete the empty lines, by editing the selector switch?
Yes you can. You can also reorder the list. As long as the name in Domoticz matches the name on the receiver, it should work.
Volume responds both ways, although percentage is not matching with receiver. I checked at one setting (PC, I think) where the receiver display shows 'PC --' instead of 'PC 29', seemed like the volume was not shown, only when I increased/decreased the volume.
The plugin does not do anything with the receiver display, so this is probably something specific to your receiver. The Domoticz plugin displays the volume as a percentage, calculated by the maxvolume supported by the receiver. So, unless the max volume of your receiver is 100, the number displayed within Domoticz (percentage), does not match the absolute volume displayed by the receiver.
Tuner window remains empty and switch in 'off' state, even while 'Source' is FM
Are the preset names in the list? The presets requested from the receiver, if the list is empty, the plugin did not receive the Tuner presets. Maybe your receiver delivers the presets in another fashion, or does not deliver them. I could create a script that dumps the Receiver configuration to analyse this.
Mode: I find hard to find out what it does. I usually use 5-channel stereo for audio and 'digital theater' for video, but that is not on the selector option list
I must admit, I wasn't to happy about how the receiver delivers the supported input modes. This list is not complete and some of them switch between different modes, if you press them multiple times. I already started thinking of another solution. Which will probably boil down to adding additional modes if they are first detected by the plugin. (So you have to switch to them once, before they appear).

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Friday 24 March 2017 22:56
by jake
jorgh wrote:@jake,
Volume responds both ways, although percentage is not matching with receiver. I checked at one setting (PC, I think) where the receiver display shows 'PC --' instead of 'PC 29', seemed like the volume was not shown, only when I increased/decreased the volume.
The plugin does not do anything with the receiver display, so this is probably something specific to your receiver.
The 'PC --' probably was shown because the PC wasn't on at that time. The PC is on now and the display shows the correct volume
The Domoticz plugin displays the volume as a percentage, calculated by the max volume supported by the receiver. So, unless the max volume of your receiver is 100, the number displayed within Domoticz (percentage), does not match the absolute volume displayed by the receiver.
Thanks, I understand. However, would it not be nicer and easier for calculation on your side, to store the maximum receiver volume also as maximum percentage in the slider switch, meaning that the percentage is identical to the receiver volume? Anything above that max. percentage could in the code be capped to that same max. level. I have no feeling what 50% does to the actual volume, but I know pretty wel what '30' means for loudness, because I am used to it.
Tuner window remains empty and switch in 'off' state, even while 'Source' is FM
Are the preset names in the list? The presets requested from the receiver, if the list is empty, the plugin did not receive the Tuner presets. Maybe your receiver delivers the presets in another fashion, or does not deliver them. I could create a script that dumps the Receiver configuration to analyse this.
Eheh, I discovered that I never put any radio stations in the preset list. After doing that, deleting the switch, re-adding it again, the presets were there. Cool!
Mode: I find hard to find out what it does. I usually use 5-channel stereo for audio and 'digital theater' for video, but that is not on the selector option list
I must admit, I wasn't to happy about how the receiver delivers the supported input modes. This list is not complete and some of them switch between different modes, if you press them multiple times. I already started thinking of another solution. Which will probably boil down to adding additional modes if they are first detected by the plugin. (So you have to switch to them once, before they appear).
Yes, there are so many audio modes (that I never use), adding those that are used, would be more convenient

Hmm, I switched to 'Net' with the Domoticz switch. Some minutes later I check the log and find the following (multiple times, but shown here only twice):

Code: Select all

 2017-03-24 22:35:42.242 (Onkyo AV Receiver TX-NR535) onMessage called
2017-03-24 22:35:42.242 (Onkyo AV Receiver TX-NR535) We received 46 bytes of data
2017-03-24 22:35:42.243 (Onkyo AV Receiver TX-NR535) Found ISCP frame
2017-03-24 22:35:42.243 (Onkyo AV Receiver TX-NR535) HeaderSize: 16
2017-03-24 22:35:42.244 (Onkyo AV Receiver TX-NR535) DataSize: 11
2017-03-24 22:35:42.244 (Onkyo AV Receiver TX-NR535) Have 2291 bytes in inputbuffer
2017-03-24 22:35:42.244 (Onkyo AV Receiver TX-NR535) We have a eISCP frame to process
2017-03-24 22:35:42.245 (Onkyo AV Receiver TX-NR535) Found ISCP frame
2017-03-24 22:35:42.245 (Onkyo AV Receiver TX-NR535) HeaderSize: 16
2017-03-24 22:35:42.246 (Onkyo AV Receiver TX-NR535) DataSize: 11
2017-03-24 22:35:42.246 (Onkyo AV Receiver TX-NR535) Version: 1
2017-03-24 22:35:42.247 (Onkyo AV Receiver TX-NR535) Reserved: [0x0][0x0][0x0]
2017-03-24 22:35:42.247 (Onkyo AV Receiver TX-NR535) eISCP Data : !1NLS
2017-03-24 22:35:42.248 Error: (Onkyo AV Receiver TX-NR535) 'onMessage' failed 'UnicodeDecodeError'.
2017-03-24 22:35:42.248 Error: (Onkyo AV Receiver TX-NR535) ----> Line 617 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-24 22:35:42.248 Error: (Onkyo AV Receiver TX-NR535) ----> Line 98 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-24 22:35:42.249 Error: (Onkyo AV Receiver TX-NR535) ----> Line 491 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function processeISCPFrame
2017-03-24 22:35:42.249 (Onkyo AV Receiver TX-NR535) onMessage called
2017-03-24 22:35:42.250 (Onkyo AV Receiver TX-NR535) We received 53 bytes of data
2017-03-24 22:35:42.250 (Onkyo AV Receiver TX-NR535) Found ISCP frame
2017-03-24 22:35:42.251 (Onkyo AV Receiver TX-NR535) HeaderSize: 16
2017-03-24 22:35:42.251 (Onkyo AV Receiver TX-NR535) DataSize: 11
2017-03-24 22:35:42.252 (Onkyo AV Receiver TX-NR535) Have 2344 bytes in inputbuffer
2017-03-24 22:35:42.252 (Onkyo AV Receiver TX-NR535) We have a eISCP frame to process
2017-03-24 22:35:42.252 (Onkyo AV Receiver TX-NR535) Found ISCP frame
2017-03-24 22:35:42.253 (Onkyo AV Receiver TX-NR535) HeaderSize: 16
2017-03-24 22:35:42.253 (Onkyo AV Receiver TX-NR535) DataSize: 11
2017-03-24 22:35:42.254 (Onkyo AV Receiver TX-NR535) Version: 1
2017-03-24 22:35:42.254 (Onkyo AV Receiver TX-NR535) Reserved: [0x0][0x0][0x0]
2017-03-24 22:35:42.254 (Onkyo AV Receiver TX-NR535) eISCP Data : !1NLS
2017-03-24 22:35:42.255 Error: (Onkyo AV Receiver TX-NR535) 'onMessage' failed 'UnicodeDecodeError'.
2017-03-24 22:35:42.255 Error: (Onkyo AV Receiver TX-NR535) ----> Line 617 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-24 22:35:42.256 Error: (Onkyo AV Receiver TX-NR535) ----> Line 98 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-24 22:35:42.256 Error: (Onkyo AV Receiver TX-NR535) ----> Line 491 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function processeISCPFrame 
After I tried to disable the Onkyo hardware in Domoticz, Domoticz was completely locked up and needed a restart of the service.

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Saturday 25 March 2017 8:11
by mrefex
@jorgh

Great job !! i decided to connect my radio antenna and listen to FM . Because i still have an issue to automatically start my internet radio presets.
But this will work fine!

As you mentioned before to use :NPR01 - doesn't work. I saw in the YAML list that some features only can be received by more expensive Onkyo models.

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Saturday 25 March 2017 10:07
by jorgh
@jake,
Thanks, I understand. However, would it not be nicer and easier for calculation on your side, to store the maximum receiver volume also as maximum percentage in the slider switch, meaning that the percentage is identical to the receiver volume? Anything above that max. percentage could in the code be capped to that same max. level. I have no feeling what 50% does to the actual volume, but I know pretty wel what '30' means for loudness, because I am used to it.
I can add a config option to configure the behavior, as this is a matter of taste. Some receivers only go to 50, making half of the slider 'dis-functional'.

On the NET issue you've seen:
Apparently the receiver sends non-ascii data in a field I expect only ascii data. I will change the code to correctly handle this and not cause the plugin to crash. The plugin does (at this time) nothing with NET data, so that should be an easy fix.
After I tried to disable the Onkyo hardware in Domoticz, Domoticz was completely locked up and needed a restart of the service.
I also noticed that Domoticz completely locks-up if a plugin throws an exception. Of course this means there is a bug in the plugin, that should be corrected. But in my humble opinion, Domoticz should handle these exceptions more gracefully, and that means it sould at least not lockup.
As the plugin system is still in Beta, I can live with the current behaviour, but think it needs adjustments before we'll mark it as stable.

Kind regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Saturday 25 March 2017 10:11
by jorgh
@mrefex,
As you mentioned before to use :NPR01 - doesn't work. I saw in the YAML list that some features only can be received by more expensive Onkyo models.
Ok, thats clear. If your receiver does not support NET presets through the control protocol. It might be an option to try if it supports the remote key commands (NTC). If that works, you could send it the keystrokes to automate the preset selection. Although this is not ideal, it might solve your issue.

Kind regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Saturday 25 March 2017 14:40
by swevm
@jorgh,

I noticed this error related to set volume level today. Eror can be reproduced from time to time if I hold mouse button down and move volume level slider. Sometime volume is changed but in some case it only changes when I release mouse button.

Do you have any plans to push this plugin to Github?
Over time more valuable to track changes and issues some place outside of a forum thread. Don´t you agree?

Code: Select all

2017-03-25 14:32:42.003 User: Admin initiated a switch command (190/Onkyo AV - TX-NR828 Main Volume/Set Level)
2017-03-25 14:32:42.193 Error: (Onkyo AV) 'onMessage' failed 'ValueError':'invalid literal for int() with base 16: '0xN/A''.
2017-03-25 14:32:42.193 Error: (Onkyo AV) ----> Line 617 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-25 14:32:42.193 Error: (Onkyo AV) ----> Line 98 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function onMessage
2017-03-25 14:32:42.193 Error: (Onkyo AV) ----> Line 511 in /home/pi/domoticz/plugins/Onkyo/plugin.py, function processeISCPFrame

/Magnus

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Saturday 25 March 2017 20:38
by jake
jorgh wrote:@jake,

I can add a config option to configure the behavior (of the slider), as this is a matter of taste. Some receivers only go to 50, making half of the slider 'dis-functional'.
Sounds like a good plan. A second alternative could be to let people decide the maximum level (that they prefer) and have the slider go between 0 and 100% (in my case I never go above a level of 35 and don't want to touch the maximum volume of the receiver anyway.
On the NET issue you've seen:
Apparently the receiver sends non-ascii data in a field I expect only ascii data. I will change the code to correctly handle this and not cause the plugin to crash. The plugin does (at this time) nothing with NET data, so that should be an easy fix.
Thanks
After I tried to disable the Onkyo hardware in Domoticz, Domoticz was completely locked up and needed a restart of the service.
I also noticed that Domoticz completely locks-up if a plugin throws an exception. Of course this means there is a bug in the plugin, that should be corrected. But in my humble opinion, Domoticz should handle these exceptions more gracefully, and that means it sould at least not lockup.
As the plugin system is still in Beta, I can live with the current behaviour, but think it needs adjustments before we'll mark it as stable.
Agreed, this is on the Domoticz side of things.

I have put your devices in parts of my code already and like it so far!

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Monday 27 March 2017 16:29
by jorgh
@swevm,
swevm wrote:@jorgh,

Do you have any plans to push this plugin to Github?
Over time more valuable to track changes and issues some place outside of a forum thread. Don´t you agree?
I've uploaded to code to GitHub and registered the current bugs en feature requests. I'll start with the bug fixing this week, that's the 1st prio.

https://github.com/jorgh6/domoticz-onkyo-plugin

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Tuesday 28 March 2017 21:59
by jorgh
All,

The bugfix branch (https://github.com/jorgh6/domoticz-onky ... ree/bugfix) on GitHub contains a new version that should resolve the crashes on some volume changes and selecting the NET device.
I'm not able to reproduce these on my receiver.
If someone confirms the issues are resolved I'll commit them to the main branch.

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 0:15
by jake
jorgh wrote:All,

The bugfix branch (https://github.com/jorgh6/domoticz-onky ... ree/bugfix) on GitHub contains a new version that should resolve the crashes on some volume changes and selecting the NET device.
I'm not able to reproduce these on my receiver.
If someone confirms the issues are resolved I'll commit them to the main branch.
I did the following: copy paste the file overtop de previous one.
Disable / enable the Onkyo hardware

Is this procedure correct? I saw during initialisation that the version (still) is 0.1.0.

I can confirm that I now can switch to NET and back without issues. Problem solved.

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 7:52
by jorgh
@Jake,
jake wrote:I did the following: copy paste the file overtop de previous one.
Disable / enable the Onkyo hardware

Is this procedure correct?
Yes, this will work.
I saw during initialisation that the version (still) is 0.1.0.
I bumped the verion number to 0.1.1, but the version number is within the XML. This information is only read if you restart Domoticz. There where no changes in the XML apart from the version number, so it doesn't realy matter.
I can confirm that I now can switch to NET and back without issues. Problem solved.
Good to hear, now if someone can confirm the volume bug is also resolved, I'll update the main branch.

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 19:31
by swevm
Jorgh,

I'm travelling and am back home on Tuesday next week. Will verify your fix for the Volume issue then.
/Magnus

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:15
by JimmyH1969
Mhhh... Added the plugin..

This is all i get:

2017-03-29 20:10:25.326 (Onkyo-AV) onHeartbeat called
2017-03-29 20:10:25.326 (Onkyo-AV) Checking if discovery data has been received

Not getting any devices....
Running Domoticz 3.7197 on Windows

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:22
by jorgh
@Jimmy,
JimmyH1969 wrote:Mhhh... Added the plugin..

This is all i get:

2017-03-29 20:10:25.326 (Onkyo-AV) onHeartbeat called
2017-03-29 20:10:25.326 (Onkyo-AV) Checking if discovery data has been received

Not getting any devices....
Running Domoticz 3.7197 on Windows
There should be more logging information before this. However, if the receiver does not respond, it will loop until the device responds.
Have you enabled network standby? Otherwise the receiver will not respond unless it's powered on (you even have to wait a bit for the network stack in the receiver to fully start).

Are you able to control the receiver using the Onkyo app on your phone or tablet?

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:29
by JimmyH1969
Hi Jorgh,

Yes, i'm using O remote on the iphone and the app detects the TX-NR646 in a second. even on stand-by. I powered up the receiver but that does not make a difference.
Before this i was using a python script and was unable to use the --discover option, i had to specify the ip adres of the receiver to make it work.

Tnx, Jimmy

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:39
by jorgh
@Jimmy,
JimmyH1969 wrote: Before this i was using a python script and was unable to use the --discover option, i had to specify the ip adres of the receiver to make it work.
Tnx, Jimmy
So apparently the discovery does not work. Does discovery work with the O remote app?

The discovery process uses a network broadcast, this requires Domoticz to be on the same IP subnet as the Receiver. Might this be an issue? (Different subnet between WLAN and LAN for example?)

The plugin does currently not have the ability to configure an IP address manually, but this could of course be added, but from what I've seen in the protocol specification, autodiscovery should work for all receivers.
It might also be an issue with your Domoticz server, where sending broadcasts is not possible. I've only used the plugin and script I've created earlier on Linux, so this might be a specific Windows issue.

Can someone confirm that they are using the plugin on Windows where it works?

Regards,

Jorg

Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:47
by JimmyH1969
Hi,

Yes, the O remote app discovers the receiver. Just tried the onkyo-script.py --discover again, but that command returns with no results.
I also thougt this might be a windows thing, the receiver and domoticz are on the same subnet, just like the iphone.
Lets just wait and see if there are more windows users out there..

Thank you so far! :D

Re: RE: Re: [RELEASED] Python plugin to control Onkyo receivers

Posted: Wednesday 29 March 2017 20:51
by jorgh
JimmyH1969 wrote:Hi,

Yes, the O remote app discovers the receiver. Just tried the onkyo-script.py --discover again, but that command returns with no results.
I also thougt this might be a windows thing, the receiver and domoticz are on the same subnet, just like the iphone.
Lets just wait and see if there are more windows users out there..

Thank you so far! :D
Might also be a firewall issue. Have read that services are blocked by default from sending broadcasts. That might also be the cause.

As other scripts are also not working with discovery, my guess is that it has something to do with windows (firewall?) blocking broadcasts.

Verstuurd vanaf mijn HTC 10 met Tapatalk