Was not excluding inactive thermostats which caused a count to be 0 which caused a number to be divided by 0.