Skip to content

Conversation

@NEXTAltair
Copy link
Contributor

Delta Pro 3デバイスの統合、バグ修正、エネルギーセンサー項目の修正を含む更新

NEXTAltair and others added 19 commits June 26, 2025 03:48
- Add VS Code task descriptions for Reset homeassistant, Generate Docs, and Run Home Assistant Core
- Document dual API architecture (private/public)
- Explain device registry structure with internal/public implementations
- Detail MQTT client architecture and protocol buffer usage
- Document entity types, configuration migration, and development workflow
- List key dependencies and development utilities
- Provide guidance for manual testing and documentation generation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…frastructure

This squashed commit consolidates multiple improvements:

**Device Support:**
- Add complete Delta Pro 3 device implementation (642 lines)
- Implement sensors, switches, and controls for Delta Pro 3
- Add protocol buffer definitions and generated code (1214 lines)
- Update device registry with new device mappings

**Development Infrastructure:**
- Add comprehensive Makefile with development shortcuts
- Implement reset, docs, run, dev, and clean targets
- Add UTF-8 decode error handling for binary protobuf data
- Improve MQTT message processing for binary data

**Technical Improvements:**
- Add support for binary protobuf data detection
- Implement proper error handling for non-JSON messages
- Update device parameter IDs and configurations
- Add comprehensive device documentation generation

Co-Authored-By: Claude <[email protected]>
- setMessageで重複していたsetHeaderを削除し、統一されたHeaderメッセージを使用
- Protocol Buffersの構造統一により、DeltaPro3のエンティティ情報取得機能を復旧
- 生成されたPythonファイルも対応する構造変更を反映

Fixes: DeltaPro3統合機能でエンティティ情報が取得できない問題
- Add cmdFunc254_cmdId22_Report message definition to ef_dp3_iobroker.proto
- Add handling for cmdFunc=254, cmdId=22 in delta_pro_3.py
- Add handling for cmdFunc=254, cmdId=23 in delta_pro_3.py
- Add fallback handling when protobuf classes are not available
- Add pb2 import to _decode_header_message method
- Add pb2 import to _decode_message_by_type method
- Fix 'name pb2 is not defined' error in all methods that use pb2
- Add better error handling for pb2 module import
- Add detailed error logging for HeaderMessage parsing
- Improve debugging information for protobuf issues
- Change warning to debug level for missing protobuf classes
- Add basic timestamp extraction from raw data
- Improve error handling for cmdFunc=254, cmdId=22 and cmdId=23 messages
…e type

- Change from cmdFunc254_cmdId22_Report to RuntimePropertyUpload
- Update comments to reflect correct message purpose (ランタイムプロパティ)
- Maintain fallback handling for when protobuf classes are not available
- Based on documentation: cmdId=22, cmdFunc=254 is RuntimePropertyUpload for frequent runtime data
…tor in ef_dp3_iobroker_pb2.py

- Added import for ef_dp3_iobroker_pb2 in _preload_proto.py
- Updated DESCRIPTOR in ef_dp3_iobroker_pb2.py to include ecopacket.proto for improved message handling
Prevent development-specific files from being committed to main branch:
- AI assistant configurations (.claude/, .cursor/)
- Development documentation (docs_4ai/)
- Research scripts (scripts/)
- Development tools (.devcontainer/post-start.sh, Makefile, etc.)

Main branch should only contain upstream sync + DeltaPro3 support code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Remove duplicate message definitions from ef_dp3_iobroker.proto
  (EventRecordItem, ProductName*, RTCTime* were already in platform.proto)
- Fix import statement to use relative import in ef_dp3_iobroker_pb2.py
  (Changed `import ecopacket_pb2` to `from . import ecopacket_pb2`)

- Add missing imports: smart_meter, stream_ac to registry.py
  (These were lost during upstream merge conflict resolution)
- Fix duplicate delta_pro_3 import that was causing issues

- Update manifest.json: protobuf>=4.23.0 → protobuf>=6.32.0
  (Required for protobuf 6.x compiled proto files compatibility)

- Merge conflict during upstream sync caused missing imports
- Proto files compiled with protobuf 6.x required runtime upgrade
- Duplicate definitions caused "duplicate symbol" errors

Fixes integration startup and MQTT connection for Delta Pro 3 devices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Change absolute imports to relative imports in ef_dp3_iobroker_pb2
files to resolve ModuleNotFoundError for ecopacket_pb2 module.

Changes:
- ef_dp3_iobroker_pb2.py: Use relative import for ecopacket_pb2
- ef_dp3_iobroker_pb2.pyi: Use relative import and consolidate typing imports
- Add Japanese translation file (ja.json)
- Add detailed fix documentation

The protobuf files are auto-generated from .proto files, but the
import style depends on the protoc version used. Relative imports
are correct for same-directory modules in Python packages.

Resolves: ModuleNotFoundError: No module named 'ecopacket_pb2'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add missing BMSHeartBeatReport protobuf message to support battery
cycles and energy accumulation tracking in Delta Pro 3.

Changes:
- Add BMSHeartBeatReport message (82 fields) to ef_dp3_iobroker.proto
- Recompile protobuf with compatible version 5.29.0
- Fix relative imports in generated protobuf files
- Update sensor definitions to use BMSHeartBeatReport fields:
  - cycles: Battery cycle count
  - accu_chg_energy: Total charge energy (Wh)
  - accu_dsg_energy: Total discharge energy (Wh)
