diff -r b56988cc516b -r ba340e00aab2 thermferm/mqtt.c --- a/thermferm/mqtt.c Sun Mar 31 13:57:25 2019 +0200 +++ b/thermferm/mqtt.c Sat Apr 27 15:36:16 2019 +0200 @@ -257,7 +257,7 @@ /* Allways turn everything off after a mode change */ unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; - unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = 0; + unit->heater_state = unit->cooler_state = unit->fan_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); device_out(unit->cooler_address, unit->cooler_state); @@ -336,12 +336,16 @@ } } - if ((json_object_object_get_ex(metric, "light", &setpoint)) && (unit->mode == UNITMODE_NONE)) { + if (json_object_object_get_ex(metric, "light", &setpoint)) { if (json_object_object_get_ex(setpoint, "state", &val)) { - if (json_object_get_int(val) != unit->light_state) { - unit->light_state = json_object_get_int(val); - unit->mqtt_flag |= MQTT_FLAG_DATA; - syslog(LOG_NOTICE, "DCMD change fermenter %s: light_state to %d", message_alias, unit->light_state); + if (json_object_get_int(val) > 0) { + unit->light_timer = 300; // 5 minutes + syslog(LOG_NOTICE, "DCMD set fermenter %s: light_timer 300", message_alias); + if (!unit->light_state) { + unit->light_state = 1; + unit->mqtt_flag |= MQTT_FLAG_DATA; + syslog(LOG_NOTICE, "DCMD change fermenter %s: light_state to %d", message_alias, unit->light_state); + } } } }