Skip to content

Add typed Powerwall readers for unit, PV string, islander and site info data - #231

Merged
Bre77 merged 1 commit into
mainfrom
fm/pw-stack-lib-parsing
Nov 17, 2026
Merged

Bre77 merged 1 commit into
mainfrom
fm/pw-stack-lib-parsing

Conversation

@Bre77

@Bre77 Bre77 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

The local Powerwall sensors in the Teslemetry Home Assistant fork still read raw gateway data themselves, naming TEDAPI signals, walking the esCan status tree, mapping PV string states, computing per-unit percentages and deciding which component rows an expansion may read. This adds typed readers for all of it next to the existing current_power and battery_units helpers, so Home Assistant only maps library values to entities. battery_unit_readings(components, unit) returns a frozen BatteryUnitReadings with a unit's BMS energies, its raw-pack percentage_charged, HVP state and firmware, its battery aggregator connection status, PCH power, AC voltage, frequency and state, PCH/PWS firmware and its PV strings. An expansion always reads None for PCH, PWS and PV, because its component slot can point at another Powerwall 3's row. pv_strings, pv_string_voltage, pv_string_state (an allowlist of active, active_parallel and standby, published as PV_STRING_STATES; any other value reads None) and pv_power cover a PCH's solar inputs. islander_frequency/islander_voltage(status, phase, side) and site_info(config) (grid code, country, distributor) cover the status and config reads, and BatteryUnit.unit_id is the device key the fork uses (serial number for an expansion, else DIN). Everything returns None for a missing or non-matching value, as the existing helpers do. Tests use the fork PRs' recorded status, config and components fixtures for a Powerwall 3 with two expansions, a single Powerwall 3, and a leader plus follower Powerwall 3. There is no version bump here; that ships in its own Bump version PR.

Inventory: Home Assistant fork code → library

Line numbers are in homeassistant/components/teslemetry/ on the top of the stack, fm/pw-local-unit-battery.

HA code (fork PR) Reads Library
sensor.py:1757 _islander_measurement, used at :1804, :1816 (Teslemetry/home-assistant#50) esCan.bus.ISLANDER.ISLAND_AcMeasurements.ISLAND_FreqL{n}_{side} / ISLAND_VL{n}N_{side} islander_frequency(status, phase, side), islander_voltage(status, phase, side)
sensor.py:1829 _site_info, used at :1837, :1843, :1849 (Teslemetry/home-assistant#51) config.site_info.grid_code / country / distributor site_info(config) → SiteInfo
sensor.py:1692 PV_STRINGS string letters PV_STRINGS
sensor.py:1694 PV_STRING_STATES, :1701 _pv_string_state (Teslemetry/home-assistant#74) PCH_PvState_{s} → enum pv_string_state, PV_STRING_STATES, PvString.state
sensor.py:1747 (Teslemetry/home-assistant#74) PCH_SlowPvPowerSum pv_power(components)
sensor.py:1715, :1728 (leader strings, pre-stack) PCH_PvVoltage{s}, PCH_PvCurrent{s} pv_strings(components) / pv_string_voltage
models.py:140 match_battery_units, :160-:162 unit key (Teslemetry/home-assistant#75) serial for expansion, else DIN BatteryUnit.unit_id (matching once stays HA lifecycle)
sensor.py:1880, :1890 (Teslemetry/home-assistant#75) BMS_nominalEnergyRemaining, BMS_nominalFullPackEnergy BatteryUnitReadings.energy_remaining, .full_pack_energy
sensor.py:1907, :1923 (Teslemetry/home-assistant#76) HVP_State, HVP_appGitHash .hvp_state, .hvp_firmware
sensor.py:1915 (Teslemetry/home-assistant#76) baggr[0].BAGGR_LOG_BattConnectionStatus{slot} .battery_connection_status
sensor.py:2028, :2035 _unit_pv_string_* (Teslemetry/home-assistant#78) follower PCH_PvVoltage{s}, PCH_PvCurrent{s} at its slot .pv_strings[s].voltage / .current
sensor.py:1931-:2021 (Teslemetry/home-assistant#77) PCH_BatteryPower, PCH_AcRealPowerAB, PCH_AcVoltageAB/AN/BN, PCH_AcFrequency, PCH_State, PCH_appGitHash, PWS_appGitHash .battery_power, .ac_power, .ac_voltage_ab/_an/_bn, .ac_frequency, .pch_state, .pch_firmware, .pws_firmware
sensor.py:1862 powerwall_only, :2565 (Teslemetry/home-assistant#77) skip PCH/PWS for an expansion built into battery_unit_readings (expansion reads None)
sensor.py:1865 _unit_percentage_charged (Teslemetry/home-assistant#81) remaining / full × 100 .percentage_charged

What stays in HA: entity descriptions, device info (the expansion name, serial and part number come from BatteryUnit), matching units once across the status and components coordinators, and choosing follower-only PV string entities.

@gitar-bot

gitar-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

New Powerwall readers expose unit, PV, islander, and site measurements through additive APIs; incorrect mappings could misreport device telemetry.

Adds typed Powerwall readers for unit, PV string, islander and site info data, so Home Assistant only maps library values to entities. Expansion units read None for PCH, PWS and PV, and missing or non-matching values return None. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@Bre77
Bre77 merged commit cc4f5db into main Nov 17, 2026
7 checks passed
@Bre77
Bre77 deleted the fm/pw-stack-lib-parsing branch November 17, 2026 01:43
@Bre77 Bre77 mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant