Skip to content

Commit e747ceb

Browse files
authored
Feature: highlight cheap phases (#31)
* added cheapest hour visualization * added epex_spot_sensor helpers support
1 parent df80c0b commit e747ceb

14 files changed

Lines changed: 1195 additions & 787 deletions

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Inspired by Tibber, this custom card visualizes **hourly energy prices** on a ti
2424
- ⚡ Simple configuration
2525
- 🔄 toggle today / tomorrow
2626

27+
The card can highlight the cheapest times of the day if you want (you can activated it in configuration - see chapter parameters)
28+
29+
![cheap_time_slots](./assets/examples/light_graph_cheap_times.png)
2730

2831
### Timeline mode:
2932
By default, the card shows a **timeline view** of today's electricity prices.
@@ -284,6 +287,9 @@ Here are the available parameters for this Lovelace card.
284287
| `day_switch` | boolean | `false` | Show day toggler to change between today and tomorrow (for circle and timeline view only) |
285288
| `start_view` | string | `today` | Determines which view is shown by default when the card loads. Possible values: `today`, `tomorrow` (for circle and timeline view only) |
286289
| `currency` | object | `{ name: "Cent", symbol: "¢" }` | Defines how the unit for energy price is displayed. Use this to customize the currency subunit (e.g., "Cent", "Öre", ...). The `name` is shown as text label. The `symbol` field is currently optional and not yet displayed in all views, but **it is recommended to set it** since it may be used by future features or visualizations. |
290+
| `cheap_times` | boolean | `false` | The card highlights the cheapest times of the day in graph and the phases are displayed in text form. <ul><li>Prices are analyzed <strong>per day</strong>, so each day is evaluated on its own.</li><li>For each day, prices are normalized using a relative scale: <code>relative price = (price - daily minimum) / (daily maximum - daily minimum)</code>.</li><li>The <strong>lowest ~25%</strong> of all intervals for that day are considered <em>cheap</em>.</li><li>Consecutive cheap intervals are grouped into longer time phases.</li><li>Only <strong>future</strong> phases are shown, and only if they last <strong>at least 1 hour</strong>.</li></ul> |
291+
| `cheap_time_sources` | array of strings | `undefined` | Optional and only available in yaml mode. If `cheap_times: true` is set, you can provide a list of sensors/entity IDs to define the cheap time periods manually instead of letting the card calculate them automatically. This is useful if you already use helpers from the [ha_epex_spot_sensor](https://github.com/mampfes/ha_epex_spot_sensor) add-on – you can pass those sensor IDs here to display their cheap periods directly.|
292+
287293
---
288294

289295
### 📘 Configuration
@@ -301,7 +307,7 @@ price: sensor.epex_price
301307

302308
circle view and dark theme:
303309
```yaml
304-
type: custom:price-timeline-card-test
310+
type: custom:price-timeline-card
305311
price: sensor.epex_price
306312
theme: dark
307313
view: circle
@@ -329,6 +335,28 @@ currency:
329335
```
330336
![Visual Editor](./assets/examples/currency.png)
331337

338+
graph view with cheap time visualization:
339+
```yaml
340+
type: custom:price-timeline-card
341+
price: sensor.tibber_prices
342+
view: graph
343+
theme: dark
344+
cheap_times: true
345+
```
346+
![cheap_time_slots](./assets/examples/light_graph_cheap_times.png) ![cheap_time_slots2](./assets/examples/light_graph_cheap_times_2.png)
347+
348+
graph view with cheap time visualization with use of ha_epex_spot_sensors:
349+
```yaml
350+
type: custom:price-timeline-card
351+
price: sensor.tibber_prices
352+
view: graph
353+
cheap_times: true
354+
cheap_time_sources:
355+
- binary_sensor.car_charge
356+
- binary_sensor.washing
357+
```
358+
![cheap_time_slots](./assets/examples/light_graph_cheap_times_addon.png)
359+
332360
#### Configuration with Visual Editor
333361

334362
The configuration can also be done using the built-in form editor (visual editor).

assets/examples/editor.png

31.9 KB
Loading
29.8 KB
Loading
44.9 KB
Loading
32.9 KB
Loading

localize/da.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export default {
99
label_tomorrow_price: "Morgendagens pris",
1010
label_average_price: "Gennemsnitspris",
1111
label_price: "Pris",
12+
label_day: "Dag",
13+
label_start: "Start",
14+
label_end: "Slut",
15+
label_duration: "Varighed",
16+
label_name: "Navn",
1217
editor_theme_light: "Lyst",
1318
editor_theme_dark: "Mørkt",
1419
editor_theme_system: "System",
@@ -28,4 +33,6 @@ export default {
2833
editor_currency_desc: "Angiv egen valuta",
2934
editor_day_switch_label: "Dagskifter",
3035
editor_day_switch_desc: "Viser eller skjuler dagskifteren",
36+
editor_cheap_times_label: "Billige tider",
37+
editor_cheap_times_desc: "Visning af billige tidsintervaller",
3138
};

localize/de.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export default {
99
label_tomorrow_price: "Morgiger Preis",
1010
label_average_price: "Durchschnittspreis",
1111
label_price: "Preis",
12+
label_day: "Tag",
13+
label_start: "Start",
14+
label_end: "Ende",
15+
label_duration: "Dauer",
16+
label_name: "Name",
1217
editor_theme_light: "Hell",
1318
editor_theme_dark: "Dunkel",
1419
editor_theme_system: "System",
@@ -28,4 +33,6 @@ export default {
2833
editor_currency_desc: "Eigene Währung angeben",
2934
editor_day_switch_label: "Tag Umschalter",
3035
editor_day_switch_desc: "Blendet den Tag Umschalter ein oder aus",
36+
editor_cheap_times_label: "Günstige Zeiten",
37+
editor_cheap_times_desc: "Anzeige von günstigen Zeitintervallen",
3138
};

localize/en.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export default {
77
label_time_nextDay: "Price range",
88
label_average_price: "Average Price",
99
label_price: "Price",
10+
label_day: "Day",
11+
label_start: "Start",
12+
label_end: "End",
13+
label_duration: "Duration",
14+
label_name: "Name",
1015
unit_cent: "Cent",
1116
label_tomorrow_price: "Tomorrow's price",
1217
editor_theme_light: "Light",
@@ -28,4 +33,6 @@ export default {
2833
editor_currency_desc: "Specify a custom currency",
2934
editor_day_switch_label: "Day Switch",
3035
editor_day_switch_desc: "Shows or hides the day switch",
36+
editor_cheap_times_label: "Cheap Times",
37+
editor_cheap_times_desc: "Display of cheap time intervals",
3138
};

localize/es.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export default {
77
label_time_nextDay: "Rango de precios",
88
label_average_price: "Precio medio",
99
label_price: "Precio",
10+
label_day: "Día",
11+
label_start: "Inicio",
12+
label_end: "Fin",
13+
label_duration: "Duración",
14+
label_name: "Nombre",
1015
unit_cent: "Céntimos",
1116
label_tomorrow_price: "Precio de mañana",
1217
editor_theme_light: "Claro",
@@ -28,4 +33,6 @@ export default {
2833
editor_currency_desc: "Especifique una moneda personalizada",
2934
editor_day_switch_label: "Conmutador de día",
3035
editor_day_switch_desc: "Muestra u oculta el conmutador de día",
36+
editor_cheap_times_label: "Tiempos económicos",
37+
editor_cheap_times_desc: "Visualización de intervalos de tiempo económicos",
3138
};

localize/fr.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export default {
77
label_time_nextDay: "Plage de prix",
88
label_average_price: "Prix moyen",
99
label_price: "Prix",
10+
label_day: "Jour",
11+
label_start: "Début",
12+
label_end: "Fin",
13+
label_duration: "Durée",
14+
label_name: "Nom",
1015
unit_cent: "Centimes",
1116
label_tomorrow_price: "Prix de demain",
1217
editor_theme_light: "Clair",
@@ -28,4 +33,6 @@ export default {
2833
editor_currency_desc: "Indiquez une devise personnalisée",
2934
editor_day_switch_label: "Commutateur de jour",
3035
editor_day_switch_desc: "Affiche ou masque le commutateur de jour",
36+
editor_cheap_times_label: "Heures avantageuses",
37+
editor_cheap_times_desc: "Affichage des intervalles horaires avantageux",
3138
};

0 commit comments

Comments
 (0)