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

[sony] New binding #6884

Closed
wants to merge 3 commits into from
Closed

[sony] New binding #6884

wants to merge 3 commits into from

Conversation

tmrobert8
Copy link

After 4 years of development - finally asking for a merge on the sony addon. This is the most complete sony implementation to date and will be one of the largest bindings to review (be prepared).

A few notes:

  1. This started as a 2.1 binding and I may have missed things that are now required (like I recently found out you need to set a status going out of a
  2. There are a number of standard conventions that I've purposely ignored because they don't make sense for this large of a binding and were detrimental. The biggest would be constants - binding wide constants are in SonyBindingConstants, service wide constants or constants that are referenced by more than one file would be in either a service constants file or in a higher level file, constants that affect only a specific file are in that file itself.
  3. I've left a number of todos, commented out code and comments in the code - these are important to keep as they have documented a number of things to remind me. The TODOs are generally things I need to find an example of. Commented out code generally was experimental code that may eventually go production or was an attempt that failed (but was important enought to document).
  4. Logging crazy - these binding has extreme amount of logging in it and defines both debug/trace levels as needed. I cannot reduce the amount of logging in that it's vital to debugging someone's system remotely.
  5. I already have a large user base - so please be aware of that when reviewing (like I'm really against changing channel names at this point or some very low level approach unless you find some drastic error with it).

Good luck and let me know what you'll need from me!

@tmrobert8 tmrobert8 added the new binding If someone has started to work on a binding. For a new binding PR. label Jan 21, 2020
@TravisBuddy
Copy link

Travis tests were successful

Hey @tmrobert8,
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
Contributor

@cpmeister cpmeister 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 @tmrobert8,
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 @tmrobert8,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@tmrobert8 tmrobert8 requested a review from a team as a code owner April 13, 2020 18:13
@TravisBuddy
Copy link

Travis tests were successful

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

2 similar comments
@TravisBuddy
Copy link

Travis tests were successful

Hey @tmrobert8,
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 @tmrobert8,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@AlejandroImagineInc
Copy link

Hi, I have STR DN1030 sound receiver
Could you tell me where i can get an instruction to install "org.openhab.binding.sony-2.5.5-SNAPSHOT" in openhab?
Thank you very much

@lsiepel
Copy link
Contributor

lsiepel commented May 2, 2020

Hi, I have STR DN1030 sound receiver
Could you tell me where i can get an instruction to install "org.openhab.binding.sony-2.5.5-SNAPSHOT" in openhab?
Thank you very much

I guess those questions belong here: https://community.openhab.org/t/sony-devices-binding/14052

Edit: All review comments are done right? 4 years of development wauw!

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.

Ok. I think I've reviewed this 😭 This is a horribly large pull request. Please don't that again 😜
In general my comments can be summarized as follows:

  • The Apache commons library will be removed in openHAB 3. Therefor it should not be used. Please replace all usages of this library (I guess the fastest is to add some util in you binding to implement the most used you have).
  • We don't have the immediate = true on Components. Please remove them (I commented on them, but I'm not sure if I got them all)
  • For java libraries we require to add a copyright notice about the library in the NOTICE file. I would suggest you need to do this for the JavaScript libraries you have included too (See some other NOTICE file on how to do it, it's 4 lines per item)
  • You have included a number of fonts. These add 2.3 MB to the size of the distribution. We try to minimize size as much as possible because with a lot of bindings it otherwise becomes a huge package. So my suggestion is to remove those fonts and rely on the standard provided fonts.
  • There are several other readme pages here. Recently I saw a comment about a missing page on our documentation page, which was also another additional page to a binding. So it looks like only the readme itself is published on the documentation page. Therefor it might be those other pages will not be available. This is something that might need to be looked into.

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.5-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<version>2.5.5-SNAPSHOT</version>
<version>2.5.9-SNAPSHOT</version>

Comment on lines +21 to +22
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
Copy link
Member

Choose a reason for hiding this comment

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

You need to remove all usages of the apache commons library as that library will be removed from openHAB 3.0.

public static final Integer RSP_WAIT_TIMEOUTSECONDS = 10;

/** The user agent for communications (and identification on the device) */
public static final String NET_USERAGENT = "OpenHab/Sony/Binding";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static final String NET_USERAGENT = "OpenHab/Sony/Binding";
public static final String NET_USERAGENT = "openHAB/Sony/Binding";

* @author Tim Roberts - Initial contribution
*/
@NonNullByDefault
@Component(immediate = true, service = ThingHandlerFactory.class, configurationPid = "sony.things")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Component(immediate = true, service = ThingHandlerFactory.class, configurationPid = "sony.things")
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.sony")

return new ArrayList<>();
}

return list.stream().filter(e -> e != null).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return list.stream().filter(e -> e != null).collect(Collectors.toList());
return list.stream().filter(Objects::nonNull).collect(Collectors.toList());

<default>eth0</default>
<advanced>true</advanced>
</parameter>
<parameter name="refresh" type="integer">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<parameter name="refresh" type="integer">
<parameter name="refresh" type="integer" unit="s">

Same comment for other parameters with time.

*
* <pre>
* {@code
need example
Copy link
Member

Choose a reason for hiding this comment

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

Remove empty example.

System.arraycopy(macBytes, 0, bytes, i, macBytes.length);
}

// logger.debug("Sending WOL to " + ipAddress + " (" + macAddress + ")");
Copy link
Member

Choose a reason for hiding this comment

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

Remove commented out code.

final Map<String, String> lowerMap1 = map1.entrySet().stream()
.map(s -> new AbstractMap.SimpleEntry<>(StringUtils.lowerCase(s.getKey()),
StringUtils.lowerCase(s.getValue())))
.collect(Collectors.toMap(k -> k.getKey(), v -> v.getValue()));
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't toLowerCase not work (without using the additonal .map)?

Suggested change
.collect(Collectors.toMap(k -> k.getKey(), v -> v.getValue()));
.collect(Collectors.toMap(k -> k.getKey().toLowerCase(), v -> v.getValue().toLowerCase()));


@Override
public boolean removeListener(final SonyModelListener listener) {
return sources.stream().map(s -> s.removeListener(listener)).anyMatch(e -> e);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return sources.stream().map(s -> s.removeListener(listener)).anyMatch(e -> e);
return sources.stream().map(s -> s.removeListener(listener)).anyMatch(Function.identity());

@openhab-bot
Copy link
Collaborator

Automatic code migration to openHAB 3 succeeded.

The resulting code can be found at https://ci.openhab.org/job/openHAB-Addons-Migration/53/artifact/bundles/.

You can download the migrated code from there and create a new PR against the master branch of the openhab-addons repo to contribute it for being included in openHAB 3.x.

Please see this issue about the details on how to proceed with your existing PR.

@openhab-bot
Copy link
Collaborator

Automatic code migration to openHAB 3 succeeded.

The resulting code can be found at https://ci.openhab.org/job/openHAB-Addons-Migration/115/artifact/bundles/.

You can download the migrated code from there and create a new PR against the main branch of the openhab-addons repo to contribute it for being included in openHAB 3.x.

Please see this issue about the details on how to proceed with your existing PR.

@kaikreuzer
Copy link
Member

Closing this PR as it is not in a mergeable state. Please follow the instructions to port this PR to the main branch for openHAB 3.

@kaikreuzer kaikreuzer closed this Jan 12, 2021
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.