@@ -9130,27 +9130,19 @@ class FastSearchCard extends HTMLElement {
91309130 try {
91319131 console.log(`🔧 Aktualisiere Timer ${timerId} auf ${newTotalMinutes} Minuten`);
91329132
9133- // Hole die aktuellen Timer-Daten
91349133 const currentTimer = this.lastLoadedTimers?.find(t => t.schedule_id === timerId);
91359134
91369135 if (!currentTimer) {
91379136 console.error('❌ Aktueller Timer nicht gefunden für Update');
91389137 return;
91399138 }
91409139
9141- // Neue Zeit berechnen
91429140 const future = new Date(Date.now() + newTotalMinutes * 60 * 1000);
91439141 const timeString = future.toTimeString().slice(0, 5);
91449142
9145- console.log(`🕐 Neue Timer-Zeit: ${timeString}`);
9146- console.log(`🔍 Current Timer:`, currentTimer);
9147-
9148- // KORRIGIERT: Entity-ID Format schedule.{id}
9149- const entityId = `schedule.${timerId}`;
9150- console.log(`🔍 Using entity_id: ${entityId}`);
9151-
9143+ // KORRIGIERT: Verwende schedule_id statt entity_id
91529144 await this._hass.callService('scheduler', 'edit', {
9153- entity_id: entityId , // ← schedule.{id} Format
9145+ schedule_id: timerId , // ← Nur die ID
91549146 timeslots: [{
91559147 start: timeString,
91569148 actions: currentTimer.timeslots[0].actions
@@ -9860,42 +9852,9 @@ class FastSearchCard extends HTMLElement {
98609852 try {
98619853 console.log(`🗑️ Timer löschen: ${timerId}`);
98629854
9863- // Debug: Schauen Sie, welche schedule-Entitäten existieren
9864- const allEntities = Object.keys(this._hass.states);
9865- const scheduleEntities = allEntities.filter(e => e.includes(timerId));
9866-
9867- console.log(`🔍 Alle Entitäten mit ${timerId}:`, scheduleEntities);
9868-
9869- // Verschiedene Format-Optionen probieren
9870- const possibleFormats = [
9871- `schedule.${timerId}`,
9872- `switch.schedule_${timerId}`,
9873- timerId,
9874- `scheduler_${timerId}`
9875- ];
9876-
9877- let foundEntity = null;
9878-
9879- for (const format of possibleFormats) {
9880- if (this._hass.states[format]) {
9881- foundEntity = format;
9882- console.log(`✅ Entität gefunden: ${format}`);
9883- break;
9884- }
9885- }
9886-
9887- if (!foundEntity) {
9888- console.error(`❌ Keine passende Entität für ${timerId} gefunden`);
9889- console.log('🔍 Verfügbare schedule/switch Entitäten:');
9890- allEntities.filter(e => e.startsWith('schedule.') || e.startsWith('switch.')).forEach(e => {
9891- if (e.includes('schedule')) console.log(` - ${e}`);
9892- });
9893- return;
9894- }
9895-
9896- // Versuche zu löschen
9855+ // KORRIGIERT: Verwende nur die schedule_id ohne Entity-Prefix
98979856 await this._hass.callService('scheduler', 'remove', {
9898- entity_id: foundEntity
9857+ schedule_id: timerId // ← Nur die ID, kein "schedule." oder "switch."
98999858 });
99009859
99019860 console.log(`✅ Timer ${timerId} erfolgreich gelöscht`);
@@ -9907,6 +9866,18 @@ class FastSearchCard extends HTMLElement {
99079866
99089867 } catch (error) {
99099868 console.error('❌ Fehler beim Löschen des Timers:', error);
9869+
9870+ // Fallback: Versuche es mit entity_id
9871+ try {
9872+ console.log('🔄 Versuche Fallback mit entity_id...');
9873+ await this._hass.callService('scheduler', 'remove', {
9874+ entity_id: timerId
9875+ });
9876+ console.log(`✅ Timer ${timerId} mit Fallback gelöscht`);
9877+ setTimeout(() => this.loadActiveTimers(entityId), 500);
9878+ } catch (fallbackError) {
9879+ console.error('❌ Auch Fallback fehlgeschlagen:', fallbackError);
9880+ }
99109881 }
99119882 }
99129883
0 commit comments