gethomepage / homepage

A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.
https://gethomepage.dev
GNU General Public License v3.0
19.38k stars 1.16k forks source link

[Feature Request] TPLink Omada Widget #202

Closed madkatz01 closed 1 year ago

madkatz01 commented 2 years ago

TPLink Omada is a becoming popular home networking hardware (similar to Ubiquiti's UniFi system) and they have a pretty extensive API for retrieving information on the network status. Would be awesome to have this added as a widget.

Here is a link to their published API for their current v5.0+ controllers: https://static-community.tp-link.com/attach/8/2/2022/78d3f067ac0c491d931426e040188632.zip

darrylgibbs commented 2 years ago

I second this!

aidzer0 commented 1 year ago

I third this! Came here to submit enhancement! Cheers!

Oupsman commented 1 year ago

After 2 hours of struggle (I'm no JS developper) I have a working widget that display the number of active AP and the number of clients connected to the wifi.

because I only use Omada soft controler (version 3.2.17) with 4 AP

aidzer0 commented 1 year ago

Thats amazing work! I look forward to the commit.

Get this man a beer and a JS developer!

Oupsman commented 1 year ago

For now, I am really not ready for the pull request, my code is really ugly (even to my low standards) and I can't get the labels to display properly. DeepinScreenshot_select-area_20221205213623

aidzer0 commented 1 year ago

For now, I am really not ready for the pull request, my code is really ugly (even to my low standards) and I can't get the labels to display properly. DeepinScreenshot_select-area_20221205213623

Oh for sure no rush, it’s awesome someone is looking into this, it’s a huge leap forward from nothing haha, I for one have no clue how to do any of that.. so you are miles ahead of me.

shamoon commented 1 year ago

If you post it somewhere accessible someone (yes maybe me) might have some time to look. only if you want to, of course.

Also, since I dont have one of these would need some help getting fake API output from the device

Oupsman commented 1 year ago

Let me first try to find out how I could possibly have fucked the translation system up on my local copy and I get back to you.

The code is here : https://github.com/Oupsman/homepage

shamoon commented 1 year ago

It doesnt look so bad =)

For translation files you only edit en, the rest come through a translation service we use.

And for displaying those strings it should look like <Block label="omada.connectedAp" value={t("common.number", { value: omadaData.connectedAp })} /> like you had it before

Oupsman commented 1 year ago

Thanks.

I added the translations in both en and fr (because I'm French). I've removed the translations from the french file but I still have problems : DeepinScreenshot_select-area_20221205223725

I'll try to fix it tomorrow.

Oupsman commented 1 year ago

I have fixed the code this morning, and it seems to work fine on my old controller. But I've tested it against a modern one and it doesn't work. So for now, no PR because I don't think anyone else uses an old controller.

aidzer0 commented 1 year ago

When you say Old/New controller, is the new one Version:5.7.4? That's the one I am running at the moment.

Also, good job! excellent work mate.

Oupsman commented 1 year ago

Yes, the old controller is version 3.x.x the new controller is version 4 and more.

I have a code that seems to work for these controllers, can I submit the PR ?

aidzer0 commented 1 year ago

I reckon you do, I don’t know though, if you’re confident with the code, I don’t see why not.

Oupsman commented 1 year ago

The Omada API is hell on earth ! Between versions, the fields needed for stats are changing. So I closed my pull request until I have a code working on the three versions I can test on.

Sorry

aidzer0 commented 1 year ago

No worries mate, don’t be sorry :) getting it working on 3 different versions sounds light a nightmare!

Oupsman commented 1 year ago

@shamoon could you please give me your feedback on the code I pushed on my repo ?

PS : I setup a few controllers for me to test on : I've deployed 2 controllers, one in 4.4.8 and one in 5.7.4 so I can have real tests.

shamoon commented 1 year ago

Wow, I see what a pain it is to support the two APIs. Not sure when I'll have time to test, youre saying they can be easily deployed as docker containers (I dont have the hardware ofc)?

Also, what does a widget with 8 blocks look like?

Oupsman commented 1 year ago

A widget with 8 blocks is quite difficult to read, but I think that all data can be important. Maybe create two widgets and filter the fields ? I've tested it because on a V3 controller, all fields are not available.

Oupsman commented 1 year ago

Here is a screenshot of my homepage : DeepinScreenshot_select-area_20221210173120

Oupsman commented 1 year ago

To deploy an omada controller as a docker container : https://github.com/mbentley/docker-omada-controller

shamoon commented 1 year ago

yea messy. So youre trying to support v3, v4 and v5?

Yea 8 blocks is too much =)

Oupsman commented 1 year ago

I want to support v3 to v5, yes. Because I'm still using v3 :)

Do you think I should split the blocks in two lines ?

EDIT : but I don't understand how to do it.

Oupsman commented 1 year ago

I may have another idea, and I'd like feedback : I can also divide the widget in two parts : one for WLAN and the other one pour LAN/WAN. Because I think most people are interested in WLAN metrics. Beside, the V3 code is only useful for WLAN as V3 controllers can't manage switches and gateways.

What do you all think about that ?

darrylgibbs commented 1 year ago

Splitting into WLAN/LAN/WAN would be amazing!

Oupsman commented 1 year ago

Ok, I've split the widget in two, the tests are good so far. DeepinScreenshot_select-area_20221213092629

@shamoon : I did not duplicate the code, did not touch anything in the omada widget (except removing the unwanted fields). The omadalan widget imports the proxy from the omada widget. But I'm not sure that's the best way to do so, so feel free to give me ANY feedback you see fit.

shamoon commented 1 year ago

TBH I would just choose the 4/5 stats you think are most important. If not, make it a configuration option on the widget instead of two separate widgets.

Oupsman commented 1 year ago

TBH I would just choose the 4/5 stats you think are most important. If not, make it a configuration option on the widget instead of two separate widgets.

Why make a configuration option when the user can select the wanted fields ? I mean, the code will be the same, because all the data are collected with a single API call.

shamoon commented 1 year ago

Because the widget should work "out-of-the-box" and not be unusable if the user doesnt specify anything

Oupsman commented 1 year ago

OK then, a setting "mode" with two choices : WLAN and LAN and a default value of WLAN. That seems to be the less bad option to me.

shamoon commented 1 year ago

Yes sure, or just chose 2/3 of each. Almost all widgets make some choices about what data to show. Homepage isn’t meant to be a comprehensive tool for monitoring every service / device it’s supposed to summarize important / useful info, briefly. For example the unifi widgets pare down the data quite a bit…

Oupsman commented 1 year ago

Thanks, I took inspiration from the unifi widget and my code will display the number of connected switches and the number of connected gateways only if there is something to display (aka, the number is greater than 0)

When I first opened the PR, you mentioned minor issues with the code, could you please give them to me so I can correct my code ?

shamoon commented 1 year ago

When I first opened the PR, you mentioned minor issues with the code, could you please give them to me so I can correct my code ?

Your code has increased in complexity quite a bit since then with the supporting of multiple versions etc. and it won’t be trivial to test (don’t have hardware, have to spin up multiple containers etc). The last time I looked it seemed it now needs a bit more but I don’t have specifics. Please get the PR to where you are happy with it and when we have time one of us will review, not sure exactly when.

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns.