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

[verisure] Verisure Binding initial contribution #4789

Merged
merged 68 commits into from Jul 9, 2020

Conversation

jannegpriv
Copy link
Contributor

@jannegpriv jannegpriv commented Feb 3, 2019

[verisure] Initial contribution of Verisure binding.

This has already appeared as a pull request before #3455, but @jarlebh is no longer active in OH community.

I’ve made a re-design of the Verisure binding to support multiple installations/sites since I also have a Verisure installation at my summer house.

I’ve based the re-design on the work made by @Andreas_L, @jarlebh and @MSV12 but updated it to handle multiple sites, the changes are not backward compatible so all discovered things will get new internal IDs.

I’ve also added support for some new things:

  • Bridge
  • Alarm
  • Smoke Detector (climate)
  • Water Detector (climate)
  • Siren (climate)
  • Night Control
  • Yaleman SmartLock
  • SmartPlug
  • Door/Window Status
  • User Presence Status
  • Broadband Connection Status

I’ve also compiled a jar-file based on OH2.5 but it also works for OH2.4.

openhab@openhab2:/usr/share/openhab2/addons $ md5sum org.openhab.binding.verisure-2.5.0-SNAPSHOT.jar 
a5b12e83b0120f9dbd31a765dd658d3f  org.openhab.binding.verisure-2.5.0-SNAPSHOT.jar

I've checked and corrected output from static code analysis.

Commit has been signed off.

URL to the community thread.

Fixes #4788

@jannegpriv jannegpriv requested a review from a team as a code owner February 3, 2019 15:39
@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/testers-for-verisure-openhab-2-binding/7499/150

@cweitkamp cweitkamp added the new binding If someone has started to work on a binding. For a new binding PR. label Feb 4, 2019
@Hilbrand
Copy link
Member

Hilbrand commented Feb 4, 2019

Ok just to make sure everybody is in agreement. @jarlebh can you give feedback on if your oke with this updated implementation replacing your pr? Or @jannegpriv if you have more information from @jarlebh can you provide that here?

@jannegpriv
Copy link
Contributor Author

I was in email-contact with Jarle during the autumn when I fixed an issue #3849 with the Tellstick-binding, since Jarle was the author of that aswell. Jarle then told me that he had moved to HA, I've not been in contact with Jarle since that.

@jarlebh
Copy link

jarlebh commented Feb 5, 2019 via email

@Hilbrand
Copy link
Member

Hilbrand commented Feb 5, 2019

@jannegpriv and @jarlebh thanks for your responses. I'll close pr #3455 and we'll continue with this pr.

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.

Thank you for picking up this binding. I've done a first review. I've looked at small style issues that make the code more readable and in style with openHAB. I understand some parts of the code were already there and you just build on it. So some comments might be on older code and something you also might have seen that could have been better.

I've also looked at some more structural issues. In general the code looks good. But there is a lot of duplicated code. This makes it harder to detect/review bugs. If something has been fixed at one place, it might be needed to fixed at other places. But due to the amount of code that might be difficult to detect.

Regarding the structural part. There is a lot of code related to sending commands that does look very similar. The code would greatly benefit if you can extract some generic component out of it and pass variables to the method. I think this can greatly reduce the code.

Another change could be to create separate handler classes for each device type (thing). Then in each handler you can restrict the code to what is needed for that device type. You could create a base class to handle the general part of the code.

I understand these changes are not small. But I think if you are willing to do are worth the effect and would make it easier to add new devices or make changes in case the api of the device changes.

The structural changes are more suggestions. So feel free to comment or discuss my review comments or ask for advice.

@jannegpriv
Copy link
Contributor Author

I've now gone through the review comments and I have made some refactoring and restructioning of the binding. I must say that the review comments were very accurate and extensive and I've learnt a lot from them, kudos for that :-)

I've now run into problems with my branch, since after some days I could no longer compile it with maven (mvn clean install -P check) and the only way I oould resolve it was to sync my branch with latest changes from master. So now my git log contains merges and I'm not that used to git so when doing a git rebase -i HEAD~5 to try to sqaush my last 5 commits, I got a long (42 items) list of commits where only 5 of them were mine and they were not in order.

