dingo35 / ha-SmartEVSEv3

Integrate SmartEVSEv3 with HomeAssistant through custom component
13 stars 8 forks source link

Energy vs Power #10

Closed Pieter-HA closed 1 year ago

Pieter-HA commented 1 year ago

Wondering whether the sensor.smartevse_ev_import_active_energy (kWh) should actually have been named sensor.smartevse_ev_import_active_power (kW). That makes it consistent with the value on the EV meter. I understand the implication of such a change, as it needs updating the json response from SmartEVSE-3 as well. So maybe just change the unit of measurement for this sensor in const.py? The unit of measurement is correct in the SmartEVSE's web interface.

dingo35 commented 1 year ago

I noticed the same, in looking for unified names for mainsmeter and evmeter here the wrong name is chosen. A bit hesitant to break backward compatibility; its easy to overcome in the HA integration, but a lot of home made scripts could break...

dingo35 commented 1 year ago

Ok, I solved the backwards compat problem by adding ev_export_active_energy and ev_import_active_power to the SmartEVSE firmware (see attachment), and then processing that info correctly in the integration (main branch). active_energy_evmeter.zip

Could you test thoroughly, after flashing this firmware, whether the following info is still correct, both on the LCD, the /settings page, and in HA through the latest main branch of custom_components: -mains_active_imported_energy -mains_active_exported_energy -ev_active_imported_energy -ev_active_exported_energy -ev_active_imported_power -ev_total_kwh -ev_charged_kwh

As said, Im not at my SmartEVSE location so can only test statically...

Pieter-HA commented 1 year ago

Results from my test: -mains_active_imported_energy = 0 in webinterface and in ha-integration -mains_active_exported_energy = 0 in webinterface and in ha-integration -ev_active_imported_energy = 0 in webinterface and in ha-integration -ev_active_exported_energy = 0 in webinterface and in ha-integration -ev_active_imported_power = = 0 in webinterface but correct in ha-integration and on LCD -ev_total_kwh = 0 in webinterface and in ha-integration -ev_charged_kwh = 0 in webinterface and LCD and in ha-integration

The raw output while charging is: {"version":"10:17:24 @Feb 23 2023","mode":"SMART","mode_id":3,"car_connected":true,"wifi":{"status":"WL_CONNECTED","ssid":"","rssi":-56,"bssid":":::::","auto_connect":false,"auto_reconnect":true},"evse":{"temp":29,"temp_max":65,"connected":true,"access":true,"mode":1,"solar_stop_timer":0,"state":"Charging","state_id":2,"error":"None","error_id":0,"rfid":"Not Installed"},"settings":{"charge_current":160,"override_current":0,"current_min":6,"current_max":16,"current_main":25,"solar_max_import":0,"solar_start_current":4,"solar_stop_time":10,"enable_C2":"Always On","mains_meter":"Sensorbox"},"home_battery":{"current":0,"last_update":0},"ev_meter":{"description":"Eastron","address":12,"import_active_power":7.1,"total_kwh":0,"charged_kwh":0,"currents":{"TOTAL":314,"L1":159,"L2":155,"L3":0},"import_active_energy":0,"export_active_energy":0},"mains_meter":{"import_active_energy":0,"export_active_energy":0},"phase_currents":{"TOTAL":303,"L1":165,"L2":134,"L3":4,"last_data_update":1677244420,"charging_L1":true,"charging_L2":true,"charging_L3":false,"original_data":{"TOTAL":303,"L1":165,"L2":134,"L3":4}},"backlight":{"timer":120}}

Screenshots from HA, Webinterface and LCD: IMG_0073

IMG_0074

IMG_2250

IMG_2251

IMG_2252

IMG_2248

IMG_2249

dingo35 commented 1 year ago

Ok there must be a problem in the function I isolated to prevent doubling the code; I'll have to test this in situ, few more weeks until I get back to the SmartEVSE location.

dingo35 commented 1 year ago

Ok the code was working but you might have been too impatient, it will take a few minutes before the values are read off of the modbus. It is implemented now in version 1.0.4, there is a typo in there that prevents ev_import_active_energy and ev_export_active_energy to be read, this is fixed in the main branch and will be in the next release.