-
Notifications
You must be signed in to change notification settings - Fork 109
enable flexible folder creation for addon (e.g. /share/emhass) #655
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
base: master
Are you sure you want to change the base?
Conversation
* create data path handed over via options.json * new try * work with try ald exept * fix formating * fix formatting * fix formatting * Exception Error message --------- Co-authored-by: Michael Metz <[email protected]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR changes how the add-on resolves and prepares its data_path: instead of only using an existing path from options, it now attempts to create the directory, logs a warning on failure, and conditionally updates the configuration, laying groundwork for using paths like /share/emhass. Sequence diagram for updated data_path handling in build_secretssequenceDiagram
actor User
participant AddonRuntime
participant utils_build_secrets as utils_build_secrets
participant Pathlib as pathlib_Path
participant Logger as logger
User ->> AddonRuntime: start_addon_with_options
AddonRuntime ->> utils_build_secrets: build_secrets(options, emhass_conf, ...)
utils_build_secrets ->> utils_build_secrets: read options data_path
alt data_path is not None
utils_build_secrets ->> Pathlib: Path(options_data_path)
activate Pathlib
Pathlib -->> utils_build_secrets: data_path_object
deactivate Pathlib
utils_build_secrets ->> Pathlib: data_path_object.mkdir(parents=False, exist_ok=True)
alt mkdir succeeds
utils_build_secrets ->> utils_build_secrets: emhass_conf data_path = data_path_object
else mkdir raises Exception
utils_build_secrets ->> Logger: warning(cannot create data_path directory...)
Logger -->> utils_build_secrets: done
utils_build_secrets ->> utils_build_secrets: keep default emhass_conf data_path
end
else data_path is None
utils_build_secrets ->> utils_build_secrets: keep default emhass_conf data_path
end
utils_build_secrets -->> AddonRuntime: updated emhass_conf
AddonRuntime -->> User: addon running with resolved data_path
Flow diagram for data_path directory creation logicflowchart TD
A[start_build_secrets] --> B{options_data_path_is_not_None}
B -- Yes --> C["Create Path object from options data_path"]
C --> D["Call mkdir on Path with parents=False and exist_ok=True"]
D --> E{mkdir_raises_exception}
E -- No --> F["Set emhass_conf data_path to created Path"]
F --> G[end_build_secrets]
E -- Yes --> H["Log warning via logger and keep default emhass_conf data_path"]
H --> G
B -- No --> I["Skip override and keep default emhass_conf data_path"]
I --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|



With this pull request, we are laying the foundation for enabling the data path /share/emhass in the add-on.
The path specified in the options is checked and any missing subfolders are created.
This is a prerequisite for the adjustment in the add-on. refer to davidusb-geek/emhass-add-on#122
Summary by Sourcery
Enhancements: