Are you using ESPhome for the D1?
You could definitely use an automation to do what you are asking. It could also be done purely on the D1 but going via HA will be better for being able to adjust the run time of the sprinkler via the GUI
Whoa back up! The HLK is NOT safe without a fuse and some other protection! There is a long discussion here https://forum.mysensors.org/topic/1607/safe-in-wall-ac-to-dc-transformers/335
IMHO you are far better to use a meanwell, which has the protections built in. eg https://www.amazon.com/Industrial-IRM-03-5-MEAN-WELL-Switching/dp/B07CQVNGTY/
I had the same issue and fixed it in about an hour using the Lutron Caseta switch and itβs remote. There is a remote holder which attaches to the wall (no hole) and looks just like a switch when done. Lutron Caseta does not require a neutral. Now it was pricy (maybe $70 for the switch, remote and the remote holder) and to use it with any other smart things requires a bridge (either Lutron or Wink). But it was high quality and it just worked and has worked well since.