Using on off switch to control water valve with water detection or leak

Install a virtual valve custom device driver. You can find the code for a virtual valve here:Feature Request: Virtual valve

After you install the custom driver, go to devices and add the virtual valve as a device. You now have the capability to select this valve in HSM. (i.e. have the valve turn off when HSM detects water from a sensor).

Having HSM turn off a virtual valve is obviously not enough as you need the power shut off to your actual valve so it will close. So to accomplish this make a new rule in rule machine:
Trigger: Virtual Valve Closes
Actions: Switch is turned off