Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nuvo] Nuvo Whole House Audio Binding - initial contribution #7651

Merged
merged 34 commits into from
Sep 2, 2020

Conversation

mlobstein
Copy link
Contributor

[nuvo] Initial contribution

This is the initial implementation of a Binding to control the Nuvo Grand Concerto or Essentia G whole house multi-zone amplifier.

@mlobstein mlobstein requested a review from a team as a code owner May 15, 2020 20:43
@mlobstein
Copy link
Contributor Author

mlobstein commented May 15, 2020

Test build available here:
https://github.com/mlobstein/mlobstein-beta-test/raw/master/org.openhab.binding.nuvo-2.5.8-SNAPSHOT.jar

If you receive an error about openhab-transport-serial, issue the following command in the openhab console:

feature:install openhab-transport-serial

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@cpmeister cpmeister added the new binding If someone has started to work on a binding. For a new binding PR. label May 15, 2020
mlobstein added 2 commits May 22, 2020 11:39
Signed-off-by: Michael Lobstein <[email protected]>
Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@mlobstein
Copy link
Contributor Author

mlobstein commented Jun 3, 2020

@fwolter
Hold off on reviewing until #7371 is sorted out. This binding's Connector classes are of the same derivative, so I will need to make the requested changes here also.

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again! There are some compiler warnings left, concerning null pointers.

case CHANNEL_TYPE_TREBLE:
if (command instanceof DecimalType) {
int value = ((DecimalType) command).intValue();
if (value >= MIN_EQ && value <= MAX_EQ && value % 2 == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth to translate odd values to even values, instead of ignoring them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device is weird in that it only accepts even values (from -18 to 18). So this was done to along with step=2 in the channel configuration to have the binding values match the device. I noted it in the readme also.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had something like this in mind:

if(value % 2 == 1) value++;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, it will automatically become a compatible value.

Comment on lines 669 to 670
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy,MM,dd,HH,mm");
connector.sendCommand(NuvoCommand.CFGTIME.getValue() + simpleDateFormat.format(new Date()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try this with different system timezones and configuring the timezone in PaperUI? I saw an example retrieving a zoned datetime service or so via @Reference in an openHAB binding, but I can't find it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not. It was just intended to use whatever the system time is regardless of time zone. I think this will be fine since most users set the host system to their local time.

Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

if ((serialPort == null || serialPort.isEmpty()) && (host == null || host.isEmpty())) {
configError = "undefined serialPort and host configuration settings; please set one of them";
} else if (serialPort != null && (host == null || host.isEmpty())) {
if (serialPort.toLowerCase().startsWith("rfc2217")) {
Copy link
Member

@Hilbrand Hilbrand Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openHAB serial port handler supports rfc2217? Is there a reason not to use it and instead of having implemented a separate ip connector and configuration options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure as this was pulled in from the rotel binding. I seems like rfc2217 (Telnet Com Port) may be supported to some degree. But there were probably issues, so a distinct connector was defined instead and this check was put in place to prevent an unusable configuration. @lolodomo any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC2217 through the openhab serial layer never worked in bindings I worked on.
I am not sure of the reason but my hypothesis was it doesn't work if you need to read and write in parallel.
But you are welcome to try with any new binding. Maybe I was just not enough clever to make it work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a problem in case you have a reader thread that always read data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. But I think I will just stick with what works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hillbrand: Honestly I don't remember. I even don't remember if I tested that with this binding in particular. But as I am using serial over IP, I could try again one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lolodomo Maybe it was related to the endless sleep 'fix' (that could be and was removed during the review process)? Did you ever test after that change?

@mlobstein Did you test if it worked at all by using the rfc2217 version?
I did not test it with rfc2217

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not tested or not known if the rfc2217 configuration way doesn't work I would be in favor of removing the specific ip implementation here and allowing the rfcc2217 configuratiin option for serial. Its always possible to add features, but removing them is hard. This also reduces the amount of copy-pasting of specific code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions...

  1. I tried rfc2217 and it seemed to work connecting to a ser2net endpoint after a few changes to the serial connector. I had to conditionally bypass SerialPort.enableReceiveThreshold(), SerialPort.enableReceiveTimeout() & SerialPort.setFlowControlMode() as the calling those with rfc2217 throws an exception. I also had to catch an IllegalStateException that was being thrown if the remote connection was refused or otherwise failed to connect. That being said, are there any bindings that currently support rfc2217 explicitly (as a reference implementation)? I did a quick scan of the 2.5.x bindings and the only references to rfc2217 were in 6 other bindings that blocked its usage during initialization.

  2. If rfc2217 is to be used, does the user need to make the choice to specify the rfc2217 url string in place of the serial port or can this be handled behind the scenes? There seems to be some controversy with setting limitToOptions=false for the serial port in the configuration. [Q] How to add a rfc2217://.. port in the UI (PaperUI, Habmin) openhab-core#1029 Once this is set to false, the user can type the url string for the rfc2217 connection (rfc2217://:). I feel this is cumbersome and it would be much easier for the user to give them a place to specify IP and port # for the remote serial port and use those to construct the rfc2217 url in the absence of a physical serial port being selected from the drop down.
    @kaikreuzer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for extensive testing this. At least we know it works (besides the exception throwing. In know the dsmr binding does also works once the exceptions would be wrapped.). The openhab-core issue 1029 you mentioned was about the possibility to be able to add a network connection. It doesn't even address the usability of it, which is too bad. I also looked at the other bindings. It looks to me this has grown historically. In the past the gnu serial library was used directly, so no rfc2217 support was availble. So that earlier binding implemented their own version of it. Later versions seem to be made by the same person and he copied that implementation. The other bindings seem to add a bridge for ip configuration. I also noted we already approved your oppo binding that does the same.

So I'll guess it should be ok to leave it as is here. What I'm planning, is to see if I can get those quircks fixed in core so it behaves the same as other direct serial connections and than see if this makes it possible to remove the custom implementations for ip connections. For example here you could construct the rfc2217 connection fromt host-port input and then use the rfc2217 of core. The configurations can than still remain (with addition that rfc2217 configuration would be allowed on serialPort configuration). But that would not be available before openHAB 3.0.

Signed-off-by: Michael Lobstein <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@TravisBuddy
Copy link

Travis tests have failed

Hey @mlobstein,
please read the following log in order to understand the failure reason. There might also be some helpful tips along the way.
It will be awesome if you fix what is wrong and commit the changes.

Copy link
Member

@Hilbrand Hilbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TravisBuddy
Copy link

Travis tests were successful

Hey @mlobstein,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@Hilbrand Hilbrand merged commit ee31df3 into openhab:2.5.x Sep 2, 2020
@Hilbrand Hilbrand added this to the 2.5.9 milestone Sep 2, 2020
@mlobstein mlobstein deleted the NuvoAudio branch September 3, 2020 00:41
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Sep 12, 2020
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cre Coordinated Review Effort new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants