Just to help clarify and hopefully not confuse! There are basically two types of 3 port diverting valves - Spring return, these have a neutral and switched live, which switches the valve to the DHW position, then the spring returns it back to the HTG position when switched off. The other type is a MOMO valve (motor on/motor off), these have a neutral and two live wires and could be either 2-point or 3-point controlled. The 2-point has one switched and one permanent live, the switched live will generally be used to move the valve to the DHW position and the permanent live will return it to the HTG position. The 3-point has two switched lives, one for the DHW position and the other for HTG position. In all of the above the optoisolated 240V sensor would be connected to the neutral and DHW switched live. As Glyn said it’s probably been connected incorrectly!