InventoCasa / ha-advanced-blueprints

Advanced Blueprints combined with pyscript for extra useful automations
139 stars 33 forks source link

Dynamic current control only increase and don't reduce current #42

Open blackbird0589 opened 9 months ago

blackbird0589 commented 9 months ago

Hi, I've a question regarding dynamic current control. In my case the wallbox starts with minimum current of 6A. When there is more sun power available pv_excess automatically increases the charging current. If pv-power is reduced the automation don't reduces the charging current, but interuppts the charging process. Later it starts again with charging at lowest level. Screenshot_20230928_100203_Home Assistant

Is this a bug or is this as intended?

Thanks for support

boxerone commented 9 months ago

same for me thanks for clarifying

InventoCasa commented 8 months ago

Could be a bug, as I also observed a similar behaviour last month. Will investigate further the next time it happens. You can help by providing an excerpt of your Home Assistant logfile, which contains the logs of the script during the occurence of the problem.

madeinoz67 commented 6 months ago

Ive seen this occur also, and from what observations I saw was for a wallbox as well, however dynamic current control has a resolution of 0.1A while the actual wall box has a 1A control resolution, so when calculating the amps to decrease was only small amount below the threshold of the wall box, e.g. 0.7 difference, so wallbox stays at its current setting, while excess power is dropping below -10 as per setting and i think it then load sheds, i.e. switches off

madeinoz67 commented 6 months ago

Ive tested my theory today and appears to be working how I thought.

What I think is happening is the current increase/decrease calculation when run is saying it needs to increase/decrease by a small amount e.g. 0.2A and then adjusts the devices power history accordingly, and sends new current setting e.g. 2.2A to charger, however a) the charger doesn't change as below its adjustment resolution of 1A, and b) the calculated power history of the device is now incorrectly showing a lower/higher value, when in fact nothings changed, when needing to decrease, it ultimately load sheds by switching off, as there no change in output seen.

As a quick and dirty test I changed the calculations for increase/decrease current to just return integer

image

Result is it adjust output current correctly for the device when required to load adjust. unfortunately my battery was full so test ended earlier than I'd have, but will continue to monitor over the next few days as will be doing some KMs over Christmas, however today was a very cloudy day and generation was changing considerably, previously this would drop off when needing to decrease.

image

So I think the solution will be in the blueprint is to select the minimum controllable amps/resolution (boolean: is_wallbox?) and calculate accordingly based on this setting as the default is too fine for wallboxes that only deal in 1A increments

Also a side note on this, I'm now finding my current increase much quicker than it did previously, where as before it would take ages due to this and being export limiting (see #47)

madeinoz67 commented 6 months ago

have been testing over the last few days with the quick and dirty fix in place mentioned above and confirm its all working, have not had a load drop event occur, the charge current adjusts for additional household load as shown about 9:30-10am when dryer, washing machine, air conditioner and dishwasher came on

This was a 20-70% charge after a 500Km round trip the day before, same with drive in the afternoon where you can see it topping battery backup to 70% as the PV production is diminishing, due to late afternoon sun.

A02CA3FB-280F-434B-BB9E-ADD9641692A0_1_102_o

052117EE-BAD7-467B-B80E-38FA137F1D9C_1_102_o

Hamudulu commented 5 months ago

Is this fixed? Same issue in my setup with a ac-elwa…

blackbird0589 commented 5 months ago

Not for now. I had no time to try it as mentioned in the last posts. @madeinoz67 could you please explain step by step what to change or do you have a repository which contains your modifications?

jurviz commented 1 month ago

I see the same problem with my ev charger, instead of decreasing power the automation shuts the charger off. Screenshot from 2024-05-09 14-20-11 Here is the log excerpt from the last occurrence: 2024-05-09 13:16:32.798 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export History: [797, 808, 876, 739, 530, 788, 820, 817, 826, 843, 0, 24.00000000000008, 1053.29, 180.2900000000002, 117.29000000000002, 517.2900000000001, 65.29000000000019, 0, 284.9999999999997, 2.5, 2.5, 2.5, 2.5, 0, 188.0, 0, 0, 0, 60.00000000000006, 1040.19, 337.19000000000005, 340.19000000000005, 617.19, 528.19, 3.0, 0, 280.0, 0, 0, 0, 221.99999999999994, 1213.01, 398.0100000000001, 421.8100000000001, 744.8099999999998, 588.8100000000001, 2.8, 0, 298.0, 0, 0, 0, 155.00000000000028, 1150.4000000000003, 355.39999999999986, 355.39999999999986, 537.4, 490.4, 0, 63] 2024-05-09 13:16:32.799 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (PV Power - Load Power) History: [797, 808, 876, 728, 507, 788, 820, 817, 826, 843, -157.0, 24.00000000000008, 1053.29, 180.2900000000002, 117.29000000000002, -22.709999999999784, -218.7099999999998, -532.0, 284.9999999999997, -30.5, -88.50000000000009, -80.50000000000017, -23.5, -1534.5, 117.0, -418.0, -763.0, -998.9999999999999, 60.00000000000006, 1040.19, 87.19000000000005, 203.19000000000005, 617.19, -21.809999999999945, -848.0, -1677.0, 114.0, -259.0, -690.0, -878.9999999999999, 221.99999999999994, 1213.01, -134.9899999999999, 213.81000000000012, 744.8099999999998, -8.189999999999895, -853.1999999999999, -1569.2, 188.0, -233.0, -735.9999999999998, -947.9999999999999, 155.00000000000028, 1150.4000000000003, 54.40000000000009, 226.39999999999998, 537.4, -19.600000000000136, -798.0000000000001, -247] 2024-05-09 13:16:32.802 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] Home battery charge is sufficient (100/100.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -60 W 2024-05-09 13:16:32.806 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] Appliance is already switched on. 2024-05-09 13:16:32.808 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.shellyplug_s_c8c9a3b87200 (Prio 1)] Home battery charge is sufficient (100/100.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -60 W 2024-05-09 13:16:32.811 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.shellyplug_s_c8c9a3b87200 (Prio 1)] Average Excess power not high enough to switch on appliance. 2024-05-09 13:16:32.813 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.shellyplug_s_c8c9a3b87200 (Prio 1)] Appliance is already switched off. 2024-05-09 13:16:32.815 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] Average Excess Power (-60 W) is less than minimum excess power (-10 W). 2024-05-09 13:16:32.818 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] actual_current=0.0A | diff_current=-0.3A | target_current=6.0A 2024-05-09 13:16:32.822 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] Current power consumption: 3.0 W 2024-05-09 13:16:32.824 INFO (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.goecharger_004416_allow_charging (Prio 1)] Switched off appliance.