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

[unifi] New site, wlan, wiredClient, and poePort. Discovery support #11959

Merged
merged 21 commits into from
May 16, 2022

Conversation

Hilbrand
Copy link
Member

@Hilbrand Hilbrand commented Jan 4, 2022

New features:

  • New Things: wiredClient, poePort, site and wlan.
  • Added discovery support of things.
  • Added guest, and experience channel to wireless thing.
  • Added command channel named cmd to wireless thing as replacement for switch reconnect channel.
  • Added Dutch translation.
  • Also included some refactoring and bug fixes.

This change includes changes made by Matthew Bowman that he created on his own branch but were never completed.

Fixes:

Also-by: Matthew Bowman mgb@otr.mx
Signed-off-by: Hilbrand Bouwkamp hilbrand@h72.nl

@Hilbrand Hilbrand added bug An unexpected problem or unintended behavior of an add-on enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Jan 4, 2022
@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/unifi-beta/131156/1

@jlaur
Copy link
Contributor

jlaur commented Jan 4, 2022

@Hilbrand - I've just given this a test spin. It seems to reintroduce #7001 which was fixed by #11451. Two options:

  • Either something went wrong when moving UniFiController from api/model to api - did you perhaps start your changes a long time ago and lost some changes happening in meantime?
  • Or you deliberately refactored the client cache logic which accidentally caused this regression?

I would need to look deeper to understand what happened, but this might give you a clue. For reference:

