Need help to program toggle switch - integration with 433Mhz hardware

This is an integration of an esp8266 and 433Mhz remote (it has two buttons on/off that need to be be toggled)
Also I have a relay that should be on when Main PW is ON and OFF when Main PW is OFF.
This code controls the 433mhz remote fine. ( The replay is just a switch in HA for now.)
Of course in HA I see to buttons Main Power ON and Main Power OFF. these will show ON for 3 sec end go OFF.
I’m wondering how to present Main power switch as one button in HA that would show ON when Main power ON ( this action will toggle GPIO4 and pull GPIO14 High) and OFF when Main power OFF (this will toggle GPIO5 and pull GPIO14 Low)
Thank you.

### Main Power  and Low pressure pump switches  

  - platform: gpio
    name: "Main PW ON"
    id: Main_Power_ON
    pin: GPIO4 # control relay
    on_turn_on:
    - delay: 3s
    - switch.turn_off: Main_Power_ON
    inverted: False

  - platform: gpio
    name: "Main PW OFF"
    id: Main_Power_OFF
    pin: GPIO5 # control relay
    on_turn_on:
    - delay: 3s
    - switch.turn_off: Main_Power_OFF
    inverted: False  
    
  - platform: gpio
    name: "Water LP relay"
    id: "Water_LP_relay"
    pin: GPIO14 # control relay
    inverted: False          
    
  ##################

Add a template switch and get rid of the names from the other switches so they won’t be exposed in HA:

  - platform: gpio
    id: Main_Power_ON
    pin: GPIO4 # control relay
    on_turn_on:
      - delay: 3s
      - switch.turn_off: Main_Power_ON
    inverted: False

  - platform: gpio
    id: Main_Power_OFF
    pin: GPIO5 # control relay
    on_turn_on:
      - delay: 3s
      - switch.turn_off: Main_Power_OFF
    inverted: False  
    
  - platform: gpio
    id: "Water_LP_relay"
    pin: GPIO14 # control relay
    inverted: False          
  
  - platform: template
    name: Master switch
    id: master_switch
    turn_on_action:
       - switch.turn_on: Main_Power_ON
       - switch.turn_on: Water_LP_relay
    turn_off_action:
       - switch.turn_off: Main_Power_OFF
       - switch.turn_off: Water_LP_relay

You write about buttons and switches.
Your yaml presents switches.
I have hard time to understand 3s on/off cycle in context of 433 remote control.

@zoogara, It was fast. Thank you. Found a typo in line, should be OFF (mentioned in case some one will try to follow this thread.
In any case. the Master switch will turn ON Main PW and Water relay fine and then will show OFF in HA GUI. I guess expected based on the code. I was hoping to see it ON when Main Power is ON. Also nothing would happen if I toggle Main Switch OFF (it will not turn off either Main power or water relay.

- switch.turn_off: Main_Power_ON

@Karosm, These 433mhz remotes have On and Off push buttons. In my case I need to push the button and hold for a second for 433Mhz receiver to take action. So I want to automate ON/OFF for the equipment controlled by receiver. The same time use second 433mhs remote to control equipment manually.
So I wired esp8266 to 433Mhz receiver: GPIO4 to ON button and GPIO5 to OFF button.

Really? Post the logs from the ESP.. EDIT: My mistake, you probably need to use optimistic mode as we aren’t setting the state explicitly. Try adding optimistic: true:

  - platform: template
    name: Master switch
    id: master_switch
    optimistic: true
    turn_on_action:
       - switch.turn_on: Main_Power_ON
       - switch.turn_on: Water_LP_relay
    turn_off_action:
       - switch.turn_on: Main_Power_OFF
       - switch.turn_off: Water_LP_relay

yes it worked. Thank you! One more thing I needed to change: from this

- switch.turn_off: Main_Power_OFF
to this
- switch.turn_on: Main_Power_OFF

Lol! At least I fixed half of it… Copy/paste error on my part.

Important part that I learn about templates. And code works. Thank you!