Skip to content
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

Implement Public Addon Config #75

Open
goebelmeier opened this issue Nov 10, 2023 · 18 comments
Open

Implement Public Addon Config #75

goebelmeier opened this issue Nov 10, 2023 · 18 comments

Comments

@goebelmeier
Copy link
Contributor

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

@thecem
Copy link
Collaborator

thecem commented Nov 10, 2023

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
Copy link
Collaborator

thecem commented Nov 11, 2023

implemented

@goebelmeier
Copy link
Contributor Author

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

@thecem
Copy link
Collaborator

thecem commented Nov 11, 2023

whats your proposal?

@bjwo
Copy link

bjwo commented Nov 11, 2023

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?

@thecem
Copy link
Collaborator

thecem commented Nov 11, 2023

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

IMG_0040

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

#72

@goebelmeier
Copy link
Contributor Author

goebelmeier commented Nov 13, 2023

whats your proposal?

My proposal is to first of all roll back to /config, because of all the confusion this generates - see evcc-io/evcc#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 home-assistant/supervisor#4697 and https://github.com/home-assistant/developers.home-assistant/pull/1975/files#diff-9ae15e79c349af300614e97def45c1260fcde69f1f194c7a169f5ac2843cb898R62 for details

@thecem
Copy link
Collaborator

thecem commented Nov 13, 2023

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

@goebelmeier
Copy link
Contributor Author

goebelmeier commented Nov 15, 2023

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.

@hzpz
Copy link

hzpz commented Jan 5, 2024

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 (home-assistant/supervisor#4697) was reverted yet again (home-assistant/supervisor#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 😄

@Frintrop
Copy link

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 ?

@thecem
Copy link
Collaborator

thecem commented Jul 17, 2024

@goebelmeier, we should give it another try…?

@klein0r
Copy link

klein0r commented Sep 25, 2024

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.

@thecem
Copy link
Collaborator

thecem commented Oct 1, 2024

@klein0r
Copy link

klein0r commented Oct 2, 2024

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

@goebelmeier
Copy link
Contributor Author

@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

@thecem
Copy link
Collaborator

thecem commented Oct 2, 2024

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
Copy link
Collaborator

thecem commented Oct 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants