Hello, I’m trying to build an automation that analyses the attributes of an entity (which predicts my home batteries SoC over 48 hours based on house load, solar forecast and cheap rate charge/discharge), tests whether the max (fully charged SoC: 19.05kWh) and or min (empty: 0.76kWh) are reached during a given time frame (from the time of trigger, say 0945) to midnight the same day) and then pick those times out and announce them via tts. I’m having real trouble getting it to work though. The entity’s (predbat.soc_kw_best) attributes as an example:
"results:
2025-02-01T18:50:00+0000: 9.91
2025-02-01T18:55:00+0000: 9.706
2025-02-01T19:00:00+0000: 9.498
2025-02-01T19:05:00+0000: 9.345
2025-02-01T19:10:00+0000: 9.086
2025-02-01T19:15:00+0000: 8.947
2025-02-01T19:20:00+0000: 8.715
2025-02-01T19:25:00+0000: 8.576
2025-02-01T19:30:00+0000: 8.321
2025-02-01T19:35:00+0000: 8.094
2025-02-01T19:40:00+0000: 7.782
2025-02-01T19:45:00+0000: 7.469
2025-02-01T19:50:00+0000: 7.157
2025-02-01T19:55:00+0000: 6.844
2025-02-01T20:00:00+0000: 6.532
2025-02-01T20:05:00+0000: 6.219
2025-02-01T20:10:00+0000: 5.907
2025-02-01T20:15:00+0000: 5.594
2025-02-01T20:20:00+0000: 5.282
2025-02-01T20:25:00+0000: 4.969
2025-02-01T20:30:00+0000: 4.657
2025-02-01T20:35:00+0000: 4.344
2025-02-01T20:40:00+0000: 4.032
2025-02-01T20:45:00+0000: 3.719
2025-02-01T20:50:00+0000: 3.407
2025-02-01T20:55:00+0000: 3.094
2025-02-01T21:00:00+0000: 2.782
2025-02-01T21:05:00+0000: 2.469
2025-02-01T21:10:00+0000: 2.157
2025-02-01T21:15:00+0000: 1.844
2025-02-01T21:20:00+0000: 1.532
2025-02-01T21:25:00+0000: 1.219
2025-02-01T21:30:00+0000: 0.907
2025-02-01T21:35:00+0000: 1.195
2025-02-01T21:40:00+0000: 1.483
2025-02-01T21:45:00+0000: 1.771
2025-02-01T21:50:00+0000: 2.059
2025-02-01T21:55:00+0000: 2.347
2025-02-01T22:00:00+0000: 2.635
2025-02-01T22:05:00+0000: 2.322
2025-02-01T22:10:00+0000: 2.01
2025-02-01T22:15:00+0000: 1.697
2025-02-01T22:20:00+0000: 1.385
2025-02-01T22:25:00+0000: 1.072
2025-02-01T22:30:00+0000: 0.76
2025-02-01T22:35:00+0000: 1.048
2025-02-01T22:40:00+0000: 1.336
2025-02-01T22:45:00+0000: 1.624
2025-02-01T22:50:00+0000: 1.912
2025-02-01T22:55:00+0000: 2.2
2025-02-01T23:00:00+0000: 2.488
2025-02-01T23:05:00+0000: 2.776
2025-02-01T23:10:00+0000: 3.064
2025-02-01T23:15:00+0000: 3.352
2025-02-01T23:20:00+0000: 3.64
2025-02-01T23:25:00+0000: 3.928
2025-02-01T23:30:00+0000: 4.216
2025-02-01T23:35:00+0000: 4.504
2025-02-01T23:40:00+0000: 4.792
2025-02-01T23:45:00+0000: 5.08
2025-02-01T23:50:00+0000: 5.368
2025-02-01T23:55:00+0000: 5.656
2025-02-02T00:00:00+0000: 5.944
2025-02-02T00:05:00+0000: 6.232
2025-02-02T00:10:00+0000: 6.52
2025-02-02T00:15:00+0000: 6.808
2025-02-02T00:20:00+0000: 7.096
2025-02-02T00:25:00+0000: 7.384
2025-02-02T00:30:00+0000: 7.672
2025-02-02T00:35:00+0000: 7.96
2025-02-02T00:40:00+0000: 8.248
2025-02-02T00:45:00+0000: 8.536
2025-02-02T00:50:00+0000: 8.824
2025-02-02T00:55:00+0000: 9.112
2025-02-02T01:00:00+0000: 9.4
2025-02-02T01:05:00+0000: 9.688
2025-02-02T01:10:00+0000: 9.976
2025-02-02T01:15:00+0000: 10.264
2025-02-02T01:20:00+0000: 10.552
2025-02-02T01:25:00+0000: 10.84
2025-02-02T01:30:00+0000: 11.128
2025-02-02T01:35:00+0000: 11.416
2025-02-02T01:40:00+0000: 11.704
2025-02-02T01:45:00+0000: 11.992
2025-02-02T01:50:00+0000: 12.28
2025-02-02T01:55:00+0000: 12.568
2025-02-02T02:00:00+0000: 12.856
2025-02-02T02:05:00+0000: 13.144
2025-02-02T02:10:00+0000: 13.432
2025-02-02T02:15:00+0000: 13.72
2025-02-02T02:20:00+0000: 14.008
2025-02-02T02:25:00+0000: 14.296
2025-02-02T02:30:00+0000: 14.584
2025-02-02T02:35:00+0000: 14.872
2025-02-02T02:40:00+0000: 15.16
2025-02-02T02:45:00+0000: 15.448
2025-02-02T02:50:00+0000: 15.736
2025-02-02T02:55:00+0000: 16.024
2025-02-02T03:00:00+0000: 16.312
2025-02-02T03:05:00+0000: 16.6
2025-02-02T03:10:00+0000: 16.888
2025-02-02T03:15:00+0000: 17.141
2025-02-02T03:20:00+0000: 17.383
2025-02-02T03:25:00+0000: 17.582
2025-02-02T03:30:00+0000: 17.755
2025-02-02T03:35:00+0000: 17.905
2025-02-02T03:40:00+0000: 18.04
2025-02-02T03:45:00+0000: 18.164
2025-02-02T03:50:00+0000: 18.288
2025-02-02T03:55:00+0000: 18.391
2025-02-02T04:00:00+0000: 18.466
2025-02-02T04:05:00+0000: 18.541
2025-02-02T04:10:00+0000: 18.616
2025-02-02T04:15:00+0000: 18.662
2025-02-02T04:20:00+0000: 18.708
2025-02-02T04:25:00+0000: 18.754
2025-02-02T04:30:00+0000: 18.8
2025-02-02T04:35:00+0000: 18.835
2025-02-02T04:40:00+0000: 18.869
2025-02-02T04:45:00+0000: 18.904
2025-02-02T04:50:00+0000: 18.939
2025-02-02T04:55:00+0000: 18.973
2025-02-02T05:00:00+0000: 19.008
2025-02-02T05:05:00+0000: 19.042
2025-02-02T05:10:00+0000: 19.05
2025-02-02T05:30:00+0000: 19.05
2025-02-02T05:35:00+0000: 19.014
2025-02-02T05:40:00+0000: 18.946
2025-02-02T05:45:00+0000: 18.901
2025-02-02T05:50:00+0000: 18.824
2025-02-02T05:55:00+0000: 18.775
2025-02-02T06:00:00+0000: 18.701
2025-02-02T06:05:00+0000: 18.657
2025-02-02T06:10:00+0000: 18.578
2025-02-02T06:15:00+0000: 18.529
2025-02-02T06:20:00+0000: 18.456
2025-02-02T06:25:00+0000: 18.413
2025-02-02T06:30:00+0000: 18.332
2025-02-02T06:35:00+0000: 18.267
2025-02-02T06:40:00+0000: 18.069
2025-02-02T06:45:00+0000: 17.971
2025-02-02T06:50:00+0000: 17.825
2025-02-02T06:55:00+0000: 17.714
2025-02-02T07:00:00+0000: 17.642
2025-02-02T07:05:00+0000: 17.598
2025-02-02T07:10:00+0000: 17.508
2025-02-02T07:15:00+0000: 17.456
2025-02-02T07:20:00+0000: 17.375
2025-02-02T07:25:00+0000: 17.327
2025-02-02T07:30:00+0000: 17.246
2025-02-02T07:35:00+0000: 17.197
2025-02-02T07:40:00+0000: 17.118
2025-02-02T07:45:00+0000: 17.074
2025-02-02T07:50:00+0000: 17.002
2025-02-02T07:55:00+0000: 16.958
2025-02-02T08:00:00+0000: 16.885
2025-02-02T08:05:00+0000: 16.832
2025-02-02T08:10:00+0000: 16.744
2025-02-02T08:15:00+0000: 16.683
2025-02-02T08:20:00+0000: 16.37
2025-02-02T08:25:00+0000: 16.112
2025-02-02T08:30:00+0000: 15.973
2025-02-02T08:35:00+0000: 15.901
2025-02-02T08:40:00+0000: 15.78
2025-02-02T08:45:00+0000: 15.703
2025-02-02T08:50:00+0000: 15.557
2025-02-02T08:55:00+0000: 15.475
2025-02-02T09:00:00+0000: 15.332
2025-02-02T09:05:00+0000: 15.249
2025-02-02T09:10:00+0000: 15.036
2025-02-02T09:15:00+0000: 14.781
2025-02-02T09:20:00+0000: 14.592
2025-02-02T09:25:00+0000: 14.429
2025-02-02T09:30:00+0000: 14.206
2025-02-02T09:35:00+0000: 14.123
2025-02-02T09:40:00+0000: 13.996
2025-02-02T09:45:00+0000: 13.902
2025-02-02T09:50:00+0000: 13.775
2025-02-02T09:55:00+0000: 13.584
2025-02-02T10:00:00+0000: 13.272
2025-02-02T10:05:00+0000: 12.959
2025-02-02T10:10:00+0000: 12.655
2025-02-02T10:15:00+0000: 12.475
2025-02-02T10:20:00+0000: 12.193
2025-02-02T10:25:00+0000: 11.92
2025-02-02T10:30:00+0000: 11.616
2025-02-02T10:35:00+0000: 11.478
2025-02-02T10:40:00+0000: 11.212
2025-02-02T10:45:00+0000: 11.018
2025-02-02T10:50:00+0000: 10.752
2025-02-02T10:55:00+0000: 10.588
2025-02-02T11:00:00+0000: 10.465
2025-02-02T11:05:00+0000: 10.302
2025-02-02T11:10:00+0000: 10.111
2025-02-02T11:15:00+0000: 9.919
2025-02-02T11:20:00+0000: 9.683
2025-02-02T11:25:00+0000: 9.501
2025-02-02T11:30:00+0000: 9.264
2025-02-02T11:35:00+0000: 9.006
2025-02-02T11:40:00+0000: 8.787
2025-02-02T11:45:00+0000: 8.474
2025-02-02T11:50:00+0000: 8.255
2025-02-02T11:55:00+0000: 8.167
2025-02-02T12:00:00+0000: 7.947
2025-02-02T12:05:00+0000: 7.776
2025-02-02T12:10:00+0000: 7.778
2025-02-02T12:15:00+0000: 7.698
2025-02-02T12:20:00+0000: 7.676
2025-02-02T12:25:00+0000: 7.58
2025-02-02T12:30:00+0000: 7.607
2025-02-02T12:35:00+0000: 7.646
2025-02-02T12:40:00+0000: 7.523
2025-02-02T12:45:00+0000: 7.478
2025-02-02T12:50:00+0000: 7.415
2025-02-02T12:55:00+0000: 7.37
2025-02-02T13:00:00+0000: 7.342
2025-02-02T13:05:00+0000: 7.356
2025-02-02T13:10:00+0000: 7.276
2025-02-02T13:15:00+0000: 7.262
2025-02-02T13:20:00+0000: 7.152
2025-02-02T13:25:00+0000: 6.974
2025-02-02T13:30:00+0000: 6.897
2025-02-02T13:35:00+0000: 6.805
2025-02-02T13:40:00+0000: 6.717
2025-02-02T13:45:00+0000: 6.61
2025-02-02T13:50:00+0000: 6.629
2025-02-02T13:55:00+0000: 6.355
2025-02-02T14:00:00+0000: 6.286
2025-02-02T14:05:00+0000: 6.282
2025-02-02T14:10:00+0000: 6.09
2025-02-02T14:15:00+0000: 5.955
2025-02-02T14:20:00+0000: 5.908
2025-02-02T14:25:00+0000: 5.744
2025-02-02T14:30:00+0000: 5.641
2025-02-02T14:35:00+0000: 5.514
2025-02-02T14:40:00+0000: 5.255
2025-02-02T14:45:00+0000: 5.11
2025-02-02T14:50:00+0000: 4.974
2025-02-02T14:55:00+0000: 4.86
2025-02-02T15:00:00+0000: 4.685
2025-02-02T15:05:00+0000: 4.572
2025-02-02T15:10:00+0000: 4.352
2025-02-02T15:15:00+0000: 4.224
2025-02-02T15:20:00+0000: 4.025
2025-02-02T15:25:00+0000: 3.896
2025-02-02T15:30:00+0000: 3.691
2025-02-02T15:35:00+0000: 3.516
2025-02-02T15:40:00+0000: 3.259
2025-02-02T15:45:00+0000: 3.123
2025-02-02T15:50:00+0000: 2.855
2025-02-02T15:55:00+0000: 2.69
2025-02-02T16:00:00+0000: 2.419
2025-02-02T16:05:00+0000: 2.249
2025-02-02T16:10:00+0000: 1.98
2025-02-02T16:15:00+0000: 1.839
2025-02-02T16:20:00+0000: 1.577
2025-02-02T16:25:00+0000: 1.429
2025-02-02T16:30:00+0000: 1.195
2025-02-02T16:35:00+0000: 1.052
2025-02-02T16:40:00+0000: 0.812
2025-02-02T16:45:00+0000: 0.76
2025-02-02T23:30:00+0000: 0.76
2025-02-02T23:35:00+0000: 1.048
2025-02-02T23:40:00+0000: 1.336
2025-02-02T23:45:00+0000: 1.624
2025-02-02T23:50:00+0000: 1.912
2025-02-02T23:55:00+0000: 2.2
2025-02-03T00:00:00+0000: 2.488
2025-02-03T00:05:00+0000: 2.776
2025-02-03T00:10:00+0000: 3.064
2025-02-03T00:15:00+0000: 3.352
2025-02-03T00:20:00+0000: 3.64
2025-02-03T00:25:00+0000: 3.928
2025-02-03T00:30:00+0000: 4.216
2025-02-03T00:35:00+0000: 4.504
2025-02-03T00:40:00+0000: 4.792
2025-02-03T00:45:00+0000: 5.08
2025-02-03T00:50:00+0000: 5.368
2025-02-03T00:55:00+0000: 5.656
2025-02-03T01:00:00+0000: 5.944
2025-02-03T01:05:00+0000: 6.232
2025-02-03T01:10:00+0000: 6.52
2025-02-03T01:15:00+0000: 6.808
2025-02-03T01:20:00+0000: 7.096
2025-02-03T01:25:00+0000: 7.384
2025-02-03T01:30:00+0000: 7.672
2025-02-03T01:35:00+0000: 7.96
2025-02-03T01:40:00+0000: 8.248
2025-02-03T01:45:00+0000: 8.536
2025-02-03T01:50:00+0000: 8.824
2025-02-03T01:55:00+0000: 9.112
2025-02-03T02:00:00+0000: 9.4
2025-02-03T02:05:00+0000: 9.688
2025-02-03T02:10:00+0000: 9.976
2025-02-03T02:15:00+0000: 10.264
2025-02-03T02:20:00+0000: 10.552
2025-02-03T02:25:00+0000: 10.84
2025-02-03T02:30:00+0000: 11.128
2025-02-03T02:35:00+0000: 11.416
2025-02-03T02:40:00+0000: 11.704
2025-02-03T02:45:00+0000: 11.992
2025-02-03T02:50:00+0000: 12.28
2025-02-03T02:55:00+0000: 12.568
2025-02-03T03:00:00+0000: 12.856
2025-02-03T03:05:00+0000: 13.144
2025-02-03T03:10:00+0000: 13.432
2025-02-03T03:15:00+0000: 13.72
2025-02-03T03:20:00+0000: 14.008
2025-02-03T03:25:00+0000: 14.296
2025-02-03T03:30:00+0000: 14.584
2025-02-03T03:35:00+0000: 14.872
2025-02-03T03:40:00+0000: 15.16
2025-02-03T03:45:00+0000: 15.448
2025-02-03T03:50:00+0000: 15.736
2025-02-03T03:55:00+0000: 16.024
2025-02-03T04:00:00+0000: 16.312
2025-02-03T04:05:00+0000: 16.6
2025-02-03T04:10:00+0000: 16.888
2025-02-03T04:15:00+0000: 17.141
2025-02-03T04:20:00+0000: 17.383
2025-02-03T04:25:00+0000: 17.582
2025-02-03T04:30:00+0000: 17.755
2025-02-03T04:35:00+0000: 17.905
2025-02-03T04:40:00+0000: 18.04
2025-02-03T04:45:00+0000: 18.164
2025-02-03T04:50:00+0000: 18.288
2025-02-03T04:55:00+0000: 18.391
2025-02-03T05:00:00+0000: 18.466
2025-02-03T05:05:00+0000: 18.541
2025-02-03T05:10:00+0000: 18.616
2025-02-03T05:15:00+0000: 18.662
2025-02-03T05:20:00+0000: 18.708
2025-02-03T05:25:00+0000: 18.754
2025-02-03T05:30:00+0000: 18.8
2025-02-03T05:35:00+0000: 18.675
2025-02-03T05:40:00+0000: 18.571
2025-02-03T05:45:00+0000: 18.495
2025-02-03T05:50:00+0000: 18.388
2025-02-03T05:55:00+0000: 18.32
2025-02-03T06:00:00+0000: 18.199
2025-02-03T06:05:00+0000: 18.126
2025-02-03T06:10:00+0000: 18.023
2025-02-03T06:15:00+0000: 17.952
2025-02-03T06:20:00+0000: 17.84
2025-02-03T06:25:00+0000: 17.777
2025-02-03T06:30:00+0000: 17.686
2025-02-03T06:35:00+0000: 17.622
2025-02-03T06:40:00+0000: 17.501
2025-02-03T06:45:00+0000: 17.428
2025-02-03T06:50:00+0000: 17.324
2025-02-03T06:55:00+0000: 17.254
2025-02-03T07:00:00+0000: 17.132
2025-02-03T07:05:00+0000: 17.06
2025-02-03T07:10:00+0000: 16.938
2025-02-03T07:15:00+0000: 16.701
2025-02-03T07:20:00+0000: 16.495
2025-02-03T07:25:00+0000: 16.303
2025-02-03T07:30:00+0000: 16.012
2025-02-03T07:35:00+0000: 15.838
2025-02-03T07:40:00+0000: 15.557
2025-02-03T07:45:00+0000: 15.411
2025-02-03T07:50:00+0000: 15.107
2025-02-03T07:55:00+0000: 14.794
2025-02-03T08:00:00+0000: 14.607
2025-02-03T08:05:00+0000: 14.386
2025-02-03T08:10:00+0000: 14.087
2025-02-03T08:15:00+0000: 13.996
2025-02-03T08:20:00+0000: 13.683
2025-02-03T08:25:00+0000: 13.488
2025-02-03T08:30:00+0000: 13.176
2025-02-03T08:35:00+0000: 13.107
2025-02-03T08:40:00+0000: 12.856
2025-02-03T08:45:00+0000: 12.673
2025-02-03T08:50:00+0000: 12.408
2025-02-03T08:55:00+0000: 12.096
2025-02-03T09:00:00+0000: 11.98
2025-02-03T09:05:00+0000: 11.953
2025-02-03T09:10:00+0000: 11.784
2025-02-03T09:15:00+0000: 11.729
2025-02-03T09:20:00+0000: 11.518
2025-02-03T09:25:00+0000: 11.367
2025-02-03T09:30:00+0000: 11.17
2025-02-03T09:35:00+0000: 11.049
2025-02-03T09:40:00+0000: 11.03
2025-02-03T09:45:00+0000: 10.717
2025-02-03T09:50:00+0000: 10.552
2025-02-03T09:55:00+0000: 10.24
2025-02-03T10:00:00+0000: 10.082
2025-02-03T10:05:00+0000: 9.88
2025-02-03T10:10:00+0000: 9.817
2025-02-03T10:15:00+0000: 9.758
2025-02-03T10:20:00+0000: 9.731
2025-02-03T10:25:00+0000: 9.602
2025-02-03T10:30:00+0000: 9.503
2025-02-03T10:35:00+0000: 9.432
2025-02-03T10:40:00+0000: 9.462
2025-02-03T10:45:00+0000: 9.419
2025-02-03T10:50:00+0000: 9.365
2025-02-03T10:55:00+0000: 9.27
2025-02-03T11:00:00+0000: 9.216
2025-02-03T11:05:00+0000: 9.059
2025-02-03T11:10:00+0000: 9.171
2025-02-03T11:15:00+0000: 9.069
2025-02-03T11:20:00+0000: 9.061
2025-02-03T11:25:00+0000: 9.067
2025-02-03T11:30:00+0000: 8.928
2025-02-03T11:35:00+0000: 8.859
2025-02-03T11:40:00+0000: 8.878
2025-02-03T11:45:00+0000: 8.891
2025-02-03T11:50:00+0000: 8.769
2025-02-03T11:55:00+0000: 8.712
2025-02-03T12:00:00+0000: 8.591
2025-02-03T12:05:00+0000: 8.291
2025-02-03T12:10:00+0000: 8.243
2025-02-03T12:15:00+0000: 8.174
2025-02-03T12:20:00+0000: 8.21
2025-02-03T12:25:00+0000: 8.17
2025-02-03T12:30:00+0000: 8.206
2025-02-03T12:35:00+0000: 8.166
2025-02-03T12:40:00+0000: 8.201
2025-02-03T12:45:00+0000: 8.145
2025-02-03T12:50:00+0000: 8.104
2025-02-03T12:55:00+0000: 8.016
2025-02-03T13:00:00+0000: 7.984
2025-02-03T13:05:00+0000: 7.969
2025-02-03T13:10:00+0000: 7.982
2025-02-03T13:15:00+0000: 7.862
2025-02-03T13:20:00+0000: 7.984
2025-02-03T13:25:00+0000: 7.873
2025-02-03T13:30:00+0000: 7.975
2025-02-03T13:35:00+0000: 7.854
2025-02-03T13:40:00+0000: 7.921
2025-02-03T13:45:00+0000: 7.951
2025-02-03T13:50:00+0000: 7.868
2025-02-03T13:55:00+0000: 7.899
2025-02-03T14:00:00+0000: 7.893
2025-02-03T14:05:00+0000: 7.755
2025-02-03T14:10:00+0000: 7.841
2025-02-03T14:15:00+0000: 7.604
2025-02-03T14:20:00+0000: 7.566
2025-02-03T14:25:00+0000: 7.254
2025-02-03T14:30:00+0000: 7.354
2025-02-03T14:35:00+0000: 7.254
2025-02-03T14:40:00+0000: 7.23
2025-02-03T14:45:00+0000: 7.119
2025-02-03T14:50:00+0000: 7.094
2025-02-03T14:55:00+0000: 7.022
2025-02-03T15:00:00+0000: 6.964
2025-02-03T15:05:00+0000: 6.778
2025-02-03T15:10:00+0000: 6.665
2025-02-03T15:15:00+0000: 6.59
2025-02-03T15:20:00+0000: 6.414
2025-02-03T15:25:00+0000: 6.354
2025-02-03T15:30:00+0000: 6.27
2025-02-03T15:35:00+0000: 6.149
2025-02-03T15:40:00+0000: 5.837
2025-02-03T15:45:00+0000: 5.68
2025-02-03T15:50:00+0000: 5.49
2025-02-03T15:55:00+0000: 5.391
2025-02-03T16:00:00+0000: 5.194
2025-02-03T16:05:00+0000: 5.084
2025-02-03T16:10:00+0000: 4.867
2025-02-03T16:15:00+0000: 4.758
2025-02-03T16:20:00+0000: 4.532
2025-02-03T16:25:00+0000: 4.393
2025-02-03T16:30:00+0000: 4.162
2025-02-03T16:35:00+0000: 4.018
2025-02-03T16:40:00+0000: 3.705
2025-02-03T16:45:00+0000: 3.449
2025-02-03T16:50:00+0000: 3.137
2025-02-03T16:55:00+0000: 2.824
2025-02-03T17:00:00+0000: 2.545
2025-02-03T17:05:00+0000: 2.399
2025-02-03T17:10:00+0000: 2.157
2025-02-03T17:15:00+0000: 2.012
2025-02-03T17:20:00+0000: 1.769
2025-02-03T17:25:00+0000: 1.624
2025-02-03T17:30:00+0000: 1.369
2025-02-03T17:35:00+0000: 1.197
2025-02-03T17:40:00+0000: 0.955
2025-02-03T17:45:00+0000: 0.809
2025-02-03T17:50:00+0000: 0.76
2025-02-03T18:45:00+0000: 0.76
today: 5.944
friendly_name: Battery SoC kWh best
state_class: measurement
unit_of_measurement: kWh
first_charge_kwh: 0.9068
soc_now: 9.91
value_per_kwh_now: 7.76
value_per_kwh_end: 7.76
value_now: 76.87
value_end: 5.9
icon: mdi:battery"
note that the max/min ocurr here, but not necessarily before midnight; it’s just an example of the data. I want to know if the battery will hit max and or min during the day, so having a way to clip the data at todays midnight, analyse whether max/min occur announce it via tts.
For clarity, the max/min from the above data are as follows:
2025-02-01T22:30:00+0000: 0.76
2025-02-02T05:10:00+0000: 19.05
2025-02-02T05:30:00+0000: 19.05
2025-02-02T16:45:00+0000: 0.76
2025-02-02T23:30:00+0000: 0.76
2025-02-03T17:50:00+0000: 0.76
2025-02-03T18:45:00+0000: 0.76
so the expected output would be something like “battery empty at 22:30”, battery full at “05:10” etc
The closest I’ve come is:
alias: Predbat TTS Analysis
description: Daily battery forecast at 09:45
mode: single
triggers:
- at: "09:45:00"
trigger: time
actions:
- variables:
full_charge: 19.05
empty_level: 0.76
predictions: >-
{% set today_midnight = now().replace(hour=0, minute=0, second=0,
microsecond=0) + timedelta(days=1) %} {% set pred_data =
state_attr('predbat.soc_kw_best', 'results') %} {% set pred_list = [] %}
{% for ts_str, value in pred_data.items() %}
{% set dt = strptime(ts_str, '%Y-%m-%dT%H:%M:%S%z') %}
{% if dt < today_midnight %}
{% set pred_list = pred_list + [{
'time': dt.time().strftime('%H:%M'),
'value': value | float
}] %}
{% endif %}
{% endfor %} {{ pred_list | sort(attribute='time') }}
charge_events: "{{ predictions|selectattr('value', '>=', full_charge)|list }}"
empty_events: "{{ predictions|selectattr('value', '<=', empty_level)|list }}"
message: |-
{% if predictions %}
Today's battery forecast:
{% if charge_events %}→ Full charge at {{ charge_events[0].time }}{% endif %}
{% if empty_events %}→ Empty at {{ empty_events[0].time }}{% endif %}
{% if not charge_events and not empty_events %}
→ Range: {{ predictions|map(attribute='value')|min|round(1) }}kWh to
{{ predictions|map(attribute='value')|max|round(1) }}kWh
{% endif %}
{% else %}
No battery predictions available
{% endif %}
- target:
entity_id: tts.piper
data:
message: "{{ message }}"
media_player_entity_id: media_player.bedroom_mat
cache: false
action: tts.speak
but it always announces nothing/no battery predictions available, even if max/min are hit.
Thanks very much