hassio-addon icon indicating copy to clipboard operation
hassio-addon copied to clipboard

Implement Public Addon Config

Open goebelmeier opened this issue 1 year ago • 18 comments

There is a new preferred way to store configs. We should implement that and somehow provide a migration for legacy installations

https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/

https://developers.home-assistant.io/docs/add-ons/configuration/#add-on-advanced-options

goebelmeier avatar Nov 10 '23 11:11 goebelmeier

Some add-ons need access to all these add-on-specific config folders. For example:

  1. Samba
    
  2. SSH
    
  3. Studio Code Server
    

When those updated I will update the addon and release notes.

thecem avatar Nov 10 '23 15:11 thecem

implemented

thecem avatar Nov 11 '23 06:11 thecem

Don't you think we should consider a non-breaking migration?

goebelmeier avatar Nov 11 '23 06:11 goebelmeier

whats your proposal?

thecem avatar Nov 11 '23 06:11 thecem

So I could migrate my evcc.yaml file to the new /addon_configs/ folder - but I have lost my complete history from the evcc.db. Any clues how to restore that?

bjwo avatar Nov 11 '23 09:11 bjwo

You have your db in /data/evcc.db?

IMG_0040

Find your old DB and copy it to /addon_configs/<addon_id>_evcc

https://github.com/evcc-io/hassio-addon/issues/72

thecem avatar Nov 11 '23 10:11 thecem

whats your proposal?

My proposal is to first of all roll back to /config, because of all the confusion this generates - see https://github.com/evcc-io/evcc/discussions/10744

The HA Supervisor Team got that too and will push out an update which makes /config and /addon_config side-by-side and this will allow us to do config migration in the background. See https://github.com/home-assistant/supervisor/pull/4697 and https://github.com/home-assistant/developers.home-assistant/pull/1975/files#diff-9ae15e79c349af300614e97def45c1260fcde69f1f194c7a169f5ac2843cb898R62 for details

goebelmeier avatar Nov 13 '23 16:11 goebelmeier

old status, next try will be when HA has fixed there problems. I will leave this open.

thecem avatar Nov 13 '23 17:11 thecem

Currently frenck is doing a hacky migration, see https://github.com/hassio-addons/addon-appdaemon/pull/285/files#diff-a3cb8f1cd3251bfb32a8e374ec6ce13a10be81b009300b9f570d5b6fd70f0352R8

https://github.com/hassio-addons/addon-appdaemon/pull/289/files#diff-a3cb8f1cd3251bfb32a8e374ec6ce13a10be81b009300b9f570d5b6fd70f0352R18

So what they do:

  • map homeassistant_config:rw into the addon
  • change mapping from config:rw to addon_config:rw
  • migrate the config file(s) from /homeassistant/ to /config/
  • ... some weeks/months/years later, you should be safe to remove homeassistant_config:rw

I'll try this inside my own fork and will monitor the official HA addons what they're doing.

goebelmeier avatar Nov 15 '23 11:11 goebelmeier

Hello everybody and first of all: thank you for providing evcc as this wonderful Home Assistant add-on! 👍

A few days ago I tried to install the add-on by following the installation instructions in the README and unfortunatelly I have to say, that I got very confused 🙈 The instructions still tell the user to copy evcc.yaml to the /addon_configs/<your addon's slug> directory. After I figured out, how to access this directory, I realized (from the discussion over at the main repository) that you reverted the change in the add-on and I had to use /config after all.

Finally, after some rather frustrating tinkering, I got the add-on to work properly 🎉 To spare future users this ordeal, please fix the README 🙏

Since almost two months have past since your last comments, I got curious what the state of affairs was. The revert mentioned above (https://github.com/home-assistant/supervisor/pull/4697) was reverted yet again (https://github.com/home-assistant/supervisor/pull/4702). So it seems that was Frenck is doing in his add-ons (mapping addon_config plus homeassistant_config and moving existing configurations from /homeassistant to /config) is the way to go.

If you find the time to implement that, you could just leave the README as is 😄

hzpz avatar Jan 05 '24 18:01 hzpz

Is there any idea out there? It looks like that evcc.db in /data is not persistent in docker host (Home Assistant) instead its only locally store in docker container, or where to find it on the host ?

Frintrop avatar Apr 29 '24 14:04 Frintrop

@goebelmeier, we should give it another try…?

thecem avatar Jul 17 '24 19:07 thecem

where to find it on the host

Just run a docker inspect on the container id. Should be /mnt/data/supervisor/addons/data/<id>_evcc (but how does this information help you? When using an ssh add-on, you're just inside another container and not on the host.

I've used docker cp to copy my evcc.db from the Terminal Add-On to the evcc Add-On.

klein0r avatar Sep 25 '24 16:09 klein0r

@klein0r an easy way:

https://github.com/evcc-io/hassio-addon/blob/main/README.md#how-to-find-and-copy-dataevccdb

documentation is adapted.

thecem avatar Oct 01 '24 11:10 thecem

@thecem Thanks, that was exactly my solution: https://www.youtube.com/watch?v=ibrmbByk0MU

klein0r avatar Oct 02 '24 05:10 klein0r

@goebelmeier, we should give it another try…?

From my point of view it's worth trying. But first of all we need to extend https://github.com/evcc-io/evcc/blob/master/packaging/docker/bin/entrypoint.sh to contain the migration logic. So:

  • check if ${CONFIG} (should be /config/evcc.yaml) exists, if yes, skip next parts
  • if not, check if /homeassistant/evcc.yaml exists and copy it to ${CONFIG} (which again should be /config/evcc.yaml)

If that logic exists, we could

  • map homeassistant_config:rw into the addon
  • change mapping from config:rw to addon_config:rw
  • on first start, the entrypoint.sh should copy the config from /homeassistant/evcc.yaml to /config/evcc.yaml and on subsequent restarts it should not change anything any more
  • some weeks/months/years later, you should be safe to remove homeassistant_config:rw

goebelmeier avatar Oct 02 '24 06:10 goebelmeier

following mapping is possible:

map: 
  - type: homeassistant_config
    read_only: False
  - type: addon_config
    read_only: False

"homeassistant_config":

/homeassistant in container maps to /config directory in home assistant

Addon Configuration -> Options -> config_file: /homeassistant/evcc.yaml maps to /config/evcc.yaml

"addon_config":

/config in container maps to /addon_configs/<slug>_evcc directory in home assistant

Addon Configuration -> Options -> config_file: /config/evcc.yaml maps to /addon_configs/<slug>_evcc/evcc.yaml

thecem avatar Oct 02 '24 11:10 thecem

With this we could trigger following:

If a file /homeassistant/backup_evcc_db_from_data.txt (or something similar) exist:

  • copy /data/evcc.db to /config/evcc.db (which maps to /addon_configs/<slug>_evcc/evcc.db)
  • if copy is sucsessfull delete /homeassistant/backup_evcc_db.txt

Advantages:

  • User could decide when they migrate the evcc.db
  • User are easy able to get there evcc.db out of the /data directory

thecem avatar Oct 02 '24 13:10 thecem