[Windows] Issue setting up Dev Environment

Tags: #<Tag:0x00007f3f25836060>

Hi all,
I’m wanting to start development of a small component. I have been trying to follow the documentation here to set up my environment (https://developers.home-assistant.io/docs/en/development_environment.html) but I am getting confused.

I am running windows and was hoping to be able to run from VS Code using the devcontainer solution but there’s obviously something I am not doing right…

Anyone has experience there and could assist?

One of the biggest problem I am facing is when running devcontainer, I don’t know where to find my “config” folder

I’m not super confident with Docker but familiar enough to think I should have a local folder mapped to it but don’t know where to look

Any help would be appreciated…

THanks

Hi @Guillaume_Corgnet,

I currently try running hass in devcontainer too. I could get it running with the following additional steps:

  1. open the repository with “reopen as container”
  2. after vscode has built and started the container there’s some error in the Terminal Console (Dev Containers):
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wgnfv6rl/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
postCreateCommand "pip3 install -e ." failed.
  1. open a shell in the container (open the vscode panel, switch to terminal and choose ‘sh’. This should take you to the shell inside the container)
  2. run the following commands in the shell:
cd /workspaces/home-assistant
mkdir config # place your home-assistant configuration here, you should be able to map it on your local filesystem, too
pip uninstall typing # this will 'fix' the error above
script/setup
script/server
  1. If you did not copy your configuration over in step 4 home-assistant should now be running with the default configuration
  2. access the frontend by opening http://localhost:8123 in your favorite browser

Same problem here with devcontainer on Windows. Opening as Remote Container works in VSCode. No errors. Also started task ‘Install all Requirements’.
However starting Hass with command:
hass
will startup the application. I can browse to it on ‘http://127.0.0.1:8123’. Registering user, password and setting location is fine. The step after that fails with message.

2019-08-18 15:37:21 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/auth.py", line 231, in auth_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/view.py", line 128, in handle
    result = await result
  File "/workspaces/home-assistant/homeassistant/components/config/config_entries.py", line 73, in get
    and handler.async_get_options_flow
AttributeError: type object 'MetFlowHandler' has no attribute 'async_get_options_flow'

Using Task ‘Remote Container: Attach to running container’ I could select one container. Connection to that one showed me the contents of the Home Assistant application. Including the configuration.yaml.

Maybe can tell us how to use this devcontainer on Windows. As the documenation on page https://developers.home-assistant.io/docs/en/development_environment.html#developing-with-devcontainer looks a bit of duplicate to me. As the devcontainer already has all stuff present. We again create a seperate environment using commands like:

$ python3 -m venv venv
$ source venv/bin/activate

Any pointer would be much appreciated.

issue with ‘async_get_options_flow’ was fixed in https://github.com/home-assistant/home-assistant/issues/26047

Also got it working by taking the following steps.

  • clone Home Assistant code
    $ git clone https://github.com/home-assistant/home-assistant.git

  • Open home-assistant with Visual Studio Code.

  • Open folder in Remote Container.

  • Get into a shell and create config directory and start Hass
    mkdir config
    hass

  • Start a browser and open http://127.0.0.1:8123/

If onboarding fails change config/configuration.yaml. Uncomment the http: with baseurl. I changed my configuration to:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
  base_url: 127.0.0.1:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

PS: when running (Visual Studio) Task: ‘Preview’ it will also start hass, but I get errors like:
2019-08-22 18:05:15 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8)