Merge pull request #14 from imonlinux/HA_LVA_Discovery

HA LVA Discovery
This commit is contained in:
imonlinux
2025-09-14 12:23:18 -07:00
committed by GitHub
3 changed files with 53 additions and 1 deletions
+17 -1
View File
@@ -25,7 +25,8 @@ This guide reproduces a working setup of the **linux-voice-assistant** project w
```bash ```bash
sudo apt update sudo apt update
sudo apt upgrade 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 sudo reboot
``` ```
@@ -82,6 +83,19 @@ aplay -l
## 7. Systemd services ## 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/: ### (Optional) for Pulse Audio with OWW copy this service file into /etc/systemd/system/:
```bash ```bash
@@ -145,6 +159,8 @@ sudo systemctl status linux-voice-assistant wyoming-openwakeword --no-pager -l
## 8. Connect to Home Assistant ## 8. Connect to Home Assistant
### If HA does not discover the new LVA:
1. In Home Assistant, go to "Settings" -> "Device & services" 1. In Home Assistant, go to "Settings" -> "Device & services"
2. Click the "Add integration" button 2. Click the "Add integration" button
3. Choose "ESPHome" and then "Set up another instance of ESPHome" 3. Choose "ESPHome" and then "Set up another instance of ESPHome"
+33
View File
@@ -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=" <txt-record>platform=linux</txt-record>
"
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+=" <txt-record>mac_${i}=${mac}</txt-record>
"
TXT+=" <txt-record>net_${i}=${net}</txt-record>
"
LIST+="${i},"
done
LIST=${LIST%,}
cat >/etc/avahi/services/esphome-lva.service <<XML
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">${NAME}</name>
<service>
<type>_esphomelib._tcp</type>
<port>${PORT}</port>
<txt-record>ifaces=${LIST}</txt-record>
${TXT} </service>
</service-group>
XML
+3
View File
@@ -0,0 +1,3 @@
[Unit]
Wants=avahi-daemon.service
After=avahi-daemon.service