For some context, ‘normal’ prod_price is around 0.05 $/ kWh.
We are in the midst of a price ‘spike’ and EMHASS doesn’t want to sell now for 17.497 $/ kWh because it wants to wait for later when the forecast is to sell for $18.073 and $17.699. Mathematically it is correct.
However, these are forecasts and subject to change. So how can I weight EMHASS to act on almost high enough prices to sell now, rather than waiting for a future forecast?
I’ve been having the same issue (except with 30 min blocks), and it’s not exactly what you’ve asked but here’s my latest approach.
I’m not sure which advanced amber price you’ve been using, but my approach has been to to use the advanced_low for the next 6 blocks, then go for the advanced_predicted for there onwards.
Tonight during the spike it seemed to have discharged slightly earlier than it would have if I was just using advanced_predicted. I’m sure i’ve left some money on the table, but it was much better than my previous approach of using a single price.
But i’m with you, it’d be great to have a “prioritise/weight selling sooner than later” option somehow.
Creating the values for “load cost forecat” from Entsoe data as follows:
“load_cost_forecast”:{{((state_attr(‘sensor.entso_energy_average_electricity_price_today’,
‘prices’) | map(attribute=‘price’) | list))[now().hour:][:24] }}
With dynamic pricing of energy, some companies define the cost for returned energy as a value which is a fixed value less than the “load cost” price.
So:
I want to create the list for “prod_price_forecast” in the same way, but subtracting a fixed value from the “load_cost_forecast” list.
I can not find a way to accomplish this.
Note: This could also be a configuration item!!
interesting to see you’re getting ready for 5 min windows. at the moment, are you slicing some of the 30 mins blocks in 6 smaller blocks?
if so do you have the code on how you’re cutting up the different inputs to the MPC?
My plan for Amber is to run day-ahead for the full 24 hour schedule at 30 minute resolution and then run MPC on the 5 minute intervals data for the next 60-120 minutes.
The charts above are from a LocalVolts account (that I’m helping setup EMHASS) that has 288x 5 minute intervals for the full 24 hours, but as you have noticed the LV forecasts are just the 30 minute forecast repeated 6 times. LV doesn’t have the Amber Advanced Price Forecast and that really makes a difference to the level of trust you can put into the forecast. Last night as you saw from my chart, it would say a $17+ spike in the next 5 minute forecast, but the spike didn’t come for over an hour.
Optimisations for 5 minutes is going to be challenging with EMHASS. Say you get the confirmed price after 20-30 seconds. On a Home Assistant green (under powered) it can take up to a minute to process 288x 5 minute intervals so you don’t start charging or discharging until 1.30 into a 5 minute interval. Obviously more processing CPU would help, but I’m also thinking of just processing with MPC the next 6-12 x 5 minute intervals would also greatly reduced optimisation time, with little effect on outcomes.
I currently have an issue where the EMHASS add-on starts, but refuses to keep running.
It simply stops running, the (debug) logs are not helpful:
INFO - web_server - Launching the emhass webserver at: http://0.0.0.0:5000
INFO - web_server - Home Assistant data fetch will be performed using url: http://supervisor/core/api
INFO - web_server - The data path is: /share
INFO - web_server - The logging is: DEBUG
INFO - web_server - Using core emhass version: 0.11.2
It’s not triggered by a call to the REST API, (but those fail ofc.)
I already deleted all saved files from the add-on folder. To no avail.
I think it fails to aqcuire some data via the supervisor-api. But I don’t know why that happens.
Unsure what made the difference, but I was able to clear the box in the Web UI and was able to perform a perfect optimization again, followed by a Dayahead and MPC again.
passing max power from grid as a runtime parameter for day-ahead and mpc?
Here in Belgium you get punished with a capacity tariff which is the highest 15min average power drawn from grid in a month. (something like every 1kw over 2,5kw costst you 40€/year on top of your energy costs). When running the optimizer, day ahead or mpc it is important you stay under a certain preset limit. As my ambiton might change over time I have a input_number slider for that in home assistant (next to reading the actual value from the p1 meter).
Is there a way to pass the " maximum_power_from_grid" configuration setting as a runtime parameter? Or use a template in the Configuration like in the screenshot below perhaps?
You are on the right track with the input slider, but it doesn’t go in your configuration file, you need to put it into your REST command or shell script when you can the optimisation.
Blockquote
you need to put it into your REST command or shell script when you can the optimisation
I know, I use a templated rest api call to configure my deferable loads from the home assistant UI, but since the " maximum_power_from_grid" parameter is’t listed in the " Passing other data at runtime section of the doc’s I didn’t think it was possible. That is why I asked
I think this is like a demand tariff we get on the Ausgrid grid (NSW Australia).
From Novermber to March and June to August we are charge an extra tariff calculated by measurung the highest 30-minute period of consumption between 15:00 to 21:00.
What some of us do is increase the supply price atificially to $1 so that the MPC calculation avoids charging or running deferrable loads during that window.
This is how I do it:
"prod_price_forecast": {{
([states('sensor.cecil_st_feed_in_price')|float(0)] +
(state_attr('sensor.cecil_st_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list))
| tojson
}},
{%- set current_month = now().month %}
{%- if (3 <= current_month <= 8) or (11 <= current_month <= 12) %}
"load_cost_forecast": {%- set current_time = now() %}
{%- set demand_tariff_start = "15:00:00" %}
{%- set demand_tariff_end = "21:00:00" %}
{%- set start_time = current_time.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(hours=(demand_tariff_start.split(":")[0]|int), minutes=(demand_tariff_start.split(":")[1]|int)) %}
{%- set end_time = current_time.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(hours=(demand_tariff_end.split(":")[0]|int), minutes=(demand_tariff_end.split(":")[1]|int)) %}
{%- if end_time <= start_time %}
{%- set end_time = end_time + timedelta(days=1) %}
{%- endif %}
{%- set values = ([states("sensor.cecil_st_general_price")|float(0)] + state_attr("sensor.cecil_st_general_forecast", "forecasts")|map(attribute="per_kwh")|list) %}
{%- set ns = namespace(x=[]) %}
{%- for i in range(values|length) %}
{%- set future_time = current_time + timedelta(minutes=i * 30) %}
{%- if start_time <= future_time < end_time and values[i] < 1 %}
{%- set ns.x = ns.x + [1.0] %}
{%- else %}
{%- set ns.x = ns.x + [values[i]] %}
{%- endif %}
{%- endfor %}
{{- ns.x | tojson }},
{%- else %}
I think this is a new feature with the 0.11.x releases that you can now include any parameter on the command line, which is really useful, but I don’t think it is actually documented.
Ah that might be a way to bend the power curve to a more realistic shape. After 90% charge start to reduce battery_charge_power_max down to match what the battery will actuall charge at. In my case after 90% is starts to drop from 3300W until it get to 95 where it will only charge at 850W. After 95 it will only periodically charge on and off at about 850W.
I have a question about day-ahead optimization followed by 5 min MPC intervals with shrinking prediction 30min horizon.
I run the day-ahead optimization at 0:01 every night, that works fine. Then MPC takes over. Initially I have a prediction horizon of 48 (30 min intervals), which declines over time (every 30 min), however when the prediction horizon reaches 5, EMHASS will generate an error because of too low prediction horizon.
@rcruikshank thanks for the tip but I can’t use a time/tariff based hack. Capacity tariff fees here are 24/7. Even when energy prices drop below zero because of renewable overproduction you are still punished for consuming to much . This was set up to battle grid congestion in neighborhoods to stop everyone from consuming max when prices are low. So 2 opposing price triggers at work at the same time, makes it an interesting optimization challenge here in the Flemish part of Belgium (the French speaking part is not on board with dynamic pricing yet)
I just tried and can confirm the paramter can indeed be set at runtime. This opens up the possibility to create a proper UI interface in HA to set al the runtime parameter.
Having the whole payload as a template makes sense indeed.
Templating the different parameters like I did doesn’t require a HA yaml reload/reboot either when the values change (I have all the variables and rest commands in a yaml package) . But when you want to add additional parameters on the fly payload: “{{ payload }}” is indeed the better option. Trying to find some time to work on this. Would be nice to have a emhass.yaml package file to combine everything emhass related. Combine that with a lovelace UI yaml dashboard file (sliders, settings, trigger buttons, apexcharts, etc) and we get close to a userfriendly HA emhass integration.