The official Wiki for CompanionPI shows several methods for getting Raspberry Pi IP address.
Here is another approach. Making use of Sctream Deck as screen. You need to previously create 4 buttons in page 1. The script will will display the IP address in the first 4 buttons of Stream Deck
import socket