Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Dec 24, 2024
1 parent 1547b52 commit 68d83ea
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/extension/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export default class Bridge extends Extension {
const oldOptions = objectAssignDeep({}, cleanup(entity.options));

if (message.options.icon) {
const base64Match = utils.isBase64File(message.options.icon);
const base64Match = utils.matchBase64File(message.options.icon);
if (base64Match) {
const fileSettings = utils.saveBase64DeviceIcon(base64Match);
message.options.icon = fileSettings;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function validate(): string[] {
if (names.includes(e.friendly_name)) errors.push(`Duplicate friendly_name '${e.friendly_name}' found`);
errors.push(...utils.validateFriendlyName(e.friendly_name));
names.push(e.friendly_name);
if ('icon' in e && e.icon && !utils.isBase64File(e.icon) && !e.icon.startsWith('device_icons/')) {
if ('icon' in e && e.icon && !utils.matchBase64File(e.icon) && !e.icon.startsWith('device_icons/')) {
errors.push(`Device icon of '${e.friendly_name}' should start with 'device_icons/', got '${e.icon}'`);
}
if (e.qos != null && ![0, 1, 2].includes(e.qos)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/settingsMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function migrateToFour(
const [validPath, previousValue] = getValue(currentSettings, ['devices']);

for (const deviceKey in currentSettings.devices) {
const base64Match = utils.isBase64File(currentSettings.devices[deviceKey].icon ?? '');
const base64Match = utils.matchBase64File(currentSettings.devices[deviceKey].icon ?? '');
if (base64Match) {
currentSettings.devices[deviceKey].icon = utils.saveBase64DeviceIcon(base64Match);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function deviceNotCoordinator(device: zh.Device): boolean {
return device.type !== 'Coordinator';
}

function isBase64File(value: string): {extension: string; data: string} | false {
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);
Expand All @@ -397,7 +397,7 @@ function saveBase64DeviceIcon(base64Match: {extension: string; data: string}): s
const noop = (): void => {};

export default {
isBase64File,
matchBase64File,
saveBase64DeviceIcon,
capitalize,
getZigbee2MQTTVersion,
Expand Down

0 comments on commit 68d83ea

Please sign in to comment.