- Fix protobuf version requirement: 6.32.0 -> 5.29.1

This resolves unknown/unavailable entity issues for:
- Battery Cycles
- Total Charge Energy
- Total Discharge Energy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…gy metrics

- Remove incorrect cmdFunc=32,cmdId=50 -> RuntimePropertyUpload mapping
- Add cmdId=50 to BMSHeartBeatReport condition for proper decoding
- Restore BaseDevice to upstream state (remove _is_binary_data)
- Add development commands to Makefile (run, restart, stop, logs, status)
- Add debug logging and fallback handling

Fixes 3 unavailable entities:
- Cycles (field 14)
- Total Charge Energy (accu_chg_energy, field 79)
- Total Discharge Energy (accu_dsg_energy, field 80)

Reference: ioBroker confirms cmdFunc=32, cmdId=50 = BMSHeartBeatReport
- Change sensor field names from snake_case to camelCase
- accuChgEnergy and accuDsgEnergy now match Protobuf MessageToDict output
- Follows upstream pattern (stream_ac.py uses same convention)
- Fixes Total Charge Energy and Total Discharge Energy entities
- All 44 Delta Pro 3 entities now working (100% success rate)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@NEXTAltair
Copy link
Contributor Author

We should carefully check for compatibility issues with other devices after upgrading to protobuf 5.29.1. Some integrations have reported errors or compatibility problems, so thorough testing is recommended.

protobuf 5.29.1にアップグレードした後、他のデバイスとの互換性問題を慎重に確認すべきです。一部のインテグレーションでエラーや互換性の問題が報告されているため、十分なテストを推奨します。

@ksleontiev
Copy link

I have Delta Pro 3. How can I help?

@tolwi tolwi requested a review from Copilot October 25, 2025 10:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the Delta Pro 3 device by implementing Protobuf message decoding, updating the device registry, and upgrading the protobuf dependency.

Key Changes:

  • Added Delta Pro 3 device implementation with Protobuf support for MQTT message decoding
  • Updated protobuf dependency from >=4.23.0 to >=5.29.1
  • Added Japanese translation file for the integration

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
custom_components/ecoflow_cloud/manifest.json Updated protobuf version requirement
custom_components/ecoflow_cloud/devices/registry.py Added Delta Pro 3 to device registry with alphabetized imports
custom_components/ecoflow_cloud/devices/internal/delta_pro_3.py New device implementation with Protobuf decoding for Delta Pro 3
custom_components/ecoflow_cloud/devices/internal/proto/ef_dp3_iobroker_pb2.py Generated Python Protobuf bindings for Delta Pro 3 messages
custom_components/ecoflow_cloud/devices/internal/proto/ef_dp3_iobroker_pb2.pyi Type stub file for Protobuf bindings
custom_components/ecoflow_cloud/devices/internal/proto/ef_dp3_iobroker.proto Protobuf schema definition for Delta Pro 3 device messages
custom_components/ecoflow_cloud/_preload_proto.py Added preload import for Delta Pro 3 Protobuf module
custom_components/ecoflow_cloud/translations/ja.json Added Japanese translations for UI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# Home Assistant反映用に必ず'params'キーで返す
_LOGGER.debug(f"[DeltaPro3] Successfully processed protobuf data, returning {len(flat_dict)} fields")
return { # noqa: TRY300
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

The # noqa: TRY300 comment suppresses the 'Consider moving this statement to else block' warning. However, this return statement should be moved outside the try block since it's the successful path and doesn't need exception handling. Remove the noqa comment and restructure the code properly.

Copilot uses AI. Check for mistakes.
Comment on lines 629 to 631
elif (cmd_func == 3 and cmd_id in [1, 2, 30, 50]) or \
(cmd_func == 254 and cmd_id in [24, 25, 26, 27, 28, 29, 30]) or \
(cmd_func == 32 and cmd_id in [1, 3, 50, 51, 52]):
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

The complex multi-line condition with hardcoded command function/ID mappings should be extracted into a named constant or helper method for better maintainability. Consider creating a set of tuples like BMS_HEARTBEAT_COMMANDS = {(3, 1), (3, 2), ...} and checking (cmd_func, cmd_id) in BMS_HEARTBEAT_COMMANDS.

Copilot uses AI. Check for mistakes.
try:
_LOGGER.debug(f"Processing {len(raw_data)} bytes of raw data")

# 1. HeaderMessageのデコード
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Comment is in Japanese. Should be translated to English: '# 1. Decode HeaderMessage' for consistency with the codebase.

Suggested change
# 1. HeaderMessageのデコード
# 1. Decode HeaderMessage

Copilot uses AI. Check for mistakes.
NEXTAltair added a commit to NEXTAltair/hassio-ecoflow-cloud that referenced this pull request Oct 30, 2025
- _preload_proto.pyでef_dp3_iobroker_pb2を事前読み込み
- delta_pro_3.pyでモジュールトップレベルでインポート(powerstream.pyと同じパターンに統一)
- dev_apl_commを_preload_proto.pyから削除(TIME_TASK_MODE重複シンボルエラー回避)
- 空のimport文を削除してSyntaxErrorを修正

これにより、エンティティが正常にデータを取得できるようになった。
Development-specific .gitignore entries should only exist in dev branch,
not in PR to upstream/main
@tolwi tolwi merged commit bdbadd1 into tolwi:main Nov 17, 2025
2 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.

3 participants