Installing HomeAssistant on oVirt
One of my big interests is home automation with self hosted platforms like the Philips Hue lights or Jasper (sadly dead it seems) so I wanted to give HomeAssistant a try to see if it could give me any new or interesting functionality. Since I can’t justify more hardware in the house I am going to try virtualizing it as well on my oVirt setup. It is designed to run happily on a Raspberry Pi so I think a small VM should be able to handle it no problem.
Installation and Template Creation
I decided to go the prebuilt appliance route available here but since there is no QCOW2 disk image available the first hurdle is to convirt the available VMDK into the right format. Thankfully I already had the QEMU tools installed from earlier so following along with this blog post I converted the image with the following commands:
$ gunzip hassos_ova-2.12.vmdk.gz
$ qemu-img convert -f vmdk -O qcow2 hassos_ova-2.12.vmdk HassOS-2.12.qcow2
From there it was a simple matter of uploading the disk image to oVirt through the web UI. Once the disk was created I set up a new VM with 4 CPU cores and 1GB of RAM to approximately mirror the resources provided by the suggested Raspberry Pi 3 B+ install platform. I also attached and resized the virtual disk to 32GB to mirror the suggested SD card size. Lastly, I added a single NIC connected to my primary VM data network and saved the VM configuration as a template.
I also tried to set the BIOS type to UEFI as required by the image but that setting did not seem to stick when the VM was changed into a template. In either case, I created a new VM from my new template and, after changing the BIOS type, booted it up.
Reconfiguring Docker Networking
A quick aside: I don’t run my home network on the usual 192.168.x.x/24
IP space.
I actually have multiple subnets set up on the 172.16.0.0/12
block so that I
have lots of room for various VMs and other network connected projects. Unfortunately,
HomeAssistant runs all of its services through Docker and by default sets up its
networks and bridges in that same IP space. What this resulted in was my VM being
unable to pull down the container images it needed to boot up correctly. The
solution was to modify both the bridge IP and the address pools provided for
overlay networks as detailed here. Below you can see an
example configuration which allowed me to pull the images correctly.
{
"bip": "10.200.0.1/24",
"default-address-pools": [
{"base": "10.201.0.0/16", "size": 24},
{"base": "10.202.0.0/16", "size": 24}
]
}
Static Network Addressing
The next hurdle was getting DNS set up for the new VM so I didn’t need to go hunting
in the router ARP tables every time I needed to log in. Since I was using the
appliance install option I couldn’t pull in ovirt-guest-agent
to have oVirt
report the IPs or even freeipa-client
to auto-update a DNS entry when DHCP re-assigned
it. I could have used the VMs MAC address and set up a static DHCP assignment in
the router but I felt a self configured static IP was much cleaner. Paraphrasing
from the official network documentation I set up a static
IP using the NetworkManager CLI commands shown below.
$ nmcli con edit "HassOS default"
nmcli> set ipv4.addresses 172.17.x.x/16
nmcli> set ipv4.dns 172.17.x.y 172.17.x.z
nmcli> set ipv4.gateway 172.17.x.z
nmcli> save
nmcli> quit
After that it was a simple matter of setting up the A and PTR records in FreeIPA and I was able to login to the configuration page.
HomeAssistant Configuration
My Hue light hub came in automatically as soon as I started the application, only requiring the same touch of a button on the hub as other applications to finish the authentication process. Next I wanted to setup access to my Amcrest camera for monitoring our puppy in his crate. The integration is already built into HomeAssistant but I needed to add the Configurator add-on to edit the required configuration files. After adding that through the configuration menu I ticked ‘Show in Sidebar’ and clicked ‘Start’ to launch the pod.
Clicking on it’s sidebar link I first selected secrets.yaml
to store the password
for the camera. Secrets are explained here in the documentation
and can be referenced in other configuration files with the !secret
directive
followed by the variable name.
amcrest_viewer_password: SecurePassword
Next I modified configuration.yaml
and added configuration for both ffmpeg
and my Amcrets camera. I wanted both accessability and motion detection
enabled for the camera so that I could keep an eye on the system should my WiFi
go down or the dog wake up unexpectedly. Once I saved the file, all that was
left to do was reboot HomeAssistant to have it reload the configuration and I was
able to watch the live video feed right in the landing page.
ffmpeg:
amcrest:
- host: camera-1.example.com
username: user
password: !secret amcrest_viewer_password
name: camera-1
stream_source: rtsp
binary_sensors:
- motion_detected
- online
Conclusions and Next Steps
So far the only thing that does not work exactly the way I would like is the RTSP stream from my camera does not include the audio channel when displaying via the webpage. Totally understandable from an implementation standpoint but it would be nice to hear as well as see what is on the far end. I’m curious to see what other add-ons and integrations are available for the system and how I can tailor it to work in our house.
As for next steps I would like to work with authentication and particularly try to authenticate with LDAP against my FreeIPA install. Beyond that I want to get proper SSL set up in front of the web interface so that login credentials are properly secured, probably using a certificate issued by FreeIPA.