New sensor proposition ZsensorGPIOMultiInput


I am new on this forum sorry if I do something wrong in this topic.

So I am building an openmqttgateway, and I would like to make something original with it. I would like it to be a decorative object and behave like a kind of controll pannel.

So I needed a simple way to connect multiple buttons. After looking at the code I haven’t found anything matching with my needs. I wanted something like GpioInputSensor but with up to 8 buttons.

So I decided to code my own senser ZsensorGPIOMultiInput wich behave like ZsensorGPIOInput but can manage up to 8 buttons.

Yesterday I tested all my code and everythings works pretty good.

So my questions are: Why is there nothing like this is in current code? Should I propose my code to review or is there a reason why it does not exist?

Thank you !

Hi @Akrobate,

this sounds very interesting.

Ideally this could be all merged into the original ZsensorGPIOInput, allowing 1-8 GPIO Inputs.

You might be the first to want such a use case :slight_smile: and please do propose a PR on GitHub with your changes for review.

Thanks for this!


Thank you for your answer,

I have just made a PR on the repository.

I decided to not enrich this existing sensor because of a specific behavour of the button

I don’t wanted to interfer with this:

    if (reading == LOW) {
      if (resetTime == 0) {
        resetTime = millis();
      } else if ((millis() - resetTime) > 10000) {
        Log.trace(F("Button Held" CR));
        Log.notice(F("Erasing ESP Config, restarting" CR));
    } else {
      resetTime = 0;
#  endif

And also I will maybe implement specific behaviour to publish message on long press on each of my inputs

1 Like

Thanks for the PR,

This is used to reset ESP flash in case of bad credentials.

Maybe we could differentiate 3 types of press depending on length, or you could publish the press duration to have the logic at the controller level.

I think it would help to merge the code of those 2 sensor GPIO inputs.