From fa82a56831a059f94b36118671f4c5cb06f481cd Mon Sep 17 00:00:00 2001 From: imonlinux <39863321+imonlinux@users.noreply.github.com> Date: Sun, 14 Sep 2025 12:01:14 -0700 Subject: [PATCH 1/3] Add script to create and install avahi service unit Intended to setup Zeroconf/mDNS for HA discovery --- script/gen-esphome-avahi.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 script/gen-esphome-avahi.sh diff --git a/script/gen-esphome-avahi.sh b/script/gen-esphome-avahi.sh new file mode 100644 index 0000000..0600c23 --- /dev/null +++ b/script/gen-esphome-avahi.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -euo pipefail +PORT=6053 +NAME="%h (Linux Voice Assistant)" + +mapfile -t IFACES < <(ip -o link show up | awk -F': ' '{print $2}' | grep -v '^lo$') + +TXT=" platform=linux +" +LIST="" +for i in "${IFACES[@]}"; do + mac=$(cat "/sys/class/net/$i/address") + if [ -d "/sys/class/net/$i/wireless" ] || [[ $i == wl* ]]; then net=wifi; else net=ethernet; fi + TXT+=" mac_${i}=${mac} +" + TXT+=" net_${i}=${net} +" + LIST+="${i}," +done +LIST=${LIST%,} + +cat >/etc/avahi/services/esphome-lva.service < + + + ${NAME} + + _esphomelib._tcp + ${PORT} + ifaces=${LIST} +${TXT} + +XML From e17e13c5ddcf4d6c2cd9845cd99670f85f200c94 Mon Sep 17 00:00:00 2001 From: imonlinux <39863321+imonlinux@users.noreply.github.com> Date: Sun, 14 Sep 2025 12:04:34 -0700 Subject: [PATCH 2/3] Add LVA service drop-in for avahi This updates the linux-voice-assistant.service to require and wait for avahi to start. Independent of the systemd unit being used to start LVA. --- service/10-avahi.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 service/10-avahi.conf diff --git a/service/10-avahi.conf b/service/10-avahi.conf new file mode 100644 index 0000000..dc5ca11 --- /dev/null +++ b/service/10-avahi.conf @@ -0,0 +1,3 @@ +[Unit] +Wants=avahi-daemon.service +After=avahi-daemon.service From 0289fd5a4c71b1c03fe341af85e458596c255593 Mon Sep 17 00:00:00 2001 From: imonlinux <39863321+imonlinux@users.noreply.github.com> Date: Sun, 14 Sep 2025 12:17:53 -0700 Subject: [PATCH 3/3] Update linux-voice-assistant-2mic-install.md Updated the tutorial to include optional avahi config for HA discovery of the LVA. --- docs/linux-voice-assistant-2mic-install.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/linux-voice-assistant-2mic-install.md b/docs/linux-voice-assistant-2mic-install.md index fc41556..8eebedd 100644 --- a/docs/linux-voice-assistant-2mic-install.md +++ b/docs/linux-voice-assistant-2mic-install.md @@ -25,7 +25,8 @@ This guide reproduces a working setup of the **linux-voice-assistant** project w ```bash sudo apt update sudo apt upgrade -sudo apt install libportaudio2 build-essential git libmpv-dev mpv python3.11-dev +sudo apt install libportaudio2 build-essential git \ + libmpv-dev mpv python3.11-dev avahi-daemon avahi-utils sudo reboot ``` @@ -82,6 +83,19 @@ aplay -l ## 7. Systemd services +### (Optional) enable Avahi service file to advertise LVA to HA: + +```bash +chmod +x ~/linux-voice-assistant/script/gen-esphome-avahi.sh +sudo ~/linux-voice-assistant/script/gen-esphome-avahi.sh +sudo mkdir -p /etc/systemd/system/linux-voice-assistant.service.d +sudo cp ~/linux-voice-assistant/service/10-avahi.conf sudo mkdir -p /etc/systemd/system/linux-voice-assistant.service.d/10-avahi.conf +``` + +```bash +sudo systemctl restart avahi-daemon.service +``` + ### (Optional) for Pulse Audio with OWW copy this service file into /etc/systemd/system/: ```bash @@ -145,6 +159,8 @@ sudo systemctl status linux-voice-assistant wyoming-openwakeword --no-pager -l ## 8. Connect to Home Assistant +### If HA does not discover the new LVA: + 1. In Home Assistant, go to "Settings" -> "Device & services" 2. Click the "Add integration" button 3. Choose "ESPHome" and then "Set up another instance of ESPHome"