thermferm/thermferm.c

changeset 293
881b1ae75468
parent 289
d810df0df36a
child 297
a70527a4e56a
--- a/thermferm/thermferm.c	Wed Oct 29 14:41:00 2014 +0100
+++ b/thermferm/thermferm.c	Wed Oct 29 20:27:37 2014 +0100
@@ -1252,6 +1252,17 @@
 		    device_out(unit->cooler_address, unit->cooler_state);
 		    device_out(unit->fan_address, unit->fan_state);
 		}
+
+		/*
+		 * Usage counters
+		 */
+		if (unit->heater_address && unit->heater_state)
+		    unit->heater_usage++;
+		if (unit->cooler_address && unit->cooler_state)
+		    unit->cooler_usage++;
+		if (unit->fan_address && unit->fan_state)
+		    unit->fan_usage++;
+
 #ifdef HAVE_WIRINGPI_H
 		if (unit->heater_address && unit->cooler_address) {
 		    piLock(LOCK_LCD);
@@ -1469,8 +1480,15 @@
 		}
 
 		minutes++;
-		if (minutes == 60)
+		if (minutes == 60) {
 		    minutes = 0;
+		    /*
+		     * Log usage counters every hour
+		     */
+		    for (unit = Config.units; unit; unit = unit->next) {
+		    	syslog(LOG_NOTICE, "Unit `%s' usage heater=%d cooler=%d fan=%d", unit->name, unit->heater_usage, unit->cooler_usage, unit->fan_usage);
+		    }
+		}
 
 		/*
 		 * Save the configuration each half hour.

mercurial