Catch error on HA Collection retrieve

This commit is contained in:
Joris Bertomeu
2024-11-19 17:44:18 +01:00
parent ca5f121d35
commit 69781c40ab

View File

@@ -18,6 +18,7 @@ export class PhotoController {
let collections = settings.unsplash?.HACollectionsId; let collections = settings.unsplash?.HACollectionsId;
if (collections && collections.length > 0) { if (collections && collections.length > 0) {
try {
const resp = await fetch(`${settings.hass.endpoint}/api/states/${collections}`, { const resp = await fetch(`${settings.hass.endpoint}/api/states/${collections}`, {
headers: { headers: {
Authorization: `Bearer ${settings.hass.token}` Authorization: `Bearer ${settings.hass.token}`
@@ -28,6 +29,9 @@ export class PhotoController {
if (collections.includes(',')) { if (collections.includes(',')) {
collections = collections.split(','); collections = collections.split(',');
} }
} catch(e) {
collections = settings.unsplash.collectionsId;
}
} else { } else {
collections = settings.unsplash.collectionsId; collections = settings.unsplash.collectionsId;
} }