Skip to content

Commit d9c81ed

Browse files
authored
Update fast-search-card.js
1 parent 14e646f commit d9c81ed

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

dist/fast-search-card.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8328,7 +8328,7 @@ class FastSearchCard extends HTMLElement {
83288328
case 'light':
83298329
return this.getLightTimerPresets();
83308330
case 'climate':
8331-
return this.getClimateTimerPresets();
8331+
return this.getClimateTimerPresets(item);
83328332
case 'media_player':
83338333
return this.getMediaTimerPresets();
83348334
case 'cover':
@@ -8377,50 +8377,53 @@ class FastSearchCard extends HTMLElement {
83778377
`;
83788378
}
83798379

8380-
getClimateTimerPresets() {
8380+
getClimateTimerPresets(item) { // ← item Parameter hinzufügen
83818381
return `
83828382
<button class="timer-control-preset" data-action="turn_off" title="Ausschalten">
8383-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
8384-
<circle cx="12" cy="12" r="10"/>
8385-
<path d="m15 9-6 6"/>
8386-
<path d="m9 9 6 6"/>
8387-
</svg>
8388-
8383+
${this.getLightOffSVG()}
83898384
</button>
83908385

83918386
<button class="timer-control-preset" data-action="heat_24" title="Heizen auf 24°C">
8392-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8393-
<path d="M14 14.76V3.5a2.5 2.5 0 0 0-5 0v11.26a4.5 4.5 0 1 0 5 0z"/>
8394-
<circle cx="12" cy="17" r="2"/>
8395-
</svg>
8396-
8387+
${this.getHvacModeSVG('heat', item)}
83978388
</button>
83988389

83998390
<button class="timer-control-preset" data-action="cool_22" title="Kühlen auf 22°C">
8400-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8401-
<path d="M2 6s1.5-2 5-2 5 2 5 2v14s-1.5-2-5-2-5 2-5 2V6z"/>
8402-
<path d="M7 4v16"/>
8403-
</svg>
8404-
8391+
${this.getHvacModeSVG('cool', item)}
84058392
</button>
84068393

84078394
<button class="timer-control-preset" data-action="dry_mode" title="Entfeuchten">
8408-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8409-
<path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z"/>
8410-
<path d="M8 14s1.5 2 4 2 4-2 4-2"/>
8411-
</svg>
8412-
8395+
${this.getHvacModeSVG('dry', item)}
84138396
</button>
84148397

84158398
<button class="timer-control-preset" data-action="fan_only" title="Lüften">
8416-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8417-
<path d="M12.5 2c-.8 0-1.5.7-1.5 1.5v6.21l-1.09-.63c-.69-.4-1.58-.16-1.98.53-.4.69-.16 1.58.53 1.98l1.09.63-1.09.63c-.69.4-.93 1.29-.53 1.98.4.69 1.29.93 1.98.53l1.09-.63v6.21c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5v-6.21l1.09.63c.69.4 1.58.16 1.98-.53.4-.69.16-1.58-.53-1.98L13.5 12l1.09-.63c.69-.4.93-1.29.53-1.98-.4-.69-1.29-.93-1.98-.53L12.5 9.5V3.5c0-.8-.7-1.5-1.5-1.5z"/>
8418-
</svg>
8419-
8399+
${this.getHvacModeSVG('fan_only', item)}
84208400
</button>
84218401
`;
84228402
}
84238403

8404+
8405+
// SVG aus Light Turn-Off Button holen
8406+
getLightOffSVG() {
8407+
const lightHTML = this.();
8408+
const match = lightHTML.match(/data-action="turn_off"[^>]*>(.*?)<\/button>/s);
8409+
if (match) {
8410+
const svgMatch = match[1].match(/<svg[^>]*>.*?<\/svg>/s);
8411+
return svgMatch ? svgMatch[0] : '';
8412+
}
8413+
return '';
8414+
}
8415+
8416+
// SVG aus Climate HVAC Mode Buttons holen
8417+
getHvacModeSVG(mode, item) {
8418+
const climateHTML = this.getClimateControlsHTML(item);
8419+
const match = climateHTML.match(new RegExp(`data-hvac-mode="${mode}"[^>]*>(.*?)<\/button>`, 's'));
8420+
if (match) {
8421+
const svgMatch = match[1].match(/<svg[^>]*>.*?<\/svg>/s);
8422+
return svgMatch ? svgMatch[0] : '';
8423+
}
8424+
return '';
8425+
}
8426+
84248427
getMediaTimerPresets() {
84258428
return `
84268429
<button class="timer-control-preset" data-action="turn_off" title="Ausschalten">
@@ -10183,11 +10186,11 @@ class FastSearchCard extends HTMLElement {
1018310186
// Light Actions
1018410187
if (action.includes('Einschalten') || action.includes('Ein')) {
1018510188
console.log('🔍 Einschalten erkannt');
10186-
presetHTML = this.getLightTimerPresets();
10189+
presetHTML = this.();
1018710190
match = presetHTML.match(/data-action="turn_on"[^>]*>(.*?)<\/button>/s);
1018810191
} else if (action.includes('Ausschalten') || action.includes('Aus')) {
1018910192
console.log('🔍 Ausschalten erkannt');
10190-
presetHTML = this.getLightTimerPresets();
10193+
presetHTML = this.();
1019110194
match = presetHTML.match(/data-action="turn_off"[^>]*>(.*?)<\/button>/s);
1019210195
} else if (action.includes('30%')) {
1019310196
console.log('🔍 30% erkannt');

0 commit comments

Comments
 (0)