Skip to content

Add configurable data_key for Tessie entities and consolidate battery health sensors#976

Closed
Bre77 wants to merge 1 commit intodevfrom
codex/move-phantom_drain-to-state-coordinator
Closed

Add configurable data_key for Tessie entities and consolidate battery health sensors#976
Bre77 wants to merge 1 commit intodevfrom
codex/move-phantom_drain-to-state-coordinator

Conversation

@Bre77
Copy link
Copy Markdown
Owner

@Bre77 Bre77 commented Mar 18, 2026

Motivation

  • Some entity keys differ from the keys used in coordinator data, and sensors need an explicit mapping to read the correct values.
  • Battery health fields are available in the vehicle state endpoint and should be created from the same vehicle sensors rather than a separate battery-only entity.

Description

  • Add an optional data_key parameter to TessieBaseEntity and propagate it to TessieEntity, TessieBatteryEntity, TessieEnergyEntity, TessieEnergyHistoryEntity, and TessieWallConnectorEntity, and default data_key to key when not provided.
  • Update _value and get to read from self.coordinator.data.get(self.data_key) and use data_key where appropriate.
  • Extend TessieSensorEntityDescription with an optional data_key field and update several sensor descriptions to use explicit data_key values for battery/state-prefixed fields (for example charge_state_pack_current, charge_state_pack_voltage, charge_state_module_temp_*, charge_state_lifetime_energy_used, and charge_state_phantom_drain_percent).
  • Consolidate battery health sensor creation: remove the separate battery-health entity usage and instead add BATTERY_DESCRIPTIONS sensors as vehicle sensors created via TessieVehicleSensorEntity using description.data_key, and update async_setup_entry accordingly.
  • Update test fixture tests/components/tessie/fixtures/online.json to include the new example fields (lifetime_energy_used, module_temp_max, module_temp_min, pack_current, pack_voltage, phantom_drain_percent).

Testing

  • Ran the tessie component test suite with pytest tests/components/tessie and the tests completed successfully.
  • Updated fixtures were used by the tests and no regressions were reported by the automated test run.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce4de12547

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +503 to 506
( # Add vehicle battery health from state endpoint
TessieVehicleSensorEntity(vehicle, description)
for vehicle in entry.runtime_data.vehicles
for description in BATTERY_DESCRIPTIONS
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard battery-health entities on available state keys

This change creates all BATTERY_DESCRIPTIONS sensors from data_coordinator without checking whether the mapped data_key exists. Because vehicle entities are seeded from last_state, keys like charge_state_pack_current/charge_state_pack_voltage/charge_state_phantom_drain_percent can be missing at setup (as reflected by the existing vehicles.json fixture), so these sensors now start as unknown and can stay that way for vehicles that never expose those fields. Previously, battery sensors were gated on available battery data, so this is a startup/availability regression.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant