Moin,
ich nutze seit neustem eine Miele Waschmaschine, die ich mit der Integration https://github.com/astrandb/miele eingebunden habe. Das ganze ist auf deutsch eingestellt, die Übersetzung läuft in den Entitätskarten auch ohne Probleme.
Nun habe ich unter sehr starker Inspiration dieses Videos eine Karte gebaut, in dem die die Anzeige über die Attribute läuft (habe das auch schon auf den state geändert, das ist leider nicht die Lösung).
Wenn ich ein Programm wähle, wird dies erst in englisch angezeigt, wechselt dann aber nach kurzer Zeit in die deutsche Übersetzung. Sobald ich die Maschine starte, bleibt alles Englisch, wie weiter unten zu sehen (darunter die Entitätsansicht zum Vergleich).
Hat hiermit schon einmal jemand Erfahrungen gemacht?
Dies ist der Code der Karte, es geht in diesem Fall um den Abschnitt “program”:
type: custom:button-card
entity: sensor.waschmaschine_status
name: Waschmaschine
show_label: true
state:
- value: "off"
label: Aus
styles:
grid:
- grid-template-areas: "'i' 'n' 'l'"
- grid-template-columns: 1fr
- grid-template-rows: 70px min-content 1fr
label:
- justify-self: start
- font-size: 16px
- font-weight: 500
- padding: 2px 0
custom_fields:
program:
- display: none
bar:
- display: none
stat1:
- display: none
stat2:
- display: none
stat3:
- display: none
- value: programmed
label: >
[[[ return 'Programm wählen, aktuell: ' +
states['sensor.waschmaschine_programm'].attributes.Localized; ]]]
styles:
grid:
- grid-template-areas: "'i' 'n' 'l'"
- grid-template-columns: 1fr
- grid-template-rows: 70px min-content 1fr
label:
- justify-self: start
- font-size: 16px
- font-weight: 500
- padding: 2px 0
custom_fields:
program:
- display: none
bar:
- display: none
stat1:
- display: none
stat2:
- display: none
stat3:
- display: none
styles:
card:
- padding: 20px
- height: 180px
grid:
- grid-template-areas: "'i program' 'n stat2' 'bar bar' 'stat1 stat3'"
- grid-template-columns: 1fr 1fr
- grid-template-rows: 70px min-content 40px min-content
name:
- justify-self: start
- font-size: 14px
- opacity: 0.7
label:
- justify-self: start
- font-size: 16px
- font-weight: 500
icon:
- width: 34px
- color: "#44729e"
img_cell:
- justify-self: start
- align-self: start
- width: 34px
- height: 34px
custom_fields:
program:
- justify-self: end
- align-self: end
- padding-bottom: 6px
- font-size: 16px
- font-weight: 500
stat1:
- justify-self: start
- font-size: 10px
- opacity: 0.7
stat2:
- justify-self: end
- font-size: 16px
- padding-bottom: 6px
- font-weight: 500
stat3:
- justify-self: end
- font-size: 10px
- opacity: 0.7
bar:
- justify-self: start
- width: 100%
- border-radius: 6px
- background: "#adbdcc"
- height: 12px
custom_fields:
bar: |
[[[
var state = states['sensor.washing_remain_percent'].state
return `<div> <div style="background: #44729e; height: 12px; width:${state}%"></div></div>`;
]]]
program: |
[[[
return (states['sensor.waschmaschine_programm'].attributes.Localized || 'Unbekannt') +
' · ' +
(states['sensor.waschmaschine_programmabschnitt'].attributes.Localized || 'Unbekannt');
]]]
stat1: |
[[[
return '0:00:00'; // Platzhalter
]]]
stat2: |
[[[
var remainingTime = states['sensor.waschmaschine_verbleibende_zeit'].state;
var remainingMinutes = parseFloat(remainingTime);
if (remainingMinutes) {
var hours = Math.floor(remainingMinutes / 60); // Ganze Stunden extrahieren
var minutes = Math.round(remainingMinutes % 60); // Restliche Minuten berechnen
var formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
return formattedTime;
}
return '00:00'; // Rückfallwert bei fehlerhaftem Format
]]]
stat3: |
[[[
// Hole die verbleibende Zeit und verstrichene Zeit (in Minuten:Sekunden Format)
var remainingTime = states['sensor.waschmaschine_verbleibende_zeit']?.state || '00:00';
var elapsedTime = states['sensor.waschmaschine_verstrichene_zeit']?.state || '00:00';
// Funktion, um MM:SS in Sekunden umzuwandeln
function convertToSeconds(time) {
var parts = time.split(':');
var minutes = parseInt(parts[0], 10) || 0;
var seconds = parseInt(parts[1], 10) || 0;
return minutes * 60 + seconds;
}
// Berechne die Gesamtzeit in Sekunden
var remainingTimeInSeconds = convertToSeconds(remainingTime);
var elapsedTimeInSeconds = convertToSeconds(elapsedTime);
var totalTimeInSeconds = remainingTimeInSeconds + elapsedTimeInSeconds;
// Berechne Stunden, Minuten und Sekunden
var hours = Math.floor(totalTimeInSeconds / 3600); // Ganze Stunden (1 Stunde = 3600 Sekunden)
var minutes = Math.floor((totalTimeInSeconds % 3600) / 60); // Minuten
var seconds = totalTimeInSeconds % 60; // Sekunden
// Gib die Zeit im Format HH:MM:SS zurück
return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
]]]