homeassistent - bunnyamin/bunnix GitHub Wiki

Overview

Home assistant OS

  1. Download the Home assistant OS image
  2. Create a qemu VM for the OS image
  3. Start the VM
  4. Access http://localhost:8123/
  5. Setup controller:
  6. Add the device controller in the "Home assistent OS":
    • "Settings" > "Devices & Services" > "Add integration" > Select "Z-wave"
  7. Add device in the "Home assistant OS":
    • "Settings" > "Devices & Services" > "Add integration" > "Add Z-wave device"

Home assistant core

Home assistant Arch Linux
build-essential base-devel
libatlas libatlas (AUR)
zlib1g zlib

Follow the official instructions.

  1. sudo -u /home/homeassistant -H -s
  2. cd /install/path/homeassistant
  3. python3 -m venv .
  4. source bin/activate
  5. pip3 install homeassistant

Moving an installation

Moving the installed Home assistant core from one path to another causes failure in execution from the new path. The problem is that the original path is written into several files. For example, search for /install/path/homeassistant

  • grep --text -r '/install/path/homeassistant' /install/path/homeassistant/

Therefore, after moving the installed Home directory core to a new path, find and replace all references to the old path with the new path. For example,

  • find /new/path/homeassistant -type f -exec sed -i 's|/install/path/homeassistant|/new/path/homeassistant|g' {} \;

SystemD

Create the service file /etc/systemd/system/homeassistant@<USER>.service

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
WorkingDirectory=/home/%i/.homeassistant
ExecStart=/sub/homeassistant/bin/hass -c "/home/%i/.homeassistant"
RestartForceExitStatus=100

[Install]
WantedBy=multi-user.target

Z-wave

Fallow the official instructions. Observe the following:

  1. Restore security keys from backup. If no previous security keys exists then create new ones and back them up.
  2. Enable "WS Server" in Menu > Settings > Home Assistant

Hardware

Zwave USB Controller

Add necessary permission

If the user is not root:

  1. Create a group groupadd zwave, or reuse an existing group.
  2. Change the group for /dev/ttyACM0 to chgrp zwave /dev/ttyACM0.
  3. Change the permission for /dev/ttyACM0 to chmod g+rw /dev/ttyACM0.
  4. Add the intended user for the VM to group usermod -aG zwave user.
  5. If everything works, and the changes are intended to be permanent, create /etc/udev/rules.d/97-ttyacm.rules:
    • Identify property: $ udevadm info --attribute-walk --path=$(udevadm info --query=path --name=/dev/ttyACM0)
    • Write appropriate Udev rule: KERNEL=="ttyACM[0-9]", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idProduct}=="<ID>", ATTRS{idVendor}=="<ID>", GROUP="zwave", MODE="660"
    • udevadm test $(udevadm info --query=path --name=/dev/ttyACM0) 2>&1
    • The rule should be applied after reboot.
    • Enable changes directly udevadm trigger --type=devices --sysname-match=ttyACM[0-9]

Qemu

Two parameters are required to pass through the "serial character device", also called TTY (teleprinter, teletype, teletypewriter), from the host to the guest:

  1. Define the "back end": -chardev serial,path=/dev/ttyACM0,id=acm, or with a more persistent path chardev serial,path=/dev/serial/by-id/usb-0000_0000-if00,id=acm
  2. Define the "front end": -usb -device usb-serial,chardev=acm

Note that the parameter "serial" is the new term for "tty" which is deprecated. For example,

  • -chardev tty,... raises The alias 'tty' is deprecated, use 'serial' instead.

Home assistant shell

  • login to leave the "HA" CLI and enter into the Linux CLI.
  • exit to leave the Linux CLI and reenter into the HA CLI.

SSH

Shutdown Home assistant OS

Qemu

  • Forward a host port to a guest port: qemu-system-x86_64 ... -nic user,hostfwd=tcp::<HOST PORT>9999-:<GUEST PORT>22
  • Login to the guest from the host local network: ssh -vx [email protected] -p 9999 or ssh -vx root@localhost -p 9999

SystemD

Qemu

For example,

Error, problem, troubleshooting

Error Event Consequence Cause Remedy
'AddonManager.install' blocked from execution, no host internet connection Trying to install add-on host_internet: false Degbug connection issues
ERROR (MainThread) [aiohttp.server] Error handling request ... "homeassistant/lib/python3.9/site-packages/aiohttp/web_protocol.py" ... aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered ... Connecting to localhost:8123 Web page does not load Ensure connection to localhost is HTTP and not HTTPS.

Debug connection issues

In the HA command line:

  • Leave the HS shell: login
  • Ping IP and domains to test connection. For example, ping 1.1.1.1 and ping example.org.
  • NSlookup nslookup example.org

If all the tests fail, ensure that there are no firewall rules preventing access to and from the HTTP and HTTPS port. If the name lookup fails, then it could indicate a problem with the DNS.

ModuleNotFoundError: No module named 'homeassistant'

Started Home Assistant.
... hass[54144]: Traceback (most recent call last):
... hass[54144]:   File "/sub/homeassistant/bin/hass", line 5, in <module>
... hass[54144]:     from homeassistant.__main__ import main
... hass[54144]: ModuleNotFoundError: No module named 'homeassistant'

[Re-]Install Home assistant.

⚠️ **GitHub.com Fallback** ⚠️