[Guide] Hass.IO on Windows 10 WSL2 (No more VMs!)

This is awesome! Just implemented it myself and works great! Can’t wait for Win 10 2004 official release in a couple weeks.

I got Home Assistant up and running now under WSL2, so that’s nice. However I am still struggling with getting my Z-Stick accessible under WSL2.

Anyone got this already working, and if so how?

My attempt so far:

  1. As per the FAQ, WSL2 does not yet support serial devices. So I tried to tunnel the serial device from Windows to WSL2 Ubuntu via TCP (Windows Server + Linux Client). I used this com2tcp-rfc2217.bat together with this hub4com.exe, as I could not find them via the official com0com link in the guide.
    I tested the forwarding by connecting a windows and a linux serial terminal via a virtual com0com serial port pair, which seems to work nicely.
  2. Now I need to enable access to the newly created /dev/ttyACM0 device from inside the home assistant docker container, but I don’t know how. In many places I see this can be done by adding the --device option to the HA “docker run” command, but I assume this is taken care of by the HA supervisor. Any thoughts?
1 Like

Thanky you, nirkins. Running everything (else) INSIDE genie was the problem. I got everything to work.

Excellent guide and installed successfully however find that docker container for “Hassio_supervisor” keeps on exiting after few seconds. Anyone else had this problem ?

Yes I appear to be having the same problem as well as if I tell it to restart, it really doesn’t. I end up having to reboot the whole box.

I read that lack of secrets.yaml file in config folder can cause this however that has made no difference. will attempt at reinstalling from scratch on 19.04 this time and see if it changes.

Is this still necessary?

Evening, folks. genie author (who is also a Home Assistant user) here just stopping by to admire the niftiness of y’all using it to get HASS to work under WSL 2, and to drop a couple of pieces of useful information.

First: if you’re having trouble getting genie to install under Ubuntu 20.02 “Focal”, that’s because there are some breaking changes in Focal that prevent the existing package from working properly, and I haven’t yet had the time to build a new one. It should be out before the end of the month; in the meantime, please use the manual install procedure, or stick with 18.04 LTS.

Second: I note that there are some workarounds being used because WSL 2 does not (currently) support bridged networking. Well, as it happens, there’s a workaround that can be used to make WSL 2 support bridged networking that synergizes very well with genie which I wrote up today, so here’s a link to that:

…which may simplify getting things working, especially if you use HASS addons that want to use various other ports besides the standard ones.

Hope this proves useful!

5 Likes

Thanks for chiming in @cerebrate!

I have yet to get WSL2 (Win 2004 update) on the public release channel on my PC, but once I do I will create an updated guide under the new forum section they made for HASS installations and include the new information you wrote, and hopefully by that time Ubuntu 20 will also be supported so that’s what I’ll write the guide on

Ubuntu 20 should be supported now. (Although there are possibly a few wrinkles to chase down, but that happens with every new release. :slight_smile: )

As a side note, I myself use Debian - and so it’s what genie is developed against - so if anyone’s concerned with the speed of genie fixes/updates, that’s the distro to use to get them fastest. Ubuntu should in theory be almost as quick, being a Debian derivative and all, but :man_shrugging: .

It works! The guide worked great, just these suggested modifications:

  • The Windows store did install Ubuntu 20.04 as mentioned but it is not broken
  • Would be nice if the hassio dependencies were a copy/pasteable command:
sudo apt-get install \
    bash \
    jq \
    curl \
    avahi-daemon \
    dbus \
    apparmor-utils \
    network-manager
  • There’s a new URL for installing the Dockerized hassio (now known as Home Assistant Supervised)
curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s -- -m qemux86-64

@nirkons , Ditto, a great How-To doc, thanks. Flawlessly describes everything in details.
However, I am not sure how the last script (Bridging workaround) brings up the HASS in a docker in case windows restarts? The description says:

it will also run HASS with the “genie -i” command.

Have I missed something? I cannot seem to be able to find the command in the script.
A pointer on how to autostart the Docker would be hugely appreciated.

I love answering my own questions :slight_smile:

The short answer is this command does the magic

bash.exe -c “genie -i”

It seems that the installer deploys the HA is an autostart/auto-restart mode (how? I have no idea :slight_smile: ), i.e. as long as the distro is up and running the HA will be up. As we all know, the distro comes to life when the first command gets executed. So executing the above command brings up the distro and that in turn makes the HA functional.

I would like to try this solution. However, before I do, can someone tell me what I need to do in order to use my HUSBZB-1 USB stick’s COM ports (COM3, COM4) under WSL2/HASSIO? What would I need to do in my configuration.yaml?

UPDATE: I just saw the link below. It seems like even if I get Home Assistant setup perfectly under WSL2, I still wouldn’t be able to use my HUSBZB-1 USB stick since there’s no support for Serial->USB devices:

Hi,

I have managed to install following this guide.
Thanks for the detailed info.

Following the guide, I have a supervised HA running.
I can see a virtual network adapter with the following address: 172.23.96.1.
The host PC IP address is 192.168.1.101 (static).
I do have a working internet connection in HA (have managed to update and set Tuya plugin to work).
My question would be how to use 192.168.1.XXX devices in HA (as is is running in 172.23.96.XXX). Do I simple use 192.168.1.XXX addresses in configuration file to control any device connected on 192.168.1.XXX network?
I am totally new to this stuff, sorry in advance if this is a dumb question.

Thanks.

Yes Hass should be able to communicate with the outside network, but if you want the network to be able to communicate with HASS you need to use the bridged networking workaround in the original post

