You could implement a Safety Monitor driver, or an Observing Conditions driver, or both.
The detail of this really belongs on the ASCOM-Talk group.
But, as @mads0100 says, if all you want to do is close the dome just before it starts raining implementing the Boltwood one line file may be good enough.
The MLX90614 is a nice pressure sensor, I'm using one to implement a glider variometer (rate of climb meter), just lifting it off the desk gives enough pressure change to register.
Chris R