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

[vera] Vera Binding initial contribution #2283

Closed
wants to merge 15 commits into from

Conversation

MakeSimpleOrg
Copy link

No description provided.

@martinvw martinvw added the new binding If someone has started to work on a binding. For a new binding PR. label May 20, 2017
@lolodomo
Copy link
Contributor

@mrguessed : as the author of the 1.x binding, could you please review and comment on this new binding for OH2 ?

@MakeSimpleOrg
Copy link
Author

The main purpose was to make binding that do not require settings. Controller and devices are added in 2 clicks.
Everything is implemented, except thermostats and colored lamps. I do not have these devices for the test.
Based on Z-Way binding, but more simple.

How to correctly sign-off the first commit?

@martinvw
Copy link
Member

martinvw commented May 21, 2017

If you squash both commits you can also change the message, for squashing / rebasing see:
http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

@martinvw
Copy link
Member

Thanks for your PR!

Please include the build in the parent pom.xml in that case it will already be tested and analysed by travis.

Please also check:

http://docs.openhab.org/developers/development/bindings.html
http://docs.openhab.org/developers/development/guidelines.html

@MakeSimpleOrg
Copy link
Author

Something else? :)

Copy link
Member

@martinvw martinvw left a comment

Choose a reason for hiding this comment

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

Thanks for this binding, I think a lot people could profit from it.

I added some review remarks please take a look at them.


