Artwork is missing in Loxone with Sonos, HTTPS and Radio Paradise recents
Artwork sonn already has is not always shown in Loxone. I hit three separate problems while testing with a Sonos Amp and a Loxone Miniserver.
1. Sonos zones show no artwork
For a zone with the Sonos output, the Loxone app shows no cover for the current track. Sonn's own web UI shows the artwork for that same track at the same time.
2. Artwork is blocked in the HTTPS Web UI
When the Loxone Web UI is accessed over HTTPS, artwork is missing because sonn generates HTTP artwork URLs, which the browser blocks as mixed content. This affects zone covers, library covers and the Radio Paradise logos in the radio menu. The phone app still shows the same images.
3. Radio Paradise keeps no logo in Recently Played
A Radio Paradise station played from LOXONE Radio shows its logo there, but the same station appears in Recently Played with the generic radio icon. Playing it again does not bring the logo back.
Expected
- A Sonos zone shows the artwork sonn has for the current track.
- Covers and station logos load in the Loxone Web UI when it is served over HTTPS.
- A Radio Paradise station keeps its logo in Recently Played.
Setup
- sonn-core built from
dev - Sonos Amp (S2) as the output of one zone
- Loxone Miniserver with the Loxone app and the Loxone Web UI served over HTTPS
- Radio Paradise stations under LOXONE Radio
Related: #197 brought the Radio Paradise logos into the catalogue. They are present under LOXONE Radio, but not in Recently Played.
AI assistance
The implementation was developed with GitHub Copilot using a locally deployed DeepSeek V4.1 Flash model via BYOK. I have tested the changes on real hardware.
On dev in 7b0cf12 and bdfb012, with you as co-author (PR #450, closed there). For HTTPS I went another way than your PR, without new settings: every http cover now goes out in the form the Loxone app retries through the Miniserver's proxy, so it should load in the HTTPS Web UI and away from home. Sonos speaker art falls under that too. The Radio Paradise logo in Recently Played is fixed as well. I can't test the HTTPS part myself, so could you try it with the dev build?
For HTTPS I went another way than your PR, without new settings: every http cover now goes out in the form the Loxone app retries through the Miniserver's proxy, so it should load in the HTTPS Web UI and away from home. Sonos speaker art falls under that too. The Radio Paradise logo in Recently Played is fixed as well. I can't test the HTTPS part myself, so could you try it with the dev build?
Thanks for implementing this! I like the idea of using the native Loxone image proxy mechanism rather than introducing additional configuration parameters.
I'll test this with the dev build.
In the meantime, I've also successfully integrated a Loxone Touch Pure Display with sonn. With our current implementation, artwork is served over HTTPS via a reverse proxy using a certificate from our private CA. The Display retrieves the artwork directly from sonn, and this works for both native Spotify playback and Radio Paradise.
I'll therefore also test whether the new imgcache mechanism works with the Touch Pure Display, in addition to the HTTPS Web UI.
Tested on dev (0fd45d23) with a Miniserver and the Loxone app at home: covers that go out through the new route do not load, so every radio logo (all http) is missing in the app. https covers (Spotify) are fine, since they go out unchanged.
What the app does differs from what the commit inferred. It never asks for the url as handed out (http://<server>:7091/imgcache/<sig>/<b64>?viaproxy=<uuid>). It asks straight away, on its connection to the server, for /proxy/<uuid>/imgcache/<sig>/<b64>, where <uuid> is the viaproxy value moved into the path and the query is dropped. At home that connection is the Audio Server itself, so the request lands on sonn's app port with the prefix:
[DEBUG][LoxoneHttp] [method=GET name=appHttp remote=<app> url=/proxy/<uuid>/imgcache/<sig>/<b64>] loxone http request received
[WARN][LoxoneHttp|Router] [command=/proxy/<uuid>/imgcache/<sig>/<b64>] unhandled loxone command
That was 84 requests in 40 minutes, all in this form, none as handed out. LoxoneCoverProxy.isCoverRequest only knows /imgcache/, so they go to the command router and the app gets JSON back. The same cover fetched as handed out returns 200 image/png.
Two changes were needed here.
1. The prefix. Take a leading /proxy/<segment> off before the cover route reads the path. The signature is checked as before, so the route still serves only covers this server handed out.
@@ -30,6 +30,13 @@ export type LoxoneCoverProxyOptions = {
};
const IMGCACHE_PREFIX = '/imgcache/';
+/**
+ * `/proxy/<viaproxy>` in front of a cover's path: the retry form, asked for on the connection the
+ * client already has. The Loxone app at home is connected to this server itself, so the request
+ * lands here with the prefix, and it does not ask for the url as handed out first (seen on a
+ * server: every cover request of the app came in this form).
+ */
+const PROXY_PREFIX = /^\/proxy\/[^/]+(?=\/imgcache\/)/;
const COVER_KEYS = new Set(['coverurl', 'coverUrl', 'thumbnail', 'icon']);
export class LoxoneCoverProxy {
@@ -55,7 +62,7 @@ export class LoxoneCoverProxy {
/** The original cover a request for `path` names, or null when it is not one of ours. */
public resolve(path: string): string | null {
- const pathname = path.split('?')[0] ?? '';
+ const pathname = withoutProxyPrefix(path.split('?')[0] ?? '');
if (!pathname.startsWith(IMGCACHE_PREFIX)) return null;
const [signature, encoded] = pathname.slice(IMGCACHE_PREFIX.length).split('/');
if (!signature || !encoded) return null;
@@ -67,7 +74,7 @@ export class LoxoneCoverProxy {
}
public static isCoverRequest(path: string): boolean {
- return path.startsWith(IMGCACHE_PREFIX);
+ return withoutProxyPrefix(path).startsWith(IMGCACHE_PREFIX);
}
private sign(encoded: string): string {
@@ -84,3 +91,8 @@ export class LoxoneCoverProxy {
return copy;
}
}
+
+/** A cover's path as handed out, whether it was asked for as it is or in the retry form. */
+function withoutProxyPrefix(path: string): string {
+ return path.replace(PROXY_PREFIX, '');
+}
2. CORS. With the prefix handled, the app still showed no cover. It asked for the same 8 covers 84 times in about ten seconds, and the server's writes failed (dispatcher socket error ... write EPIPE): the app dropped every response. The app reads covers with fetch (CoverRepository.fetch), and at home the cover comes from another origin than the app's, so a response without Access-Control-Allow-Origin is refused. The hosts it loads covers from directly send it: the station logo CDN and Spotify's both answer Access-Control-Allow-Origin: *, while the cover route sent only Content-Type, Content-Length and Cache-Control. Through the Miniserver the retry is on the same origin, which may be why it did not show there.
@@ -184,6 +184,10 @@ export class LoxoneHttpService {
// A cover handed to the clients by way of this server, asked for directly or through the
// Miniserver's proxy (#449).
const cover = this.options.notifier.getCoverProxy()?.resolve(url) ?? null;
+ // The app reads a cover with `fetch`, from an origin of its own when it is connected to this
+ // server: without this the response is refused, the request dropped and asked again. The
+ // hosts it loads covers from directly answer the same way.
+ res.setHeader('Access-Control-Allow-Origin', '*');
await serveCover(res, cover, this.log, { cacheControl: 'public, max-age=86400' });
return;
}
Tests in tests/loxoneCoverProxy.test.ts: the retry form is served, and a forged signature, a non-cover path, an extra segment and an empty uuid are refused; and a cover fetched through the route on a local server comes back with the header, its type, length and bytes. Full suite green.
With both changes the radio logos show again in the app at home. Away from home and in the HTTPS Web UI not tested yet.
@rudyberends
I've now tested both your implementation on dev (0fd45d23) and the same build with @sebastienfouss's two proposed corrections.
Your implementation:
- Native Spotify artwork works on the iOS app, HTTPS Web UI and Touch Pure Display.
- All three room favourites and their artwork are now displayed correctly on the Touch Pure Display.
- Radio Paradise station logos were still missing, including in Recently Played on iOS.
After applying Sébastien's corrections:
- All six Radio Paradise station logos now work in the iOS app.
- Recently Played station logos work in both the iOS app and HTTPS Web UI.
- All 26 observed prefixed imgcache requests were handled successfully.
- Previously working artwork continues to work.
Remaining observations:
- The HTTPS Web UI displays four of the six Radio Paradise station logos, although all six assets are available over HTTPS with the correct content type and CORS header.
- When switching from native Spotify to Radio Paradise, the previous Spotify artwork still reappears on iOS and Web UI. My diagnostics show that an external Sonos state update retains the previous Spotify cover in the internal zone state. This appears to be related to playback ownership rather than artwork delivery, so I'll investigate it separately in the context of #452.
Overall, your implementation combined with Sébastien's corrections works well across my three clients, apart from the remaining observations above. I would support integrating the two corrections.
Thanks both. Sébastien, your two corrections are on dev now (9202b24, e61f0d2), with you as co-author: the /proxy/<uuid> prefix is taken off before the cover route reads the path, and covers are served with Access-Control-Allow-Origin: *. TheNinth7, thanks for testing across the three clients. On the two remaining points: for the HTTPS Web UI showing four of the six Radio Paradise logos, could you tell me which two are missing and whether the browser console says anything for them? And I'll wait for what you find on the old Spotify cover coming back, since that sounds like the external state rather than the delivery.
Thanks Rudy, I have now completed a more detailed browser and server-side capture.
First, to clarify, the artwork delivery issue described below is specific to the HTTPS Web UI. In the native iOS app, all six Radio Paradise station logos are displayed correctly, as is the song artwork. I have not tested remote access yet.
In the Web UI, none of the six station logos are visible in the Radio Paradise folder. In Recently Played, the two missing logos were Beyond and Rock.
The browser capture shows 42 failed artwork requests, covering all six stations. They all follow this pattern:
https://loxone.dts.home:7091/proxy/<uuid>/imgcache/<sig>/<b64>
Firefox reports "CORS request did not succeed" with a null status code. However, this is actually a connection failure rather than a CORS header issue.
sonn publishes the URL with port 7091, and the Web UI appears to retain that port while substituting the hostname and scheme of its connection to the Miniserver. The Miniserver does not listen on port 7091.
Interestingly, requesting the same path on port 443 reaches sonn through the Miniserver and returns cover-not-found with the correct CORS header.
This also explains the difference between the Radio Paradise folder and Recently Played. The folder generates fresh HTTP artwork URLs, which are wrapped by imgcache. Some of my previously stored favourites and recently played entries still contain direct HTTPS URLs from my earlier implementation, which continue to work.
I have also repeated the Spotify-to-Radio-Paradise transition. This time the stale Spotify artwork did not reappear. Both the expanded and minimized players displayed the correct artwork in the Web UI as well. These two issues therefore appear to be intermittent, and I would keep them separate from the artwork delivery issue.
The current validation build contains functionally equivalent versions of the two latest corrections.
Given these findings, I think there may still be value in the optional HTTPS artwork origin from my original PR. It could coexist with your imgcache implementation, which would remain the default for installations without a configured HTTPS origin.
There may also be a way to correct the proxy URL generation without additional configuration, although I have not identified one yet.
What do you think?
Thanks, that capture nails it. The client takes host, port and scheme from its own connection, but takes the port only when the connection has one: connectionTarget.port || coverUrl.port. Over HTTPS on 443 that port is empty, so it fell back to the 7091 in our URL. The cover URL now goes out without a port (20caf58 on dev), so every client asks on the port of its own connection, and the optional HTTPS origin shouldn't be needed. The cover-not-found on 443 was probably a URL from before a restart, since the signature key lives as long as the process. Can you test again on the next dev build?
Thanks Rudy, that makes perfect sense. Removing the port from the published URL is indeed a much cleaner solution.
I will test the next dev build across the Web UI, iOS app and Touch Pure Display and report back.
I have now tested the unmodified upstream dev image containing 20caf58.
All six Radio Paradise station logos are now displayed correctly in the LOXONE Radio folder in the HTTPS Web UI. Favourites, Recently Played and Spotify artwork also render correctly.
I have additionally tested artwork in the native iOS app and on the Touch Pure Display, and both are working.
Unfortunately, my browser diagnostic recorder did not capture the proxied artwork requests, so I cannot independently confirm the corrected request path. However, the previously reproducible rendering failure is gone.
The only remaining artwork issue I observed was an intermittent occurrence where the correct song artwork was replaced by artwork from a previous Radio Paradise song. The server-side capture confirms that sonn published the outdated cover URL, so this is a separate metadata issue rather than an artwork delivery issue. I will report it separately.
From a functional perspective, your correction appears to have resolved the original issue, and I no longer see a need for the optional HTTPS artwork origin.
Thanks for your work on this!