springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
91 stars 32 forks source link

Support for Myenergi Libbi hybrid inverter #1224

Open MalcolmSpencer opened 1 week ago

MalcolmSpencer commented 1 week ago

Hi,

I would like to add support for the Mynergi Libbi hybrid inverter and battery. I have used the SolarEdge config and it seems to be working well but I have I have a few questions about some parameters that I can't find answers to in the documentation.

Load today This doesn't exist in the inverter but I can create a helper to calculate it. Should I include the EV charger (Zappi) and hot water diverter (Eddi) in the load and then add them in the apps.yaml for EV charging and iSolar or exclude them from the load calculation?

Charge rate/discharge rate This doesn't exist in the inverter (myenergi integration). The inverter will charge the battery and 4600w when on force charge or at the available PV power when charging from solar. The inverter will discharge the battery at 5000w minus the power coming from the PV as its hybrid. Should I just set these to 4600/5000 or create a helper to calculate the value? I appreciate that in hot or cold conditions it might not charge at these rates but I have no way of getting the actual rate.

Charge Limit Is this the target SOC?

Inverter Limit Is this import or export as I have different values for each (4600/5000)?

Battery Rate max What is this and do I need to set it? the battery can charge and discharge at the full inverter rate 4600/5000.

Thanks for any help you can provide. I will cover control integration once the predictions are working.

gcoan commented 1 week ago

Hello, thanks for your questions, I'll try to answer them, but do recommend looking at the documentation, in particular for apps.yaml https://springfall2008.github.io/batpred/apps-yaml/ which should guide you how to set Predbat for different inverters.

When you get to a working config please do share it so we can store it for other users, and also any updates/gotcha's for the Other Inverters part of the docs https://springfall2008.github.io/batpred/other-inverters/#

Load today This doesn't exist in the inverter but I can create a helper to calculate it. Should I include the EV charger (Zappi) and hot water diverter (Eddi) in the load and then add them in the apps.yaml for EV charging and iSolar or exclude them from the load calculation?

Yes a helper is fine. There is a sample in https://springfall2008.github.io/batpred/apps-yaml/#data-from-home-assistant that you can tailor to your use. Its probably best to exclude your EV and Eddi as these are usually variable things that don't happen every day and then predbat can predict your base house load.

Charge rate/discharge rate This doesn't exist in the inverter (myenergi integration). The inverter will charge the battery and 4600w when on force charge or at the available PV power when charging from solar. The inverter will discharge the battery at 5000w minus the power coming from the PV as its hybrid. Should I just set these to 4600/5000 or create a helper to calculate the value? I appreciate that in hot or cold conditions it might not charge at these rates but I have no way of getting the actual rate.

Set them to the max values that the inverter will charge/discharge at, Predbat uses these to predict how quickly the battery will charge/discharge when grid charging/exporting

Charge Limit Is this the target SOC?

This is the max SOC value recorded when the batteries are full (e.g. 100 for 100%)

Inverter Limit Is this import or export as I have different values for each (4600/5000)?

This is the max AC limit from your inverter. So 5000.

Battery Rate max What is this and do I need to set it? the battery can charge and discharge at the full inverter rate 4600/5000.

This is the max output rate from the battery which may be lower than the inverter's limit, so hence the ability to set it. There isn't the ability to set different charge and discharge rates so just set the higher.

MalcolmSpencer commented 5 days ago

Hi @gcoan, thanks for your help. I have predbat working in read-only mode and the plans it produces look fairly sensible. The apps.yaml is attached. On the plan the thing I don't understand is why in the middle of the day with excess solar the plan is dumping power from the battery and then recharging it as shown on the picture below. This seems very inefficient, I would have thought that the battery would charge to 100%, then the isolar take the power and then it would spill to the grid until the peak time when the excess power is dumped. I can't see the point in charging and discharging the battery. When you first restart predbat it doesn't do this and then after it has run the model a few times it seems to come up with this dump and recharge behaviour.

image

apps.yaml.txt

gcoan commented 5 days ago

Great to see you've made such progress.

The discharging then recharging, yes, I have seen similar behaviour in my own Predbat. Just wondering what version of predbat you are using, might be worth upgrading to the latest as some fixes were introduced in response to #1235.

If you are on a version less than 8.0.0 then you need to upgrade to 7.22.5 first, and then upgrade to v8+

To upgrade, select the version you want to upgrade to from the select.predbat_update control

Let me know if that improves things.

Can we also check what you have set your battery and inverter losses to, these should all be >0 https://springfall2008.github.io/batpred/customisation/#battery-loss-options

input_number.predbat_metric_battery_cycle can be set to 0 but if you set it to a value then predbat will allocate a 'cost' to using the battery which can dissuade it from charging and discharging as much.

But first try the latest version

MalcolmSpencer commented 5 days ago

I am using the predbat addon V1.1.7 set to auto update and its using predbat 8.1.1 which is the latest version. I haven't adjusted any of the battery or inverter losses and they are all >0

I think predbat_metric_battery_cycle is only in expert mode and I haven't ventured that far yet

image

image

MalcolmSpencer commented 5 days ago

Just a thought but its almost like predbat is trying to keep the soc below the boost min soc to prevent iboost getting the power. Could this be correct? my iboost settings are image image

gcoan commented 5 days ago

Just a thought but its almost like predbat is trying to keep the soc below the boost min soc to prevent iboost getting the power. Could this be correct?

