Pilight and multiple quick code matches SOLVED

I can see that pilight is capable of sensing that I’m holding in a button on a remote by creating multiple “hits” when I look at the output from pilight-receive. It can produce several “hits” per second. I would like to use this fact in order to create an automation that can do different things depending on how long the button has been pressed (dimming a light for a long press and toggle it off or on with a short press). The problem is when I use the pilight addon in HA those multiple “hits” in quick succession turn in to single “hits” with several seconds in between. I think this is by design in order not to spam the event bus:

In pylight.py it says:

def _handle_code(self, call):
    """Check if received code by the pilight-daemon.

    If the code matches the receive on/off codes of this switch the switch
    state is changed accordingly.
    """
    # - True if off_code/on_code is contained in received code dict, not
    #   all items have to match.
    # - Call turn on/off only once, even if more than one code is received
    if any(self._code_on_receive):
        for on_code in self._code_on_receive:
            if on_code.match(call.data):
                on_code.run(switch=self, turn_on=True)
                break

    if any(self._code_off_receive):
        for off_code in self._code_off_receive:
            if off_code.match(call.data):
                off_code.run(switch=self, turn_on=False)
                break

I’m not skilled enough to alter this, so I’m need of some assistance. How do I remove or improve the spam filter the pilight addon uses?

I found the solution. I was looking in the wrong file. Changing veto_repeats=True to False in site-packages/pilight/pilight.py did the trick.

@DavidLP Would it be possible to expose the veto_repeat option so that you could set it in the HA configuration.yaml file?

Simply exposing this option is possible, but would create issues since most senders send their code multiple times per second. But you do not want to call device functions multiple times per second… This means that such a feature has to differentiate the device type and this makes it complex. I have no time to implement this, maybe you want to try?

I would like to try, I just don’t have the know how to pull it off. :slight_smile:

I realize that me just suggesting to implementing something, all the while not really understanding how much time and effort is involved in doing that, can come across in a way I do not intend.

But if you don’t mind me asking, why can’t it just be an optional option (that most would not use) that defaults to True, just like host and port also are optional with default values?