Help with automation script based on TH16 temperature sensors

Hello,
I need assistance with building an automation script based on 2 TH16 temperature sensors.
first sensor connected to a water pipe heating water inside a solar boiler, the second one connected to a water pipe leaving the solar boiler. The script should trigger when the first sensor temperature is lower than the second sensor temperature - it should go to state ON to block coming water by using electric water tap connected to the water pipe.
Very appriciate any assistant with this script.