Could you please elaborate?
Please let me explain the issues I have.

  1. I would like to communicate with the Broadlink which has the internal IP address (192.168.XXX.XXX) from the HA which is 172.XXX.XXX.XXX).
    How should I do it? As I can’t get this to work.
  2. I have installed Homekit Bridge. I can’t connect to it. My iPhone says devices not found when I scan the QR code.
    My guess would be this IPs issue (due to virtual ethernet adapter).
  1. Out of the box HASS should be able to communicate with the outside network as long as your PC running WSL can also do it, see this image, the IP is 172.X but it is able to ping 192.X without an issue

image

  1. For that to work you need to use the workaround in the original post, and add any ports you need (maybe homekit needs additional ports), check the section under where it says “Save this script somewhere on your PC with a .ps1 ending, note that you can add/remove/edit the ports you want forwarded from WSL” in the original post

Thank you very much for your help, this is very helpful.
Now I know the problem is outside HA communication.
I have no ping to my local PC (192.168.1.100).

The script is running according to the first post, I can access HA on local port, HA is running.

My ps1 file is as follows:

bash.exe -c “genie -i”
$remoteport = bash.exe -c “ifconfig eth0 | grep 'inet '”
$found = $remoteport -match ‘\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}’;

if( $found ){
$remoteport = $matches[0];
} else{
echo “The Script Exited, the ip address of WSL 2 cannot be found”;
exit;
}

#[Ports]

#All the ports you want to forward separated by coma
$ports=@(80,443,8123,1880,1883,1884,8883,8884,51827,51828);
$portsudp=@(5353);

#[Static ip]
#You can change the addr to your ip config to listen to a specific address
$addr=‘0.0.0.0’;
$ports_a = $ports -join “,”;
$ports_b = $portsudp -join “,”;

#Remove Firewall Exception Rules
iex "Remove-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock TCP’ ";
iex "Remove-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock UDP’ ";

#adding Exception Rules for inbound and outbound Rules
iex “New-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock TCP’ -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP”;
iex “New-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock TCP’ -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP”;
iex “New-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock UDP’ -Direction Outbound -LocalPort $ports_b -Action Allow -Protocol UDP”;
iex “New-NetFireWallRule -DisplayName ‘WSL 2 Firewall Unlock UDP’ -Direction Inbound -LocalPort $ports_b -Action Allow -Protocol UDP”;

for( $i = 0; $i -lt $ports.length; $i++ ){
$port = $ports[$i];
iex “netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr”;
iex “netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport”;
}

ifconfig from ubuntu shows the following:

docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:f1ff:fe5f:ea59 prefixlen 64 scopeid 0x20
ether 02:42:f1:5f:ea:59 txqueuelen 0 (Ethernet)
RX packets 30 bytes 2942 (2.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 429 bytes 65879 (65.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.27.84.192 netmask 255.255.240.0 broadcast 172.27.95.255
inet6 fe80::215:5dff:fe06:bc65 prefixlen 64 scopeid 0x20
ether 00:15:5d:06:bc:65 txqueuelen 1000 (Ethernet)
RX packets 2864 bytes 1731423 (1.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1683 bytes 199612 (199.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

hassio: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.30.32.1 netmask 255.255.254.0 broadcast 172.30.33.255
inet6 fe80::42:33ff:fe1e:104a prefixlen 64 scopeid 0x20
ether 02:42:33:1e:10:4a txqueuelen 0 (Ethernet)
RX packets 399 bytes 49177 (49.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1954 bytes 376346 (376.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 471 bytes 48673 (48.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 471 bytes 48673 (48.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth7479615: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::bc82:f6ff:fe02:b01f prefixlen 64 scopeid 0x20
ether be:82:f6:02:b0:1f txqueuelen 0 (Ethernet)
RX packets 71 bytes 5571 (5.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1710 bytes 320078 (320.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth2261e93: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::645f:91ff:fe98:2d56 prefixlen 64 scopeid 0x20
ether 66:5f:91:98:2d:56 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1637 bytes 314804 (314.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth6b192e4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::7853:45ff:fec3:224d prefixlen 64 scopeid 0x20
ether 7a:53:45:c3:22:4d txqueuelen 0 (Ethernet)
RX packets 43 bytes 4795 (4.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1660 bytes 322300 (322.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth772f74b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::38b5:c4ff:fef8:ffab prefixlen 64 scopeid 0x20
ether 3a:b5:c4:f8:ff:ab txqueuelen 0 (Ethernet)
RX packets 291 bytes 48993 (48.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1927 bytes 374904 (374.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth7bdc8df: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::ca9:bcff:fef8:79f3 prefixlen 64 scopeid 0x20
ether 0e:a9:bc:f8:79:f3 txqueuelen 0 (Ethernet)
RX packets 30 bytes 3362 (3.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 450 bytes 68399 (68.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth9b5266c: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::cc25:e1ff:fe33:94b5 prefixlen 64 scopeid 0x20
ether ce:25:e1:33:94:b5 txqueuelen 0 (Ethernet)
RX packets 121 bytes 15519 (15.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1711 bytes 325303 (325.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethb2c194b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::84e6:abff:fe57:c8a4 prefixlen 64 scopeid 0x20
ether 86:e6:ab:57:c8:a4 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1167 bytes 240978 (240.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethf3b8a2c: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::1c9c:4eff:fe47:3c93 prefixlen 64 scopeid 0x20
ether 1e:9c:4e:47:3c:93 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1635 bytes 314398 (314.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Could you identify whether something is wrong?

@pgross - Thanks for the update on the hassio URL. Unfortunately I now get

bash: line 73: /etc/docker/daemon.json: No such file or directory

Docker Desktop is working fine, as it runs my Deepstak AI server flawlessly.