mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 09:06:14 +00:00
`addManualDevice` and the per-device branch of `discoverDevices` were ~40 lines of near-identical client setup, info fetch, connection build, and map write — differing only in log wording. Extract a shared `addDevice(app, host, port, source)` helper used by both paths. Side effects of consolidating: - Duplicate-host guard (LastSeen bump) now applies to both paths, so passing `--devices 1.2.3.4` twice is idempotent and matches how discovery treats repeat sightings. - Map write happens before the UpdateDeviceStatus goroutine launch, so a concurrent GET /api/devices sees the device with `IsConnected: false` instead of racing the status update. - Log wording is consistent: "Failed to fetch device info from <host> (<source>): <err>" and "Added <source> device <name> (<type>) at <host>:<port>". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>