How to edit a Lovelace plugin?

Assume there is a Lovelace plugin.
It was installed by HACS and is stored here:
изображение

Since HA is an open-source project, everyone is supposed to be welcome to contribute.
Assume I want to add some new features to some custom card, correct bugs etc.
And I want to achieve it by PR.

But before proposing a PR - I need to test it locally.
So, I go to the plugin’s folder, open JS file - and I see it is obfuscated - which make a “hacker”'s life a bit more difficult.

OK, I go the GitHub repo, open the source code, decide about required chages - then trying to edit that ugly obfuscated (i.e. “optimized”) code correspondingly - which in some cases not possible due to this “optimization”.

Next, I decide to fork the repo, add necessary changes to my repo, then I want to replace the “official plugin” by “my plugin” .
Go to HACS, uninstall the plugin.
The trying to install my plugin (“add a new repo”) - and getting a “Repository structure is not compliant” error.
My forked repo cannot be added as a Lovelace plugin.

So, I cannot ether to replace a custom card (HACS does not allow) or to edit plugin’s code locally (“optimized” code).
What am I doing wrong?


One more thing.
Some small changes I can do with that obfuscated JS file, and it is a bit uneasy:
– remove gz file for this plugin;
– edit js file;
– restart HA;
– clear browser’s cache.
Is it necessary to restart HA every time?
Using HA Container.

leave the original plugin in place and just drop the new file in over the top for local testing I think…

Which one a “new file”?
Assume that source codes are “a few ts files” in many cases.
I tried to save these files in some folder (/www/community/my-plugin), then this plugin is supposed to be added as a resource - but the standard “Add a resource” needs JS file.

P.S. I used to be a C/C++ dev since 90x, practised some Java, know nothing about a connection between ts & js.

oh I thought you meant you had already made the js file.
Making the file is above my pay grade.

Have no idea how to make a js file from the source codes.
And this is again about collective work & contribution.

Well HACs is really a separate project in that sense…
I don’t have a quote at hand or anything, I believe the owner didn’t want to merge it officially into HA…

You can add it via the HACS custom - repo …

Already did.

OK, but why there is no possibility to install such plugins manually?
Adding as a resource does not work.

Odd…did not have these issues before, if you created a proper fork then it should work imo.
Other option is indeed to add a new folder under www/community and copy the github js in it
Do note that I had issues before where the js file had the same name as another, already installed, js

Are you ok to share your github pages? I could verify this with my dev ha env.

Sorry, I already wrote about it too.

Or it could be a set of js files. Which one should be declared as a Resource then?

I wonder what is a great meaning of providing plugins as obfuscated js files?
Is it about “prevent stealing someone’s code”?
Btw, once I realized that some Lovelace plugin was ALREADY obfuscated on Github !

One of my cards is a weather card and I wanted to fix things, the fork could not work next to the parent one only until the name of the js file changed

Yes, please.

Usually I provided issues / FRs to plugin’s authors/maintainers; here I wanted to change something by myself.
Some changes I managed to add into js file locally.
The initial idea was to change files locally in my repo, upload them to GitHub, re-download my plugin to HA, test on HA - then propose a PR to the “official” repo.

Please try if this repo can be added via HACS.
(works still in progress)

In my case I simply removed the “official” plugin before attempting to install my version

Same issue as you have (structure…) and having now looked at this, this is quite a bit more complex then I have seen before so I doubt that I will be of further help

And this happens not with this particular card only.
I tested with some other cards - it’s a common problem.

Again - this does not help to contribute.
Hope that someone from Dev team hears me.

Yes…I indeed retried with button-card and it is the same

You could raise it in discord maybe…see here
HACS: Help | HACS

1 Like

I think this is not just a HACS issue.
As you said - HACS is a custom plugin itself.
This is about global HA issues:

  1. How plugins are installed into HA - there are must be a possibility to manually install a plugin w/o using HACS. Now I see that this does not work and people have to use HACS - which does not allow to use forked repos.
  2. How plugins are provided for HA - currently they are provided obfuscated to make a life worse for HA users (who wants to change codes).