EMHASS: An Energy Management for Home Assistant

I’ve got some weird results when running this MPC:

curl -i -H "Content-Type: application/json" -X POST -d '{
        "load_cost_forecast": [0.1616, 0.1604, 0.1604, 0.1612, 0.1612, 0.1591, 0.1591, 0.1596, 0.1596, 0.1593, 0.1593, 0.1587, 0.1587, 0.1589, 0.1589, 0.1602, 0.1602, 0.1613, 0.1613, 0.1722, 0.1722, 0.1859, 0.1859, 0.1626, 0.1626, 0.1613, 0.1613, 0.1602, 0.1602, 0.16, 0.16, 0.1597, 0.1597, 0.1612, 0.1612, 0.1621, 0.1621, 0.2413, 0.2413, 0.3016, 0.3016, 0.316, 0.316, 0.2767, 0.2767, 0.2633, 0.2633, 0.2501],
        "prediction_horizon": 48,
        "pv_power_forecast": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 511, 677, 839, 1090, 1311, 1574, 2072, 2605, 3306, 3893, 4433, 4769, 5023, 5196, 5251, 5016, 4708, 3979, 3103, 2079, 1035, 889, 0, 0, 0, 0, 0, 0, 0],
        "alpha": 0.75,
        "beta": 0.25,
        "num_def_loads": 3,
        "def_total_hours": [0,3,0],
        "P_deferrable_nom":  [
            2250,
            2000,2000
          ],
        "treat_def_as_semi_cont": [false, false, false],
        "set_def_constant": [true, true, true]
      }' http://localhost:5000/action/naive-mpc-optim

It splits up the load into more then 3 hours.

This won’t be better if running for two deferrable loads (3h each).

curl -i -H "Content-Type: application/json" -X POST -d '{
        "load_cost_forecast": [0.1616, 0.1604, 0.1604, 0.1612, 0.1612, 0.1591, 0.1591, 0.1596, 0.1596, 0.1593, 0.1593, 0.1587, 0.1587, 0.1589, 0.1589, 0.1602, 0.1602, 0.1613, 0.1613, 0.1722, 0.1722, 0.1859, 0.1859, 0.1626, 0.1626, 0.1613, 0.1613, 0.1602, 0.1602, 0.16, 0.16, 0.1597, 0.1597, 0.1612, 0.1612, 0.1621, 0.1621, 0.2413, 0.2413, 0.3016, 0.3016, 0.316, 0.316, 0.2767, 0.2767, 0.2633, 0.2633, 0.2501],
        "prediction_horizon": 48,
        "pv_power_forecast": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 511, 677, 839, 1090, 1311, 1574, 2072, 2605, 3306, 3893, 4433, 4769, 5023, 5196, 5251, 5016, 4708, 3979, 3103, 2079, 1035, 889, 0, 0, 0, 0, 0, 0, 0],
        "alpha": 0.75,
        "beta": 0.25,
        "num_def_loads": 3,
        "def_total_hours": [0,3,3],
        "P_deferrable_nom":  [
            2250,
            2000,2000
          ],
        "treat_def_as_semi_cont": [false, false, false],
        "set_def_constant": [true, true, true]
      }' http://localhost:5000/action/naive-mpc-optim

If I ran the same command with a prediction_horizon of 36 it seems to produce the right output:

Any ideas?

Furthermore I would expect that one of the loads could already start at 12:30 pm…