-
-
Notifications
You must be signed in to change notification settings - Fork 194
Serve device icons locally #1477
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
Comments
There are some folks running z2m on some ludicrously underpowered hardware and very space constrained. Adding all z2m images into the bundle would be death sentence for them. I just committed some changes regarding image loading, it should solve frontend loading issues in case of offline usage https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html#switch-to-the-dev-branch |
We are speaking about 17MB:
IMHO, hardware that is killed by that amount of data is already dead. You can't even properly upgrade any base package with that low amount of space left. I'm running zigbee2mqtt-frontend as part of the official zigbee2mqtt Docker image, so I'll have to wait until your changes are merged and released to see them. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is still an issue and still not fixed. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I would really appreciate this to be fixed. It would significantly increase privacy. There is no need to load resources from www.zigbee2mqtt.io (which resolves to ...github.io) on every move in the frontend, except for allowing github (=Microsoft) to track us. The reason I'm not using proprietary gateways / services etc. and supporting open source projects is that I don't want to be tracked. Thank you. |
Fully agree with previous comment. In addition for me full refresh of the the page is slow. With about 15 unique devices, while most of the images load in 50ms, some take 3-5s to load. @nurikk I understand your point about users with underpowered hardware, but maybe it is possible to add a setting to the frontend config to allow users to override base URL for the images? |
I will serve the icons locally. |
What's stopping anyone from extending this function (that already exists!) to take an optional configuration parameter into account where you can specify a custom asset host? |
I can only speak for myself: It's that it's more than extending that function.
The latter will become a real pain. In the end it would lead to requiring two separate Docker images of zigbee2mqtt, one including zigbee2mqtt-frontend without images and one with images being contained. To serve @nurikk s requirement of having a small image for underpowered devices and an docker image containing the image files. Another option would be some downloading mechanism within zigbee2mqtt-frontend itself, but that would be another thing one would have to implement and would still not solve the problem for people who would want to run their zigbee2mqtt outbound firewalled. Overall, for me, it just was not worth the effort of implementing all that + likely having some back and forth until the MR would be accpeted compared to just accepting my problem of bad frontend performance if internet is down which happens once in a year. I don't see any fighting with a stale bot here since one year but I also will never befriend with stalebot (see https://drewdevault.com/2021/10/26/stalebot.html) |
Take all this with a grain of salt as I'm quite new to this project, but
There's already a way to configure the frontend via the frontend. You'd just need to extend its configuration schema with another string. As a tip on how to approach something like that in an unknown codebase: As an example, here's a commit that added a different new config option: Really not that much to change. Just some schemas and test case. As for the frontend side.. the form seems to be generated automatically from the payload from the backend?
You mean
See above. They're on GitHub. Same source where you also get the software from
I kinda suspect that the maintainers might feel the same way. It's probably just very low priority because it works fine and only causes mild unhappiness in probably less than 3% of installations. So why this issue then? I know the usual story is "Maybe some day someone will be looking to contribute something and then they will look at the list of feature requests" but that's frankly just not happening. It never has and it never will. There is no magic coding santa clause. Jesus also won't implement your feature requests, of that you can be sure. This is just so very pointless and a waste of time for everyone involved. And it's everywhere in the issue trackers on GitHub. Especially worse when it comes to software close to consumer tech. And that's likely why there's a stale bot active in the repo, because writing this reply took 40 minutes. Anyway, I threw in some pointers on how to approach this issue. I hope that can help reducing the scary-ness of tackling this task. |
I also think that serving the icons locally is a good idea for privacy and stability reasons. The server serving the images seems to be down quite often. |
zigbee2mqtt supports Base64 encoding them directly for Home Assistant. They
don't even need to get downloaded en masse, when a url is found, instead
snag it, encode it, and store the image that way maybe?
…On Sat, Nov 11, 2023, 14:54 setfire2 ***@***.***> wrote:
I also think that serving the icons locally is a good idea for privacy and
stability reasons. The server serving the images seems to be down quite
often.
—
Reply to this email directly, view it on GitHub
<#1477 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHROWYMOGMAKTVRNMNJ2I3YD7JV3AVCNFSM5V6ZN632U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBQGY4TAMZWGM3Q>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This is a good point. Maybe someone can create a javascript code to automate this process? |
Okay folks, I just implemented feature for you.
This will download your device images and save them locally in |
How cool is this? Thank's man! I will try it as soon as this development makes it into the latest koenkk/zigbee2mqtt development Docker image. @Koenkk ;-) |
as soon as a new frontend release is made it will be in development dev docker image, awesome @nurikk ! |
Looking forward to being able to host the images locally, thanks for adding that. the zigbee2mqtt.io site is down right now (like, extremely down, I can't even |
I have been playing around in having a nginx as a server for the images. |
FIXED: Found the issues, need TLS (https) and a CORS policy, generated certs, and updated nginx to support cors as well. |
with that new function in since Version 0.34.0 Navigate to Settings -> Tools -> Click Localise device images WORKING great! can be closed |
The "Localize device images" stores the whole icon in the configuration.yaml file. I am not happy with this. Can the icons please be moved to the local file system? By the way, can I just remove the icon data from the configuration.yaml and will the default (online) icons be used again? Or will the icons be gone? Edit: Edit 2: |
Base64 encoding increases size by 33-37% (33% because the encoding itself takes 4/3 times the space, and up to 4% due to additional newlines being added). It also clutters up the config with non-human-readable data. It also increases the download speed for the same reason. Far better would be to cache the images locally as jpegs/PNGs, which are already in their most compressed form. When serving the frontend Z2M should check for the presence of a cached image, and, if absent, download from the git repo and cache. If it fails to download it can put a placeholder image in the cache to prevent rechecks. Even better would be to cache the images locally at the various required sizes. For example, the main device page shows 30x30 thumbnails, but the UI downloads every image at full resolution. Similarly, the main info on a device uses the images at 150x150. However, some images are 512x512, or bigger, in the Github! When creating the cache, it is trivial to use the Image library (or similar) to store a 150x150 version and a 30x30 version, using the appropriate one in each case. The size of these 2 smaller images would be smaller than some of the full-size images currently being downloaded! Frankly, the bigger issue is that the cache expiry for images are set to be cached by the web browser for only 10 minutes! Pages would load much quicker if the cache expiry was longer, as your browser would only load them once rather than round-tripping every 10 minutes. However, if you implemented local server caching then a short remote cache duration would make more sense. |
Get the image from the manufacturer, base64 encode it, put it in config.yaml? For me I can say that I'm happy with the current solution. In todays plenty of storage I don't care about the few bytes. |
Unfortunately the localise_images options doesnt work for me as my zigbee2mqtt instance doesn't have internet access. @nurikk Wdyt about the following workflow, could this be a definitive solution to be able to close this issue? If you approve I could help with this if you like.
Having a second docker build with all device images might not be super ideal, but the 150MB is not that big and could potentially also be optimized to use lower resolutions as @thargy already mentioned. Also it's quite easy to change the Cache-Control headers using serve-static for these static device images. |
** SERIOUS BUG ** The localise images tool doesn't appear for me correctly: This is the button HTML (you can see it has no content: <button type="button" class="btn btn-primary d-block mt-2"></button> Clicking on it produces a long list of devices, and the Z2m dies. On reboot, the UI doesn't list any devices. I only know this is the Localise Images button because I can see my configuration explode by 100s of Base64 Sure enough, restarting Z2m looks like there are no devices configured, and this was only fixed by reverting out the As mentioned above, I don't think you should be encoding the image into the config anyway, but it's unquestionably a bad idea to encode the same image repeatedly. |
Had the same problem today. Not nice at all. At first I thought I had broken my Zigbee2MQTT. |
How to fix? My zigbee fucked up due to that button! |
The only way is to edit the configuration.yaml file and take all the lines for the encoded images out… |
Any news on this? |
It's still there and it's a ticking time bomb for any unsuspecting user. It really needs removing as a feature for now until it is implemented properly. |
The issue that the localise buttons messes up the Icons should now be placed in the
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is your feature request related to a problem? Please describe.
When my internet connection or the zigbee2mqtt.io server is down, Zigbee2MQTT frontend takes very long to load. See also Koenkk/zigbee2mqtt#11908
Describe the solution you'd like
Serve device images locally.
Describe alternatives you've considered
-
Additional context
-
The text was updated successfully, but these errors were encountered: