The STFT yields complex values. Energy conservation (up to a scaling factor) should apply to the square of its magnitude, also called spectrogram. Depending on
- the initial normalization of the FFT,
- the window shape,
- the lag (do you compute the FFT every $h$ sample, $h$ is called the hop, sometimes),
the scaling factor will differ, but will be the same for all signals.
$2$/window length is specific to a choice of the three parameters above. A scaling factor will only result in a $\log$-magnitude shift, which does not really matter for display or relative energy.
If you can compute the energy normalization based on the three parameters above, good. If not, take a randomly-picked signal (non zero), compute the ratio between the energy of the signal and that of the spectrogram, and you have your factor. Beware of the border effect, better take a centered signal with enough zeros (above the window support) on the right and the left.