Skip to content

Add env vars support to options#349

Merged
kellerza merged 9 commits intokellerza:mainfrom
maslyankov:improvement/support-env-vars
Oct 13, 2024
Merged

Add env vars support to options#349
kellerza merged 9 commits intokellerza:mainfrom
maslyankov:improvement/support-env-vars

Conversation

@maslyankov
Copy link
Copy Markdown
Contributor

Added support of env vars for docker image

Copy link
Copy Markdown
Owner

@kellerza kellerza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use env vars, how would you specify the inverters?

Comment thread hass-addon-sunsynk-multi/README.md
Comment thread src/ha_addon_sunsynk_multi/options.py Outdated
Comment thread src/ha_addon_sunsynk_multi/options.py Outdated
maslyankov and others added 2 commits October 11, 2024 13:00
Co-authored-by: Johann Kellerman <kellerza@gmail.com>
Co-authored-by: Johann Kellerman <kellerza@gmail.com>
@maslyankov
Copy link
Copy Markdown
Contributor Author

maslyankov commented Oct 11, 2024

If you use env vars, how would you specify the inverters?

Have not looked at this case. The idea behind was to pass MQTT config more easily when using Docker Compose with env vars. I will look into ways to pass inverter config as well but not sure how useful that would be.

edit: Maybe a good way would be to pass a json object/list in the env vars where lists are specified - inverters, sensors, etc. This would be rather easy to implement.
Will also add the standalone documentation.

@maslyankov maslyankov force-pushed the improvement/support-env-vars branch from 5e980f6 to 3feb369 Compare October 11, 2024 20:39
@maslyankov
Copy link
Copy Markdown
Contributor Author

@kellerza Discussed changes have been implemented and functionality verified! Seems to work on my side. I also added documentation on this matter.

@kellerza kellerza merged commit d4c0f38 into kellerza:main Oct 13, 2024
for inv in loads(os.getenv("INVERTERS", "[]"))
]
sensor_definitions: str = os.getenv("SENSOR_DEFINITIONS", "single-phase")
sensors: list[str] = loads(os.getenv("SENSORS", "[]"))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially support simple comma separated strings here? split instead of loads

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I think this is more consistent with other options. In my opinion it could be added as another way to input a list, but shouldn't replace the json format.

@maslyankov maslyankov deleted the improvement/support-env-vars branch December 28, 2024 10:19
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

Successfully merging this pull request may close these issues.

2 participants