Background on how to estimate the night sky conditions

Hi all,
I’ve been using a temperature sensor in a jar for a while now and am fascinated how good this thing works. It’s really really simple…
I wonder what is the background (theory) of this measurement principle. Why is the temperature in a jar lower at clear sky? And why it gets closer at cloud cover?
I do understand how this same jar can be used as a simple solar sensor but I can’t imagine what makes such temperature difference at night.

Basically because without clouds the relatively warm sensor loses (radiates) heat to space, which is very cold, clouds are much warmer. Scientifically it’s Terrestrial Radiative Cooling, see this Wikipedia article.