<name>Vera Binding</name>
<description>
<![CDATA[
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a useful description and do not add in a CDATA if there is nothing to escape.

Copy link
Author

Choose a reason for hiding this comment

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

done

<parameter-group name="veraController">
<label>Vera controller</label>
<description>The configuration of the Vera. All the information can be detected during the discovery.</description>
</parameter-group>
Copy link
Member

Choose a reason for hiding this comment

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

XML files should be indented using tabs according to our code formatter.

Please format using the ESH profile in eclipse

Copy link
Author

Choose a reason for hiding this comment

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

done

<context>network-address</context>
<label>IP address</label>
<description>The IP address or hostname of the Vera controller.</description>
<default>localhost</default>
Copy link
Member

Choose a reason for hiding this comment

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

This does not feel like a sane default or can you run the vera controller as software I thought it was some box.

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,78 @@
# binding
binding.vera2.name = Vera Binding
binding.vera2.description = description
Copy link
Member

Choose a reason for hiding this comment

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

Put the English texts just in place, use I18N for non-english only
@ThomDietrich @kaikreuzer @SJKA does this assumption comply with what others think about this subject?

Copy link
Author

Choose a reason for hiding this comment

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

done

<label>Vera Controller</label>
<description>
<![CDATA[
The Vera Controller
Copy link
Member

Choose a reason for hiding this comment

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

Please only escape if needed, or is there another reason you did this?

Copy link
Author

Choose a reason for hiding this comment

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

done

ThingUID thingUID = new ThingUID(VeraBindingConstants.THING_TYPE_BRIDGE,
ipAddress.replaceAll("\\.", "_"));

// Attention: if is already present as thing in the ThingRegistry
Copy link
Member

Choose a reason for hiding this comment

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

You can avoid this by an additional interface ExtendedDiscoveryService just search for it.

Copy link
Author

Choose a reason for hiding this comment

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

done

.withLabel("Vera controller " + ipAddress).build();
thingDiscovered(discoveryResult);
}
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need to catch the Exception-class or are there more specific exceptions you could catch like the IOException or maybe only RuntimeException's (which is not that good either). The current code and also catching RuntimeException's might 'hide' programming errors like NullPointerExceptions occurring.

https://www.google.nl/search?q=java%20why%20not%20to%20catch%20exception

Copy link
Author

Choose a reason for hiding this comment

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

done


List<Device> deviceList = mBridgeHandler.getData().devices;
for (Device device : deviceList) {
if (device.category.equals("0")) {
Copy link
Member

Choose a reason for hiding this comment

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

Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false. source: PMD

Copy link
Author

Choose a reason for hiding this comment

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

done

}
ThingUID thingUID = new ThingUID(THING_TYPE_DEVICE, mBridgeHandler.getThing().getUID(), device.id);
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withLabel(device.uName)
.withBridge(bridgeUID).withProperty(DEVICE_CONFIG_ID, device.id)
Copy link
Member

Choose a reason for hiding this comment

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

allign them such that the . get at a newline with one call per line.

Copy link
Author

Choose a reason for hiding this comment

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

formatter do that

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

It is missing from the parent pom.xml

Copy link
Member

Choose a reason for hiding this comment

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

To have the binding being picked up by the distro, you furthermore need to add it to the feature.xml, again at the alphabetically correct position. If you have a dependency on some transport bundle (e.g. upnp, mdns or serial), make sure to add a line for this dependency as well (see the other bindings as an example).

Copy link
Author

Choose a reason for hiding this comment

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

done

@MakeSimpleOrg
Copy link
Author

MakeSimpleOrg commented May 27, 2017

Great work @martinvw. I would not be able to find so many mistakes in someone else's code.
I'm glad that you did not see the first version of the code :)

I'll do everything as I find the time.

@martinvw
Copy link
Member

I'll do everything as I find the time.

Thanks for the first changes, just give a shout if you are ready.

@MakeSimpleOrg
Copy link
Author

MakeSimpleOrg commented May 31, 2017

I want to make 2 another bindings for Fibaro and Zipato controllers. They have a very similar api. No difference in binding code, only in api part. All devices for these controllers are the same.
Maybe, i need make a one binding for all?

@MakeSimpleOrg
Copy link
Author

Only README, rename and TODO remains only.
Maybe I'll write readme tomorrow. But can't implement any TODO items now, maybe other people can do that later.

@MakeSimpleOrg
Copy link
Author

@martinvw i am ready :)

@martinvw martinvw dismissed their stale review June 3, 2017 06:33

Give Kai a clean slate

@martinvw martinvw requested a review from kaikreuzer June 3, 2017 06:33
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
include the build in the parent project
add copyrights

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Add to pom and feature.
Fix equals.
Fix typo.
Change replaceAll to regexp.
Remove cdata.
Fix default ip.

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
enum for CategoryType
SerializedName for gson
format for all xml files
remove unused imports from manifest.mf
getters, setters, private fields
reuse gson
handle config change for bridge
remove unused code and cleanup

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Unnecessary code

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Descriptions.
Cleanup unused channels and code.
Remove i18n.

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
New parameters: clearNames and defaultRoomName.
Remove unused sensorTamper channel.
Remove polling for devices and scenes, all work is performed by the controller polling.
Refresh name, location and states during polling, after config change, or after manually refresh.

Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
Signed-off-by: Dmitriy Ponomarev <diamond5170@gmail.com>
@MakeSimpleOrg
Copy link
Author

MakeSimpleOrg commented Jun 10, 2017

Soo looong :)

While waiting, I made a new binding for the Fibaro.
How do I add it? If i push it, he will be added here, which is not good.

@martinvw
Copy link
Member

Soo looong :)

You should try to read (or better review) all the code which is currently pending as PR here ;-) That should be over 500K lines of code :-D

While waiting, I made a new binding for the Fibaro.
How do I add it? If i push it, he will be added here, which is not good.

You should use feature branches for that, with the term you should be able to find more info online.

@MakeSimpleOrg
Copy link
Author

Very fast approval ;)

@kaikreuzer
Copy link
Member

@diamond5170 Very sorry, this somehow completely fell of my plate - I know, there's no excuse :-/
Before spending the time to do a final review, I just like to check that you are still around and still waiting for it to be merged. Just give me a "peep" and I'll do the review within hours, promised!

@wborn wborn changed the title Vera controller binding for new SmartHome API version. [vera] Vera Binding initial contribution Dec 18, 2018
Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

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

Thanks for your awesome work on the new Vera Binding @diamond5170! The code looks good. 👍

I've added my comments below. Quite a few are due to the passing of time and the binding still not being merged.

Bundle-Name: Vera Binding
Bundle-SymbolicName: org.openhab.binding.vera;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.1.0.qualifier
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
Bundle-Version: 2.1.0.qualifier
Bundle-Version: 2.5.0.qualifier

http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true"
Copy link
Member

Choose a reason for hiding this comment

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

