I have finally got this setup back up online again after the SD-corruption and the problems around daylight savings.
Lets see if I can manage to explain.
First off all. I have a batterypack without solar, wind or water. I have a charger/inverter and a grid-tie inverter. The intension is to charge the batteries with cheap power, and use that power when its more expensive. The way I have setup this to work the best is to adjust when to charge/discharge based on how much power I have stored. I also adjust the temperature of the waterheater to store more energy that way. It uses an external temp sensor, so when I set it to 60degrees, the water is in reality a bit warmer. Its based on trial and error during a lot of showers monitoring the temp sensor. I never want it too cold, but when the batteries is low on charge, I don’t want to use power on heating the water warmer then needed for a short shower.
I made this chart with the numbers I have set today. (this will most likely change based on use)
“Prosent” is the state of charge.
“Lav” is the percentage from the lowest price the batteries will charge.
“Høy” is the percentage from the highest price the grid-tie will activate if the usage is above 1600w (Inverter is 1000w).
“Temp” is the temperature setting for the waterheater.
The first thing to do then is to find out what the lowest and highest price is (today and tomorrow).
Finding tomorrows low/high:
- platform: template
sensors:
norpool_values_tomorrow_max:
friendly_name: "Norpool tomorrow max"
value_template: "{% set high=namespace(kr=-100.0) -%}
{% set time=namespace(hr=0) -%}
{%- for kr in states.sensor.nordpool_kwh_oslo_nok_3_10_025.attributes.tomorrow -%}
{%- if kr > high.kr|float -%}{%- set high.kr=kr|float -%}{%- endif -%}
{% endfor -%}
{% set hr=time.hr -1 -%}
{{ high.kr }}"
norpool_values_tomorrow_min:
friendly_name: "Norpool tomorrow min"
value_template: "{% set low=namespace(kr=100.0) -%}
{% set time=namespace(hr=0) -%}
{%- for kr in states.sensor.nordpool_kwh_oslo_nok_3_10_025.attributes.tomorrow -%}
{%- if kr < low.kr|float -%}{%- set low.kr=kr|float -%}{%- endif -%}
{% endfor -%}
{% set hr=time.hr -1 -%}
{{ low.kr }}"
Then figuring out what the lowest/highest numbers are combining both today and tomorrow:
- platform: template
sensors:
min_pris:
value_template: >-
{% set sensors = [
state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'min')|float,
states('sensor.norpool_values_tomorrow_min')|float,
]
%}
{{ sensors|min }}
unit_of_measurement: 'kr'
- platform: template
sensors:
max_pris:
value_template: >-
{% set sensors = [
state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'max')|float,
states('sensor.norpool_values_tomorrow_max')|float,
]
%}
{{ sensors|max }}
unit_of_measurement: 'kr'
Then we need to figure out when to charge and discharge.
High price - Low price * percentage (one for the low, and one for the high):
- platform: template
sensors:
prosent_lav:
friendly_name: “prosentlav”
value_template: "{{ ((states('sensor.max_pris') |float - (states('sensor.min_pris') |float)) * (states('input_number.lavprosent') |float)) }}"
- platform: template
sensors:
prosent_hoy:
friendly_name: “prosenthoy”
value_template: "{{ ((states('sensor.max_pris') |float - (states('sensor.min_pris') |float)) * (states('input_number.hoyprosent') |float)) }}"
We now know how much to add and subtract from the lowest and highest price :
- platform: template
sensors:
prosent_ned:
friendly_name: “Prosentned”
value_template: "{{ (states('sensor.max_pris') |float - states('sensor.prosent_hoy') |float) }}"
- platform: template
sensors:
prosent_opp:
friendly_name: “Prosentopp”
value_template: "{{ (states('sensor.min_pris') |float + states('sensor.prosent_lav') |float) }}"
Then its just another automation activating “cheap” and “expensive” if the current price is under or above the set “low” and “high” limits.
The automations activate a couple of boolean inputs, the charger or the grid-tie inverter.
This is also visually shown in a chart where the green line shows the “low” limit and the red line shows the “high” limit. When the price has been above or under the limits, it lights up in green og red:
Sorry for the long an confusing post. Feel free to ask, and Ill try to explain in better words .
The next step will be to use “average price” . Now if we have 1 hour with extreme high or low price, the whole days limits will be based from that price. I would like to find a way to incorporate the avg price to get better use of the battery.