Click here to Skip to main content
15,904,822 members
Articles / Home-Assistant

Solutions for Common Issues with Home Assistant

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
15 May 2023CPOL7 min read 6.1K   1

In the process of setting up Home Assistant, I've encountered various problems. A lot of these time, you can and will need to Google your particular issue. If that fails there are a couple of forums that might be helpful:

However, since I solved some problems myself, I have compiled the ones I experienced and solved into this article, in case you run into the same one.

If you have further problems, please feel free to ask them in the comments below. I will help if I can.

Error List

Where is my Home Assistant Container config folder?

If you're setting up Home Assistant Container, the Docker command you need to run in order to establish a config folder for Home Assistant is specific, in addition to being specific to your operating system. You need the config folder in order to be able to edit the Home Assistant configuration.yaml file, which is required for setting up a lot of integrations in Home Assistant.

The first thing we need to do is create a configuration folder for Home Assistant.

Image 1

The configuration folder will be on whatever drive you run the Docker pull on, which in my case, is the C:\ drive. So open Windows Explorer, go to the C:\ drive, right-click in the folder area, and go to New -> Folder. Input the folder name you want, I'm calling mine "haconfig".

Now go to the Start button for Windows and type "CMD" and open Command Prompt. Then type

BAT
docker run -d --name homeassistant --privileged --restart=unless-stopped -e TZ=America/Edmonton -v c:\haconfig:/config -p 8123:8123 homeassistant/home-assistant:latest

where --name homeassistant is the name of your container, TZ=America/Edmonton is the time zone for Home Assistant (just enter your own time zone here), and -v c:\haconfig:/config is the path of the config folder (if you created a folder in C:\Users\Joseph\haconfig this would be -v C:\Users\Joseph\haconfig:/config).

balena Etcher Error - Attention Something Went Wrong

If you're using balena Etcher to set up Home Assistant OS, you might be trying to use Flash from URL. For most people, this should work. For me, I got an error:

It says:

Attention. Something went wrong. if it is a compressed image, please check that the archive is no corrupted. Command failed: cmd /c "C:\Users\AppData\Local\Temp\etcher\balena-etcher-electron-78afb6aee66.cmd"

I Googled this error. On the balena forums I found a long thread from 2020 filled with people with a similar / the same issue. Seven days prior to my query, one user responded that they downloaded the first image instead of pointing to the Git URL. Let's try that.

Image 2

Take the URL https://github.com/home-assistant/operating-system/releases/download/10.0/haos_rpi4-64-10.0.img.xz and put it into a browser window. It automatically downloads. Go back to balena Etcher. Only this time, select Flash from a file instead of from a URL. Select the haos_rpi4-64-10.0.img.xz that downloads automatically.

Image 3

Bam! Worked automatically. Thank you, user DirkJam from the balenaEtcher forums. Thank you. As soon as balena Etcher says, "Flash Completed!" the the Home Assistant OS image has been successfully flashed to the microSD.

socket.gaierror: [Errno -2] Name does not resolve

For my purposes, I needed to set up CodeProject.AI Server on a different machine than Home Assistant was on. In my case, I set up CodeProject.AI Server on Windows. Then, when I went to go call CodeProject.AI Server, even though my Raspberry Pi was on the same network, CodeProject.AI could not be reached. I got an error in the Home Assistant logs.

Here is the full log error from Home Assistant, home-assistant.log, which can be found from File Editor in the left navigation pane, in the same place we edited configuration.yaml, by clicking the Browse Filesystem button.

