Zendure: Multiple Updates and DPL feature#2447
Zendure: Multiple Updates and DPL feature#2447vaterlangen wants to merge 12 commits intohoylabs:developmentfrom
Conversation
…d bypass not handled during charge through
Fix typo in BypassMode string for AlwaysOn
Zendure: Feature: Added support for official Zendure API
…if single pack reaches min soc
…o stay on 100% for a configurable duration
Build ArtifactsFirmware built from this pull request's code:
Notice
|
|
Thanks a lot for your contributions @vaterlangen! Please split this into multiple smaller PRs. The review of a massive PR takes a lot of time and in case of review comments its a lot harder to get back into it after a couple of days have passed. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (24)
WalkthroughThis PR refactors the Zendure battery provider architecture to support multiple connection types (LocalMqtt, ZendureMqtt, Bluetooth), introduces virtual provider methods for subclass customization, expands Stats with optional types and new tracking fields, adds inverter priority support to PowerLimiter for smarter power allocation, and updates configuration/UI for the new connectivity options. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Web UI
participant Backend as OpenDTU Backend
participant LocalMQTT as Local MQTT Broker
participant ZendureCloud as Zendure Cloud MQTT
participant Device as Zendure Device
rect rgba(0, 150, 200, 0.5)
Note over UI,Backend: LocalMqttProvider Connection Type
UI->>Backend: POST config (connection_type=LocalMqtt, device_id=ABC12345)
Backend->>Backend: Instantiate LocalMqttProvider
LocalMqttProvider->>LocalMQTT: Subscribe to device topics (report, log, timesync)
LocalMqttProvider->>LocalMQTT: Send device config/control messages
Device->>LocalMQTT: Publish report (pack data, state, SoC)
LocalMQTT->>LocalMqttProvider: Deliver report payload
LocalMqttProvider->>LocalMqttProvider: Parse JSON, extract pack data
LocalMqttProvider->>Backend: Update Stats (SoC, voltage, power, state)
LocalMqttProvider->>LocalMqttProvider: Check battery protection (SoC thresholds)
alt SoC triggers protection
LocalMqttProvider->>Backend: setControlState(BatteryProtection)
Backend->>LocalMqttProvider: Publish persistent settings
end
end
rect rgba(200, 100, 50, 0.5)
Note over UI,ZendureCloud: ZendureMqttProvider Connection Type
UI->>Backend: POST config (connection_type=ZendureMqtt, server, app_key, secret, client_id)
Backend->>Backend: Instantiate ZendureMqttProvider
ZendureMqttProvider->>ZendureMqtt: Create client with credentials
ZendureMqttProvider->>ZendureCloud: Connect & authenticate
ZendureMqttProvider->>ZendureCloud: Subscribe to report topic (derived from app_key)
Device->>ZendureCloud: Publish device metrics (via cloud)
ZendureCloud->>ZendureMqttProvider: Deliver encrypted/fragmented report
ZendureMqttProvider->>ZendureMqttProvider: Reassemble fragments & deserialize JSON
ZendureMqttProvider->>ZendureMqttProvider: Extract pack count, serial, power metrics
ZendureMqttProvider->>Backend: Update Stats with cloud data
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly Related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
This PR adds multiple changes on the Zendure integration and also adds #2176
DPL
Allow to prioritize one or more SmartBufferBattery (SBB) powered Inverters over non-priorized. This is usefull if one uses multiple SBBs with different solar input power. The DPL always try to fulfill the requested output power with priorized SBB-powered inverters before using unpriorized SBB-powered inverters.
Also see #2176
Zendure
Added battery protection mode
This protects single batteries from deep discharge due to BMS only looks at overall SoC and not the SoC reported by every pack. So if BMS of one or more battery packs has an offset, one pack may be discharged below lower threshold.
This solves #2370
Added support for Offical Zendure API
The integration has been split into one part working with local MQTT broker and one connecting to the offical Zendure Servers (as I do not use them, this part receives no in-depth testing)
Show password used by Zendure to connect to MQTT broker
BatteryAdmin now also shows the password used by the Zendure device to connect to the broker
Updated FullCharge
FullCharge now stays on 100% for a configurable time to ensure proper calibrations