Irrigation system with olimex esp32-poe with waterproof ultrasonic sensor and 2 sonoff

Hello I am just starting with my first project with esp32 and need some advice. It is all very new for me. Hope you can help me. I am trying to build automatic irrigation system for a small garden. We have here a water tank for rain water (7 m deep) and water tap. I would like to place ultrasonic sensor in the water tank - got for this olimex esp32-poe with waterproof ultrasonic sensor. Also I have a RainMachine Mini 8. My plan is to some how use 24V from master valve of RainMachine as a input for signal for esp32-poe with waterproof ultrasonic sensor . Once RainMachine starts irrigation this signal should tell esp32-poe with ultrasonic sensor to check water level in the tank. If it is 2 or more meters esp32-poe should command sonoff -1 to power on the pump in the water tank . If it is less than 2 meters esp32-poe should command sonoff -2 to open valve of the water tap. I hope somebody can help me and point me into right direction how I can use 24V from master valve of RainMachine as a input for signal and how I can connect outputs from esp32-poe to sonoff-1 and sonoff-2 to switch them on or off. At the moment I got esp32-poe with waterproof ultrasonic sensor working and getting measurements from sensor. Also I am using Home Assistant but as I wrote I am just starting with esp32 :). Thx & Regards

Wouldn’t you be better to start with incorporating rain machine with home assistant?