SAFP
(Peter)
April 12, 2026, 8:05pm
1
- trigger:
- trigger: time_pattern
minutes: "/15"
sensor:
- name: "Current price inc VAT"
unique_id: "current_price_inc_vat"
unit_of_measurement: "EUR/kWh"
icon: "mdi:transmission-tower"
state: >
{% set today = now().strftime('%d') %}
{% set time_now = now().strftime('%H:%M') %}
{% if ((state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')|selectattr('startsAt','contains','T00:00:00')|first)|length and
(state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')|selectattr('startsAt','contains','T00:00:00')|first)['startsAt'][8:10] == today) %}
{{ (state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')|selectattr('startsAt','contains',time_now)|first)['total'] }}
{% elif ((state_attr('sensor.nodered_aa1f2c338725cf4f', 'tomorrow')|selectattr('startsAt','contains','T00:00:00')|first)|length and
(state_attr('sensor.nodered_aa1f2c338725cf4f', 'tomorrow')|selectattr('startsAt','contains','T00:00:00')|first)['startsAt'][8:10] == today) %}
{{ (state_attr('sensor.nodered_aa1f2c338725cf4f', 'tomorrow')|selectattr('startsAt','contains',time_now)|first)['total'] }}
{% endif %}
If have this code to show the current 15 minute dynamic energy price based on getting prices from the Tibber api. The jinja part works - in developer tools I see the price every 15 minutes. However, it doesn’t update as a template with a trigger. I have spent so much time on this, really hope anyone sees why this fails.
The Tibber-api also returns current price so I could query the API every 15 minutes but I find that unnecesarilly unefficient as I have all prices already.
123
(Taras)
April 12, 2026, 8:13pm
2
What do you mean exactly?
It fails to report a value.
It reports a value but it never changes.
SAFP:
The jinja part works
Post an example of the value reported by the template when tested in the Template Editor.
SAFP
(Peter)
April 12, 2026, 8:30pm
3
Fair question. It worked for a little while but stopped working. Reloading yaml, restarting HA and manually triggering an api call doesn’t work. Correct result for 22:30:
0.2914
123
(Taras)
April 12, 2026, 8:53pm
4
Thanks for the additional information.
This Trigger-based Template Sensor relies entirely on data provided by sensor.nodered_aa1f2c338725cf4f.
Has anything changed with sensor.nodered_aa1f2c338725cf4f?
How frequently does sensor.nodered_aa1f2c338725cf4f get data from the Tibber API?
SAFP
(Peter)
April 12, 2026, 9:03pm
5
Technically nothing changed. The content is fetched once a day from the Tibber API.
123
(Taras)
April 12, 2026, 9:31pm
6
Please post the result of the following template. Ensure it is formatted properly.
{{ state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')
| selectattr('startsAt', 'contains', 'T00:00:00') | first }}
SAFP
(Peter)
April 13, 2026, 5:28am
7
123:
{{ state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')
| selectattr('startsAt', 'contains', 'T00:00:00') | first }}
{
"total": 0.2152,
"energy": 0.0658,
"startsAt": "2026-04-12T00:00:00.000+02:00",
"level": "NORMAL"
}
koying
(Chris B)
April 13, 2026, 10:34am
8
selectattr('startsAt','contains',time_now)
Does sensor.nodered_aa1f2c338725cf4f return a list with a price per minute?
And then again, are you sure the returned list contains the current time?
petro
(Petro)
April 13, 2026, 11:12am
9
There is nothing special about template triggers and the behavior for trigger based template entities hasn’t changed. This issue is almost certainly an issue with sensor.nodered_aa1f2c338725cf4f.
123
(Taras)
April 13, 2026, 1:27pm
10
Thank you, that gives me a better idea of what your template is doing.
Please post the result of this template (it should contain far more data).
{{ state_attr('sensor.nodered_aa1f2c338725cf4f', 'today')
| selectattr('startsAt', 'contains', 'T00:00:00') | list }}
SAFP
(Peter)
April 13, 2026, 7:06pm
11
The trigger works every 15 minutes. The price changes every 15 minutes. So if the sensor looks for a price at minute 0, 15, 30 and 45 of any given hour it will find prices.
Here’s the complete object:
today:
- total: 0.2849
energy: 0.1233
startsAt: '2026-04-13T00:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2801
energy: 0.1194
startsAt: '2026-04-13T00:15:00.000+02:00'
level: EXPENSIVE
- total: 0.2712
energy: 0.112
startsAt: '2026-04-13T00:30:00.000+02:00'
level: NORMAL
- total: 0.2668
energy: 0.1084
startsAt: '2026-04-13T00:45:00.000+02:00'
level: NORMAL
- total: 0.2727
energy: 0.1133
startsAt: '2026-04-13T01:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2695
energy: 0.1106
startsAt: '2026-04-13T01:15:00.000+02:00'
level: NORMAL
- total: 0.2688
energy: 0.11
startsAt: '2026-04-13T01:30:00.000+02:00'
level: NORMAL
- total: 0.2631
energy: 0.1053
startsAt: '2026-04-13T01:45:00.000+02:00'
level: NORMAL
- total: 0.2678
energy: 0.1092
startsAt: '2026-04-13T02:00:00.000+02:00'
level: NORMAL
- total: 0.2599
energy: 0.1027
startsAt: '2026-04-13T02:15:00.000+02:00'
level: NORMAL
- total: 0.2651
energy: 0.107
startsAt: '2026-04-13T02:30:00.000+02:00'
level: NORMAL
- total: 0.2639
energy: 0.106
startsAt: '2026-04-13T02:45:00.000+02:00'
level: NORMAL
- total: 0.2679
energy: 0.1093
startsAt: '2026-04-13T03:00:00.000+02:00'
level: NORMAL
- total: 0.2625
energy: 0.1048
startsAt: '2026-04-13T03:15:00.000+02:00'
level: NORMAL
- total: 0.265
energy: 0.1069
startsAt: '2026-04-13T03:30:00.000+02:00'
level: NORMAL
- total: 0.2613
energy: 0.1038
startsAt: '2026-04-13T03:45:00.000+02:00'
level: NORMAL
- total: 0.2677
energy: 0.1092
startsAt: '2026-04-13T04:00:00.000+02:00'
level: NORMAL
- total: 0.2682
energy: 0.1095
startsAt: '2026-04-13T04:15:00.000+02:00'
level: NORMAL
- total: 0.2644
energy: 0.1064
startsAt: '2026-04-13T04:30:00.000+02:00'
level: NORMAL
- total: 0.2701
energy: 0.1111
startsAt: '2026-04-13T04:45:00.000+02:00'
level: NORMAL
- total: 0.2719
energy: 0.1126
startsAt: '2026-04-13T05:00:00.000+02:00'
level: NORMAL
- total: 0.2734
energy: 0.1138
startsAt: '2026-04-13T05:15:00.000+02:00'
level: NORMAL
- total: 0.2778
energy: 0.1175
startsAt: '2026-04-13T05:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2858
energy: 0.1241
startsAt: '2026-04-13T05:45:00.000+02:00'
level: EXPENSIVE
- total: 0.285
energy: 0.1234
startsAt: '2026-04-13T06:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2979
energy: 0.1341
startsAt: '2026-04-13T06:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3073
energy: 0.1418
startsAt: '2026-04-13T06:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3055
energy: 0.1404
startsAt: '2026-04-13T06:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3113
energy: 0.1452
startsAt: '2026-04-13T07:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3092
energy: 0.1434
startsAt: '2026-04-13T07:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3102
energy: 0.1442
startsAt: '2026-04-13T07:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3106
energy: 0.1446
startsAt: '2026-04-13T07:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3938
energy: 0.2133
startsAt: '2026-04-13T08:00:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3439
energy: 0.1721
startsAt: '2026-04-13T08:15:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3261
energy: 0.1574
startsAt: '2026-04-13T08:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3179
energy: 0.1506
startsAt: '2026-04-13T08:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3707
energy: 0.1942
startsAt: '2026-04-13T09:00:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3518
energy: 0.1787
startsAt: '2026-04-13T09:15:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3142
energy: 0.1476
startsAt: '2026-04-13T09:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2975
energy: 0.1338
startsAt: '2026-04-13T09:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3555
energy: 0.1817
startsAt: '2026-04-13T10:00:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3006
energy: 0.1364
startsAt: '2026-04-13T10:15:00.000+02:00'
level: EXPENSIVE
- total: 0.29
energy: 0.1275
startsAt: '2026-04-13T10:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2833
energy: 0.1221
startsAt: '2026-04-13T10:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2905
energy: 0.128
startsAt: '2026-04-13T11:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2793
energy: 0.1188
startsAt: '2026-04-13T11:15:00.000+02:00'
level: EXPENSIVE
- total: 0.278
energy: 0.1177
startsAt: '2026-04-13T11:30:00.000+02:00'
level: NORMAL
- total: 0.2848
energy: 0.1233
startsAt: '2026-04-13T11:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2813
energy: 0.1203
startsAt: '2026-04-13T12:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2676
energy: 0.109
startsAt: '2026-04-13T12:15:00.000+02:00'
level: NORMAL
- total: 0.2718
energy: 0.1125
startsAt: '2026-04-13T12:30:00.000+02:00'
level: NORMAL
- total: 0.2632
energy: 0.1054
startsAt: '2026-04-13T12:45:00.000+02:00'
level: NORMAL
- total: 0.2666
energy: 0.1082
startsAt: '2026-04-13T13:00:00.000+02:00'
level: NORMAL
- total: 0.2653
energy: 0.1072
startsAt: '2026-04-13T13:15:00.000+02:00'
level: NORMAL
- total: 0.2646
energy: 0.1065
startsAt: '2026-04-13T13:30:00.000+02:00'
level: NORMAL
- total: 0.2612
energy: 0.1037
startsAt: '2026-04-13T13:45:00.000+02:00'
level: NORMAL
- total: 0.2691
energy: 0.1103
startsAt: '2026-04-13T14:00:00.000+02:00'
level: NORMAL
- total: 0.278
energy: 0.1176
startsAt: '2026-04-13T14:15:00.000+02:00'
level: NORMAL
- total: 0.2723
energy: 0.1129
startsAt: '2026-04-13T14:30:00.000+02:00'
level: NORMAL
- total: 0.2762
energy: 0.1162
startsAt: '2026-04-13T14:45:00.000+02:00'
level: NORMAL
- total: 0.2802
energy: 0.1194
startsAt: '2026-04-13T15:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2797
energy: 0.119
startsAt: '2026-04-13T15:15:00.000+02:00'
level: NORMAL
- total: 0.2701
energy: 0.1112
startsAt: '2026-04-13T15:30:00.000+02:00'
level: NORMAL
- total: 0.2787
energy: 0.1182
startsAt: '2026-04-13T15:45:00.000+02:00'
level: NORMAL
- total: 0.2591
energy: 0.102
startsAt: '2026-04-13T16:00:00.000+02:00'
level: NORMAL
- total: 0.2619
energy: 0.1043
startsAt: '2026-04-13T16:15:00.000+02:00'
level: NORMAL
- total: 0.2771
energy: 0.1169
startsAt: '2026-04-13T16:30:00.000+02:00'
level: NORMAL
- total: 0.2947
energy: 0.1314
startsAt: '2026-04-13T16:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2508
energy: 0.0952
startsAt: '2026-04-13T17:00:00.000+02:00'
level: NORMAL
- total: 0.2778
energy: 0.1175
startsAt: '2026-04-13T17:15:00.000+02:00'
level: NORMAL
- total: 0.3
energy: 0.1358
startsAt: '2026-04-13T17:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3213
energy: 0.1534
startsAt: '2026-04-13T17:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2877
energy: 0.1257
startsAt: '2026-04-13T18:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3054
energy: 0.1403
startsAt: '2026-04-13T18:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3136
energy: 0.1471
startsAt: '2026-04-13T18:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3359
energy: 0.1655
startsAt: '2026-04-13T18:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3201
energy: 0.1524
startsAt: '2026-04-13T19:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3283
energy: 0.1592
startsAt: '2026-04-13T19:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3353
energy: 0.165
startsAt: '2026-04-13T19:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3572
energy: 0.1831
startsAt: '2026-04-13T19:45:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3297
energy: 0.1604
startsAt: '2026-04-13T20:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3294
energy: 0.1601
startsAt: '2026-04-13T20:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3179
energy: 0.1506
startsAt: '2026-04-13T20:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3099
energy: 0.144
startsAt: '2026-04-13T20:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3323
energy: 0.1625
startsAt: '2026-04-13T21:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3139
energy: 0.1473
startsAt: '2026-04-13T21:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3004
energy: 0.1362
startsAt: '2026-04-13T21:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2895
energy: 0.1272
startsAt: '2026-04-13T21:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3013
energy: 0.1369
startsAt: '2026-04-13T22:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2941
energy: 0.131
startsAt: '2026-04-13T22:15:00.000+02:00'
level: EXPENSIVE
- total: 0.2912
energy: 0.1286
startsAt: '2026-04-13T22:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2886
energy: 0.1264
startsAt: '2026-04-13T22:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2941
energy: 0.131
startsAt: '2026-04-13T23:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2862
energy: 0.1245
startsAt: '2026-04-13T23:15:00.000+02:00'
level: EXPENSIVE
- total: 0.2834
energy: 0.1221
startsAt: '2026-04-13T23:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2728
energy: 0.1134
startsAt: '2026-04-13T23:45:00.000+02:00'
level: NORMAL
tomorrow:
- total: 0.2859
energy: 0.1241
startsAt: '2026-04-14T00:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2768
energy: 0.1167
startsAt: '2026-04-14T00:15:00.000+02:00'
level: NORMAL
- total: 0.2733
energy: 0.1137
startsAt: '2026-04-14T00:30:00.000+02:00'
level: NORMAL
- total: 0.2705
energy: 0.1114
startsAt: '2026-04-14T00:45:00.000+02:00'
level: NORMAL
- total: 0.2738
energy: 0.1141
startsAt: '2026-04-14T01:00:00.000+02:00'
level: NORMAL
- total: 0.2734
energy: 0.1138
startsAt: '2026-04-14T01:15:00.000+02:00'
level: NORMAL
- total: 0.2728
energy: 0.1133
startsAt: '2026-04-14T01:30:00.000+02:00'
level: NORMAL
- total: 0.2756
energy: 0.1157
startsAt: '2026-04-14T01:45:00.000+02:00'
level: NORMAL
- total: 0.2755
energy: 0.1156
startsAt: '2026-04-14T02:00:00.000+02:00'
level: NORMAL
- total: 0.2754
energy: 0.1155
startsAt: '2026-04-14T02:15:00.000+02:00'
level: NORMAL
- total: 0.2747
energy: 0.1149
startsAt: '2026-04-14T02:30:00.000+02:00'
level: NORMAL
- total: 0.276
energy: 0.116
startsAt: '2026-04-14T02:45:00.000+02:00'
level: NORMAL
- total: 0.273
energy: 0.1135
startsAt: '2026-04-14T03:00:00.000+02:00'
level: NORMAL
- total: 0.2719
energy: 0.1126
startsAt: '2026-04-14T03:15:00.000+02:00'
level: NORMAL
- total: 0.2739
energy: 0.1143
startsAt: '2026-04-14T03:30:00.000+02:00'
level: NORMAL
- total: 0.2734
energy: 0.1138
startsAt: '2026-04-14T03:45:00.000+02:00'
level: NORMAL
- total: 0.2728
energy: 0.1133
startsAt: '2026-04-14T04:00:00.000+02:00'
level: NORMAL
- total: 0.2731
energy: 0.1136
startsAt: '2026-04-14T04:15:00.000+02:00'
level: NORMAL
- total: 0.2753
energy: 0.1154
startsAt: '2026-04-14T04:30:00.000+02:00'
level: NORMAL
- total: 0.2763
energy: 0.1162
startsAt: '2026-04-14T04:45:00.000+02:00'
level: NORMAL
- total: 0.2744
energy: 0.1146
startsAt: '2026-04-14T05:00:00.000+02:00'
level: NORMAL
- total: 0.2769
energy: 0.1167
startsAt: '2026-04-14T05:15:00.000+02:00'
level: NORMAL
- total: 0.2784
energy: 0.118
startsAt: '2026-04-14T05:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2842
energy: 0.1228
startsAt: '2026-04-14T05:45:00.000+02:00'
level: EXPENSIVE
- total: 0.281
energy: 0.1201
startsAt: '2026-04-14T06:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2996
energy: 0.1355
startsAt: '2026-04-14T06:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3059
energy: 0.1407
startsAt: '2026-04-14T06:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3254
energy: 0.1568
startsAt: '2026-04-14T06:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3239
energy: 0.1556
startsAt: '2026-04-14T07:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3385
energy: 0.1676
startsAt: '2026-04-14T07:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3436
energy: 0.1719
startsAt: '2026-04-14T07:30:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3239
energy: 0.1556
startsAt: '2026-04-14T07:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3752
energy: 0.198
startsAt: '2026-04-14T08:00:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3544
energy: 0.1808
startsAt: '2026-04-14T08:15:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3176
energy: 0.1504
startsAt: '2026-04-14T08:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2954
energy: 0.132
startsAt: '2026-04-14T08:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3443
energy: 0.1724
startsAt: '2026-04-14T09:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2987
energy: 0.1348
startsAt: '2026-04-14T09:15:00.000+02:00'
level: EXPENSIVE
- total: 0.305
energy: 0.1399
startsAt: '2026-04-14T09:30:00.000+02:00'
level: EXPENSIVE
- total: 0.2801
energy: 0.1194
startsAt: '2026-04-14T09:45:00.000+02:00'
level: NORMAL
- total: 0.3042
energy: 0.1393
startsAt: '2026-04-14T10:00:00.000+02:00'
level: EXPENSIVE
- total: 0.2856
energy: 0.1239
startsAt: '2026-04-14T10:15:00.000+02:00'
level: NORMAL
- total: 0.2796
energy: 0.119
startsAt: '2026-04-14T10:30:00.000+02:00'
level: NORMAL
- total: 0.2701
energy: 0.1111
startsAt: '2026-04-14T10:45:00.000+02:00'
level: NORMAL
- total: 0.2728
energy: 0.1133
startsAt: '2026-04-14T11:00:00.000+02:00'
level: NORMAL
- total: 0.2695
energy: 0.1106
startsAt: '2026-04-14T11:15:00.000+02:00'
level: NORMAL
- total: 0.2602
energy: 0.1029
startsAt: '2026-04-14T11:30:00.000+02:00'
level: NORMAL
- total: 0.257
energy: 0.1003
startsAt: '2026-04-14T11:45:00.000+02:00'
level: NORMAL
- total: 0.2637
energy: 0.1058
startsAt: '2026-04-14T12:00:00.000+02:00'
level: NORMAL
- total: 0.2562
energy: 0.0997
startsAt: '2026-04-14T12:15:00.000+02:00'
level: NORMAL
- total: 0.2569
energy: 0.1002
startsAt: '2026-04-14T12:30:00.000+02:00'
level: NORMAL
- total: 0.2521
energy: 0.0962
startsAt: '2026-04-14T12:45:00.000+02:00'
level: NORMAL
- total: 0.2497
energy: 0.0942
startsAt: '2026-04-14T13:00:00.000+02:00'
level: NORMAL
- total: 0.2494
energy: 0.094
startsAt: '2026-04-14T13:15:00.000+02:00'
level: NORMAL
- total: 0.2503
energy: 0.0948
startsAt: '2026-04-14T13:30:00.000+02:00'
level: NORMAL
- total: 0.2481
energy: 0.093
startsAt: '2026-04-14T13:45:00.000+02:00'
level: NORMAL
- total: 0.2367
energy: 0.0835
startsAt: '2026-04-14T14:00:00.000+02:00'
level: NORMAL
- total: 0.2417
energy: 0.0876
startsAt: '2026-04-14T14:15:00.000+02:00'
level: NORMAL
- total: 0.2478
energy: 0.0927
startsAt: '2026-04-14T14:30:00.000+02:00'
level: NORMAL
- total: 0.2601
energy: 0.1028
startsAt: '2026-04-14T14:45:00.000+02:00'
level: NORMAL
- total: 0.246
energy: 0.0912
startsAt: '2026-04-14T15:00:00.000+02:00'
level: NORMAL
- total: 0.2561
energy: 0.0995
startsAt: '2026-04-14T15:15:00.000+02:00'
level: NORMAL
- total: 0.2635
energy: 0.1057
startsAt: '2026-04-14T15:30:00.000+02:00'
level: NORMAL
- total: 0.2727
energy: 0.1132
startsAt: '2026-04-14T15:45:00.000+02:00'
level: NORMAL
- total: 0.2542
energy: 0.098
startsAt: '2026-04-14T16:00:00.000+02:00'
level: NORMAL
- total: 0.2583
energy: 0.1014
startsAt: '2026-04-14T16:15:00.000+02:00'
level: NORMAL
- total: 0.2721
energy: 0.1128
startsAt: '2026-04-14T16:30:00.000+02:00'
level: NORMAL
- total: 0.2811
energy: 0.1202
startsAt: '2026-04-14T16:45:00.000+02:00'
level: NORMAL
- total: 0.2629
energy: 0.1052
startsAt: '2026-04-14T17:00:00.000+02:00'
level: NORMAL
- total: 0.2864
energy: 0.1246
startsAt: '2026-04-14T17:15:00.000+02:00'
level: NORMAL
- total: 0.2996
energy: 0.1355
startsAt: '2026-04-14T17:30:00.000+02:00'
level: NORMAL
- total: 0.3062
energy: 0.141
startsAt: '2026-04-14T17:45:00.000+02:00'
level: EXPENSIVE
- total: 0.2876
energy: 0.1256
startsAt: '2026-04-14T18:00:00.000+02:00'
level: NORMAL
- total: 0.3091
energy: 0.1434
startsAt: '2026-04-14T18:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3203
energy: 0.1526
startsAt: '2026-04-14T18:30:00.000+02:00'
level: EXPENSIVE
- total: 0.365
energy: 0.1896
startsAt: '2026-04-14T18:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3341
energy: 0.164
startsAt: '2026-04-14T19:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3601
energy: 0.1855
startsAt: '2026-04-14T19:15:00.000+02:00'
level: EXPENSIVE
- total: 0.4044
energy: 0.2221
startsAt: '2026-04-14T19:30:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.4733
energy: 0.2791
startsAt: '2026-04-14T19:45:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.4332
energy: 0.2459
startsAt: '2026-04-14T20:00:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.4275
energy: 0.2412
startsAt: '2026-04-14T20:15:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.4004
energy: 0.2188
startsAt: '2026-04-14T20:30:00.000+02:00'
level: VERY_EXPENSIVE
- total: 0.3673
energy: 0.1914
startsAt: '2026-04-14T20:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3537
energy: 0.1802
startsAt: '2026-04-14T21:00:00.000+02:00'
level: EXPENSIVE
- total: 0.334
energy: 0.164
startsAt: '2026-04-14T21:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3187
energy: 0.1513
startsAt: '2026-04-14T21:30:00.000+02:00'
level: EXPENSIVE
- total: 0.3105
energy: 0.1445
startsAt: '2026-04-14T21:45:00.000+02:00'
level: EXPENSIVE
- total: 0.3208
energy: 0.153
startsAt: '2026-04-14T22:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3115
energy: 0.1453
startsAt: '2026-04-14T22:15:00.000+02:00'
level: EXPENSIVE
- total: 0.3077
energy: 0.1422
startsAt: '2026-04-14T22:30:00.000+02:00'
level: NORMAL
- total: 0.2984
energy: 0.1345
startsAt: '2026-04-14T22:45:00.000+02:00'
level: NORMAL
- total: 0.3112
energy: 0.145
startsAt: '2026-04-14T23:00:00.000+02:00'
level: EXPENSIVE
- total: 0.3001
energy: 0.1359
startsAt: '2026-04-14T23:15:00.000+02:00'
level: NORMAL
- total: 0.2923
energy: 0.1295
startsAt: '2026-04-14T23:30:00.000+02:00'
level: NORMAL
- total: 0.2768
energy: 0.1167
startsAt: '2026-04-14T23:45:00.000+02:00'
level: NORMAL
SAFP
(Peter)
April 13, 2026, 7:07pm
12
Or maybe I’m overlooking something in the template. But I can’t find it.
SAFP
(Peter)
April 13, 2026, 7:08pm
13
[
{
"total": 0.2849,
"energy": 0.1233,
"startsAt": "2026-04-13T00:00:00.000+02:00",
"level": "EXPENSIVE"
}
]
It’s what I’d expect from that template isn’t it? You’re choosing an attribute with a specific time and there is only one of that.
123
(Taras)
April 13, 2026, 8:14pm
14
You said you tested your template in the Template Editor. I also tested it, using the data you provided for today and tomorrow. What I discovered is that the template relies on the trigger time to be exactly 00, 15, 30, or 45 minutes. If it’s any other time, like 01 or 16 or 31, etc the template fails with an error (for the simple reason there is no Tibber data for that time).
In theory, a Time Pattern Trigger set for minutes: /15 should only trigger exactly at 00, 15, 30, or 45 minutes and never earlier/later. However, if for some reason it did trigger a little earlier or later then the template would fail to produce a value.
Just to clarify, does your Template Sensor currently report a numeric value that never changes all day or does it report unknown?
SAFP
(Peter)
April 13, 2026, 8:21pm
15
You are completely right. Testing is a chore - I either have to set a fixed time to see if the developer tools return any value at all or wait for the time to hit 0,15,30 or 45. I find it very hard to find an effective way of debugging my problem.
Current status is unavailable.
123
(Taras)
April 13, 2026, 9:26pm
16
Test the following example in the Template Editor.
It should produce a correct value at any time you test it because it rounds the current minutes to the nearest 0, 15, 30, or 45 minutes.
{% set today_date = now().date() | string ~ 'T00:00:00' %}
{% set minutes = now().minute %}
{% set remainder = minutes % 15 %}
{% set minutes = (0 if remainder == 0
else minutes - remainder if remainder < 8
else minutes + 15 - remainder) % 60 %}
{% set time_now = '{:02d}:{:02d}'.format(now().hour, minutes) %}
{% set source = 'sensor.nodered_aa1f2c338725cf4f' %}
{% set data_today = state_attr(source, 'today') %}
{% set data_tomorrow = state_attr(source, 'tomorrow') %}
{% set first_data_today = (data_today | selectattr('startsAt', 'contains', today_date) | list)[0] | default(none, true) %}
{% set first_data_tomorrow = (data_tomorrow | selectattr('startsAt', 'contains', today_date) | list)[0] | default(none, true) %}
{% if first_data_today is not none %}
{{ (data_today | selectattr('startsAt', 'contains', time_now) | first)['total'] }}
{% elif first_data_tomorrow is not none %}
{{ (data_tomorrow | selectattr('startsAt', 'contains', time_now) | first)['total'] }}
{% else %}
0
{% endif %}
If it works properly, I recommend you use it in your Trigger-based Template Sensor; that’s the ultimate test. Wait for it to trigger on the quarter-hour and let me know if it still reports unavailable.
EDIT
After you modify the configuration of your Trigger-based Template Sensor to use this template, ensure you execute Reload Template Entities and then check Logs for any related warnings or errors.
123
(Taras)
April 15, 2026, 7:25pm
17
Any progress to report?
Did you try the example I posted above?
SAFP
(Peter)
April 17, 2026, 6:52pm
18
I will this weekend. Had a terribly busy week at work, I’m exhausted. Thanks for checking.
SAFP
(Peter)
April 18, 2026, 2:52pm
19
At 12:25 it’s showing the price of 12:30 so that isn’t correct. I’ve tried setting
else minutes - remainder if remainder < 8
to 14 and 15 but now there seems to be an intermediate value 1 minute long before proceeding to the new correct value. Still working on it though.
Edit: found the cause.
{% set minutes = (0 if remainder == 0
This parts makes the minute 0 in case of real time minute 0, 15, 30 and 45. On all those minutes the price of the exact hour :00 will be used. To be continued.
123
(Taras)
April 18, 2026, 7:05pm
20
True, but it’s an improvement compared to your original template which failed when tested at any time other than exactly at 0, 15, 30, or 45 minutes. The fact it reports something is a step forward.
The remainder’s midway point between 0 and 15 is 8 so that’s what it uses to determine which value (current or next) to report. We need to make two changes to the calculation so that it reports exactly the way you want.
{% set minutes = (minutes if remainder == 0 else minutes - remainder) % 60 %}
Here’s the complete, revised version:
{% set today_date = now().date() | string ~ 'T00:00:00' %}
{% set minutes = now().minute %}
{% set remainder = minutes % 15 %}
{% set minutes = (minutes if remainder == 0 else minutes - remainder) % 60 %}
{% set time_now = '{:02d}:{:02d}'.format(now().hour, minutes) %}
{% set source = 'sensor.nodered_aa1f2c338725cf4f' %}
{% set data_today = state_attr(source, 'today') %}
{% set data_tomorrow = state_attr(source, 'tomorrow') %}
{% set first_data_today = (data_today | selectattr('startsAt', 'contains', today_date) | list)[0] | default(none, true) %}
{% set first_data_tomorrow = (data_tomorrow | selectattr('startsAt', 'contains', today_date) | list)[0] | default(none, true) %}
{% if first_data_today is not none %}
{{ (data_today | selectattr('startsAt', 'contains', time_now) | first)['total'] }}
{% elif first_data_tomorrow is not none %}
{{ (data_tomorrow | selectattr('startsAt', 'contains', time_now) | first)['total'] }}
{% else %}
0
{% endif %}
EDIT
Simplified the calculation.
1 Like