// Prefer lookups through _id, until initialized use cid.
String id = cidToIdCache.get(cid);
synchronized (this) {
// mgb: first check active clients and fallback to insights if not found
client = clientsCache.get(id != null ? id : cid);
if (client == null) {
client = insightsCache.get(id != null ? id : cid);
}

changed back to:
synchronized (this) {
// mgb: first check active clients and fallback to insights if not found
client = clientsCache.get(cid);
if (client == null) {
client = insightsCache.get(cid);
}

@Hilbrand
Copy link
Member Author

Hilbrand commented Jan 4, 2022

@jlaur I did refactor this part, and also thought I handled this case. But didn't realize it keeps track of gone clients. I've updated the cache to not reset the map with references and use it to to get the id. So it should now work again. I've updated the marketplace jar.

@jlaur
Copy link
Contributor

jlaur commented Jan 5, 2022

I've updated the cache to not reset the map with references and use it to to get the id. So it should now work again.

Confirmed, it works again now.

This change adds the following changes:
- 2 new things: a wired client and POE port.
- Adds discovery of clients and poePort.
- Adds guest channel to client thing.
Also included some refactoring and bug fixes.

This change includes changes made by Matthew Bowman that he created on his own branch but were never completed.

Closes openhab#9609: Implemented async http call, which should fix the buffer overflow.
Closes openhab#10375: At least should avoid the stack overflow.
Closes openhab#11964: cid will be handled in lower case.

Also-by: Matthew Bowman <mgb@otr.mx>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@jlaur
Copy link
Contributor

jlaur commented Jan 11, 2022

@Hilbrand, I've been running this in production since January 5th and have so far discovered no issues. Only tested with access point though and so far only normal operation, i.e. stability and online channel working.

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@lolodomo lolodomo removed the bug An unexpected problem or unintended behavior of an add-on label Jan 14, 2022
It's redundant and only used for logging.

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@Hilbrand Hilbrand changed the title [unifi] New wiredClient and poePort, Discovery support [unifi] New site, elan, wiredClient, and poePort. Discovery support Feb 19, 2022
@Hilbrand Hilbrand changed the title [unifi] New site, elan, wiredClient, and poePort. Discovery support [unifi] New site, wlan, wiredClient, and poePort. Discovery support Feb 19, 2022
@jlaur
Copy link
Contributor

jlaur commented Feb 27, 2022

Ah crap... I've recompiled against 3.2.0 and updated the jar as I'm on 3.2.0, but didn't checked all channels and developed on 3.3.0... 😭 Reinstalling from the marketplace should fix this.

I compiled it myself, so probably I made a similar mistake as I'm deploying it to a 3.2 system. For now I added .longValue() three places in UniFiClientThingHandler where DecimalType is instantiated with Integer, so now working correctly. I'll try with a 3.3 snapshot later without these modifications.

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@jlaur
Copy link
Contributor

jlaur commented Mar 27, 2022

@Hilbrand - signoff is missing for last commit, can you fix the commit message? How much more work is planned before going out of draft state? If aiming for 3.3, perhaps we should try to get it ready for one of the next milestones?

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@Hilbrand Hilbrand removed the work in progress A PR that is not yet ready to be merged label Mar 30, 2022
@Hilbrand Hilbrand marked this pull request as ready for review March 30, 2022 07:27
@Hilbrand Hilbrand requested a review from mgbowman as a code owner March 30, 2022 07:27
@Hilbrand
Copy link
Member Author

At this moment I'm not planning additional features to this pr therefor I've removed the draft. So this pr can be reviewed for inclusion.

I've updated the description in the pr so it can be used as the message for the squashed merge of this pr (or I can squash this pr when the review is done).

I've included the new dutch translation. When this pr is merged and synchronized with crowdin I'll upload the dutch translation to crowdin to make sure it won't get lost when a new sync would be done.

Copy link
Contributor

@jlaur jlaur 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 all these improvements! The code looks really good, I have added only a few minor comments.

@jlaur
Copy link
Contributor

jlaur commented May 6, 2022

@Hilbrand - gentle ping. :) Only a few minor comments from my side to consider.

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
@jlaur
Copy link
Contributor

jlaur commented May 12, 2022

@Hilbrand - thanks, I've resolved the comments addressed by your last commit and left the rest open.

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Sorry, last round of proof-reading after last commit.

bundles/org.openhab.binding.unifi/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.unifi/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.unifi/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.unifi/README.md Outdated Show resolved Hide resolved
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks a lot for these many improvements!

@jlaur jlaur merged commit dec6483 into openhab:main May 16, 2022
@jlaur jlaur added this to the 3.3 milestone May 16, 2022
@Hilbrand Hilbrand deleted the unifi branch May 16, 2022 21:31
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…penhab#11959)

* [unifi] New wiredClient and poePort, Discovery support

This change adds the following changes:
- 2 new things: a wired client and POE port.
- Adds discovery of clients and poePort.
- Adds guest channel to client thing.
Also included some refactoring and bug fixes.

This change includes changes made by Matthew Bowman that he created on his own branch but were never completed.

Closes openhab#9609: Implemented async http call, which should fix the buffer overflow.
Closes openhab#10375: At least should avoid the stack overflow.
Closes openhab#11964: cid will be handled in lower case.

* Removed type from UniFiCache constructor

It's redundant and only used for logging.

* Added UniFi Site and wLAN things

* Improved default state handling

Updated refresh/state update, to also update when no data available.
Simplified usage of cache: call cache directly instead of implicit via controller class.
Made getDefaultState generic to all things, and simplified passing channelId instead of channelUID to sub methods.

* Moved dto objects to dto package.

* Added support for client experience

* Made fields private

No need to have them protected.

* Added PoE power-cycle command

Also added wireless client as command as this better fits with the openHAB model to handle commands that are only one way and not have a state.

* Updated readme

* [unifi] Added client/guest count to wlan

* Fix QRcode construction and added hidden ssid support in qrcode string

Also-by: Matthew Bowman <mgb@otr.mx>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Co-authored-by: Matthew Bowman <mgb@otr.mx>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…penhab#11959)

* [unifi] New wiredClient and poePort, Discovery support

This change adds the following changes:
- 2 new things: a wired client and POE port.
- Adds discovery of clients and poePort.
- Adds guest channel to client thing.
Also included some refactoring and bug fixes.

This change includes changes made by Matthew Bowman that he created on his own branch but were never completed.

Closes openhab#9609: Implemented async http call, which should fix the buffer overflow.
Closes openhab#10375: At least should avoid the stack overflow.
Closes openhab#11964: cid will be handled in lower case.

* Removed type from UniFiCache constructor

It's redundant and only used for logging.

* Added UniFi Site and wLAN things

* Improved default state handling

Updated refresh/state update, to also update when no data available.
Simplified usage of cache: call cache directly instead of implicit via controller class.
Made getDefaultState generic to all things, and simplified passing channelId instead of channelUID to sub methods.

* Moved dto objects to dto package.

* Added support for client experience

* Made fields private

No need to have them protected.

* Added PoE power-cycle command

Also added wireless client as command as this better fits with the openHAB model to handle commands that are only one way and not have a state.

* Updated readme

* [unifi] Added client/guest count to wlan

* Fix QRcode construction and added hidden ssid support in qrcode string

Also-by: Matthew Bowman <mgb@otr.mx>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Co-authored-by: Matthew Bowman <mgb@otr.mx>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
…penhab#11959)

* [unifi] New wiredClient and poePort, Discovery support

This change adds the following changes:
- 2 new things: a wired client and POE port.
- Adds discovery of clients and poePort.
- Adds guest channel to client thing.
Also included some refactoring and bug fixes.

This change includes changes made by Matthew Bowman that he created on his own branch but were never completed.

Closes openhab#9609: Implemented async http call, which should fix the buffer overflow.
Closes openhab#10375: At least should avoid the stack overflow.
Closes openhab#11964: cid will be handled in lower case.

* Removed type from UniFiCache constructor

It's redundant and only used for logging.

* Added UniFi Site and wLAN things

* Improved default state handling

Updated refresh/state update, to also update when no data available.
Simplified usage of cache: call cache directly instead of implicit via controller class.
Made getDefaultState generic to all things, and simplified passing channelId instead of channelUID to sub methods.

* Moved dto objects to dto package.

* Added support for client experience

* Made fields private

No need to have them protected.

* Added PoE power-cycle command

Also added wireless client as command as this better fits with the openHAB model to handle commands that are only one way and not have a state.

* Updated readme

* [unifi] Added client/guest count to wlan

* Fix QRcode construction and added hidden ssid support in qrcode string

Also-by: Matthew Bowman <mgb@otr.mx>
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Co-authored-by: Matthew Bowman <mgb@otr.mx>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
6 participants