WireGuard

Overview #

WireGuard allows you to establish a VPN tunnel connecting a remote Dongle-MZG23 and a Home Assistant (HA) host to a single local network. This enables you to add and remotely manage the Dongle-MZG23 within the HA and manage Z-Wave devices.

Prerequisites #


  • HA host must have a public IP.
  • Using Home Assistant platform.
  • WireGuard Add-on
  • DuckDNS Add-on
  • Advanced SSH & Web Terminal Add-on

Overall Workflow #


  1. Configure port forwarding on your router to map the HA host to the public internet.
  2. Use DuckDNS to create a dynamic domain name to handle changing public IPs.
  3. Enable WireGuard on Home Assistant to create a VPN network, exposing the host to the public network.
  4. The remote Dongle-MZG23 connects to the HA host via the public IP or dynamic domain, putting both devices on the same LAN.
  5. Add Dongle-MZG23 to the Z-Wave JS UI to add and control remote Z-Wave devices.

Detailed Steps #


1. Map the HA host to the public network so that remote dongles can access it

1.1. If you don't have a public internet connection

1. Create a Duck DNS domain at duckdns.org, which will generate a DuckDNS domain, such as dong-mzg23.duckdns.org.

2. To install the Duck DNS add-on in Home Assistant, go to HA -> Settings -> Add-ons -> Add-on Store -> Office apps -> Duck DNS page, and click the Install button to download and install the Duck DNS add-on, as shown in the following screenshot:

3. Configure Duck DNS add-on

  • domain: Enter the domain name you created in Duck DNS
  • token: Enter the token generated in Duck DNS
  • accept_terms: true

The following configuration can be used as a reference:

domains:
  - dongle-mzg23.duckdns.org
token: 694bb20f-2c91-4168-9218-c97ff98de394
aliases: []
lets_encrypt:
  accept_terms: true
  algo: secp384r1
  certfile: fullchain.pem
  keyfile: privkey.pem
seconds: 300
YAML

1.2. If you have a public internet connection

you need to configure port forwarding on your router. Taking a Xiaomi router as an example, on Advance Settings -> Port forwarding, add a rule and configure it as follows:

  • Server: WireGuard
  • Device IP Address: Home Assistant's IP address (e.g., 192.168.31.49)
  • External ports: 51820
  • Internal Port: 51820
  • Protocol: UDP

2. Install the WireGuard Add-on

Install the WireGuard add-on in Home Assistance, on Settings -> Add-ons -> Add-on Store -> Office apps -> WireGuard, and click the Install button to download and install the WireGuard add-on, as shown in the following screenshot:

3. Configuring the WireGuard Add-on

1. HA -> Settings -> Add-ons -> Add-on Store -> Office apps -> WireGuard -> Configuration. Select Edit in YAML and confirm the configuration, as shown in the following screenshot:

  • server:
    • host: The public IP address that the client can use to access WireGuard, or the Duck DNS domain name.
    • address: The virtual IP address assigned to WireGuard. It is recommended to use a different network segment than Home Assistant (e.g.,if your Home Assistant is 192.168.1.168, it is recommended to set the virtual IP to 192.168.10.1).
    • dns: You can use the router's address, or 1.1.1.1
  • Peer:
    • name: Enter any name, such as Dongle-MZG23. A configuration file named Dongle-MZG23 will be generated.
    • address: The virtual IP address assigned to the client. It is recommended to use a different network segment than Dongle (e.g., if your Dongle is on a different network segment than Home Assistant). The IP address is 192.168.21.155 (it is recommended to set the virtual IP to 192.168.10.2).
    • client_allowed_ips: A list of networks allowed for the client. It is recommended to enter the main network and the WireGuard network.

The following configuration can be used as a reference:

server:
  host: http://192.168.31.49/ #home assistant public IP or Duck DNS domain
  addresses:
    - 192.168.10.1
  dns: []
peers:
  - name: Dongle-MZG23
    addresses:
      - 192.168.10.2
    allowed_ips: []
    client_allowed_ips:
      - 192.168.31.0/24
      - 192.168.10.0/24
YAML

2. Click Save button, then click Start on the Info page to launch the Addon. You can view the log on the Log page. If the log appears as shown in the image, it means WireGuard has started successfully.

4. Obtain Key Information

4.1. Method 1

1. On HA -> Settings -> Add-ons -> Add-on Store -> Office apps -> File editor and download and install it.

2. In File editor -> Configuration, disable Enforce Basepath.

3. In File editor -> Configuration, click Start to enable the Add-on and open the Web UI.

4. Click the back button in the upper right corner to return to the previous level. Follow the path ssl -> wireguard -> {Peer Name defined in WireGuard, e.g., Dongle-MZG23} -> client.conf to find the WireGuard configuration information

As shown in the following screenshot:

4.2. Method 2

1. On HA -> Settings -> Add-ons -> Add-on Store -> Office apps -> Advanced SSH & Web Terminal to download and install the Advanced SSH & Web Terminal Add-on.

2. In Advanced SSH & Web Terminal info page, go to Info and disable Protection mode.

3. Click the Start button to enable the Add-on, then click Open web UI to open it.

4. Enter the command: `cd ssl/wireguard/{Peer Name defined in WireGuard (e.g., Dongle-MZG23)}` to navigate to the file corresponding to `{Peer Name}`.

5. Enter the command: `cat client.conf`.

As shown in the following screenshot:

Dongle-MZG23 Console Web UI Configuration #


Access and log in to the Dongle-MZG23 console web UI. Enable the WireGuard feature in Tools -> WireGuard, and fill in the obtained WireGuard configuration information in the corresponding options. After filling in the information, click Save. Once the connection is successful, the VPN Connection Status will display "Connected". As shown in the following screenshot:

Install the Z-Wave JS UI Add-on and add Dongle-MZG23 #


  1. HA -> Settings -> Add-ons -> Add-on Store -> Office apps -> Z-Wave JS UI to download and install the Z-Wave JS UI Add-on.
  2. Click the Start button to enable the Add-on, and then click Open web UI to open the UI interface.
  3. Complete the Z-Wave configuration. Note: Serial port: the client's virtual IP address.
  4. The device will now be visible in the Control Panel. The addition was successful.

As shown in the following screenshot:

What are your feelings

Updated on November 2, 2026