Rpi_rf push button

Hello. I have been using a modified version of the rpi_rf with the intent of simulating a push button (which homeassistant lacks) with great results so I thought of sharing the idea for others to benefit too.
To achieve the push button effect I modified the code to return False when a turn_on command is sent. This way homeassistant believe that the command was not successful and returns the switch back to off possition.

This is done in the file /root/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/rpi_rf/switch.py towards the end:

def turn_on(self, **kwargs):
    """Turn the switch on."""
    if self._send_code(self._code_on, self._protocol, self._pulselength):
        self._state = False

In addition to that change, I have added the following small piece of code to the file /root/srv/homeassistant/lib/python3.5/site-packages/rpi_rf/rpi_rf.py
where the routine tx_code is defined:

if code == 0:
    return True

(actually that change is my modified copy located in the custom_components folder)

That is necessary because now that the switches are working as push buttons then there is no need for a turn_off code (I have defined all my turn_off codes as 0), so I want no action there.

This is an actual example I’m using:

    rf_ch_a_3_on:
      protocol: 8
      code_on: 31418347
      code_off: 0
      signal_repetitions: 3
    rf_ch_a_3_off:
      protocol: 8
      code_on: 48195563
      code_off: 0

The only issue is every time I update homeassistant I have to go an edit the file to add the “False” statement back since it gets overwritten with the original version.

It would be great if someone could
update this rpi_rf module to add an optional parameter to set this “push button” mode on.

Sorry for being this cryptic, and the lack of formatting. Hope this helps the 315/433 MHz enthusiasts.