Skip to content

Commit 3c8e164

Browse files
authored
Update fast-search-card.js
1 parent e5a9eb7 commit 3c8e164

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

dist/fast-search-card.js

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,12 @@ class FastSearchCard extends HTMLElement {
411411

412412
set hass(hass) {
413413
if (!hass) return;
414+
415+
// 🚀 NEU: Favorites Helper beim ersten Laden sicherstellen
416+
if (!this._favoritesHelperChecked) {
417+
this._favoritesHelperChecked = true;
418+
this.ensureFavoritesHelper();
419+
}
414420

415421
const oldHass = this._hass;
416422
this._hass = hass;
@@ -11332,7 +11338,76 @@ class FastSearchCard extends HTMLElement {
1133211338
}
1133311339
}
1133411340

11335-
11341+
async ensureFavoritesHelper() {
11342+
try {
11343+
// Prüfen ob Helper bereits existiert
11344+
const existingHelper = this._hass.states['input_text.fast_search_favorites'];
11345+
11346+
if (existingHelper) {
11347+
console.log('✅ Favorites Helper bereits vorhanden');
11348+
return;
11349+
}
11350+
11351+
console.log('🔧 Erstelle input_text.fast_search_favorites Helper...');
11352+
11353+
// Helper erstellen
11354+
await this._hass.callService('input_text', 'reload');
11355+
11356+
// Konfiguration für den Helper
11357+
const helperConfig = {
11358+
name: 'Fast Search Favorites',
11359+
initial: '{}',
11360+
max: 255,
11361+
mode: 'text'
11362+
};
11363+
11364+
// Helper über die Configuration API erstellen
11365+
await this._hass.callWS({
11366+
type: 'config/config_entries/options/flow/create',
11367+
handler: 'input_text',
11368+
context: {
11369+
source: 'user'
11370+
}
11371+
});
11372+
11373+
console.log('✅ Favorites Helper erfolgreich erstellt');
11374+
11375+
} catch (error) {
11376+
console.warn('⚠️ Konnte Favorites Helper nicht automatisch erstellen:', error);
11377+
console.warn('Bitte erstellen Sie manuell: input_text.fast_search_favorites');
11378+
11379+
// Benutzer informieren
11380+
if (this.shadowRoot) {
11381+
const notification = document.createElement('div');
11382+
notification.style.cssText = `
11383+
position: fixed;
11384+
top: 20px;
11385+
right: 20px;
11386+
background: #ff9800;
11387+
color: white;
11388+
padding: 12px 16px;
11389+
border-radius: 8px;
11390+
z-index: 10000;
11391+
font-size: 14px;
11392+
max-width: 300px;
11393+
`;
11394+
notification.innerHTML = `
11395+
<strong>Setup erforderlich:</strong><br>
11396+
Bitte erstellen Sie einen Input Text Helper:<br>
11397+
<code>input_text.fast_search_favorites</code>
11398+
`;
11399+
11400+
document.body.appendChild(notification);
11401+
11402+
// Nach 5 Sekunden entfernen
11403+
setTimeout(() => {
11404+
if (notification.parentNode) {
11405+
notification.parentNode.removeChild(notification);
11406+
}
11407+
}, 5000);
11408+
}
11409+
}
11410+
}
1133611411

1133711412

1133811413

0 commit comments

Comments
 (0)