SmartEVSE / SmartEVSE-3

Smart Electric Vehicle Charging Station (EVSE)
MIT License
128 stars 87 forks source link

Similar commands for Curl and MQTT #65

Open HeinvdW opened 1 month ago

HeinvdW commented 1 month ago

The commands in the MQTT API and the PEST API are not similar void mqtt_receive_callback(const String topic, const String payload) { if (topic == MQTTprefix + "/Set/Mode") { if (payload == "Off") { ToModemWaitStateTimer = 0; ToModemDoneStateTimer = 0; LeaveModemDoneStateTimer = 0; setAccess(0); } else if (payload == "Normal") { setMode(MODE_NORMAL); } else if (payload == "Solar") { OverrideCurrent = 0; setMode(MODE_SOLAR); } else if (payload == "Smart") { OverrideCurrent = 0; setMode(MODE_SMART); } For mode setting Curl expects 0, 1, 2 or 3 and MQTT expects Off, Normal, Solar or Smart I suggest to add some code like shown hereafter. void mqtt_receive_callback(const String topic, const String payload) { if (topic == MQTTprefix + "/Set/Mode") { if (payload == "Off" | payload == 0) { ToModemWaitStateTimer = 0; ToModemDoneStateTimer = 0; LeaveModemDoneStateTimer = 0; setAccess(0); } else if (payload == "Normal" | payload == 1) { setMode(MODE_NORMAL); } else if (payload == "Solar" | payload == 2) { OverrideCurrent = 0; setMode(MODE_SOLAR); } else if (payload == "Smart" | payload == 3) { OverrideCurrent = 0; setMode(MODE_SMART); } In the documentation just 0, 1, 2 and 3 are described.

Same goes for ip-of-evse/settings - override_current Curl command - override_current MQTT command - CurrentOverride mosquitto_sub returns - ChargeCurrentOverride By adding some ' | ' here and there the naming could get more consistent and can be reflected like that in the docs without having to change the code heavily.