@@ -348,7 +348,12 @@ class FastSearchCard extends HTMLElement {
348348 // NEU: Autocomplete State
349349 this.currentSuggestion = '';
350350 this.autocompleteTimeout = null;
351- }
351+
352+ // ✅ SAFETY: Ensure critical methods exist
353+ setTimeout(() => {
354+ this.ensureCriticalMethods();
355+ }, 100);
356+ }
352357
353358 setConfig(config) {
354359 if (!config) {
@@ -6562,6 +6567,12 @@ class FastSearchCard extends HTMLElement {
65626567
65636568 updateSubcategoryCounts() {
65646569 if (!this._hass || !this.allItems) return;
6570+
6571+ // ✅ SAFETY CHECK
6572+ if (typeof this.isItemInCategory !== 'function') {
6573+ console.error('❌ isItemInCategory missing in updateSubcategoryCounts');
6574+ this.defineIsItemInCategoryFunction();
6575+ }
65656576
65666577 // Domain-zu-Subcategory Mapping (gleich wie in renderCategoryChips)
65676578 const domainMap = {
@@ -7230,7 +7241,32 @@ class FastSearchCard extends HTMLElement {
72307241 this.currentSuggestion = '';
72317242 }
72327243
7244+ isItemInCategory(item, category) {
7245+ if (!item || !item.domain) return false;
7246+
7247+ switch (category) {
7248+ case 'devices':
7249+ return !['script', 'automation', 'scene', 'custom'].includes(item.domain);
7250+ case 'scripts':
7251+ return item.domain === 'script';
7252+ case 'automations':
7253+ return item.domain === 'automation';
7254+ case 'scenes':
7255+ return item.domain === 'scene';
7256+ case 'custom':
7257+ return item.domain === 'custom';
7258+ default:
7259+ return true;
7260+ }
7261+ }
7262+
72337263 showCurrentCategoryItems() {
7264+ // ✅ SAFETY CHECK: Prüfe ob Funktion existiert
7265+ if (typeof this.isItemInCategory !== 'function') {
7266+ console.error('❌ isItemInCategory function missing! Defining it now...');
7267+ this.defineIsItemInCategoryFunction();
7268+ }
7269+
72347270 console.log('🔍 showCurrentCategoryItems called');
72357271 console.log('📊 allItems:', this.allItems.length);
72367272 console.log('🏷️ activeCategory:', this.activeCategory);
@@ -7249,6 +7285,52 @@ class FastSearchCard extends HTMLElement {
72497285 console.log('📊 Final filteredItems:', this.filteredItems.length);
72507286 }
72517287
7288+ ensureCriticalMethods() {
7289+ if (typeof this.isItemInCategory !== 'function') {
7290+ console.warn('🔧 Adding missing isItemInCategory function');
7291+ this.defineIsItemInCategoryFunction();
7292+ }
7293+ console.log('✅ Critical methods check completed');
7294+ }
7295+
7296+ defineIsItemInCategoryFunction() {
7297+ console.log('🔧 Defining backup isItemInCategory function');
7298+
7299+ this.isItemInCategory = (item, category) => {
7300+ if (!item || !item.domain) {
7301+ console.warn('❌ Invalid item:', item);
7302+ return false;
7303+ }
7304+
7305+ switch (category) {
7306+ case 'devices':
7307+ return !['script', 'automation', 'scene', 'custom'].includes(item.domain);
7308+ case 'scripts':
7309+ return item.domain === 'script';
7310+ case 'automations':
7311+ return item.domain === 'automation';
7312+ case 'scenes':
7313+ return item.domain === 'scene';
7314+ case 'custom':
7315+ return item.domain === 'custom';
7316+ default:
7317+ return true;
7318+ }
7319+ };
7320+ }
7321+
7322+ debugAvailableMethods() {
7323+ console.log('🔍 Available methods on this object:');
7324+ const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(this))
7325+ .filter(name => typeof this[name] === 'function');
7326+ console.log('Methods:', methods);
7327+
7328+ console.log('🔍 Checking specific functions:');
7329+ console.log('isItemInCategory:', typeof this.isItemInCategory);
7330+ console.log('showCurrentCategoryItems:', typeof this.showCurrentCategoryItems);
7331+ console.log('updateSubcategoryCounts:', typeof this.updateSubcategoryCounts);
7332+ }
7333+
72527334 debugDisableAnimations() {
72537335 console.log('🚫 Disabling animations for debugging');
72547336
0 commit comments