-
Notifications
You must be signed in to change notification settings - Fork 17
Add support for Venus A and Venus D #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change adds support for two new Venus device types (VNSA and VNSD) which use the same communication protocol as existing Venus devices (HMG and VNSE3). Changes include: - Added VNSA and VNSD to the device type registration in venus.ts - Updated README.md with device type documentation - Updated docs/venus.md with the new device types - Updated Home Assistant addon translations (English and German) - Added changelog entry
WalkthroughThis PR adds support for two new Venus device types—VNSA (Venus A) and VNSD (Venus D)—by extending device type listings across documentation, translations, and device registration code. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (1)
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. Comment |
💡 Codex ReviewLines 48 to 52 in 36faeaa
The constructor now skips unknown device types but leaves them in ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
CHANGELOG.md (1)
2-5: Clarify the "loop" terminology in the changelog.The changelog entry mentions "Fix loop when all configured devices have invalid/unknown device types," but based on the code changes in
src/deviceManager.tsandsrc/mqttClient.ts, this appears to be adding validation that throws an error early rather than fixing an actual infinite loop. Consider revising to something like:
- "Add validation to fail fast when all configured devices have invalid/unknown device types"
This would more accurately describe the enhancement.
src/deviceManager.ts (1)
272-275: Good defensive check before GCD calculation.This validation correctly prevents attempting to calculate GCD on an empty array, which would fail. The guard ensures that at least one device has a polling interval configured.
Optional: Consider a more specific error message
The error message "No valid devices configured" could be more specific since this particular check is about polling intervals. A device could be valid but have no polled messages. Consider:
if (allPollingIntervals.length === 0) { - throw new Error('No valid devices configured'); + throw new Error('No devices with polling intervals configured'); }This helps distinguish between "no valid devices at all" (caught in constructor) vs. "valid devices exist but none have polling enabled."
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
CHANGELOG.mdREADME.mddocs/venus.mdha_addon/translations/de.yamlha_addon/translations/en.yamlsrc/device/venus.tssrc/deviceManager.test.tssrc/deviceManager.tssrc/index.tssrc/mqttClient.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/deviceManager.ts (1)
src/deviceDefinition.ts (1)
getDeviceDefinition(196-206)
src/deviceManager.test.ts (1)
src/deviceManager.ts (1)
DeviceManager(32-295)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build (linux/arm/v7)
- GitHub Check: build (linux/amd64)
- GitHub Check: build (linux/arm64)
- GitHub Check: build-addon (linux/arm64)
- GitHub Check: build-addon (linux/arm/v7)
🔇 Additional comments (10)
README.md (1)
317-318: LGTM! Device type documentation expansion looks good.The new Venus device types (VNSA-X and VNSD-X) are documented consistently with the existing format and align with the code changes.
docs/venus.md (1)
81-81: LGTM! Documentation update is clear and comprehensive.The Venus device type listing now includes all four supported types with helpful examples.
ha_addon/translations/en.yaml (1)
31-31: LGTM! Translation file updated correctly.The device type examples in the configuration description now include the new Venus types (VNSA-1, VNSD-1).
ha_addon/translations/de.yaml (1)
31-31: LGTM! German translation updated consistently.The German translation mirrors the English version with the new Venus device types included.
src/deviceManager.test.ts (2)
57-74: LGTM! Test coverage for invalid device types is thorough.This test correctly verifies that the DeviceManager throws a clear error message when all configured devices have unknown types, ensuring fail-fast behavior.
76-105: Excellent test coverage for mixed valid/invalid scenarios.This test comprehensively verifies the behavior when some devices are valid and others are invalid:
- Invalid devices correctly return undefined topics
- Valid devices correctly return defined topics
getPollingInterval()works when at least one valid device existsThis ensures robust handling of partial configuration errors.
src/index.ts (1)
326-334: LGTM! Enhanced error logging improves observability.The structured error handling provides clear, actionable information while keeping stack traces limited to debug mode. This pairs well with the new validation errors that can be thrown during initialization.
src/mqttClient.ts (1)
162-169: Defensive error handling is appropriate here.This try/catch guard ensures
setupPeriodicPollingfails gracefully if polling intervals cannot be determined. While the DeviceManager constructor also validates device configurations, this provides a safety net in case the MqttClient is called in unexpected scenarios or if the initialization order changes in the future.The clear error message helps with debugging.
src/device/venus.ts (1)
137-137: LGTM! Clean extension of supported Venus device types.The addition of 'VNSA' and 'VNSD' device types is straightforward and will be handled by the existing runtime info and BMS message processing logic. This change correctly expands device support without modifying any behavior.
src/deviceManager.ts (1)
46-82: Excellent addition of device validation in constructor.The validation logic correctly ensures at least one valid device is configured before proceeding. By counting devices that successfully return a device definition and throwing an early error if none exist, this prevents the system from initializing in an invalid state. The error message clearly indicates the issue.
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.