feat(sensors): add home_battery() to push home/powerwall battery data#617
Conversation
Mirror of the existing soc() push helper: POST home_battery_soc and/or
home_battery_power to {url}status, version-gated at firmware 4.1.0. Adds
the two const keys plus a unit test covering both-fields, single-field,
no-data, and the unsupported-firmware (UnsupportedFeature) paths.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: PR #617 — Add Home Battery Sensors🔴 Critical
|
|
Thanks @RAR, please review the suggestion. |
|
Thanks for the review! The empty-payload guard you suggested is already in place — if not data:
_LOGGER.info("No home battery data to send to device.")
else:
_LOGGER.debug("Posting home battery data: %s", data)
response = await self.process_request(url=url, method="post", data=data)
...Called with neither |
1.3.0 adds home_battery() (firstof9/python-openevse-http#617); the vehicle SoC/range/ETA push already worked via soc() in 1.2.0. Also corrects the manifest pin, which was stale at 1.0.1 while requirements.txt was at 1.2.0. Addresses the 'please include a library version bump' review on firstof9#646.
…e charger (#646) * feat: push vehicle SoC/range/ETA and home battery to the charger Wire user-mapped Home Assistant sensors to the charger's POST /status push API via python-openevse-http: - vehicle_soc / vehicle_range / vehicle_eta -> manager.soc(...) - home_battery_soc / home_battery_power -> manager.home_battery(...) Adds the five CONF_* keys + SENSOR_FIELDS entries, options-flow entity selectors, state-change listener blocks, en/es translations, and tests (config-flow expected dicts + push round-trip in test_init). * build: bump python-openevse-http to 1.3.0 (home_battery push support) 1.3.0 adds home_battery() (firstof9/python-openevse-http#617); the vehicle SoC/range/ETA push already worked via soc() in 1.2.0. Also corrects the manifest pin, which was stale at 1.0.1 while requirements.txt was at 1.2.0. Addresses the 'please include a library version bump' review on #646. * test: cover vehicle/home-battery push branches for 100% patch coverage Add coverage for the unavailable/unknown/empty -> None path, the non-numeric warning path on range/ETA/power, and both the UnsupportedFeature and connection-error handlers on each push block in handle_state_change. Brings patch coverage to 100% (full suite 107 passed, custom_components/openevse at 100%). --------- Co-authored-by: Andrew Rankin <andrewrankin@gmail.com>
Summary
Adds a
home_battery()push helper toSensorsMixin, mirroring the existingsoc()/set_shaper_live_pwr()pattern. It POSTshome_battery_socand/orhome_battery_powerto{url}statusso a Home Assistant integration (or any caller) can push home/powerwall battery state to the charger.Details
home_battery(soc=None, power=None)— sends only the fields provided; logs and no-ops when called with neither.4.1.0(raisesUnsupportedFeaturebelow that), same gate assoc().HOME_BATTERY_SOC/HOME_BATTERY_POWERmatching the firmware's/statusPOST keys.Testing
test_home_batterycovers: both fields, single field, no-data, and the unsupported-firmware path.421 passed.Context
Pairs with a Home Assistant
firstof9/openevseintegration PR that wires user-mapped HA battery sensors to this method (linked there). The firmware side already parseshome_battery_soc/home_battery_poweronPOST /status.🤖 Generated with Claude Code
Summary by CodeRabbit