Hi
Please forgive me if this is not the correct way to approach you, but I’m a total noob with HA, and want to understand what I want to do is possible before I get too ‘invested’. The reason for raeching out was because I’ve seen many of your posts and you seem to be doing a lot of what I am hoping to achive, but wanted to check first…
I have a SolarEdge inverter and battery system, and want to be able to optimise battery charging based on Solcast data for the next day. Basically, I want to charge the battery overnight (cheaper rate here in the UK), but only for as long (or as slowly) as required to get me past whatever the minimum battery level is forecast to be, based on time-dependent estimated house consumption and the time-dependent solar PV forecast.
So, my questions are:
Is the above possible using HA? i.e. combining Solcast data AND estimated house consumption data AND current battery level during the cheaper overnight period to optimise (minimise) battery charging?
I would be wanting run HA on an Apple Mac that stays on permanently, but is allowed to sleep. Will HA run continuously in the backgorund, or do I need a different machine?
Thanks in advance for your help with this, Please do let me know if you need any more information from me to respond. “Help me to help you…!”
Very best regards
Spence
I’ve noticed some issues with the tariffs in that my offpeak can increase slightly during peak… I think it is an HA bug but it’s only a few pence a day so not so worried i need to fix it right now.
This is my energy.yaml for our 2 inverter 1 battery set up. We have Inverter 1 as leader and Inverter 2 as follower. The battery is connected to Inverter 1. all connected via RS485/modbus.
I’d previously said that your battery and inverter effectiveness should actally be battery and inverter efficiency. However, looking back through your excellent other thread
I now realise what you’re trying to achieve, which is to show how effective the battery is at meeting the house demand for power and also how effective the inverter is at doing the same.
What I don’t understand yet is that when the battery effectiveness falls to say 50%, which it can do, and the house is demanding 3kW, for example, where is the additional power coming from to meet that demand? The power flow shows the reduced power to the house, but it doesn’t show what is making up the difference. If I put the kettle on and the house consumption rises to over 3kW, at 50% effectiveness, the battery would need to provide 6kW. The SE battery can only provide the inverter plate value, which in my case is 4kW, but all that happens is the flow values are lower. I hope that makes sense. It’s clearly a tricky thing to demonstrate.
I’ve just had a SolarEdge & StorEdge system set up. I’ve enabled modbus via TCP and have what looks like all the stats. Some of them don’t make any sense which makes me think some of the setup is wrong (e.g. it’s bright sunshine right now with no shading and our 5 kWp array is producing 400 W regardless of whether the sun is behind a cloud or not).
For example, m1_ac_power is always zero. I believe this is meant to show house consumption? If so, does that mean some CT clamp is missing or incorrectly wired?
EDIT: It looks like m1_ac_power is showing grid import/export and ac_power is showing house consumption. Haven’t yet figured out which stat is meant to show solar production. Given the battery discharge is just above the house consumption figure, I don’t think we’re producing anything currently.
Thank you! I will try your code and see if it works better (most of the time mine does seem to produce good results though, but sometimes when production is low I get strange values).
What I just noticed is that “Solar Panel Production” seems to be giving me random spikes when there is no sun at all. Do you have an idea what’s causing that?
It looks like those spikes started come in more often right after 20:00 (8pm), which is when I changed “my” code for your code. But that could just be a coincidence. Last night there were only very few spikes:
I’ve noticed a few “new” glitches myself recently. My house consumption drops to zero at times so I need to look at that. “Spikes” are often caused by the system trying to balance after a demand. Remember that the equipment is not perfect. When the house calls for power suddenly, eg when you turn on the kettle, that demand is immediately met by the grid because that’s always quickest to respond. Then the inverter realises it has power and jumps in. When that call for powed stops suddenly, eg when the kettle turns off, that power cannot suddenly stop. What you usually see is a short period of export, then the system settles down again. Likewise with panel production. The flow can seem to reverse for short periods while the system settles, giving you those strange spikes.
It’s always a good idea to have a copy of your “own” original code to go back to if you need to. I keep mine in a simple Notepad ++ file. It’s also useful for comparing code side by side.
Whenever I see an issue I copy the relevant piece of code into the Developer Tools > Template editor and watch what the results are. Then you an adjust the variables fo make sure it’s working before replacing code in the live version.
This morning my battery decided to switch back to “Disabled” a minute after being re-ebabled (sufficiently charged during off-peak, off-peak window ends).
This automation has been running flawlessly for a few weeks.
Anyone else seen this sort of thing happen?
Did the re-enable command fail or did the battery/inverter just decide to spontaneously change mode?
The spikes are fine, but it’s somewhat interesting that I get those spikes for “panel production”, at night, where there can’t be any panel production whatsoever. But I guess there is nothing I can do about that, as it is data coming via modbus from the SolarEdge system?
I do have an “issue” with your code now. The solar_grid_to_battery_w seems to be wrong, at least sometimes. Right now my battery is being charged my panel only, and I get the following:
The old code I was using was working, as far as I know. Do you know why that could be?
My old code:
- name: "Solar Grid To Battery W"
unique_id: solar_grid_to_battery_w
unit_of_measurement: "W"
state_class: measurement
device_class: power
icon: mdi:battery-positive
state: >
{% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
{% set i2_ac_power = states('sensor.solaredge_i2_ac_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_b1_dc_power') | float(0) %}
{% if ((i1_ac_power + i2_ac_power) <= 0 and b1_dc_power > 0) %}
{{ b1_dc_power }}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_b1_dc_power') | is_number}}
Your code:
- name: "Solar Grid To Battery W"
unique_id: solar_grid_to_battery_w
unit_of_measurement: "W"
state_class: measurement
device_class: power
icon: mdi:battery-positive
state: >
{% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_b1_dc_power') | float(0) %}
{% if i1_ac_power < 0 %}
{% set i1_ac_power = (i1_ac_power * -1) %}
{% else %}
{% set i1_ac_power = (states('sensor.solaredge_i1_ac_power') | float(0)) %}
{% endif %}
{% if (i1_ac_power <= 0 and b1_dc_power > 0 ) %}
{{ b1_dc_power }}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_b1_dc_power') | is_number}}
I’ve discovered the glitches in the code. Two sections of code are wrong. If you replace them with these then the flow to the house and battery should be correct.
The two sectiosn of code are panel_to_house_w and panel_to_battery_w
The tricky bit with two inverters is that i1_dc_power often goes negative in value while the battery is charging. With the original section of code, this fools the flow into thinking the battery is charging from the grid. The new piece of code simply watches for i1_dc_power going negative and makes it positive again.
Unfortunately, that didn’t fix it. I will have to take a closer look when I find the time. Sun is shining, house car is charging, oven is on… but panel to house is 0 for a short period. House consumption somehow is 0 as well.
That’s a shame. Perhaps your setup is not quite the same as mine. Currently, the sun is shining, the battery is charging and the house is drawing power.
I did notice with mine that once the battery was charged, the panels appeared to show no generation.
Mostly my flows work fine with my current code, but sometimes in the mornings I do see some negative panel production flow. Might be the negative values for DC power on inverter 1.
Also, efficiency calculations seem to be wrong with my code, so I will maybe try to use those parts from your code and see how that goes.
I had to set battery efficiency to 100 % for now, but of course that’s not correct.
Thanks for the update. I missed that, should have seen that.
I am now trying “your code” again to see if there are any glitches
The “Power Flow” card is great, I do look at that sometime as well. Do you display an average of the two inverter efficiency values or just the efficiency or inverter 1?