Skip to content

Identity name wiring: hostname-based IDs, Snapserver as player registry, remove mDNS/player-API #31

Description

@thomaseleff

Problem

Three related gaps exist in how device names are wired across services:

  1. Snapclient on both streamer and player has no --name set — every device shows up as audera in Snapserver, which is broken for multi-device setups.
  2. PlexAmp CLIENT_NAME is set dynamically from the system hostname via $(hostname -s) in the systemd unit. The PlexAmp player name will instead be the static value "Audera", set by changing the literal value of CLIENT_NAME in the systemd unit. Per-device Plex naming is out of scope.
  3. The _audera._tcp.local. mDNS service and the player FastAPI server are vestigial from the pre-Snapcast architecture. Snapserver already provides the player registry (IP, MAC, name). Removing both simplifies the architecture significantly.

Architecture After This Change

  • Snapserver is the player registry. The streamer reaches any player via Snapserver's client list (IP, MAC, display name). No separate player API or mDNS discovery needed.
  • System hostname is the permanent machine ID, derived deterministically from the MAC address at provisioning time (e.g. audera-a1b2c3). It never changes. Snapclient reports this hostname to Snapserver automatically — no --name flag needed.
  • Client.SetName JSON-RPC is the sole pathway for display name changes. The user renames a device from the streamer UI; this calls Client.SetName and the name persists in Snapserver's config across client reconnects (keyed by MAC address).
  • identity.json is dropped entirely. The WiFi AP SSID uses the system hostname. The setup wizard drops the name field.
  • audera.local is static — nginx and avahi are never touched on rename.
  • PlexAmp player name is static "Audera" — set once at provisioning via the settings file. CLIENT_NAME env var is removed from the systemd unit.

What Does Not Change

  • audera.local nginx domain and avahi hostname — static, never tied to device identity.
  • Snapserver source name (name=PlexAmp in snapserver.conf) — unrelated to device identity.
  • CamillaDSP — no name concept, untouched.

What Is Removed

Artifact Reason
audera/models/identity.py No identity object needed; hostname replaces it
audera/dal/identities.py No identity persistence needed
audera/server/player/app.py All info available via Snapserver; endpoints are dead code
audera/services/mdns.py Snapserver replaces mDNS as the player registry
tests/services/test_mdns.py Test file for removed service
coolname dependency Only used in generate_cool_name() in identity model
zeroconf dependency Only used in mdns.py
fastapi / uvicorn dependencies Only used in server/player/app.py (verify not used in streamer)

Implementation Steps

Step 1 — Set system hostname from MAC address at provisioning

Both setup scripts (os/dietpi/streamer/automation/setup.sh, os/dietpi/player/automation/setup.sh):

After the network interface is up, derive a deterministic hostname from the last 6 hex digits of the MAC address and apply it:

MAC=$(cat /sys/class/net/eth0/address 2>/dev/null || cat /sys/class/net/wlan0/address)
SHORT=$(echo "$MAC" | tr -d ':' | tail -c 7)
NEW_HOSTNAME="audera-${SHORT}"
hostnamectl set-hostname "$NEW_HOSTNAME"
echo "127.0.1.1   $NEW_HOSTNAME" >> /etc/hosts

Step 2 — Remove the player FastAPI server

  • Delete audera/server/player/app.py.
  • In audera/cli/commands.py: remove the player-server branch from run() and remove it from the type_ choices list.
  • In audera/cli/audera.py: remove 'player-server' from the choices list on the type_ argument.
  • In os/dietpi/player/automation/setup.sh: remove the audera run player-server autostart entry from /var/lib/dietpi/dietpi-autostart/custom.sh.
  • Remove fastapi and uvicorn from pyproject.toml.

Step 3 — Remove the mDNS service

  • Delete audera/services/mdns.py.
  • Delete tests/services/test_mdns.py.
  • Remove zeroconf from pyproject.toml.

Step 4 — Remove the Identity model and DAL

  • Delete audera/models/identity.py.
  • Delete audera/dal/identities.py.
  • Remove identity from the imports in audera/models/__init__.py.
  • Remove coolname from pyproject.toml.
  • Check audera/dal/__init__.py and remove any identities import.

Step 5 — Update the AccessPoint service

In audera/services/ap.py, remove the identity parameter entirely. Derive the AP SSID from the system hostname:

import socket
self.hostname = socket.gethostname()

Step 6 — Update the setup wizard

In audera/server/setup.py:

  1. Remove the identity parameter from Page.__init__. Remove self.identity, self.name, update_name_callback(), and the IP-update block in connect_callback().
  2. Construct AccessPoint without an identity.
  3. Collapse the wizard to three pages: welcome → connect → finish. Remove the /discover and /setup routes. Update the progress indicator from five dots to three.
  4. In run(), remove all identity generation — replace with just starting the AP and the UI.
  5. Remove all imports of audera.dal.identities, audera.models.identity, and coolname.

Step 7 — Wire PlexAmp static name at provisioning

In os/dietpi/streamer/automation/setup.sh:

# Before:
ExecStart=/bin/bash -c 'export CLIENT_NAME=$(hostname -s); exec /usr/bin/node /opt/plexamp/js/index.js'
# After:
ExecStart=/bin/bash -c 'export CLIENT_NAME=Audera; exec /usr/bin/node /opt/plexamp/js/index.js'

Step 8 — Add set_client_name() to SnapserverClient

In audera/services/snapserver.py, add a set_client_name(client_id, name) method using the existing JSON-RPC 2.0 over WebSocket pattern, calling Client.SetName.

Step 9 — Streamer UI: rename flow

In audera/server/streamer/app.py, add an inline rename control per player card and for the streamer's own name. On submit, call await snapserver.set_client_name(client_id, new_name) and refresh the player list. No local identity file is written — Snapserver is the sole persistent store.

Files Changed

File Change
audera/models/identity.py Delete
audera/dal/identities.py Delete
audera/server/player/app.py Delete
audera/services/mdns.py Delete
tests/services/test_mdns.py Delete
audera/models/__init__.py Remove identity import
audera/dal/__init__.py Remove identities import
audera/cli/commands.py Remove player-server branch
audera/cli/audera.py Remove player-server from choices
audera/services/ap.py Remove identity param; use socket.gethostname()
audera/server/setup.py Collapse to three pages; remove identity handling
audera/services/snapserver.py Add set_client_name()
audera/server/streamer/app.py Add rename UI per player + streamer self
os/dietpi/streamer/automation/setup.sh Set hostname from MAC; static CLIENT_NAME=Audera
os/dietpi/player/automation/setup.sh Set hostname from MAC; remove player-server autostart
pyproject.toml Remove coolname, zeroconf, fastapi, uvicorn

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions