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

[hueemulation] Migrate to bnd #5243

Merged
merged 8 commits into from
May 2, 2019

Conversation

davidgraeff
Copy link
Member

@davidgraeff davidgraeff commented Mar 25, 2019

Fixes #5419
Fixes #5424

  • Migrated to bnd (cherry pick possible)
  • Added Hue scenes support (via the automation engine)
  • Added Hue rules support (via the automation engine)
  • Added Hue schedules support (via the automation engine)
  • Added sensors support (exposing COLOR, DIMMER, ROLLERSHUTTER, SWITCH, CONTACT, NUMBER item types)
  • Self-check page with many statistics for troubleshooting
  • Added tests for all added functionality and extended other tests
    • All tests are non-OSGi tests now. REST access is tested via a local jersey server. upnp is tested via direct udp datagram sockets. Test coverage 90%.
    • There is only one OSGi test left for testing if the hue service comes up with all OSGi dependencies.

The Hue emulation service now provides about 95% of a real Hue bridge with firmware 1.22 and 100% of a Hue bridge with firmware 1.12.
Some details like https access and recurring timers with random element cannot be expressed by current openHAB means.

File statistics:

  • Tests: 3434 LOC (those are unit tests but also real http access tests for all endpoints)
  • Main: 6722 LOC (including non-java: 7027)
    • Service + UPNP Server + Utilities: 1672 LOC
    • Automation: 793 LOC
    • DTO: 1875 LOC
    • Logic/REST-API: 2342 LOC
  • Integration test: 236 LOC

Jar (works on OH 2.5 snapshots only)

  1. Uninstall an existing hue emulation service.
  2. Install the ("experimental") new rule engine
  3. Install any binding that uses and installs "upnp" (for example the Yahama binding)
  4. Download and unzip the following file
  5. Drop the unzipped jar into your addons directory.

V29
org.openhab.io.hueemulation-2.5.0-SNAPSHOT-v29.zip

Do not use this on your production system, as it does not respect former item <--> hue id mappings.

Head to http://your-ip:8080/api/status for the self test status page:
Bildschirmfoto vom 2019-04-15 19-59-25

@davidgraeff davidgraeff requested review from digitaldan and a team as code owners March 25, 2019 16:17
@davidgraeff davidgraeff added work in progress A PR that is not yet ready to be merged infrastructure Build system and Karaf related issues and PRs labels Mar 26, 2019
@martinvw
Copy link
Member

The build seems unhappy

@davidgraeff
Copy link
Member Author

Yup, I have added the wip label. I'm also extending this service atm to support rooms, scenes and rules.

@davidgraeff davidgraeff force-pushed the migrate_hueemulation branch 3 times, most recently from 1211cab to 1157c4c Compare April 6, 2019 08:37
@davidgraeff davidgraeff removed the work in progress A PR that is not yet ready to be merged label Apr 6, 2019
@davidgraeff
Copy link
Member Author

davidgraeff commented Apr 6, 2019

Because 9k lines of code is hard to review, how should I proceed here?

The service is very modular, so I could make multiple pull requests introducing one feature at a time? 1/4 of the code is also tests only.

To make the review process easier I have:

  • Checked all author tags
  • Checked all licenses
  • Fixed or worked around all SAT warning findings
  • Changed the formatter settings to include newlines for all java files
  • Performed an eclipse autoformat for all java files
  • Added javadoc to all classes with reduced (one line or zero line) javadoc for DTO classes

I will also try to find 2 people that can confirm it works for them.

@davidgraeff davidgraeff force-pushed the migrate_hueemulation branch from 1157c4c to 11ec316 Compare April 6, 2019 09:07
@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/hue-emulation-only-color-temperature-light/71832/4

@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/hue-emulation-re-sequences-hueids-on-openhab-service-restart-causes-out-of-sync-with-alexa/62294/7

@davidgraeff davidgraeff force-pushed the migrate_hueemulation branch from 11ec316 to 8e6b8ba Compare April 6, 2019 09:55
@wborn wborn changed the title [HueEmulation] Migrate to bnd [hueemulation] Migrate to bnd Apr 6, 2019
@mbehr1
Copy link

