Skip to content

Conversation

@EVWorth
Copy link
Contributor

@EVWorth EVWorth commented Oct 29, 2025

@andrew-codechimp this includes all the previous changes from #3902 but I think** I got the devcontainer working. please clone my branch and test and let me know if there are any issues! happy to tackle any.

I switched everything up and moved to a uv based image: https://docs.astral.sh/uv/guides/integration/docker/?utm_source=chatgpt.com#installing-a-project

Figured going with a minimal build made the most sense (add anything needed as part of the build process) and had to create a Dockerfile to enable that, and creating the vscode user. also allowed for simplifying the setup file since UV is already installed by default, and the Dockerfile is cd'ing to the project dir, we can just run uv sync to update the .venv

I hadn't messed with devcontainers before. this is neat!

(devcontainer builds and lets me run uv commands on the terminal)

@andrew-codechimp
Copy link
Owner

Hi, thanks for persevering with this and yeah dev containers are quite neat, though I've only got them running from examples and never had the time to really get to grips with them, too busy on the python code to fix the devops.

I managed to get the environment built and running ./scripts/develop does start HA but DevContainer tasks aren't working.

Within .vscode there's a tasks file that has a single task to run HA dev, that fails within ./scripts/develop: line 20: hass: command not found

You get to the tasks with a Cmd Shift P and Tasks: Run Task if you've never seen it before.

Really appreciate the effort your putting in, if your happy to work on it and learn about dev containers I'll continue testing iterations.

@EVWorth
Copy link
Contributor Author

EVWorth commented Oct 29, 2025

ok.. I think I got it figured out. ended up cleaning up some of the config I added but the big thing was that we needed to update hass -> uv run hass in the develop script, and we were able to drop the pythonpath logic, as uv builds the venv and handles pointing to it when you use uv run.

I was able to run the task, and connect to the dev homeassistant instance!

image

@andrew-codechimp
Copy link
Owner

A quick test and the custom_components folder isn't being mapped so HA can't find Battery Notes. Within the old develop script this did it

# Set the path to custom_components
## This let's us have the structure we want <root>/custom_components/integration_battery_types
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

@EVWorth
Copy link
Contributor Author

EVWorth commented Oct 29, 2025

Can you share steps to reproduce the error you're getting so I can test and validate?

I assume it's something in the dev instance of homeassistant once you spin it up?

@andrew-codechimp
Copy link
Owner

If you start the HA within the dev instance, create your account etc. then try and add Battery Notes integration it is not found.
If you have an existing config entry for Battery Notes it will complain it can't find the integration.
The custom_components folder needs to be mapped within the config folder for HA to see it.

Another thing, I used to have colorlog, which isn't there anymore.
Doing a uv pip install colorlog does not seem to install it/update UV lock so wonder if this again is a mapping into the container issue.

@EVWorth
Copy link
Contributor Author

EVWorth commented Oct 29, 2025

I can add colorlog back! I don't find a reference to it being imported in any scripts in the project? How are you using it?

The command I'll run to add it is uv add colorlog

uv pip install colorlog should add it to the venv but won't add it to the pyproject.toml or the lock file

Here's some background!
astral-sh/uv#9219

@andrew-codechimp
Copy link
Owner

Colorlog was added via the requirements.txt, it gave me nice color output from HA logs (never really looked into it beyond that)
Thanks for the background, I'll have a read, really want to try and get more into the tooling side and understand what is going on, always the problem when you start with a template project and just build on it.

@EVWorth
Copy link
Contributor Author

EVWorth commented Oct 29, 2025

ok. I think I got it :)

image

should I be able to search for something here or is this expected behavior?

image

Id taken out this code not understanding what it was doing... (:
image

@andrew-codechimp
Copy link
Owner

A quick test and this is looking good.. want to do a lot more though and it's approaching UK evening and I'm more of a morning person. Will try a few common tasks like updating HA min version so I'm comfortable with it.

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