-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
@mrguessed : as the author of the 1.x binding, could you please review and comment on this new binding for OH2 ? |
The main purpose was to make binding that do not require settings. Controller and devices are added in 2 clicks. How to correctly sign-off the first commit? |
If you squash both commits you can also change the message, for squashing / rebasing see: |
Thanks for your PR! Please include the build in the parent Please also check: http://docs.openhab.org/developers/development/bindings.html |
Something else? :) |
There was a problem hiding this 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[ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"?> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Great work @martinvw. I would not be able to find so many mistakes in someone else's code. I'll do everything as I find the time. |
Thanks for the first changes, just give a shout if you are ready. |
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. |
Only README, rename and TODO remains only. |
@martinvw i am ready :) |
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>
Soo looong :) While waiting, I made a new binding for the Fibaro. |
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
You should use feature branches for that, with the term you should be able to find more info online. |
Very fast approval ;) |
@diamond5170 Very sorry, this somehow completely fell of my plate - I know, there's no excuse :-/ |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 ("Content"). Unless otherwise |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this becomes:
about.html | |
NOTICE |
updateState(channelUID, OnOffType.OFF); | ||
} | ||
} else { | ||
logger.warn("Unknown command type: {}, {}, {}, {}", command, sceneId); |
There was a problem hiding this comment.
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<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashMap<String, String> properties) { | |
Map<String, String> properties) { |
return getBinaryState(device.getTripped()); | ||
} | ||
case HVAC: // TODO | ||
logger.warn("TODO: {}, {}", device, device.getCategoryType()); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
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:
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 |
I do not want to waste time. |
I'm unsure about the state of this PR. Are the review comments being incorporated so that we can merge? |
There was a problem hiding this 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> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Closing due to inactivity for more than six month. If someone intends to continue working on this, please open a new PR. Thanks. |
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? |
@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 |
@renescherer To update the license text in all source files you can run |
@renescherer I am still using a Vera Lite with UI5. I'm available to test! |
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 |
No description provided.