Should I create a new PR with a clean branch or how should I continue? I could of course push my changes to my branch for further review, and then after fixing those comments create a new branch.

@jannegpriv
Copy link
Contributor Author

I pushed up my latest updates for review, I will then need help on how to proceed.

@wborn wborn changed the title [verisure] Initial contribution [verisure] Verisure Binding initial contribution Feb 20, 2019
@Hilbrand
Copy link
Member

Hilbrand commented Mar 1, 2019

Do you still have problems with your branch? It should not be necessary to create a new pr. It's always possible to fix the branch. If you still have problems let me know. I see you made some changes, but now the sign off is missing. Can you re-add them (or squash the commits and add it the one commit)?

If you still have problems with the building, you might need to rebase again from master. There have been a number of changes lately due to changes to openhab-core, which resulted in problems with openhab2 addons. It could be you just merged at such point. Updating again should fix that.

In general updating source to the latest from the remote master can be done with git pull --rebase and than push the changes back to your branch with git push --force-with-lease.

@jannegpriv
Copy link
Contributor Author

Do you still have problems with your branch? It should not be necessary to create a new pr. It's always possible to fix the branch. If you still have problems let me know. I see you made some changes, but now the sign off is missing. Can you re-add them (or squash the commits and add it the one commit)?

After syncing my branch with master a while ago I managed to get my branch to compile again.
I do need help with the squash since I've synced my branch with upstream/master in the middle of my commits.
I think I accidently also merged my local branch changes into my my local master branch, however that should not impact my local feature branch and the squash.

A git log in my branch reveals 6 commits that I've made, including 2 merges.

$ git log
commit ac23666cbef5065a89eb198e65da613f5118ca9a (HEAD -> 4788-verisure, origin/4788-verisure)
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Fri Feb 22 21:32:08 2019 +0100

    Fixed an introduced bug and added a new string to login URL.

commit 3cfd79c8f6e28ba92a5d30a573d044cd31dc6195
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Sun Feb 17 12:39:48 2019 +0100

    Updated and refactored after review comments

commit 621ffb3453eef086c29dc475e1a8b92138ea9017
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Tue Feb 12 22:50:05 2019 +0100

    Continue with refactoring and adaptions of review comments

commit 62bf997845dcd034a796102581d79bfa975a5029
Merge: a27912d2cb a31d83657d
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Mon Feb 11 21:23:23 2019 +0100

    Merge branch 'master' into 4788-verisure

commit a31d83657dbb2c7b4e69277a9841283cb65469de (master)
Merge: 07acf4c56b 543cf472ab
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Mon Feb 11 20:53:52 2019 +0100

    Merge remote-tracking branch 'origin/4788-verisure'

commit a27912d2cbf060dc80c4bdb2c6d2bdb33c9ecad1
Author: jannegpriv <jannegpriv@gmail.com>
Date:   Mon Feb 11 20:53:05 2019 +0100

    Updated after review comments

