Home Assistant (HA) Smart Home

Hardware Setup #

  • 4x Old Dell Optiplex 755 (only one machine necessary)
  • Wired ethernet switch to home wireless router and WAN
  • SONOFF Zigbee USB Dongle (this one) on one of the machines (only necessary to interact with Zigbee devices)

System Setup #

Each machine has the following:

  • Ubuntu Linux 20.04
  • Docker (with Swarm Cluster, Docker and Swarm not necessary for HA)
  • GlusterFS shared disk across the cluster, not necessary for HA

Home Assistant Docker Setup #

Start from Linux on command line as swarm service (from the machine that has the USB dongle if necessary):

1
2
3
4
5
6
7
8
9
docker service create --replicas=1 \
    -p 8123:8123 \
    --name ha-service \  # used in the device permissions script below as well, so make changes in both
    -e TZ=America/New_York \
    --mount type=bind,source=/local/path/to/ClusterServices/homeassistant,target=/config \
    --mount type=bind,source=/dev/ttyUSB0,target=/dev/ttyUSB0 \ # may depend on the system or linux install
    --constraint "node.hostname == your_dongle_system" \ # just an example
    ghcr.io/home-assistant/home-assistant:stable \
&& allow_device_permissions.sh # only if necessary

/dev/ttyUSB0 mount and constraint are only necessary to use the Zigbee USB dongle specifically in the case of a swarm service. Because Docker Swarm services do not have direct device permissions like docker run or compose would, the following allow_device_permissions.sh script manually passes the device permissions through to the docker container running HA. This script was adapted from a udev routine from the Home Assistant community and I’ll post a link to the discussion when I can find it again.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# The following `/dev/serial/...` path is specific to the physical USB dongle
USBDEV=`readlink -f /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_62f6e4fcce12ec118f3c23c7bd930c07-if00-port0`
read minor major < <(stat -c '%T %t' $USBDEV)
if [[ -z $minor || -z $major ]]; then
	echo 'Device not found'
	exit
fi
dminor=$((0x${minor}))
dmajor=$((0x${major}))
CID=`docker ps -a --no-trunc | grep ha-service | head -1 |  awk '{print $1}'`
if [[ -z $CID ]]; then
	echo 'CID not found'
	exit
fi
echo 'Setting permissions'
echo "c $dmajor:$dminor rwm"
echo "c $dmajor:$dminor rwm" > /sys/fs/cgroup/devices/docker/$CID/devices.allow

Home Assistant Integrations #

Manual configuration.yaml modification examples #

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
wemo:
    discovery: false
    static:
      - 192.168.100.100
      - 192.168.100.200

light:
  - platform: hubspace
    username: username@email.address
    password: yourpasswordforhubspace
    debug: true
    friendlynames:
      - 'PorchLight' 
      - 'LivingRoomTableLamp'
      - 'DeskLamp'

landroid_cloud:
  - email: username@email.address
    password: yourpasswordforlandroid

Support #

The HA community seems is very active: https://community.home-assistant.io/