mbehr1 commented Apr 7, 2019

I'm testing the .jar you linked above but it fails to start:
│2019-04-07 08:07:34.279 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.io.hueemulation-2.5.0-SNAPSHOT.jar
.5.0-SNAPSHOT.zip&response-content-type=application%2Fzip [following] │org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.hueemulation [257]
Unresolved requirement: Import-Package: io.swagger.annotations; version="[1.5.0,2.0.0)"; resolution:="optional"
Unresolved requirement: Import-Package: org.openhab.core.automation.internal.module.handler

any suggestions? (as part of issue #5419)

@davidgraeff
Copy link
Member Author

I have updated the jar file and fixed that particular problem

@TheLexus
Copy link

I'm testing the .jar you linked above but it fails to start:
│2019-04-07 08:07:34.279 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.io.hueemulation-2.5.0-SNAPSHOT.jar
.5.0-SNAPSHOT.zip&response-content-type=application%2Fzip [following] │org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.hueemulation [257]
Unresolved requirement: Import-Package: io.swagger.annotations; version="[1.5.0,2.0.0)"; resolution:="optional"
Unresolved requirement: Import-Package: org.openhab.core.automation.internal.module.handler

I have the exact same problem with V5 jar from above. Do I need to add something else? Im on 2.5.0~S1566-1 from apt.

@davidgraeff
Copy link
Member Author

davidgraeff commented Apr 10, 2019

Are you sure that it is the exact error? Because org.openhab.core.automation.internal.module.handler cannot happen anymore, I'm pretty sure. org.openhab.core.automation can happen, if you haven't installed the new ("experimental") rule engine.

@TheLexus
Copy link

TheLexus commented Apr 10, 2019

Sorry David, my fault. Youre right, Rule Engine was missing!

Is there any change in using the hue emulation? I added a Lighting tag to one of my dimmers and connect a harmony hub. It finds multiple (really many) devices, but it seems that I did not add the one with the tag.

Are the tags obsolete?

@Matthy1810
Copy link

I still get an error during startup with V5 using 2.5.0 M1 from the debian repo. The experimental rule engine is installed.

Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.io.hueemulation-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.hueemulation [80]
Unresolved requirement: Import-Package: io.swagger.annotations; version="[1.5.0,2.0.0)"; resolution:="optional"
Unresolved requirement: Import-Package: org.openhab.core.automation

@davidgraeff
Copy link
Member Author

The readme file of this pull request might shed some light into which items are exposed.

Tags are not obsolete, but hue emulation will also expose items based on other criteria like the category and item type.

Regarding the unresolved requirement:
Can you please open the openhab console / karaf console (openhab-cli console) and enter bundle:list? That should show if automation is indeed installed and if it is the old eclipse automation or the new openHAB automation. I'm not sure when the renaming took place. Could be after oh 2.5m1 in which case this zip file only works on snapshots.

@Matthy1810
Copy link

The startup indeed works with the Snapshot-version. But now I have problems discovering my devices. I'm still on it.

J-N-K and others added 2 commits May 1, 2019 18:45
…io/hueemulation/internal/RuleUtils.java

Co-Authored-By: davidgraeff <[email protected]>
…io/hueemulation/internal/dto/changerequest/HueChangeRequest.java

Co-Authored-By: davidgraeff <[email protected]>
@davidgraeff
Copy link
Member Author

I'm currently reworking "org.openhab.core.io.rest.core". It's a mess. So can't work on this bundle atm, but should be able to address review comments by end of the week.

Signed-off-by: David Graeff <[email protected]>
Signed-off-by: David Graeff <[email protected]>
@J-N-K J-N-K added rebuild Triggers Jenkins PR build enhancement An enhancement or new feature for an existing add-on and removed rebuild Triggers Jenkins PR build labels May 2, 2019
@davidgraeff
Copy link
Member Author

Jenkins fails on AmazonEchoControl, but succeed with this service.
Merging now, to no longer blocking the migration.

@davidgraeff davidgraeff merged commit a5e6930 into openhab:master May 2, 2019
@mdeneen
Copy link

mdeneen commented May 2, 2019

Yes it's finished and working for myself and also two other people. I was waiting for more tests but no one had time yet apparently.

David,

I will try to test between now and this weekend. Thank you for your efforts!

@thesebastianf
Copy link

sorry
I still need to test more.
for now I strangely alexa does not discover all devices (I think it did with the old version).

a) I think it only finds "Lighing" tags but not "Switchable" tagged items
b) With the Alexa Openhab Skill those tags also expose GROUP items to alexa which works pretty good for my light and rolltershutter groups. While I could use a proxy switch for that it might also be possible to allow Group items in Hue Emulation?

