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

Add-on translations also for environment vars when creating own Add-on #5739

Open
amaciuc opened this issue Mar 9, 2025 · 3 comments
Open
Labels
new-feature A new feature

Comments

@amaciuc
Copy link

amaciuc commented Mar 9, 2025

Describe the issue you are experiencing

Hi team,

I am writing you about a feature request. I am sorry that I use the issue form for asking a feature request, but it passed more than 1 month since I wrote on Community Forum, here is the link, and until now I haven't received an answer.

I am asking a way to pass values of environment variables through UI for an Add-on like we can do for options.
Here is my description wrote on community:

I have started to create my own several Add-ons but without building the docker image. I preferred to have an Add-on like you would deploy a docker container: a base image from docker io, mapping some dirs for persistency, bind tcp ports and passing several environments.
All of these could be made according to Add-on Configuration documentation (with a small mention regarding to binding dirs by using map, but that would be another discussion).
I started to need a way to pass values for environmemt variables from UI like it can be made for Options / Schema along with Add-on translations. I understand that this mechanism is created to pass options as variables inside the container and to be read with bashio module into an entrypoint script, but in my case I don't want to mess with building a new image as long as I can find a good enough image on docker io.
For example, here I already tried to pass somehow the options values to environment for my redis-stack Add-on. It ends up without interpreting the yaml, therefore my envs won't have the values of options, just a plain text like it appears starting with line 36.

Maybe this can be made already and I didn't find yet how to do that. Could you guide me, guys ?

To be honest, that would be a nice feature if it doesn't exist yet.

What type of installation are you running?

Home Assistant OS

Which operating system are you running on?

Home Assistant Operating System

Steps to reproduce the issue

There isn't a problem.

Anything in the Supervisor logs that might be useful for us?

I don't have logs, it is just a request for an answer.

System information

System Information

version core-2024.12.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.13.0
os_name Linux
os_version 6.6.63-haos
arch x86_64
timezone Europe/Bucharest
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4998
Installed Version 1.34.0
Stage running
Available Repositories 1566
Downloaded Repositories 36
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 14.0
update_channel stable
supervisor_version supervisor-2025.03.2
agent_version 1.6.0
docker_version 27.2.0
disk_total 116.7 GB
disk_used 81.4 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization
board generic-x86-64
supervisor_api ok
version_api ok
installed_addons Studio Code Server (5.14.2), Mosquitto broker (6.4.0), Home Assistant Google Drive Backup (0.112.1), AdGuard Home (5.0.1), ESPHome Device Compiler (2024.11.3), Zigbee2MQTT (2.1.3-1), Cloudflared (5.2.7), Samba share (12.3.2), Portainer (2.19.1), Whisper (1.0.0), Piper (1.4.0), Squeezelite (0.0.17), openWakeWord (1.8.2), VLC (0.2.0), Logitech Media Server (8.3.1.57), Uptime Kuma (0.12.4), Network UPS Tools (0.13.0), Filebrowser (2.23.0_14), ESPresense Companion (1.0.3), Samba NAS (12.3.2-nas), go2rtc (1.9.7), Frigate (Full Access) (0.14.1), HDD Tools (1.1.0), Terminal & SSH (9.16.0), Redis Stack (7.4.0-v1), ClamAV (1.4.1_base), MariaDB (2.7.2), Nextcloud (30.0.4), Advanced SSH & Web Terminal (20.0.0), ONLYOFFICE Document Server (8.2), Double Take (1.13.11.8), CodeProject AI.Server (CPU) (2.9.7)
Dashboards
dashboards 2
resources 26
views 14
mode storage
Recorder
oldest_recorder_run September 5, 2023 at 8:36 AM
current_recorder_run March 4, 2025 at 8:40 PM
estimated_db_size 39638.70 MiB
database_engine sqlite
database_version 3.45.3
Sonoff
version 3.5.4 (a4a8c5f)
cloud_online 0 / 7
local_online 2 / 2
debug failed to load:

Supervisor diagnostics

No response

Additional information

No response

@amaciuc amaciuc added the bug label Mar 9, 2025
@mdegat01 mdegat01 added new-feature A new feature and removed bug labels Mar 10, 2025
@mdegat01
Copy link
Contributor

mdegat01 commented Mar 10, 2025

So I get what youre trying to do with the environment bit. My experience has been making existing images into add-ons isn't typically this simple but I guess the changes to the map option to allow you to choose the name within the container makes this more feasible at times. That's doable but I'd have to think about how to handle it because your example would be a breaking change, since its possible (albeit unlikely) a user wanted the text [REDISTIMESERIES_ARGS] as their env value.

I'm not understanding your add-on translation use case though. Add-on translations are used for providing language specific translations to the static documentation around options and such. Why would you need to substitute user-entered data in?

Btw if you are comfortable in python you're welcome to submit a PR for one or both of these. I can review and help get it in.

@amaciuc
Copy link
Author

amaciuc commented Mar 10, 2025

I'm not understanding your add-on translation use case though. Add-on translations are used for providing language specific translations to the static documentation around options and such

I assumed that using translations would be the key for injecting values from UI to environment (like it happens with options).

Why would you need to substitute user-entered data in?

Like I tried in the Redis Add-on, they offer the possibility for defining arguments for multiple components, here is the doc. So, that means I would like offering to end user a way for injecting these values.

Another example where triggered me the need for opening this request is onlyoffice document server. I want this for local documents editor in Nextcloud. I made my own add-on for it, but check this link, at section Available configuration parameters. They have, let's say, a lot of enviroment variables. Most of these could have static values like I did here, but the one that bothered me is JWT_SECRET, link. This one should be defined as unique by each end user and it is mandatory for a right connection between nextcloud and onlyoffice.

So, that being said, I try finding a way to inject values from UI to envs when the container is deployed.

Do you try to say that I could implement support for this in python? I am okay with that if you could guide me a little how I can prepare a developing env, maybe some docs / links.

@mdegat01
Copy link
Contributor

I assumed that using translations would be the key for injecting values from UI to environment (like it happens with options).

Just to clarify, when you say "translations" then you mean these right? The JSON files you put in a folder called translations within the folder for your add-on that provides a mapping of text to translated text for a given language? Those are only used by the Home Assistant frontend to translate names and descriptions of options your add-on has into the users language. They are not used at runtime by addons or included in the addon's container at all.

Or at least Supervisor doesn't, as an addon developer you're obviously welcome to include whatever you want in the published image for your addon. But Supervisor will not do anything to make these translations available in the container at runtime. It believes the only consumer is the Home Assistant frontend, not the addon itself.

Like I tried in the Redis Add-on, they offer the possibility for defining arguments for multiple components, here is the doc. So, that means I would like offering to end user a way for injecting these values.

Yea this all makes sense to me. Currently we expect add-on developers to make their own images for add-ons and use scripts that run at start of the container to map add-on options into envs if that is what is needed. You can see a rudimentary example of how this works in the example add-on here

But your idea of referencing options in envs defined in environment makes sense to me. I'd have to think about how to do it without breaking backwards compatibility though.

Do you try to say that I could implement support for this in python? I am okay with that if you could guide me a little how I can prepare a developing env, maybe some docs / links.

We do have a guide for getting started on Supervisor development here. It's not too different then core development except a much smaller code base with much less throughput in terms of PRs. You'd probably want to look at this and this. The first is Supervisor's object representing an addon you have installed, the second is an object representing how an installed addon is translated into a Docker container.

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

No branches or pull requests

2 participants