-
-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Is your feature request related to a problem? Please describe.
No, however the excess charging based on the Huawei RG4850G2 poses challenges to users (cabling, configuration) and the # of support requests show that a more straightforward solution could benefit many users.
Describe the solution you'd like
Overview
Add support for the Trucki T2MG stick and Trucki T2hG stick to enhance the excess charging capabilities of OpenDTU-onBattery.
Proposed Changes, based on the Input from Trucki himself.
1. UDP Communication:
- Transmission: OpenDTU will transmit a UDP packet at least every second to the T2MG/T2HG stick’s IP address on port 4211.
- Payload: The packet will contain the desired charging power, where the value (in watts) is multiplied by 10 to encode the data.
uint16_t udp_ac_setpoint ; //Ladeleistung in W*10
unsigned int udpPort = 4211;
IPAddress udpIP; //T2MG IP
udp.beginPacket(udpIP, udpPort);
udp.print(String(udp_ac_setpoint));
udp.endPacket();
2. Response Handling:
- Format: The T2MG stick is expected to respond with a UDP packet structured as follows:
AC OUT; Powerlimit; Battery State
(Battery State is optional and will only be provided by newer versions.) - Integration: The system will parse this response to update the charging status and other relevant system metrics.
//Battery & Grid state
#define VBAT_LOW 0
#define VBAT_NORMAL 1
#define VBAT_FULL 2
#define VBAT_FULL_DELAYED 3
#define VGRID_LOW_DELAYED 4
#define VGRID_LOW 5
char *token;
char ac_str[6];
char limit_str[6];
char vbat_state_str[6] = "1";
token = strtok(incomingUdpPacket, ";");
strncpy(ac_str, token,sizeof(ac_str));
ac_str[sizeof(ac_str) - 1] = '\0';
token = strtok(NULL, ";");
if (token!= 0)strncpy(limit_str, token,sizeof(limit_str));else strncpy(limit_str,"0",sizeof(limit_str));
limit_str[sizeof(limit_str) - 1] = '\0';
token = strtok(NULL, ";");
if (token!= 0)strncpy(vbat_state_str, token,sizeof(vbat_state_str)); else strncpy(vbat_state_str,"1",sizeof(vbat_state_str));
vbat_state_str[sizeof(vbat_state_str) - 1] = '\0';
3. Device Discovery: (optional)
- mDNS Integration: The T2MG stick will be automatically discovered using mDNS with the call:
MDNS.addService("t2mglink", "tcp", 80);
4. Receive detailed state via MQTT : (optional)
- MQTT integration: The T2MG/T2HG stick will be publish data to the MQTT broker if configured. And we can use this data to show more details. Topics can be found in the PDFs linked below.
4. Receive detailed state via HTTP:
- HTTP integration: The T2MG/T2HG stick provides data via HTTP that we can poll and show in the live view.
Rationale
The proposed changes follow the integration guidelines provided by Trucky, ensuring that the implementation is straightforward while significantly enhancing the functionality of OpenDTU-onBattery. This feature will simplify the process of installing and using the excess charging capability.