Elegant solution for installing addditional packages in HA docker?

Hi all,

I’m using HA in docker on UnRAID, and I have some janky setup that I’m trying to improve.

I have a couple of simple bash scripts that I use for processing incoming data to create HA sensors - for example, one scrapes info about upcoming bin collections from the local government website. Some of these scripts rely on packages that are not installed by default within the HA docker image. Although I can install those packages, they of course get wiped whenever I update HA so I have to reinstall them.

At the moment I’m storing these scripts on a vm, and using HA’s command line integrations to SSH into the vm and run the scripts. This works, but it’s untidy, and sometimes introduces problems.

I’d like to move these scripts to my HA config directory, which means I need a way of keeping the additional packages installed. So far I can think of a few options:

  • Include a check in my bash scripts which installs any missing packages when the script is run - this is what I’m leaning towards but it would cause inconvenient delays in some cases
  • Use a combination of command line sensors, switches and on-start automations to have HA install missing packages when it starts - this would work but it’s pretty convoluted
  • Modify the docker image - but I would have to reapply the modifications every time I update, so this just moves the problem

Does anyone have any better ideas than these? I realise I could rewrite the scripts in Python and use AppDaemon, but I don’t want to, because I know jack about Python and don’t generally get on very well with AppDaemon. :smiley:

Are you managing the HA container yourself, or using a supervised install?
If the former, I guess you could create your own image…

EDIT: Which is basically your 3) proposal.

Probably the best compromise would be 1), but executed only on HA start, so an automation that would trigger on homeasssistant.start (Automation Trigger - Home Assistant ) and execute a script that would check for installed packages and install them if not.