Skip to content

Commit c9534a4

Browse files
authored
Update fast-search-card.js
1 parent 1304474 commit c9534a4

File tree

1 file changed

+29
-53
lines changed

1 file changed

+29
-53
lines changed

dist/fast-search-card.js

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12404,48 +12404,34 @@ class FastSearchCard extends HTMLElement {
1240412404
};
1240512405
}
1240612406

12407-
// ⏸️ SMART PAUSE PLAYER (Hierarchie mit Fallbacks)
12407+
// ⏸️ SMART PAUSE PLAYER (verwendet Ihre bewährte smartPlayPause Logik)
1240812408
async smartPausePlayer(entityId) {
12409-
// Temporär zum Debugging - fügen Sie das in smartPausePlayer() ganz oben hinzu:
12410-
console.log('🔍 Available services:', Object.keys(this._hass.services));
12411-
console.log('🔍 Music Assistant services:', this._hass.services.music_assistant);
12412-
1241312409
console.log('⏸️ Smart pausing player...');
12414-
12415-
const pauseMethods = [
12416-
// Music Assistant - RICHTIGER Service-Name
12417-
{ service: 'music_assistant', action: 'pause', priority: 1 },
12418-
// Standard Media Player
12419-
{ service: 'media_player', action: 'media_pause', priority: 2 },
12420-
// Fallback: Stop
12421-
{ service: 'media_player', action: 'media_stop', priority: 3 }
12422-
];
12423-
12424-
for (const method of pauseMethods) {
12425-
try {
12426-
console.log(`🔄 Trying ${method.service}.${method.action}...`);
12427-
12428-
await this._hass.callService(method.service, method.action, {
12410+
12411+
try {
12412+
// 🎯 Verwende die gleiche Logik wie der Play/Pause Button
12413+
await this.smartPlayPause({ id: entityId });
12414+
12415+
// ⏱️ Kurz warten und Status prüfen
12416+
await new Promise(resolve => setTimeout(resolve, 300));
12417+
12418+
const newState = this._hass.states[entityId];
12419+
if (newState.state !== 'playing') {
12420+
console.log(`✅ Successfully paused using smartPlayPause`);
12421+
return true;
12422+
} else {
12423+
console.log(`⚠️ Player still playing, trying direct pause...`);
12424+
// Fallback zu direkter Pause
12425+
await this._hass.callService('media_player', 'media_pause', {
1242912426
entity_id: entityId
1243012427
});
12431-
12432-
// ⏱️ Kurz warten und Status prüfen
12433-
await new Promise(resolve => setTimeout(resolve, 300));
12434-
12435-
const newState = this._hass.states[entityId];
12436-
if (newState.state !== 'playing') {
12437-
console.log(`✅ Successfully paused with ${method.service}.${method.action}`);
12438-
return true;
12439-
}
12440-
12441-
} catch (error) {
12442-
console.warn(`❌ ${method.service}.${method.action} failed:`, error);
12443-
continue;
12428+
return true;
1244412429
}
12430+
12431+
} catch (error) {
12432+
console.warn(`❌ Pause failed:`, error);
12433+
return false;
1244512434
}
12446-
12447-
console.warn('⚠️ All pause methods failed, proceeding anyway...');
12448-
return false;
1244912435
}
1245012436

1245112437
// 🕒 ENHANCED DURATION CALCULATION
@@ -12556,23 +12542,13 @@ class FastSearchCard extends HTMLElement {
1255612542
try {
1255712543
console.log('🎵 Auto-resuming music...');
1255812544

12559-
// 🎯 Versuche verschiedene Resume-Methoden
12560-
const resumeMethods = [
12561-
{ service: 'music_assistant', action: 'play' }, // GEÄNDERT
12562-
{ service: 'media_player', action: 'media_play' },
12563-
{ service: 'media_player', action: 'media_play_pause' }
12564-
];
12565-
12566-
for (const method of resumeMethods) {
12567-
try {
12568-
await this._hass.callService(method.service, method.action, {
12569-
entity_id: entityId
12570-
});
12571-
console.log(`✅ Resumed with ${method.service}.${method.action}`);
12572-
break;
12573-
} catch (error) {
12574-
console.warn(`❌ Resume ${method.service}.${method.action} failed:`, error);
12575-
}
12545+
// 🎯 Verwende smartPlayPause für Resume
12546+
try {
12547+
console.log('🎵 Auto-resuming music...');
12548+
await this.smartPlayPause({ id: entityId });
12549+
console.log(`✅ Resumed using smartPlayPause`);
12550+
} catch (error) {
12551+
console.error('❌ Auto-resume failed:', error);
1257612552
}
1257712553

1257812554
} catch (error) {

0 commit comments

Comments
 (0)