Help with pilight

I have succesfully reached to integrate HA with another Raspberrpy pi running pilight with relays conected to gpio. But this only works with “send” control, but not receiving changes in state of switch from pilight.
This is my related HA config…

pilight:
  host: 192.168.1.5
  port: 5000
  whitelist:
    protocol:
      - relay
switch:
  - platform: pilight
    switches:
      sw1_filt:
        name: Piscina filtrar
        on_code:
          protocol: relay
          'gpio': 2
          'on': 1
        off_code:
          protocol: relay
          'gpio': 2
          'off': 0
      sw2_filt_speed:
        name: Piscina vel.filtrado
        on_code:
          protocol: relay
          'gpio': 3
          'on': 1
        off_code:
          protocol: relay
          'gpio': 3
          'off': 0
        on_code_receive:
          protocol: relay
          'gpio': 3
          state: 'on'
          echo: true
        off_code_receive:
          protocol: relay
          'gpio': 3
          state: 'off'
          echo: true

The related pilight config (pilight v.8)

    "devices": {
            "sw1_filt": {
                    "protocol": [ "relay" ],
                    "id": [{
                            "gpio": 2
                    }],
                    "default-state": "off",
                    "state": "on"
            },
            "sw2_filt_speed": {
                    "protocol": [ "relay" ],
                    "id": [{
                            "gpio": 3
                    }],
                    "state": "off",
                    "default-state": "off"
            },
    "settings": {
            "port": 5000,
            "standalone": 0,
            "log-level": 6,
            "pid-file": "/var/run/pilight.pid",
            "log-file": "/var/log/pilight.log",
            "webserver-enable": 1,
            "webserver-root": "/usr/local/share/pilight/webgui",
            "webserver-http-port": 5001,
            "webserver-https-port": 5002,
            "webserver-cache": 1,
            "gpio-platform": "raspberrypi2"
    },

I have tried lots of “on_code_receive” and “off_code_receive” options, but when I change switch from pilight webgui, the state of HA switch is not updated, so seems that piligh-receive in HA dont work.

This is the output of “pilight-receive” command in the remote raspberry pi (running pilight), when I turn on - turn off one switch:
pi@rpi2:~ $ pilight-receive -F datetime,cpu_temp
{
“origin”: “sender”,
“protocol”: “relay”,
“message”: {
“gpio”: 3,
“state”: “on”
},
“repeat”: 1,
“uuid”: “0000-b8-27-eb-24787e”
}
{
“origin”: “sender”,
“protocol”: “relay”,
“message”: {
“gpio”: 3,
“state”: “off”
},
“repeat”: 1,
“uuid”: “0000-b8-27-eb-24787e”
}