Skip to content

Commit c2a9078

Browse files
committed
feat: add shadow-only joint EV and home-battery planning
1 parent d6985b6 commit c2a9078

11 files changed

Lines changed: 2401 additions & 1 deletion

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Predbat
22

3+
> Experimental [joint EV/home-battery planning](docs/joint-site-planning.md)
4+
> is opt-in and shadow-only. It never replaces the executable native plan.
5+
36
![image](https://github.com/springfall2008/batpred/actions/workflows/code-quality.yml/badge.svg)
47
![image](https://github.com/springfall2008/batpred/actions/workflows/publish-docs.yml/badge.svg)
58
![image](https://github.com/springfall2008/batpred/actions/workflows/pages/pages-build-deployment/badge.svg)

‎apps/predbat/config.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@
25972597

25982598
# Apps.yaml validation schema
25992599
APPS_SCHEMA = {
2600+
"joint_site": {"type": "dict"},
26002601
"currency_symbols": {"type": "string|string_list"},
26012602
"db_enable": {"type": "boolean"},
26022603
"db_days": {"type": "integer"},

‎apps/predbat/ha.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,9 @@ def update_state_item(self, item, entity_id, nodb=False):
853853
last_changed = item.get("last_changed", item.get("last_updated", None))
854854
if "state" in item:
855855
state = item["state"]
856-
self.state_data[entity_id] = {"state": state, "attributes": attributes, "last_changed": last_changed}
856+
# Preserve observation freshness separately from a state transition.
857+
# An unchanged SOC may have a fresh device timestamp/attribute update.
858+
self.state_data[entity_id] = {"state": state, "attributes": attributes, "last_changed": last_changed, "last_updated": item.get("last_updated", last_changed)}
857859
if not nodb and self.db_enable and ((self.db_mirror_ha and (entity_id in self.db_mirror_list)) or self.db_primary):
858860
# Instead of appending to a local mirror_updates list, call the database manager to schedule the update
859861
if last_changed:

0 commit comments

Comments
 (0)