2023-04-28 09:33:30.468 ERROR (MainThread) [homeassistant.helpers.entity] Update for image_processing.codeproject_ai_object_10_0_0 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/codeprojectai/core.py", line 103, in post_image
    return requests.post(url, files={"image": image_bytes}, data=data, timeout=timeout)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //10.0.0:32168/v1/vision/detection (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9fd21990>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/codeproject_ai_object/image_processing.py", line 365, in process_image
    predictions = self._cpai_object.detect(image)
  File "/usr/local/lib/python3.10/site-packages/codeprojectai/core.py", line 209, in detect
    response = process_image(
  File "/usr/local/lib/python3.10/site-packages/codeprojectai/core.py", line 122, in process_image
    response = post_image(url=url, image_bytes=image_bytes, timeout=timeout, data=data)
  File "/usr/local/lib/python3.10/site-packages/codeprojectai/core.py", line 108, in post_image
    raise CodeProjectAIException(f"CodeProject.AI Server connection error, check your IP and port: {exc}")
codeprojectai.core.CodeProjectAIException: CodeProject.AI Server connection error, check your IP and port: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //10.0.0:32168/v1/vision/detection (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9fd21990>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 550, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 755, in async_device_update
    raise exc
  File "/usr/src/homeassistant/homeassistant/components/image_processing/__init__.py", line 193, in async_update
    await self.async_process_image(image.content)
  File "/usr/src/homeassistant/homeassistant/components/image_processing/__init__.py", line 174, in async_process_image
    return await self.hass.async_add_executor_job(self.process_image, image)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/codeproject_ai_object/image_processing.py", line 366, in process_image
    except cpai.CodeProjectAIServerException as exc:
AttributeError: module 'codeprojectai.core' has no attribute 'CodeProjectAIServerException'

I started Googling. I created threads on Home Assistant subreddit and the Home Assistant Community page. No response. Alone and afraid, I sent the error to Matthew. He said, "You may need to open port 32168 on your Windows machine. Or simpler would be to configure CPAI to run on port 80."

Because in my configuration CodeProject.AI Server is running as a service on my Windows machine and not locally on the Raspberry Pi 4, I need to open port 32168 so it can communicate with the Pi. Here's how to you do that on Windows 10.

From the Windows Start button, select Settings. Then select Update and Security. Then select Windows Security from the left navigation pane and click the Open Windows Security button. Then select Firewall and nework protection from the left navigation pane, then Advanced Settings. Click Yes to allow the app to make changes. Now click Inbound Rules.

Image 4

From here, click New Rule....

Image 5

We want to create a rule for port 32168, so select Port then hit Next.

Image 6

Make sure TCP is selected, then in Specific local ports type "32168" and hit Next.

Image 7

The default selection is Allow the connection which is correct. Hit Next.

Image 8

Networking is not my forte. I hate it, and it hates me. I'm not 100% sure what the correct selection is here for which networks apply. I'm fairly certain it's just Private which is likely the safest selection and the only one necessary, but I just want this to work, so I checked all these boxes and hit Next.

Image 9

You can name the rule whatever you want. Probably best to name it something you'll recognize later. I called mine "CPAI Rule". Hit Finish. All right! Now CodeProject.AI Server can be called from Home Assistant OS on my Raspberry Pi 4.

How to Create a docker-compose.yml File

I don't know why the internet is so determined to be vague about how to create a docker-compose.yml file. It's probably because you actually have to create the file yourself out of nothing, and people who already know you create the file yourself understand this implicitly. I thought you had to follow some kind setup when making your Docker container, and that may be a thing, but I couldn't figure it out. So I'm going to break down my steps on how to to this, the simplest way possible.

Just for demonstrative purposes, I'm going to demonstrate how to creat a docker-compose.yml file that is used for setting up a Wyze Cam v3, using docker-wyze-bridge, a container that you have to setup in order for Home Assistant to use a Wyze Cam.

Go to the main GitHub page https://github.com/mrlt8/docker-wyze-bridge.

Under Basic Usage you'll find some instructions on how to set up docker-wyze-bridge using Docker Compose. These instructions also link to a sample docker-compose.yml that you can use. This is the basis of what I used, but modified it to the following:

yml
version: '2.4'
services:
    wyze-bridge:
        container_name: wyze-bridge
        restart: unless-stopped
        image: mrlt8/wyze-bridge:latest
        ports:
            - 1935:1935 # RTMP
            - 8554:8554 # RTSP
            - 8888:8888 # HLS
            - 8889:8889 #WebRTC
            - 8189:8189/udp # WebRTC/ICE
            - 5001:5000 # WEB-UI
        environment:
            # [REQUIRED] Fill the following two lines:
            - WYZE_EMAIL=
            - WYZE_PASSWORD= 
            # [OPTIONAL] IP Address of the host to enable WebRTC e.g.,:
            - WB_IP=youripaddress

Open Notepad. Paste this in there. Make sure you put in the email you used to create your Wyze account after WYZE_EMAIL= and the password you used for that account in WYZE_PASSWORD=. Because CodeProject.AI Server uses port 5000, you need to change that next line to - 5001:5000. If you try to use port 5000, when opening up the local steam you're creating for your Wyze Cam, it will open CodeProject.AI Server. I also included my IP address in the - WB_IP= line. If you do not know your IP address, go to the Start button in Windows and start to type "CMD" then select Command Prompt. Then, type ipconfig. The address you want is the IPv4 Address.

Image 10

Go to Windows Explorer. Create a new folder to hold your docker-compose.yml file. I called mine "docker-wyze-bridge".

Image 11

Go back to Notepad. Go to File, then Save As. In the Save as type field, change the dropdown from Text Documents (*.txt) to All Files (*). Type in "docker-compose.yml". Hit Save.

There. That's how you create a docker-compose.yml. Take THAT internet.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Writer CodeProject
Canada Canada
Sean Ewington is the Content Manager for CodeProject.

His background in programming is primarily C++ and HTML, but has experience in other, "unsavoury" languages.

He loves movies, and likes to say inconceivable often, even if it does not mean what he thinks it means.

Comments and Discussions

 
QuestionSolutions for Common Issues with Home Assistant (View) Pin
Sanjeev Senthil Kumar15-May-23 17:33
Sanjeev Senthil Kumar15-May-23 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.