commit 07acf4c56bf42e06589de938c1e19bb66fbd3063 (upstream/master)
Author: J-N-K <J-N-K@users.noreply.github.com>
Date:   Mon Feb 11 20:29:35 2019 +0100

    [network] fixes excessive testing of arping method during discovery (#4854)
    
    fixes escessive testing of arping method during discovery
    
    Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>

I then tried to squash my 6 commits via `git rebase -i HEAD~6, I then get a long list of commits in the editor:

$ git rebase -i HEAD~6

pick 543cf472ab Initial Verisure binding. Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh) Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
pick a27912d2cb Updated after review comments
pick d0c58b9b96 Added Standby Switch (#4791)
pick 2f5d7db81d [bluetooth] fix typo in documentation (#4795)
pick fa9408fdfe [onewire] Fixed NumberFormatException (#4777)
pick 8693bced53 [amazonechocontrol] State update bugfixes (#4792)
pick 73a66f28be [Nibeuplink] Minor bugfixes (#4773)
pick 1011ffa8b2 [onewire] fix DS2438 Vad measurement (#4770)
pick 1549b646cd [homekit] Augment README with some debugging help, links, and other help (#4464)
pick 4866a36c06 Remove step size to support smaller increments for volume control (#4799)
pick dd0ce62b71 [gpstracker] Fixed URL to OwnTracks in Google Play Store. (#4798)
pick 040880a71b Fixed spelling of channel id in example (#4803)
pick 07faf6f96d adapted addons to the new openhab-core (#4809)
pick 6f244c28e5 [solaredge] improved documentation / minor bugfix (#4771)
pick 2fa113a156 [dsmr.test] replaced tabs with spaces in pom.xml (#4811)
pick a7e6bc67fb Removed lolodomo from CODEOWNERS for Hue binding (#4813)
pick 0949659229 [openweathermap] Fixed and improved translations (#4740)
pick 9ff7621fdf [sonos] Added PlayLineIn as a standard channel (#4810)
pick e1d8a9503b [modbus] update time-of-last-update (#4802)
pick 58e38f2130 [hue] Improved ONLINE/OFFLINE handling of things (#4805)
pick 19cf63ec11 [homebuilder] Removed files from repository which are deleted by 'mvn clean' (#4814)
pick 73e24d3e5a [amazonechocontrol] (#4817)
pick e2f2e34486 [tplink] Added KL110, KL120, and KL130 Light Bulb Support (#4818)
pick 9460b1878f [Network] Present used arping tool to user (#4821)
pick ddfc06ea1c Fix mixed content (#4823)
pick 3451e084c7 [Network] Fix regex for tool recognition (#4822)
pick 0bbc40fdde adapted feature names to new openhab-core (#4826)
pick f64f89519a [nibeheatpump] Support for Nibe F1x55 (#4796)
pick d7ad7620be Added removed files to .gitignore (#4831)
pick 52da6cb26a Changed feature dependencies to openHAB Core (#4832)
pick 103300be22 [hue] Added configuration for port (#4728)
pick ceb6f8d2ec fixed automation feature references (#4840)
pick 2a2372b13d [network] Fix arping command line (#4843)
pick 46898ded19 [amazonechocontrol] Removed jsoup library (#4838)
pick 411f00decc [systeminfo] Updated OSHI library and minor improvements (#4834)
pick 372fc49354 removed patch folder from classpath (#4853)
pick 0a5e0fc889 [Network] fix oom bug (#4827)
pick 8335f3787b [mqtt] Update README.md (#4861)
pick 55fd980223 [knx] DPT 232.600 sends percentage instead of byte (#4864)
pick 07acf4c56b [network] fixes excessive testing of arping method during discovery (#4854)
pick 621ffb3453 Continue with refactoring and adaptions of review comments
pick 3cfd79c8f6 Updated and refactored after review comments
pick ac23666cbe Fixed an introduced bug and added a new string to login URL.

# Rebase 23ae9f8c9f..ac23666cbe onto 23ae9f8c9f (43 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
"~/git/openhab2-master/git/openhab2-addons/.git/rebase-merge/git-rebase-todo" 62L, 3629C

Here I'm lost since my commits are not in a chronological order due to the merge.
Is there another way of doing it? I really need step to step instructions I'm afraid :-)
5 listed rows are my commits, how should the list look like, can I just move my 5 rows to the top?
What should I do with all other commits?

If I get help with solving this this sqaush there is only need or one sign-off, isn't it? I should be able to edit the commit message as a part of the squash procedure if I'n not mistaking.

In general updating source to the latest from the remote master can be done with git pull --rebase and than push the changes back to your branch with git push --force-with-lease.

I've always used the following schema for updating my local master and local feature branch with latest upstream master changes:

  1. git fetch upstream
  2. git checkout master
  3. [master] git merge upstream/master
  4. git checkout local_feature_branch
  5. [local_feature_branch] git merge master

I then push my changes to my local branch to origin via git push origin local_feature_branch.

My remotes:

$ git remote -v
origin	https://github.com/jannegpriv/openhab2-addons.git (fetch)
origin	https://github.com/jannegpriv/openhab2-addons.git (push)
upstream	https://github.com/openhab/openhab2-addons.git (fetch)
upstream	https://github.com/openhab/openhab2-addons.git (push)

The command sequence you listed, how is the use-case flow I described in step 1)-5) for updating local master and local feature branch and then pushing local feature branch done using those commands?

I'm really glad for the all the help and I'm eager to get this resolved! :-)

@Hilbrand
Copy link
Member

Hilbrand commented Mar 2, 2019

5 listed rows are my commits, how should the list look like, can I just move my 5 rows to the top?
What should I do with all other commits?

Yes you can move them to the top. It would look as if you had rebased on master. When done you must push force to github otherwise it will not work.
What you can do is just create a new branch as backup so you can more easily rollback if you need to redo the changes.

If I get help with solving this this sqaush there is only need or one sign-off, isn't it?

Yes that's correct.

The command sequence you listed, how is the use-case flow I described in step 1)-5) for updating local master and local feature branch and then pushing local feature branch done using those commands?

Assuming you don't commit on master, it's all the same except for step 5: git rebase master. That will recommit your own commits on the branch on top of the updated master. But it changes the history of that branch. Therefor you need to push force it back to github.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
@TravisBuddy
Copy link

Travis tests were successful

Hey @jannegpriv,
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: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
@TravisBuddy
Copy link

Travis tests were successful

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

…e review remark. Added more info to README.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
@TravisBuddy
Copy link

Travis tests were successful

Hey @jannegpriv,
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 requested a review from fwolter July 8, 2020 19:13
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.

LGTM, but there are some formatting issues. You can view them with mvn spotless:check -Dspotless.check.skip=false and fix them with mvn spotless:apply.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
@Hilbrand Hilbrand requested a review from fwolter July 9, 2020 06:26
@TravisBuddy
Copy link

Travis tests were successful

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

@fwolter
Copy link
Member

fwolter commented Jul 9, 2020

Just waiting for Jenkins to build before merging. @Hilbrand do you know why the DCO check fails?

@Hilbrand
Copy link
Member

Hilbrand commented Jul 9, 2020

The DCO check sometimes seems to be magic. Because while it looks like it's correctly signed of it still fails. Sometimes it's because a commit is made with a different e-mail as used in the sign-off, but other times I have no idea. In general when there is a sign off in the commit (or at lease a sign off in a single commit) we consider it signed off. And when we merge it's squashed anyway so the merged commit message can updated with the signed off as set in the original commit.

@Hilbrand Hilbrand merged commit b5c5e39 into openhab:2.5.x Jul 9, 2020
@fwolter fwolter added this to the 2.5.7 milestone Jul 9, 2020

@Override
public void run() {
logger.debug("Trigger Event {} on {} at time {}", event, vth, DateTime.now());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace by ZonedDateTime.

logger.debug("Trigger Event {} on {} at time {}", event, vth, ZonedDateTime.now());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

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 create a new pull request with this commit as this pull request is merged already.

import org.eclipse.smarthome.core.thing.binding.BridgeHandler;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.RefreshType;
import org.joda.time.DateTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

The usage of org.joda.time is deprecated and already removed from OHC (see openhab/openhab-core#1342).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

knikhilwiz pushed a commit to knikhilwiz/openhab2-addons that referenced this pull request Jul 12, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
@fwolter fwolter removed the cre Coordinated Review Effort label Jul 22, 2020
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
Signed-off-by: CSchlipp <christian@schlipp.de>
MPH80 pushed a commit to MPH80/openhab-addons that referenced this pull request Aug 3, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
Signed-off-by: MPH80 <michael@hazelden.me>
@openhab openhab deleted a comment Aug 12, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
Also-by: Jarle Hjortland <jarlebh@gmail.com> (github: jarlebh)
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[verisure] Verisure Binding initial contribution