Please use DS annotations instead of adding these XML files:

  • Remove this file
  • Add a .gitignore file to this directory ignoring all XML file i.e.: *.xml
  • Annotate VeraBridgeDiscoveryService with:
@Component(service = DiscoveryService.class, immediate = true, configurationPid = "discovery.vera")

http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true"
Copy link
Member

Choose a reason for hiding this comment

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

Please use DS annotations instead of adding these XML files:

  • Remove this file
  • Add a .gitignore file to this directory ignoring all XML file i.e.: *.xml
  • Annotate VeraHandlerFactory with:
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.vera")

<h3>License</h3>

<p>
The openHAB community makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
Copy link
Member

Choose a reason for hiding this comment

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

Please replace this with a NOTICE file. See also this community topic.

.,\
OSGI-INF/,\
ESH-INF/,\
about.html
Copy link
Member

Choose a reason for hiding this comment

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

So this becomes:

Suggested change
about.html
NOTICE

updateState(channelUID, OnOffType.OFF);
}
} else {
logger.warn("Unknown command type: {}, {}, {}, {}", command, sceneId);
Copy link
Member

Choose a reason for hiding this comment

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

The number of parameters does not match the number of {} placeholders.

if (scene != null) {
logger.debug("Add scene as channel: {}", scene.getName());

HashMap<String, String> properties = new HashMap<>();
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
HashMap<String, String> properties = new HashMap<>();
Map<String, String> properties = new HashMap<>();

}

private synchronized void addChannel(String id, String acceptedItemType, String label,
HashMap<String, String> properties) {
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
HashMap<String, String> properties) {
Map<String, String> properties) {

return getBinaryState(device.getTripped());
}
case HVAC: // TODO
logger.warn("TODO: {}, {}", device, device.getCategoryType());
Copy link
Member

Choose a reason for hiding this comment

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

Can you change it to debug instead? I wouldn't like a log file full of warnings just because devices aren't yet supported by a binding. It would also help to make a note about this in the docs.

case Weather:
case PhilipsController:
case Appliance:
logger.warn("TODO: {}, {}", device, device.getCategoryType());
Copy link
Member

Choose a reason for hiding this comment

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

Can you change it to debug instead? I wouldn't like a log file full of warnings just because devices aren't yet supported by a binding. It would also help to make a note about this in the docs.

@martinvw
Copy link
Member

martinvw commented Mar 4, 2019

Hello @diamond5170,

Thanks for your contribution and sorry to keep you waiting. Because we are better staffed now we hope to wrap up a bunch of our old pending pull requests.

Our first important question is, are you still interested in finishing your binding and if so, can we get >your commitment to process the review comments in approximately 2-4 weeks.

What do we commit to, we will review your binding in the upcoming 1-2 week(s) and with a quick response from your side the binding should be merged in 2-4 weeks.

So the main question, are you able to commit to processing review comments of this PR in 2-4 weeks:

  • Yes, I’m going to process the comments in the next weeks.
  • Yes, but I’d like to get some help, (for example with my git branch and/or changes that have been made to openHAB that affect my contribution)
  • No, I have no time in the coming weeks. But please review it I will pick it up within 3 months.
  • No, I have other priorities or are not able to finish the work. I would welcome someone to takeover this PR (and I thus confirm the origin of my work )
  • No, this pr can be closed for reason: … (please specify. For example the service it connects to has been discontinued).

If you did not yet publish your binding on the marketplace and or announce it on the community forum that would be great thing to do as well:

See Distributing bindings through the IoT Marketplace

Thanks for your support,

Best regards,

The openhab2-maintainers

@wborn
@cweitkamp
@Hilbrand
@kaikreuzer
@martinvw

@cweitkamp cweitkamp added awaiting feedback cre Coordinated Review Effort labels Mar 13, 2019
@MakeSimpleOrg
Copy link
Author

I do not want to waste time.

@davidgraeff
Copy link
Member

I'm unsure about the state of this PR. Are the review comments being incorporated so that we can merge?

@J-N-K J-N-K added the stale As soon as a PR is marked stale, it can be removed 6 months later. label Apr 10, 2019
@martinvw martinvw removed the cre Coordinated Review Effort label Jul 10, 2019
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

Oh hell - I just noticed here that I had some pending review comments (since more than a year). Afair, I was waiting for a peep, which never came :-( .

Are the review comments being incorporated so that we can merge?

Afaics, only @martinvw's comments were addressed, so in order to merge this PR, there's still something to do.
As @diamond5170 seems to have lost interest in pursuing this further, is there anybody else using Vera and interested to get this job finished?

<context>network-address</context>
<label>IP address</label>
<description>The IP address or hostname of the Vera controller.</description>
<default>192.168.1.10</default>
Copy link
Member

Choose a reason for hiding this comment

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

remove this and rather add required=true instead.

http://eclipse.org/smarthome/schemas/config-description-1.0.0.xsd">
<config-description uri="binding:vera:veraController">

<parameter-group name="veraController">
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to remove this group as you do not have that many parameters.

<state readOnly="false" />
</channel-type>

<channel-type id="battery">
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this and rather use the existing system.battery-level type (see https://www.eclipse.org/smarthome/documentation/development/bindings/thing-definition.html#channels)

<channel-type id="doorlock">
<item-type>Switch</item-type>
<label>Doorlock</label>
<category>Door</category>
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line, it isn't a door, it is a lock :-)

</channel-type>

<channel-type id="doorlock">
<item-type>Switch</item-type>
Copy link
Member

Choose a reason for hiding this comment

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

please re-apply the auto-formatter


Another discovery service provides available devices. The device discovery service is performed at a specified interval, but can also be started manually.

Note: devices with type "controller" and "interface" not loaded.
Copy link
Member

Choose a reason for hiding this comment

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

What does "not loaded" mean here? Could you reformulate this?


## Thing Configuration

The textual configuration (via \*.thing files) isn't useful because the resulting elements are read-only. But the configuration and properties of things are changed at runtime and channels are dynamically added and removed.
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct, at least not anymore. If your binding dynamically adds properties and channels, this is also applied to things defined in a file, you do not need to worry about how the things are defined. You can therefore remove this statement.

- 26: Philips Controller
- 27: Appliance

The integration for most of these types isn't planned.
Copy link
Member

Choose a reason for hiding this comment

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

remove this


The integration for most of these types isn't planned.

Thermostats and colored lamps are also not supported, but will be implemented later.
Copy link
Member

Choose a reason for hiding this comment

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

remove this


The locations are loaded during the discovery and based on the Vera devices rooms.

## Developer stuff
Copy link
Member

Choose a reason for hiding this comment

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

This should go in a separate file, but as there isn't much content right now anyhow, you can simply remove it here.

@Hilbrand Hilbrand added oh1 migration Relates to migrating an openHAB 1 addon to openHAB 2 and removed oh1 migration Relates to migrating an openHAB 1 addon to openHAB 2 labels Sep 13, 2019
@J-N-K
Copy link
Member

J-N-K commented Sep 22, 2019

Closing due to inactivity for more than six month. If someone intends to continue working on this, please open a new PR. Thanks.

@renescherer
Copy link
Contributor

renescherer commented Oct 12, 2019

I'm happy to have a look at this binding and hopefully get it to a state where it can be merge. I'm not that familiar with the PR code commenting system. Apart from @kaikreuzer comments (28 July) above, are there other things outstanding?

I noticed that the code in @diamond5170 repo is still based on the old folder structure. What is the best thing to migrate this. Shall I run the new binding script to create the necessary entry in the new structure and then copy the code over manually?

@Hilbrand
Copy link
Member

@renescherer great if you can pick up this binding. I quickly browsed the code. In general it looks ok. I do expect some additional comments, but not to much.

Using the binding script is the fastest way to get it migrated. I wrote a tutorial, maybe you've seen it: https://community.openhab.org/t/tutorial-migrate-your-binding-to-the-maven-bnd-based-build-system/81389

@Hilbrand
Copy link
Member

@renescherer To update the license text in all source files you can run mvn license:format.

@digitlength
Copy link
Contributor

@renescherer I am still using a Vera Lite with UI5. I'm available to test!

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/need-help-with-vera-binding/114120/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR. oh1 migration Relates to migrating an openHAB 1 addon to openHAB 2 stale As soon as a PR is marked stale, it can be removed 6 months later.
Projects
None yet
Development

Successfully merging this pull request may close these issues.