Thermostat for solenoid valve