Fix autorestore logic and protocol badge per device type
Autorestore fixes: - Snapshot WLED state before connect() mutates it (lor, AudioReactive) - Gate restore on auto_shutdown setting (was unconditional) - Remove misleading auto_restore capability from serial provider - Default auto_shutdown to false for all new devices Protocol badge fixes: - Show correct protocol per device type (OpenRGB SDK, MQTT, WebSocket) - Was showing "Serial" for all non-WLED devices Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
||||
ICON_CLONE, ICON_EDIT, ICON_START, ICON_STOP,
|
||||
ICON_LED, ICON_FPS, ICON_OVERLAY, ICON_LED_PREVIEW,
|
||||
ICON_GLOBE, ICON_RADIO, ICON_PLUG, ICON_FILM, ICON_SUN_DIM, ICON_TARGET_ICON, ICON_HELP,
|
||||
ICON_WARNING,
|
||||
ICON_WARNING, ICON_PALETTE, ICON_WRENCH,
|
||||
} from '../core/icons.js';
|
||||
import { EntitySelect } from '../core/entity-palette.js';
|
||||
import { wrapCard } from '../core/card-colors.js';
|
||||
@@ -163,6 +163,24 @@ class TargetEditorModal extends Modal {
|
||||
|
||||
const targetEditorModal = new TargetEditorModal();
|
||||
|
||||
function _protocolBadge(device, target) {
|
||||
const dt = device?.device_type;
|
||||
if (!dt || dt === 'wled') {
|
||||
const proto = target.protocol === 'http' ? 'HTTP' : 'DDP';
|
||||
return `${target.protocol === 'http' ? ICON_GLOBE : ICON_RADIO} ${proto}`;
|
||||
}
|
||||
const map = {
|
||||
openrgb: [ICON_PALETTE, 'OpenRGB SDK'],
|
||||
adalight: [ICON_PLUG, t('targets.protocol.serial')],
|
||||
ambiled: [ICON_PLUG, t('targets.protocol.serial')],
|
||||
mqtt: [ICON_GLOBE, 'MQTT'],
|
||||
ws: [ICON_GLOBE, 'WebSocket'],
|
||||
mock: [ICON_WRENCH, 'Mock'],
|
||||
};
|
||||
const [icon, label] = map[dt] || [ICON_PLUG, dt];
|
||||
return `${icon} ${label}`;
|
||||
}
|
||||
|
||||
let _targetNameManuallyEdited = false;
|
||||
|
||||
function _autoGenerateTargetName() {
|
||||
@@ -936,7 +954,7 @@ export function createTargetCard(target, deviceMap, colorStripSourceMap, valueSo
|
||||
<div class="stream-card-props">
|
||||
<span class="stream-card-prop stream-card-link" title="${t('targets.device')}" onclick="event.stopPropagation(); navigateToCard('targets','led','led-devices','data-device-id','${target.device_id}')">${ICON_LED} ${escapeHtml(deviceName)}</span>
|
||||
<span class="stream-card-prop" title="${t('targets.fps')}">${ICON_FPS} ${target.fps || 30}</span>
|
||||
${device?.device_type === 'wled' || !device ? `<span class="stream-card-prop" title="${t('targets.protocol')}">${target.protocol === 'http' ? ICON_GLOBE : ICON_RADIO} ${(target.protocol || 'ddp').toUpperCase()}</span>` : `<span class="stream-card-prop" title="${t('targets.protocol')}">${ICON_PLUG} ${t('targets.protocol.serial')}</span>`}
|
||||
<span class="stream-card-prop" title="${t('targets.protocol')}">${_protocolBadge(device, target)}</span>
|
||||
<span class="stream-card-prop stream-card-prop-full${cssId ? ' stream-card-link' : ''}" title="${t('targets.color_strip_source')}"${cssId ? ` onclick="event.stopPropagation(); navigateToCard('targets','led','led-css','data-css-id','${cssId}')"` : ''}>${ICON_FILM} ${cssSummary}</span>
|
||||
${bvs ? `<span class="stream-card-prop stream-card-prop-full stream-card-link" title="${t('targets.brightness_vs')}" onclick="event.stopPropagation(); navigateToCard('streams','value','value-sources','data-id','${bvsId}')">${getValueSourceIcon(bvs.source_type)} ${escapeHtml(bvs.name)}</span>` : ''}
|
||||
${target.min_brightness_threshold > 0 ? `<span class="stream-card-prop" title="${t('targets.min_brightness_threshold')}">${ICON_SUN_DIM} <${target.min_brightness_threshold} → off</span>` : ''}
|
||||
|
||||
Reference in New Issue
Block a user