serkri / SmartEVSE-3

Smart Electric Vehicle Charging Station (EVSE)
MIT License
72 stars 27 forks source link

evmeter em_api #135

Closed daninden closed 1 year ago

daninden commented 1 year ago

Support EM_API for evmeter

daninden commented 1 year ago

@dingo35 I removed the gitignore and index.html changes (altough the last one has bothered my OCD for quite a while). image

As for the endpoint, I could move the EvMeter L1-L3 under the currents endpoint.. but I also have the import/export kWh and current power (w) data that needs to be provided (which does not make sense to put under 'currents'), thats why I put them all together under a single new endpoint. If i have to split it, it would mean making 2 API calls to be able to provide all EvMeter data. Suggestions?

I will update the readme and swagger file accordingly.

As for testing, I have been running it since last Thursday. I will be around for any other futher testing needs (or other changes).

image

As for discussions... I'm doing my fair share of PR reviews on a daily base :)

dingo35 commented 1 year ago

Good point on the endpoint! Lets keep one endpoint, as you suggested already, but keep the naming conventions as close to the JSON stuff as possible: doc["ev_meter"]["description"] = EMConfig[EVMeter].Desc; doc["ev_meter"]["address"] = EVMeterAddress; doc["ev_meter"]["import_active_power"] = round(PowerMeasured / 100)/10; //in kW, precision 1 decimal doc["ev_meter"]["total_kwh"] = round(EnergyEV / 100)/10; //in kWh, precision 1 decimal doc["ev_meter"]["charged_kwh"] = round(EnergyCharged / 100)/10; //in kWh, precision 1 decimal doc["ev_meter"]["currents"]["TOTAL"] = Irms_EV[0] + Irms_EV[1] + Irms_EV[2]; doc["ev_meter"]["currents"]["L1"] = Irms_EV[0]; doc["ev_meter"]["currents"]["L2"] = Irms_EV[1]; doc["ev_meter"]["currents"]["L3"] = Irms_EV[2]; doc["ev_meter"]["import_active_energy"] = round(EV_import_active_energy / 100)/10; //in kWh, precision 1 decimal doc["ev_meter"]["export_active_energy"] = round(EV_export_active_energy / 100)/10; //in kWh, precision 1 decimal

I'm fine with current evse.cpp and glcd.cpp, so this change, and README and swagger, and we're good to go!

daninden commented 1 year ago

I think all should be well now.

dingo35 commented 1 year ago

Great work Dan, thanks for the PR!