Closed purcell-lab closed 2 years ago
Hi, this specific issue was solved. Other issues arised in the mean time. They are now normally solved. I've tested the MPC on the add-on and is working fine on my side.
Also the prediction_horizon
parameter is an integer with the number of time steps to use for the MPC iteration. I've set the default to 10 for this.
The following curl command is working fine for me:
curl -i -H "Content-Type: application/json" -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6,"def_total_hours":[1,3]}' http://localhost:5000/action/naive-mpc-optim
Thanks, the prediction_horizon is working very well for me as I don't always have forecasts for the next 48 time steps.
The below scripts work for minutes 26-29 & minutes 46-59, due to the way emhass is rounding the forecasts to the nearest time block. I'll raise a separate issue. Ideally emhass would always receive currentvalue & forecasts for each.
"soc_init":{{states('sensor.powerwall_charge')|float(0)/100}}
"prediction_horizon":{{(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list|length)}}
"load_cost_forecast":{{(state_attr('sensor.amber_general_forecast', 'forecasts') |map(attribute='per_kwh')|list)}}
"prod_price_forecast":{{(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list)}}
curl -i -H "Content-Type: application/json" -X POST -d '{"prod_price_forecast":{{(
(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list) )
}},"load_cost_forecast":{{(
(state_attr('sensor.amber_general_forecast', 'forecasts') |map(attribute='per_kwh')|list) )
}},"prediction_horizon":{{(state_attr('sensor.amber_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list|length)
}},"soc_init":{{states('sensor.powerwall_charge')|float(0)/100
}},"soc_final":0.01,"def_total_hours":[4,5,3,1]}' http://localhost:5000/action/naive-mpc-optim
"soc_init":0.49
"prediction_horizon":32
"load_cost_forecast":[0.25, 0.21, 0.22, 0.28, 0.28, 0.33, 0.42, 0.33, 0.33, 0.61, 1.49, 15.36, 1.49, 0.79, 0.72, 0.61, 0.47, 0.45, 0.45, 0.45, 0.45, 0.45, 0.44, 0.43, 0.44, 0.38, 0.37, 0.42, 0.38, 0.38, 0.37, 0.38]
"prod_price_forecast":[0.14, 0.1, 0.11, 0.16, 0.16, 0.21, 0.3, 0.21, 0.21, 0.47, 1.26, 13.88, 1.26, 0.63, 0.57, 0.47, 0.34, 0.33, 0.32, 0.32, 0.32, 0.32, 0.31, 0.31, 0.31, 0.26, 0.25, 0.29, 0.25, 0.25, 0.25, 0.26]
curl -i -H "Content-Type: application/json" -X POST -d '{"prod_price_forecast":[0.14, 0.1, 0.11, 0.16, 0.16, 0.21, 0.3, 0.21, 0.21, 0.47, 1.26, 13.88, 1.26, 0.63, 0.57, 0.47, 0.34, 0.33, 0.32, 0.32, 0.32, 0.32, 0.31, 0.31, 0.31, 0.26, 0.25, 0.29, 0.25, 0.25, 0.25, 0.26],"load_cost_forecast":[0.25, 0.21, 0.22, 0.28, 0.28, 0.33, 0.42, 0.33, 0.33, 0.61, 1.49, 15.36, 1.49, 0.79, 0.72, 0.61, 0.47, 0.45, 0.45, 0.45, 0.45, 0.45, 0.44, 0.43, 0.44, 0.38, 0.37, 0.42, 0.38, 0.38, 0.37, 0.38],"prediction_horizon":32,"soc_init":0.49,"soc_final":0.01,"def_total_hours":[4,5,3,1]}' http://localhost:5000/action/naive-mpc-optim
dayahead optim works, naive-mpc-optim fails: