First, huge thanks to David and others for such a fantastic tool! It takes a lot of effort to set it up, but I’m sure, the reward will be there.
I have a silly issue which I am not able to solve myself. All the basic stuff are fully functional and I get impressive optimisation schedules which are mostly rational as well, however with one caveat. The electricity price is wrong in relation to timestamps.
I live in Finland and use Nordpool to extract price data. Solcast integration is set for solar prediction modeling. Nordpool has hourly data whereas Solcast 30 min. I would much prefer to widen Nordpool data to a template sensor with price in 30 min or even 15 min intervals compared to dampening Solcast data to hourly format. Reason being that Finnish pricing system is getting more dynamic all the time and netting for solar production is already performed in 15 min intervals. I suppose, a prection model with more detailed data would overcome some of complexity. Yes, I probably need to set up a functional mpc to fully solve this, but still.
So how have you solved this? Here’s my current command, but this leads to wrong timestamps and a large error in modeling.
trigger_nordpool_forecast:
url: http://homeassistant.local:5000/action/dayahead-optim
method: POST
content_type: 'application/json'
payload: >-
{
"pv_power_forecast":{{
([states('sensor.inverter_input_power') | int(0)]) +
(state_attr('sensor.solcast_pv_forecast_forecast_today', 'detailedForecast') |
selectattr('period_start', 'gt', utcnow()) | map(attribute='pv_estimate')
|map('multiply', 1000) | map('int') | list +
state_attr('sensor.solcast_pv_forecast_forecast_tomorrow', 'detailedForecast') |
selectattr('period_start', 'gt', utcnow()) | map(attribute='pv_estimate') |
map('multiply', 1000) | map('int') |
list)[:(state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'raw_today') |
map(attribute='value') | list +
state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'raw_tomorrow') |
map(attribute='value') | list)[now().hour:][:24] | length]
}},
"load_cost_forecast":{{
((state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'raw_today') | map(attribute='value') | list +
state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'raw_tomorrow') | map(attribute='value') | list))[now().hour:][:24]
}},
"prod_price_forecast":{{
((state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'raw_today') | map(attribute='value') | list +
state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'raw_tomorrow') | map(attribute='value') | list))[now().hour:][:24]
}}
}
This is the ChatGPT-interpretation of a similar problem, but it doesn’t work because list.extend and list.append are forbidden commands in HASS environment.
{% set original_list = [1, 2, 3, 4, 5] %} {# Example original list #}
{% set repeated_list = [] %}
{% for num in original_list %}
{% set _ = repeated_list.extend([num, num]) %}
{% endfor %}
Original List: {{ original_list }}
Repeated List: {{ repeated_list }}
Original List: [1, 2, 3, 4, 5]
Repeated List: [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]