thomase1234 / esphome-fake-xemex-csmb

ESPHome Modbus Server/Slave component to fake the Xemex CSMB
MIT License
13 stars 5 forks source link

Enhancement for older Home Advanced chargers 2.0 #7

Closed Edwintenhaaf closed 1 year ago

Edwintenhaaf commented 1 year ago

Hi Thomas,

Not an issue but a feature request. Is it possible to adapt you're solution to use it with the Xemex CSP1 ? Send fake p1 data to adjust the charging and adapt to produced solar power. We have a Home Advanced 2.0 charger connected via p1 port.

Edwin

Edwintenhaaf commented 1 year ago

First attempt failed yesterday. I had disconnected the p1 cable from the charger and attached the rs485 interface to the inepro 380mod inside the charger. Did not get any data from it. On the next day without rain I will open the charger again and check the wiring. The webinterface also mentioned that there was no p1 feed.

http://[chargerip]:12800/user/status {"cpid":"xxxxxxxx","serial":"xxxxxxxxx","model":"HOMEADVANCED","imsi":"xxxxxxxxxx","iccid":"xxxxxxxx","meterSerial":"xxxxxxxxx","meterType":"3f_Inepro","ocppType":"JOCPP15","ocppEndpoint":"wss://chargenetwork.thenewmotion.com/ocppws/","ocppProtocolType":"ocpp/json","ocppStatus":"Accepted","modemStatus":"Modem active with csq UNKNOWN connected ip: x.x.x.x","connectors":[{"id":1,"type":"Type2 Socket","status":"ON","max":{"phases":"PHASE1","current":32.0,"currentArray":[32.0,0.0,0.0]},"limit":{"phases":"PHASE1","current":0.0,"currents":[0.0,0.0,0.0],"currentArray":[0.0,0.0,0.0]},"chargingRate":"Charging rate: 0kw 3 phase [0A pf ] ","chargingNeed":"","errors":[],"warnings":[]}],"maxLimit":{"phases":"PHASE1","current":32.0,"currentArray":[32.0,0.0,0.0]},"status":"ON","version":"1.7.9.1.4","errors":[],"warnings":["PowerMeterFailure"]}

thomase1234 commented 1 year ago

Hi Edwin, I don't have access to any devices that produce or consume the data from a P1 port. That makes it very difficult for me create and test this.

I'm afraid I can't help you. Thomas

Edwintenhaaf commented 1 year ago

No problem, I understand. I will try to get you're sollution working and share the results.

Question: Do you still need a load balancing subscription with newmotion/shell ?

thomase1234 commented 1 year ago

I don't know about a 'load balancing' subscription, but yes, in for the ShellRecharge Advanced 3.0 that i have, you need a subscription or the whole thing doesn't work.

fluppie commented 1 year ago

Also a 2.0/2.1 here with P1 port. A P1 generator is also what I want/had in mind :). I think something based on this device can work https://github.com/jaccobezemer/Smart-DSMR-P1-Splitter

I tried copy/pasting code to the bare minimum, but need to get fast optocouplers first. https://github.com/fluppie/TestP1Generator

I also don't know if the code works, it compiles, but that's it.

fluppie commented 1 year ago

In the meantime I have something basic working, it's only super dumb, since it's writing 24A on all phases to the charging point https://github.com/fluppie/TestP1Generator/blob/main/ESPHome-P1generator/P1generator.yaml

Maybe better programmers can make it dynamic, so the same sliders as in this repo but then modiyfing the DSMR4/P1 telegram and recalculating the CRC16 checksum. In Arduino it's done like this, but maybe CRC16 is integrated in ESPhome?

uint16_t crc16(const uint8_t *data) {
    uint16_t crc = 0x0000; // initial value
    while (*data) {
        crc ^= (uint8_t)(*data++);  // xor byte into least sig. byte of crc
        for (int i = 0; i < 8; i++) {
            if (crc & 1)
                crc = (crc >> 1) ^ 0xA001;
            else
                crc >>= 1;
        }
    }
    return crc;
}