davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
316 stars 64 forks source link

load_cast_forecast nordpool fails #144

Closed mschneider82 closed 11 months ago

mschneider82 commented 11 months ago

Hi,

i tried to load the data from nordpool forecast from documentation but i get the failure:

2024-01-04 13:09:10,166 - web_server - ERROR - ERROR: The passed data is either not a list or the length is not correct, length should be 48
2024-01-04 13:09:10,167 - web_server - ERROR - Passed type is <class 'list'> and length is 24

my post command:

  trigger_nordpool_forecast: "curl -i -H \"Content-Type: application/json\" -X POST -d '{\"load_cost_forecast\":{{((state_attr('sensor.nordpool_kwh_de_lu_eur_3_095_0', 'raw_today') | map(attribute='value') | list  + state_attr('sensor.nordpool_kwh_de_lu_eur_3_095_0', 'raw_tomorrow') | map(attribute='value') | list))[now().hour:][:24] }}}' http://emhass:5000/action/dayahead-optim"

applying the template in the editor gets this values:

[0.29, 0.297, 0.306, 0.339, 0.352, 0.329, 0.303, 0.299, 0.293, 0.286, 0.283, 0.276, 0.272, 0.267, 0.268, 0.271, 0.277, 0.284, 0.287, 0.293, 0.295, 0.297, 0.29, 0.289]

since the list is stripped with [:24] it can only be 24 hours (the next 24hours)

I have skipped the "prod_price_forecast" from the docs in the curl because we have static pv export prices in germany.

Why it expects 48 values? We have just prices per hour:

raw_today:
  - start: "2024-01-04T00:00:00+01:00"
    end: "2024-01-04T01:00:00+01:00"
    value: 0.248
  - start: "2024-01-04T01:00:00+01:00"
    end: "2024-01-04T02:00:00+01:00"
    value: 0.24
  - start: "2024-01-04T02:00:00+01:00"
    end: "2024-01-04T03:00:00+01:00"
    value: 0.228
  - start: "2024-01-04T03:00:00+01:00"
    end: "2024-01-04T04:00:00+01:00"
    value: 0.21
  - start: "2024-01-04T04:00:00+01:00"
    end: "2024-01-04T05:00:00+01:00"
    value: 0.222
  - start: "2024-01-04T05:00:00+01:00"
    end: "2024-01-04T06:00:00+01:00"
    value: 0.249
  - start: "2024-01-04T06:00:00+01:00"
    end: "2024-01-04T07:00:00+01:00"
    value: 0.267
  - start: "2024-01-04T07:00:00+01:00"
    end: "2024-01-04T08:00:00+01:00"
    value: 0.281
  - start: "2024-01-04T08:00:00+01:00"
    end: "2024-01-04T09:00:00+01:00"
    value: 0.289
  - start: "2024-01-04T09:00:00+01:00"
    end: "2024-01-04T10:00:00+01:00"
    value: 0.292
  - start: "2024-01-04T10:00:00+01:00"
    end: "2024-01-04T11:00:00+01:00"
    value: 0.289
  - start: "2024-01-04T11:00:00+01:00"
    end: "2024-01-04T12:00:00+01:00"
    value: 0.287
  - start: "2024-01-04T12:00:00+01:00"
    end: "2024-01-04T13:00:00+01:00"
    value: 0.283
  - start: "2024-01-04T13:00:00+01:00"
    end: "2024-01-04T14:00:00+01:00"
    value: 0.282
  - start: "2024-01-04T14:00:00+01:00"
    end: "2024-01-04T15:00:00+01:00"
    value: 0.29
  - start: "2024-01-04T15:00:00+01:00"
    end: "2024-01-04T16:00:00+01:00"
    value: 0.297
  - start: "2024-01-04T16:00:00+01:00"
    end: "2024-01-04T17:00:00+01:00"
    value: 0.306
  - start: "2024-01-04T17:00:00+01:00"
    end: "2024-01-04T18:00:00+01:00"
    value: 0.339
  - start: "2024-01-04T18:00:00+01:00"
    end: "2024-01-04T19:00:00+01:00"
    value: 0.352
  - start: "2024-01-04T19:00:00+01:00"
    end: "2024-01-04T20:00:00+01:00"
    value: 0.329
  - start: "2024-01-04T20:00:00+01:00"
    end: "2024-01-04T21:00:00+01:00"
    value: 0.303
  - start: "2024-01-04T21:00:00+01:00"
    end: "2024-01-04T22:00:00+01:00"
    value: 0.299
  - start: "2024-01-04T22:00:00+01:00"
    end: "2024-01-04T23:00:00+01:00"
    value: 0.293
  - start: "2024-01-04T23:00:00+01:00"
    end: "2024-01-05T00:00:00+01:00"
    value: 0.286
