I’ve just upgraded my HA and EMHASS to the latest versions (since my initial installation in January or so). Now the curl
command gives an ‘internal server error’. Below is the format of the command I use, and below that the error reported by the Services Dev Tool. Did something change in the supported format?
Shell command defined in configuration.yaml:
shell_command:
mpc_optim_emhass: >
curl -i -H "Content-Type: application/json" -X POST -d '{
"load_cost_forecast": [{% for item in states('sensor.load_cost_forecast').split(',') %}{% if not loop.first %},{% endif %}{{ item }},{{ item }}{% endfor %}],
"prod_price_forecast": [{% for item in states('sensor.prod_price_forecast').split(',') %}{% if not loop.first %},{% endif %}{{ item }},{{ item }}{% endfor %}],
"pv_power_forecast":{{ states('sensor.pv_power_forecast_halfhourly') }},
"load_power_forecast":[{% for item in states('sensor.load_power_forecast').split(',') %}{% if not loop.first %},{% endif %}{{item}},{{item}}{% if loop.last %}]{% endif %}{% endfor %},
"prediction_horizon":48,
"soc_init":{{ (states('sensor.battery_state_of_capacity')|float(0))/100 }},
"soc_final":0.6,
"def_total_hours":[0]
}' http://localhost:5000/action/naive-mpc-optim
Resulting string of this syntax from the Template Dev Tool:
curl -i -H "Content-Type: application/json" -X POST -d '{
"load_cost_forecast": [0.1271,0.1271,0.1096,0.1096,0.0967,0.0967,0.0957,0.0957,0.0991,0.0991,0.1116,0.1116,0.1315,0.1315,0.1502,0.1502,0.1613,0.1613,0.188,0.188,0.225,0.225,0.2175,0.2175,0.1852,0.1852,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661,0.1661],
"prod_price_forecast": [0.0652,0.0652,0.0487,0.0487,0.0366,0.0366,0.0357,0.0357,0.0388,0.0388,0.0506,0.0506,0.0694,0.0694,0.0871,0.0871,0.0976,0.0976,0.1228,0.1228,0.1576,0.1576,0.1506,0.1506,0.1201,0.1201,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102,0.102],
"pv_power_forecast":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
"load_power_forecast":[700,700,700,700,1000,1000,700,700,700,700,700,700,1000,1000,1000,1000,1000,1000,1500,1500,1500,1500,1000,1000,500,500,300,300,300,300,300,300,300,300,300,300,300,300,300,300,1000,1000,1000,1000,1000,1000,700,700],
"prediction_horizon":48,
"soc_init":0.16,
"soc_final":0.6,
"def_total_hours":[0]
}' http://localhost:5000/action/naive-mpc-optim
The ‘pv_power_forecast’ has all zeros, probably because the Solcast API call did not return properly, but the format is what counts I suppose.
Here is the error message:
stdout: "HTTP/1.1 500 INTERNAL SERVER ERROR\r\nContent-Length: 265\r\nContent-Type: text/html; charset=utf-8\r\nDate: Thu, 18 Jul 2024 08:12:00 GMT\r\nServer: waitress\r\n\r\n<!doctype html>\n<html lang=en>\n<title>500 Internal Server Error</title>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>"
stderr: "% Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 1418 100 265 100 1153 840 3659 --:--:-- --:--:-- --:--:-- 4501"
returncode: 0
Thanks for any advise in getting this working again!