I don't have an iboost so have never set it up in my predbat, but I don't know that Predbat is that clever, I thought it just turned iboost on when it predicted there would be excess solar.

You could test this though by turning off switch.predbat_iboost_enable and see how the plan changes?

If it keeps doing this then there must be something more fundamental happening, so can you share the logfile so @springfall2008 can look at it.

In the meantime you can use the controls select.predbat_manual_xxx to manually override Predbat's behaviour for a 30 minute time slot. So for example changing the slots where discharging is planned to Idle.

MalcolmSpencer commented 5 days ago

@gcoan thanks for the suggestion. I think we have found the problem. When I turn on 'iboost on solar' predbat is trying to keep the soc below the 'iboost_min_soc' so that power is not diverted to iboost. screens shots of the plan with iboost on solar on and off. I appreciate that financially using iboost might not be the best thing to do but environmentally I want to use iboost in the summer rather than using gas. @springfall2008 shall I raise an issue for this?

iboost on solar on image

iboost on solar off image

gcoan commented 5 days ago

Yes I suggest you do create a new issue for the iboost behavior and we'll keep this one for the libbi documentation which I'll do based on your experience

Just a thought on the iboost, if you increase artificially the gas price it should favour using iboost over gas for the hot water

MalcolmSpencer commented 5 days ago

Next observation. I am on Octopus Flux which has 3 price bands and is therefore very stable. Yesterday 24th the high and low thresholds were the same all day. Sunday (23rd) and today (25th) they seem to change every time predbat recalculates and I think this is shown in the noise on the calibration chart. Is this normal behaviour?

attached is the predbat.log predbat.log

image image image image

gcoan commented 5 days ago

Yesterday 24th the high and low thresholds were the same all day. Sunday (23rd) and today (25th) they seem to change every time predbat recalculates and I think this is shown in the noise on the calibration chart. Is this normal behaviour?

This sounds like a defect. There was I think a similar defect a while ago of the thresholds changing each time predbat runs, so have a look on github to see if its still open, or please raise a new ticket if it isn't.

Personally I don't really use these thresholds or the calibration chart, I just look at the plan and see if it's 'about right'. I have expert mode turned on, because it gives more config options, but also because the predbat plan then shows import and export rates with losses which are more important (to me) to understand than the raw rates. There's a long explanation in the FAQ's about how to understand and optimise the plan.

But the threshold and calibration charts and thresholds are part of predbat so should be accurate. As long as you have reasonable forecast window (24+ hours) they shouldn't wildly oscillate

MalcolmSpencer commented 4 days ago

@gcoan Again, many thanks for your help

Turning to controls:

The Libbi via the HA Myenergi integration has 3 controls available via services

Mode Stop - turn off the Inverter Normal - charge from PV or grid when triggered, discharge to avoid grid use Discharge - force discharge to grid

Set target battery charge SOC - % enable grid charging - on, off

Easy one first to start discharge, I think this exists looking at other config files

discharge_start_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Export"

SoC doesn't apply to discharge in Libbi and it keeps exporting at full rate until the operating mode is set to normal or the battery is empty. Does Predbat monitor the battery soc and then stop the export or would I need to automate that outside predbat?

If predbat stops the export when the target rate is reached then I need a config like the following but I can't see it any of the other configs?

discharge_stop_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Normal"

If I need to automate then I would need the target soc for the discharge.

gcoan commented 4 days ago

No problem, I see you created a new issue for the iboost and found the other issue that I thought might exist about the stability of the thresholds.

Answering your questions:

Easy one first to start discharge, I think this exists looking at other config files

discharge_start_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Export"

Yes looks correct except do you mean "Discharge" (per the above list of modes)?

SoC doesn't apply to discharge in Libbi and it keeps exporting at full rate until the operating mode is set to normal or the battery is empty. Does Predbat monitor the battery soc and then stop the export or would I need to automate that outside predbat?

Every time Predbat runs (every 5 minutes) it re-evaluates the plan based on load, solar, battery SoC, etc. When it decides it needs to be in Idle mode it will send the appropriate commands to the inverter to go into that mode. So basically Predbat stops the discharge.

If predbat stops the export when the target rate is reached then I need a config like the following but I can't see it any of the other configs?

discharge_stop_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Normal"

That's correct, its not described in the 'other inverters' doc but there is an example of using it in the Huawei inverter template. I will correct the documentation for this as well!

MalcolmSpencer commented 4 days ago

Sorry my mistake the modes are stopped, normal and export.

If predbat is monitoring the soc and turning charge/discharge on and off then that should make things relatively easy. To start grid charging then mode = normal, enable grid charge and set target soc. I will manually set the target soc to 100% as predbat will monitor that then predbat can enable/disable change from grid to control the charge.

I think the yaml for this is

charge_start_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_charge_from_grid" option: "True" charge_stop_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_charge_from_grid" option: "False" discharge_start_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Export" discharge_stop_service: service: select.select_option entity_id: "select.myenergi_libbi_24042899_operating_mode" option: "Normal"

does that look correct?

gcoan commented 4 days ago

Seems reasonable, fingers crossed 🤞

MalcolmSpencer commented 2 hours ago

I have been keeping an eye on the calibration chart and generally, the 1 hour looks fairly close to actual considering I am still in read-only mode. However some days I see a lot of noise on the 8 and 12 hour predictions. There is no way the battery can charge and discharge this fast so any idea what could be causing these oscillations? I have checked the load data and PV data and they both look clean and realistic

image image image