jeroenterheerdt / ring-hassio

A Home Assistant add-on for live streaming from Ring devices.
MIT License
131 stars 93 forks source link

Home Assistant Full Snapshot from 16 to 150 Mb #35

Open johanvh83 opened 3 years ago

johanvh83 commented 3 years ago

Yesterday I implemented your repository into my Home Assistant. Everything works fine. Every day I make a full snapshot. Yesterday, before installation of your repository the full snapshot file was 16 Mb. The snapshot today is 150 Mb! Can you clarify this and eventually how to avoid this high disk usage

johanvh83 commented 3 years ago

I just made a full snapshot, 152,2 Mb and made partial snapshot without the Media folder. The size was exactly the same and my Media folder is empty. Schermafbeelding 2021-01-21 om 16 54 36

It has to do with the Add-on: Ring Livestream: When I disable this option the snapshot is only 16 Mb: Schermafbeelding 2021-01-21 om 16 53 39

This add-on takes around 130 Mb! I suppose it contains all the Ring livestreams and will only grow in the future! Where are the Livestreams stored by default? Once more: my Media folder is empty...

DeliriousMetro commented 3 years ago

Oh, I see, I was referring if you were saving videos with automation to the media folder because HA will backup that in a full snapshot so this would include any recording/snapshot (if you save these to media file using automation).

I understand your issue now and can confirm it happens on my end as well and it is as expected lol.

When the addon has never been run and you have not launched it for the first time, and you take a partial snapshot of this addon. The size is relatively small (0.1mb). This is because the addon has not been built yet.

You'll see that even though you ticked a partial snapshot of Ring Livestream, the addon is not present in your snapshot at all. Even in your referenced snapshot - it is missing when you disabled it.

missing partial

Now you will compile the addon by pressing build and you see the large increase.

partial-after

When the addon is built and a partial snapshot of this addon is taken, the size is about 150mb as you say. I took a look inside the folder and it is due to the Node_modules which are built. This is designed on purpose as Node would not want to download the dependencies on the start of every runtime - that would be insane downloading 150mb to launch the addon lol. So it caches these in the modules folder.

These files are dependencies that is used to run the unofficial Ring API which this addon wraps around. Node_modules are usually downloaded from the web when Node.js launches but it will cache them in the 'Node_modules' folder so that these are not redownloaded again (saves you bandwidth).

Corneloues commented 3 years ago

I was interested in using this add-on, but 150Mb of dependent Node modules seems very inefficient. Are all these 100% necessary?

tsightler commented 3 years ago

It's difficult for me to see how he could cut this down, the dependency list for this project is already quite short. The vast majority of the growth (~70MB), is from the dependency on ring-client-api, which you can't do without. The reason ring-client-api is so big is because it depends on rxjs (~17MB), ffmpeg (~32MB), loadash (~5MB), and a few dozen other smaller dependencies. There's nothing that this project could do about that. I also maintain a project that uses ring-client-api and my addon is 145MB, so not much different.

Basically, 150MB is really nothing for a project of this type these days (as amazing as that sounds to a guy like myself that used to have to code assembler and fit it into a few KB). I have several addons that are nearly 300MB in size!