Repository navigation
Add typed Powerwall readers for unit, PV string, islander and site info data - #231
Merged
Merged
Conversation
Code Review ✅ Approved 🟡 Medium riskNew 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. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Approved For more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The local Powerwall sensors in the Teslemetry Home Assistant fork still read raw gateway data themselves, naming TEDAPI signals, walking the
esCanstatus 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 existingcurrent_powerandbattery_unitshelpers, so Home Assistant only maps library values to entities.battery_unit_readings(components, unit)returns a frozenBatteryUnitReadingswith a unit's BMS energies, its raw-packpercentage_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 ofactive,active_parallelandstandby, published asPV_STRING_STATES; any other value reads None) andpv_powercover a PCH's solar inputs.islander_frequency/islander_voltage(status, phase, side)andsite_info(config)(grid code, country, distributor) cover the status and config reads, andBatteryUnit.unit_idis 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 ownBump versionPR.Inventory: Home Assistant fork code → library
Line numbers are in
homeassistant/components/teslemetry/on the top of the stack,fm/pw-local-unit-battery.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/distributorsite_info(config)→SiteInfosensor.py:1692PV_STRINGSPV_STRINGSsensor.py:1694PV_STRING_STATES,:1701_pv_string_state(Teslemetry/home-assistant#74)PCH_PvState_{s}→ enumpv_string_state,PV_STRING_STATES,PvString.statesensor.py:1747(Teslemetry/home-assistant#74)PCH_SlowPvPowerSumpv_power(components)sensor.py:1715,:1728(leader strings, pre-stack)PCH_PvVoltage{s},PCH_PvCurrent{s}pv_strings(components)/pv_string_voltagemodels.py:140match_battery_units,:160-:162unit key (Teslemetry/home-assistant#75)BatteryUnit.unit_id(matching once stays HA lifecycle)sensor.py:1880,:1890(Teslemetry/home-assistant#75)BMS_nominalEnergyRemaining,BMS_nominalFullPackEnergyBatteryUnitReadings.energy_remaining,.full_pack_energysensor.py:1907,:1923(Teslemetry/home-assistant#76)HVP_State,HVP_appGitHash.hvp_state,.hvp_firmwaresensor.py:1915(Teslemetry/home-assistant#76)baggr[0].BAGGR_LOG_BattConnectionStatus{slot}.battery_connection_statussensor.py:2028,:2035_unit_pv_string_*(Teslemetry/home-assistant#78)PCH_PvVoltage{s},PCH_PvCurrent{s}at its slot.pv_strings[s].voltage/.currentsensor.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_firmwaresensor.py:1862powerwall_only,:2565(Teslemetry/home-assistant#77)battery_unit_readings(expansion reads None)sensor.py:1865_unit_percentage_charged(Teslemetry/home-assistant#81).percentage_chargedWhat 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.