Skip to content

Commit

Permalink
sorting timer_values configured by yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatik committed Dec 30, 2024
1 parent 023c7f0 commit 4b71bd7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dist/switcher-boiler-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class SwitcherBoilerCard extends LitElement {
//pointer-events: none;
color: var(--primary-text-color);
font-weight: 500;
font-size: 20px;
font-size: 18px;
display: inline-flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -374,7 +374,11 @@ class SwitcherBoilerCard extends LitElement {
event.stopPropagation();
event.preventDefault();

const timerValues = this.config.timer_values ? this.config.timer_values : ['15', '30', '45', '60']; // Array of string values
// Create a copy of the array and sort it numerically
const timerValues = [...(this.config.timer_values || ['15', '30', '45', '60'])].sort(
(a, b) => parseInt(a) - parseInt(b)
);

const currentIndex = timerValues.indexOf(this.timerValue);

// Fallback to the first value if currentValue is not in the array
Expand Down

0 comments on commit 4b71bd7

Please sign in to comment.