Add configurable data_key for Tessie entities and consolidate battery health sensors#976
Add configurable data_key for Tessie entities and consolidate battery health sensors#976
data_key for Tessie entities and consolidate battery health sensors#976Conversation
There was a problem hiding this comment.
💡 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".
| ( # Add vehicle battery health from state endpoint | ||
| TessieVehicleSensorEntity(vehicle, description) | ||
| for vehicle in entry.runtime_data.vehicles | ||
| for description in BATTERY_DESCRIPTIONS |
There was a problem hiding this comment.
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 👍 / 👎.
Motivation
Description
data_keyparameter toTessieBaseEntityand propagate it toTessieEntity,TessieBatteryEntity,TessieEnergyEntity,TessieEnergyHistoryEntity, andTessieWallConnectorEntity, and defaultdata_keytokeywhen not provided._valueandgetto read fromself.coordinator.data.get(self.data_key)and usedata_keywhere appropriate.TessieSensorEntityDescriptionwith an optionaldata_keyfield and update several sensor descriptions to use explicitdata_keyvalues for battery/state-prefixed fields (for examplecharge_state_pack_current,charge_state_pack_voltage,charge_state_module_temp_*,charge_state_lifetime_energy_used, andcharge_state_phantom_drain_percent).BATTERY_DESCRIPTIONSsensors as vehicle sensors created viaTessieVehicleSensorEntityusingdescription.data_key, and updateasync_setup_entryaccordingly.tests/components/tessie/fixtures/online.jsonto include the new example fields (lifetime_energy_used,module_temp_max,module_temp_min,pack_current,pack_voltage,phantom_drain_percent).Testing
pytest tests/components/tessieand the tests completed successfully.Codex Task