Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ESP32 gpio available to MQTT #77

Closed
Zuikkis opened this issue May 14, 2020 · 5 comments
Closed

Make ESP32 gpio available to MQTT #77

Zuikkis opened this issue May 14, 2020 · 5 comments

Comments

@Zuikkis
Copy link

Zuikkis commented May 14, 2020

Hi,

small "feature request".. I have a Raspberry Pi running Domoticz home automation. I'd like to have a few buttons on the OpenEVSE box, which would just signal Domoticz to do stuff.

There's plenty of free GPIO pins on the esp32. If I wire buttons to those, is there any way to read them remotely? Ideal would be if any change of state would send MQTT message.

@glynhudson
Copy link
Collaborator

This is possible, you would just need to add the code to read from the button and post the MQTT. There are plenty of esp code examples for how to do this. Since this is a niche use case I'm afraid this is not a priority feature for us to add. But feel free to customise your own unit.

@Zuikkis
Copy link
Author

Zuikkis commented May 14, 2020

Oh! I don't think I bother. I'll just install some Sonoff Tasmota box next to OpenEVSE and read the button from there..

What I really wanted though, some super easy way to set different charging modes:

  1. Need car later today: NORMAL mode with full power
  2. Need car tomorrow: ECO mode + timer enabled for next night
  3. Need car several days later: ECO mode + timer disabled

I kinda thought the included OpenEVSE button would do something like this, but it seems to be for something else. :)

@glynhudson
Copy link
Collaborator

The charging mode can be set via MQTT, {base-topic}/divertmode/set (1 = normal, 2 = eco).

We have an update for Eco+ mode which will pause the charging when solar PV stops generating below a certian level coming soon, see #54

@Zuikkis
Copy link
Author

Zuikkis commented May 15, 2020

Yeah, the updated Eco+ mode was the reason I bought OpenEVSE. :)

Setting the charging mode through MQTT is easy, but I'd like to be able to do it easily using the button on the EVSE itself.

@Zuikkis
Copy link
Author

Zuikkis commented May 16, 2020

Turns out this was far easier to add than I thought. One line added to src/net_manager.cpp, near line 454:

  if(wifiButtonState != button)
  {
    wifiButtonState = button;
    if(WIFI_BUTTON_PRESSED_STATE == button) {
      DBUGF("Button pressed");
      wifiButtonTimeOut = millis();
      apMessage = false;
    } else {
      DBUGF("Button released");
      if(millis() > wifiButtonTimeOut + WIFI_BUTTON_AP_TIMEOUT) {
        startAP();
      } else {
        if (config_mqtt_enabled()) mqtt_publish(F("button:1"));  // ** Added this line
//        display_state();                                       // **Removed this line
      }
    }
  }

Now when I press the button on wifi module, I correctly get "openevse/button/1" mqtt message. :)

I commented out the "display_state()" as I plan to send out lcd RAPI commands from Domoticz, when pressing the button. So they would interfere probably..

Other functionality of the button is still preserved. I think it's actually quite convenient to have this button external to the box, then you can start AP mode or factory reset easily if there are problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants