255 if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg) |
255 if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg) |
256 unit->event_msg = xstrcpy((char *)UNITMODE[i]); |
256 unit->event_msg = xstrcpy((char *)UNITMODE[i]); |
257 /* Allways turn everything off after a mode change */ |
257 /* Allways turn everything off after a mode change */ |
258 unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; |
258 unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; |
259 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
259 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
260 unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = 0; |
260 unit->heater_state = unit->cooler_state = unit->fan_state = unit->light_state = unit->light_timer = 0; |
261 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
261 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
262 device_out(unit->heater_address, unit->heater_state); |
262 device_out(unit->heater_address, unit->heater_state); |
263 device_out(unit->cooler_address, unit->cooler_state); |
263 device_out(unit->cooler_address, unit->cooler_state); |
264 device_out(unit->fan_address, unit->fan_state); |
264 device_out(unit->fan_address, unit->fan_state); |
265 device_out(unit->light_address, unit->light_state); |
265 device_out(unit->light_address, unit->light_state); |
334 syslog(LOG_NOTICE, "DCMD change fermenter %s: fan_state to %d", message_alias, unit->fan_state); |
334 syslog(LOG_NOTICE, "DCMD change fermenter %s: fan_state to %d", message_alias, unit->fan_state); |
335 } |
335 } |
336 } |
336 } |
337 } |
337 } |
338 |
338 |
339 if ((json_object_object_get_ex(metric, "light", &setpoint)) && (unit->mode == UNITMODE_NONE)) { |
339 if (json_object_object_get_ex(metric, "light", &setpoint)) { |
340 if (json_object_object_get_ex(setpoint, "state", &val)) { |
340 if (json_object_object_get_ex(setpoint, "state", &val)) { |
341 if (json_object_get_int(val) != unit->light_state) { |
341 if (json_object_get_int(val) > 0) { |
342 unit->light_state = json_object_get_int(val); |
342 unit->light_timer = 300; // 5 minutes |
343 unit->mqtt_flag |= MQTT_FLAG_DATA; |
343 syslog(LOG_NOTICE, "DCMD set fermenter %s: light_timer 300", message_alias); |
344 syslog(LOG_NOTICE, "DCMD change fermenter %s: light_state to %d", message_alias, unit->light_state); |
344 if (!unit->light_state) { |
|
345 unit->light_state = 1; |
|
346 unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
347 syslog(LOG_NOTICE, "DCMD change fermenter %s: light_state to %d", message_alias, unit->light_state); |
|
348 } |
345 } |
349 } |
346 } |
350 } |
347 } |
351 } |
348 |
352 |
349 if ((json_object_object_get_ex(metric, "product", &setpoint)) && (unit->mode == UNITMODE_OFF)) { |
353 if ((json_object_object_get_ex(metric, "product", &setpoint)) && (unit->mode == UNITMODE_OFF)) { |