best

@davidgraeff
Copy link
Member Author

If your group items are tagged as Lighting (or whatever you have configured) that should actually work otherwise it's a bug. Group items are per default exposed as Hue Groups.

@davidgraeff
Copy link
Member Author

When you guys find undefined, unclear behaviour or bugs in the implementation, please open new Issues so that I can keep track of them.

@mdeneen
Copy link

mdeneen commented May 5, 2019

How stable are the 2.5 snapshot builds? I didn't appreciate that the bundle was incompatible with the 2.4 release.

@davidgraeff
Copy link
Member Author

davidgraeff commented May 5, 2019

Unfortunately that had to be done because of #4602. I couldn't even add a migration routine, because the hue id sequence numbers were gone after stopping openHAB.

The current implementation is expected to be stable. The sequence numbers are stored as item metadata which is managed by the core.

@davidgraeff davidgraeff deleted the migrate_hueemulation branch May 5, 2019 19:33
@mdeneen
Copy link

mdeneen commented May 5, 2019

I tried updating to the latest 2.5 snapshot available through the openhabian repos, but openhab fails to start for unknown reasons -- nothing in the log.

I apologize for being unable to test the changes at this time.

mherwege pushed a commit to mherwege/openhab-addons that referenced this pull request May 10, 2019
* [HueEmulation] Migrate to bnd
* [hueemulation] Use JAX-RS for hue emulation

* Split RESTapi class into logical units (ConfigurationAccess, UserManagement, LightsAndGroups)
* rules support
* scenes support
* schedule support
* New self-test page under /api/status
* Refactor tests: Use jersey JAX-RS server to test without requiring the framework (non OSGi tests)
* Worked around doube-activate problem.

Signed-off-by: David Graeff <[email protected]>
@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/new-rules-engine/74428/12

1 similar comment
@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/new-rules-engine/74428/12

@wborn wborn added this to the 2.5 milestone May 26, 2019
@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/new-rules-engine/74428/12

Pshatsillo pushed a commit to Pshatsillo/openhab-addons that referenced this pull request Jun 19, 2019
* [HueEmulation] Migrate to bnd
* [hueemulation] Use JAX-RS for hue emulation

* Split RESTapi class into logical units (ConfigurationAccess, UserManagement, LightsAndGroups)
* rules support
* scenes support
* schedule support
* New self-test page under /api/status
* Refactor tests: Use jersey JAX-RS server to test without requiring the framework (non OSGi tests)
* Worked around doube-activate problem.

Signed-off-by: David Graeff <[email protected]>
Signed-off-by: Pshatsillo <[email protected]>
ne0h pushed a commit to ne0h/openhab-addons that referenced this pull request Sep 15, 2019
* [HueEmulation] Migrate to bnd
* [hueemulation] Use JAX-RS for hue emulation

* Split RESTapi class into logical units (ConfigurationAccess, UserManagement, LightsAndGroups)
* rules support
* scenes support
* schedule support
* New self-test page under /api/status
* Refactor tests: Use jersey JAX-RS server to test without requiring the framework (non OSGi tests)
* Worked around doube-activate problem.

Signed-off-by: David Graeff <[email protected]>
Signed-off-by: Maximilian Hess <[email protected]>
@wborn wborn removed the enhancement An enhancement or new feature for an existing add-on label Dec 8, 2019
@wborn wborn removed this from the 2.5 milestone Dec 8, 2019
@wborn wborn added this to the 2.5 milestone Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Build system and Karaf related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hueemulation] readyMarker not received. var started never gets true?