thermferm/thermferm.c

changeset 582
ba340e00aab2
parent 578
d694abd9d809
child 583
9795a16de807
--- a/thermferm/thermferm.c	Sun Mar 31 13:57:25 2019 +0200
+++ b/thermferm/thermferm.c	Sat Apr 27 15:36:16 2019 +0200
@@ -415,7 +415,7 @@
     /* Allways turn everything off after a mode change */
     current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0;
     current_unit->PID_cool->Mode = current_unit->PID_heat->Mode = PID_MODE_NONE;
-    current_unit->heater_state = current_unit->cooler_state = current_unit->fan_state = current_unit->light_state = 0;
+    current_unit->heater_state = current_unit->cooler_state = current_unit->fan_state = current_unit->light_state = current_unit->light_timer = 0;
     current_unit->heater_wait = current_unit->cooler_wait = current_unit->fan_wait = current_unit->light_wait = 0;
     device_out(current_unit->heater_address, current_unit->heater_state);
     device_out(current_unit->cooler_address, current_unit->cooler_state);
@@ -1105,7 +1105,7 @@
 	 * Safety, turn everything off
 	 */
 	unit->mqtt_flag = unit->alarm_flag = unit->alarm_last = 0;
-	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0;
+	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0;
 	unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
 	if (unit->mode == UNITMODE_PROFILE) {
 	    if (!unit->profile_uuid)
@@ -1637,7 +1637,10 @@
 		 * Interior lights
 		 */
 		if (unit->light_address) {
-		    if (unit->door_state && (unit->mode == UNITMODE_NONE) && unit->light_state) {
+		    if (unit->light_timer) {
+			unit->light_timer--;
+		    }
+		    if (unit->door_state && !unit->light_timer && unit->light_state) {
 			if (unit->light_wait > 0) {
 			    unit->light_wait--;
 			} else {
@@ -1646,7 +1649,7 @@
 			    unit->mqtt_flag |= MQTT_FLAG_DATA;
 			}
 		    }
-		    if ((!unit->door_state || (unit->mode != UNITMODE_NONE)) && !unit->light_state) {
+		    if ((!unit->door_state || unit->light_timer) && !unit->light_state) {
 			unit->light_wait = unit->light_delay;   /* No delay to turn lights on   */
 			unit->light_state = 1;
 			unit->mqtt_flag |= MQTT_FLAG_DATA;
@@ -2060,7 +2063,7 @@
 	/*
 	 * Turn everything off
 	 */
-	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0;
+	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0;
 	unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
 	device_out(unit->heater_address, unit->heater_state);
 	pub_domoticz_output(unit->heater_idx, unit->heater_state);

mercurial