mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-25 20:20:00 +00:00
@@ -459,15 +459,19 @@ function migrateToFour(
|
||||
|
||||
const saveBase64DeviceIconsAsImage = (currentSettings: Partial<Settings>): ReturnType<SettingsCustomHandler['execute']> => {
|
||||
const [validPath, previousValue] = getValue(currentSettings, ['devices']);
|
||||
let changed = false;
|
||||
|
||||
for (const deviceKey in currentSettings.devices) {
|
||||
const base64Match = utils.matchBase64File(currentSettings.devices[deviceKey].icon ?? '');
|
||||
if (base64Match) {
|
||||
currentSettings.devices[deviceKey].icon = utils.saveBase64DeviceIcon(base64Match);
|
||||
if (validPath) {
|
||||
for (const deviceKey in currentSettings.devices) {
|
||||
const base64Match = utils.matchBase64File(currentSettings.devices[deviceKey].icon);
|
||||
if (base64Match) {
|
||||
changed = true;
|
||||
currentSettings.devices[deviceKey].icon = utils.saveBase64DeviceIcon(base64Match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [validPath, previousValue, validPath];
|
||||
return [validPath, previousValue, changed];
|
||||
};
|
||||
|
||||
customHandlers.push({
|
||||
|
||||
+7
-5
@@ -375,11 +375,13 @@ function deviceNotCoordinator(device: zh.Device): boolean {
|
||||
return device.type !== 'Coordinator';
|
||||
}
|
||||
|
||||
function matchBase64File(value: string): {extension: string; data: string} | false {
|
||||
const match = value.match(BASE64_IMAGE_REGEX);
|
||||
if (match) {
|
||||
assert(match.groups?.extension && match.groups?.data);
|
||||
return {extension: match.groups.extension, data: match.groups.data};
|
||||
function matchBase64File(value: string | undefined): {extension: string; data: string} | false {
|
||||
if (value !== undefined) {
|
||||
const match = value.match(BASE64_IMAGE_REGEX);
|
||||
if (match) {
|
||||
assert(match.groups?.extension && match.groups?.data);
|
||||
return {extension: match.groups.extension, data: match.groups.data};
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user