raw_tomorrow:
  - start: "2024-01-05T00:00:00+01:00"
    end: "2024-01-05T01:00:00+01:00"
    value: 0.283
  - start: "2024-01-05T01:00:00+01:00"
    end: "2024-01-05T02:00:00+01:00"
    value: 0.276
  - start: "2024-01-05T02:00:00+01:00"
    end: "2024-01-05T03:00:00+01:00"
    value: 0.272
  - start: "2024-01-05T03:00:00+01:00"
    end: "2024-01-05T04:00:00+01:00"
    value: 0.267
  - start: "2024-01-05T04:00:00+01:00"
    end: "2024-01-05T05:00:00+01:00"
    value: 0.268
  - start: "2024-01-05T05:00:00+01:00"
    end: "2024-01-05T06:00:00+01:00"
    value: 0.271
  - start: "2024-01-05T06:00:00+01:00"
    end: "2024-01-05T07:00:00+01:00"
    value: 0.277
  - start: "2024-01-05T07:00:00+01:00"
    end: "2024-01-05T08:00:00+01:00"
    value: 0.284
  - start: "2024-01-05T08:00:00+01:00"
    end: "2024-01-05T09:00:00+01:00"
    value: 0.287
  - start: "2024-01-05T09:00:00+01:00"
    end: "2024-01-05T10:00:00+01:00"
    value: 0.293
  - start: "2024-01-05T10:00:00+01:00"
    end: "2024-01-05T11:00:00+01:00"
    value: 0.295
  - start: "2024-01-05T11:00:00+01:00"
    end: "2024-01-05T12:00:00+01:00"
    value: 0.297
  - start: "2024-01-05T12:00:00+01:00"
    end: "2024-01-05T13:00:00+01:00"
    value: 0.29
  - start: "2024-01-05T13:00:00+01:00"
    end: "2024-01-05T14:00:00+01:00"
    value: 0.289
  - start: "2024-01-05T14:00:00+01:00"
    end: "2024-01-05T15:00:00+01:00"
    value: 0.295
  - start: "2024-01-05T15:00:00+01:00"
    end: "2024-01-05T16:00:00+01:00"
    value: 0.299
  - start: "2024-01-05T16:00:00+01:00"
    end: "2024-01-05T17:00:00+01:00"
    value: 0.303
  - start: "2024-01-05T17:00:00+01:00"
    end: "2024-01-05T18:00:00+01:00"
    value: 0.308
  - start: "2024-01-05T18:00:00+01:00"
    end: "2024-01-05T19:00:00+01:00"
    value: 0.309
  - start: "2024-01-05T19:00:00+01:00"
    end: "2024-01-05T20:00:00+01:00"
    value: 0.304
  - start: "2024-01-05T20:00:00+01:00"
    end: "2024-01-05T21:00:00+01:00"
    value: 0.299
  - start: "2024-01-05T21:00:00+01:00"
    end: "2024-01-05T22:00:00+01:00"
    value: 0.292
  - start: "2024-01-05T22:00:00+01:00"
    end: "2024-01-05T23:00:00+01:00"
    value: 0.293
  - start: "2024-01-05T23:00:00+01:00"
    end: "2024-01-06T00:00:00+01:00"
    value: 0.283
ronaldt80 commented 11 months ago

Is your time step set to 60? If its still at 30 (default value) the it expects 48 values for a 24 hour period

mschneider82 commented 11 months ago

Do you mean this one:

retrieve_hass_conf:
  - freq: 30 # The time step to resample retrieved data from hass in minutes
mschneider82 commented 11 months ago

I have changed it to 60 and it works, thanks, maybe we should add this to the nordpool configuration docs thanks!