Skip to content

Commit 9a35c93

Browse files
Fix issue where fdSoc can not be less than minSocOnGrid (#3104)
* Fix issue where fdSoc can not be less than minSocOnGrid * Version bump
1 parent 431e040 commit 9a35c93

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

apps/predbat/fox.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -840,17 +840,6 @@ async def publish_schedule_settings_ha(self, deviceSN):
840840
app="fox",
841841
)
842842

843-
def getMinSocOnGrid(self, deviceSN):
844-
"""
845-
Get the MinSocOnGrid setting for the device
846-
"""
847-
value = self.device_settings.get(deviceSN, {}).get("MinSocOnGrid", {}).get("value", 10)
848-
try:
849-
value = int(float(value))
850-
except ValueError:
851-
value = 10
852-
return value
853-
854843
async def get_schedule_settings_ha(self, deviceSN):
855844
"""
856845
Get the current schedule from HA database
@@ -1390,7 +1379,7 @@ async def apply_battery_schedule(self, serial):
13901379
)
13911380
elif direction == "discharge":
13921381
new_schedule.append(
1393-
{"enable": 1, "startHour": start_hour, "startMinute": start_minute, "endHour": end_hour, "endMinute": end_minute, "workMode": "ForceDischarge", "fdSoc": soc, "maxSoc": reserve, "fdPwr": power, "minSocOnGrid": reserve}
1382+
{"enable": 1, "startHour": start_hour, "startMinute": start_minute, "endHour": end_hour, "endMinute": end_minute, "workMode": "ForceDischarge", "fdSoc": max(soc, reserve), "maxSoc": reserve, "fdPwr": power, "minSocOnGrid": reserve}
13941383
)
13951384
new_schedule = validate_schedule(new_schedule, reserve, fdPwr_max)
13961385
self.log("Fox: New schedule for {}: {}".format(serial, new_schedule))

apps/predbat/predbat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import requests
2828
import asyncio
2929

30-
THIS_VERSION = "v8.30.2"
30+
THIS_VERSION = "v8.30.3"
3131

3232
# fmt: off
3333
PREDBAT_FILES = ["predbat.py", "hass.py", "config.py", "prediction.py", "gecloud.py", "utils.py", "inverter.py", "ha.py", "download.py", "web.py", "web_helper.py", "predheat.py", "futurerate.py", "octopus.py", "solcast.py", "execute.py", "plan.py", "fetch.py", "output.py", "userinterface.py", "energydataservice.py", "alertfeed.py", "compare.py", "db_manager.py", "db_engine.py", "plugin_system.py", "ohme.py", "components.py", "fox.py", "carbon.py", "web_mcp.py", "component_base.py", "axle.py"]

apps/predbat/tests/test_fox_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4322,7 +4322,7 @@ def test_apply_battery_schedule_discharge_only(my_predbat):
43224322
assert group["startMinute"] == 0
43234323
assert group["endHour"] == 18
43244324
assert group["endMinute"] == 59
4325-
assert group["fdSoc"] == 10
4325+
assert group["fdSoc"] == 15 # fdsoc_min is 10, reserve is 15, so fdSoc should be max(10,15)=15
43264326
assert group["fdPwr"] == 5000
43274327
assert group["maxSoc"] == 15, f"Expected maxSoc=15, got {group['maxSoc']}"
43284328
assert group["minSocOnGrid"] == 15, f"Expected minSocOnGrid=15, got {group['minSocOnGrid']}"

0 commit comments

Comments
 (0)