Skip to content

Conversation

@nipar4
Copy link
Contributor

@nipar4 nipar4 commented Jan 4, 2026

With the changes to the addon and moving hass.py into the main batpred repository this has removed some of the modifications I have made to the file in the addon as they will now always be overwritten.

This prevents the docker image in some versions from automatically rebooting when updating the application python files.

Many users in docker mount the config directory using bind mounts to allow for configuration to persist across updates therefore if the python files are all stored in the config directory there is a risk of file and version conflicts

So, In the docker image these python are stored in the /addon directory allowing the container to be completely removed and updated without affecting the configuration files

This also allows the container to be fully reset without impacting any other files and logs

This approach might also be beneficial for the Home Assistant Addon although I don't have much experience with the addon at the moment but will look at this for future versions

Let me know what you think

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the file monitoring mechanism in standalone Predbat to watch an additional /addon directory for changes, addressing Docker deployment scenarios where Python files are separated from configuration files to prevent version conflicts and enable clean container updates.

  • Adds /addon as a second root directory to monitor alongside the current directory
  • Modifies the file discovery loop to iterate through multiple root directories
  • Maintains existing file monitoring behavior while extending coverage to the /addon path

Comment on lines 64 to 68
for root_dir in roots:
for root, dirs, files in os.walk(root_dir):
for file in files:
if (file.endswith(".py") or file == "apps.yaml") and not file.startswith("."):
py_files.append(os.path.join(root, file))
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The code should check if each root directory exists before attempting to walk it. If "/addon" doesn't exist (e.g., in non-Docker environments), os.walk() will silently skip it, but it would be clearer to log this or validate the paths upfront. Consider adding existence checks with appropriate logging to make debugging easier.

Copilot uses AI. Check for mistakes.
springfall2008 and others added 2 commits January 4, 2026 20:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@springfall2008 springfall2008 merged commit b3a6f3d into springfall2008:main Jan 4, 2026
1 check passed
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