Skip to content

Commit

Permalink
adjusting timer values handle from yaml and layout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatik committed Dec 30, 2024
1 parent 74435d4 commit 2a2b9a7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dist/switcher-boiler-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,12 @@ class SwitcherBoilerCard extends LitElement {
event.stopPropagation();
event.preventDefault();

// 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)
);
// Create a unique, sorted array, filter values, and convert back to strings
const timerValues = [...new Set(this.config.timer_values || ['15', '30', '45', '60'])]
.map(Number) // Convert all values to numbers
.filter((value) => value >= 1 && value <= 150) // Keep only values in the range of 1 and 150
.sort((a, b) => a - b) // Sort numerically
.map(String); // Convert back to strings

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

Expand Down Expand Up @@ -439,10 +441,12 @@ class SwitcherBoilerCard extends LitElement {

getLayoutOptions() {
return {
grid_rows: 1,
grid_columns: 6,
grid_min_rows: 1,
grid_rows: 2,
grid_columns: 2,
grid_min_rows: 2,
grid_max_rows: 2,
grid_min_columns: 2,
grid_max_columns: 4
};
}
}
Expand Down

0 comments on commit 2a2b9a7

Please sign in to comment.