firstof9 / openevse

OpenEVSE Integration for Home Assistant
MIT License
70 stars 12 forks source link

[Feature Request]: Provide OpenEVSE Max Current configuration value (i.e. max_current_soft) #384

Closed jstebbins closed 1 month ago

jstebbins commented 1 month ago

The feature

The diagnostic sensor max_amps provides the hardware enforced max current value (e.g. 80A). It would be helpful to also have a diagnostic sensor for the software enforced value that is set in the OpenEVSE configuration settings (e.g. 40A in my case). It appears this is the config key max_current_soft in python-evse-http.

In addition, select.openevse_max_current options really should only contain options up to the soft limit since they get sanitized to this when an option above the soft limit is attempted.

Thanks for your consideration (and a great HA integration)

Additional information

No response

firstof9 commented 1 month ago

Shouldn't the max_current_soft already be aligned with sensor.openevse_current_capacity from the pilot output from the openevse, if I'm not mistaken?

jstebbins commented 1 month ago

I'm making some guesses here since I'm not entirely certain of the source of the dictionary value max_current_soft returned from OpenEVSE get config. My assumption is this is the user set value of max current in OpenEVSE settings. I.e. the value the user sets to limit the current to what is supported by their physical breaker and wiring situation. It appears current_capacity is only aligned with max_current_soft when max_current_soft doesn't exist in the dictionary returned by OpenEVSE get config. See:

def max_current_soft(self) -> int | None:
        """Return the firmware version."""
        if self._config is not None and "max_current_soft" in self._config:
            return self._config["max_current_soft"]
        return self._status["pilot"]

pilot === current_capacity

From my observations, current_capacity changes as you change "Charge Rate" in the OpenEVSE UI.

firstof9 commented 1 month ago

That's just the library I created, if you dig into the firmware of the devices max_current_soft and pilot should be the same reading as that's the 'soft limit' as configured by the user.

jstebbins commented 1 month ago

Let me try restating the request. You certainly know more about this than I do.

What I'm interested in getting is the value that is set in the OpenEVSE when you navigate to settings (⚙️) -> EVSE -> MAX CURRENT. This value is is not available in your integration. It is not the same as the pilot value since the pilot value may be changed by a manual override to a lesser value that is between 6A and this max current value. I had assumed that max_current_soft was this OpenEVSE configuration value since it comes from the get configuration API of OpenEVSE.

I hope this explains better my intent.

firstof9 commented 1 month ago

Yes that setting, when you adjust it, is reflected in sensor.openevse_current_capacity

firstof9 commented 1 month ago
{"evse_connected":1,"amp":0,"voltage":220,"power":0,"pilot":48,"max_current":48,"temp":486,"temp_max":782,"temp1":false,"temp2":486,"temp3":false,"temp4":560,"state":254,"status":"disabled","flags":512,"vehicle":0,"colour":5,"manual_override":0,"freeram":146324,"divertmode":1,"srssi":-67,"time":"2024-10-10T19:15:25Z","local_time":"2024-10-10T12:15:25-0700","offset":"-0700","uptime":5159311,"session_elapsed":0,"session_energy":0,"total_energy":20090.0096,"total_day":0,"total_week":0,"total_month":0,"total_year":2118.001411,"total_switches":1087,"elapsed":0,"wattsec":0,"watthour":2.00900096e7}
{"session_elapsed":0,"session_energy":0,"total_energy":20090.0096,"total_day":0,"total_week":0,"total_month":0,"total_year":2118.001411,"total_switches":1087}
{"divert_update":0,"grid_ie":1105}
max_current_soft changed
Flushing RAPI command queue ... Done
config_ver = 2
{"config_version":2}
{"evse_connected":1,"amp":0,"voltage":220,"power":0,"pilot":40,"max_current":40,"temp":486,"temp_max":782,"temp1":false,"temp2":486,"temp3":false,"temp4":560,"state":254,"status":"disabled","flags":512,"vehicle":0,"colour":5,"manual_override":0,"freeram":147020,"divertmode":1,"srssi":-67,"time":"2024-10-10T19:15:55Z","local_time":"2024-10-10T12:15:55-0700","offset":"-0700","uptime":5159341,"session_elapsed":0,"session_energy":0,"total_energy":20090.0096,"total_day":0,"total_week":0,"total_month":0,"total_year":2118.001411,"total_switches":1087,"elapsed":0,"wattsec":0,"watthour":2.00900096e7}
{"session_elapsed":0,"session_energy":0,"total_energy":20090.0096,"total_day":0,"total_week":0,"total_month":0,"total_year":2118.001411,"total_switches":1087}
max_current_soft changed
Flushing RAPI command queue ... Done
config_ver = 3
{"config_version":3}
{"divert_update":0,"grid_ie":433}
{"evse_connected":1,"amp":0,"voltage":220,"power":0,"pilot":48,"max_current":48,"temp":487,"temp_max":782,"temp1":false,"temp2":487,"temp3":false,"temp4":565,"state":254,"status":"disabled","flags":512,"vehicle":0,"colour":5,"manual_override":0,"freeram":138584,"divertmode":1,"srssi":-61,"time":"2024-10-10T19:17:55Z","local_time":"2024-10-10T12:17:55-0700","offset":"-0700","uptime":5159461,"session_elapsed":0,"session_energy":0,"total_energy":20090.0096,"total_day":0,"total_week":0,"total_month":0,"total_year":2118.001411,"total_switches":1087,"elapsed":0,"wattsec":0,"watthour":2.00900096e7}

Note pilot and max_current change in tandem.

jstebbins commented 1 month ago

We are talking past each other a bit here.

I don't see in your log any values for max_current_soft. All that is present is "max_current_soft changed" without any indication what it changed to.

Changing the settings value "MAX CURRENT" in the OpenEVSE will be reflected in the pilot value (a.k.a. current_capacity) if you do not also override the value with the "CHARGE RATE" option in the "CHARGE SESSION" screen. But the opposite is not true. The value of pilot (current_capacity) has no influence on the value of "MAX CURRENT" in settings. The value of "MAX CURRENT" does not change unless the user changes it directly. If you change the value of "CHARGE RATE" on the "CHARGE SESSION" screen, current_capacity changes while "MAX CURRENT" does not change.

So in summary, current_capacity in the integration can be a different value than "MAX CURRENT" in OpenEVSE settings and it is the "MAX CURRENT" value that I would like to have.

firstof9 commented 1 month ago

I see now, working on it.