Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: incorrect SensorDeviceClass on Powerwall reserve setting#1164

Merged
alandtse merged 2 commits intoalandtse:devfrom
jonootto:dev
Jan 18, 2026
Merged

fix: incorrect SensorDeviceClass on Powerwall reserve setting#1164
alandtse merged 2 commits intoalandtse:devfrom
jonootto:dev

Conversation

@jonootto
Copy link
Contributor

@jonootto jonootto commented Jan 14, 2026

The Backup Reserve is incorrectly assigned a SensorDeviceClass of Battery. This results in home assistant thinking the battery charge level is instead the reserve setting:
image
image

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the device classification for the Tesla Energy Backup Reserve sensor by removing an incorrect battery classification. The sensor will now display with the proper device type.

✏️ Tip: You can customize this high-level summary in your review settings.

Backup reserve was reported as a Battery which is isn't as it's a reserve. This was causing it to show the reserve setting as the battery charge.
Test not needed due to backup reserve setting not being a battery state, and therefore not needing a SensorDeviceClass
@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

Removed the battery device class attribute from the TeslaEnergyBackupReserve sensor and its corresponding test assertion. The sensor now has no explicitly set device class, affecting its semantic categorization without changing other properties or behavior.

Changes

Cohort / File(s) Summary
Device class removal
custom_components/tesla_custom/sensor.py
Removed _attr_device_class = SensorDeviceClass.BATTERY from TeslaEnergyBackupReserve class
Test assertion removal
tests/test_sensor.py
Removed device class assertion from test_backup_reserve test case

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

No longer a battery in name,
The sensor sheds its class with grace,
What once was labeled now has space,
To be undefined, neither blamed nor claimed. 🔋✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: removing an incorrect SensorDeviceClass assignment from the Powerwall backup reserve sensor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dcca682 and 2d2c292.

📒 Files selected for processing (2)
  • custom_components/tesla_custom/sensor.py
  • tests/test_sensor.py
💤 Files with no reviewable changes (2)
  • custom_components/tesla_custom/sensor.py
  • tests/test_sensor.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonootto jonootto changed the title Fix incorrect SensorDeviceClass on Powerwall reserve setting fix: incorrect SensorDeviceClass on Powerwall reserve setting Jan 14, 2026
@jonootto
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jonootto jonootto marked this pull request as ready for review January 14, 2026 01:17
@alandtse alandtse merged commit f1bc4c0 into alandtse:dev Jan 18, 2026
7 of 8 checks passed
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.

2 participants