403 void change_mode(int mode) |
403 void change_mode(int mode) |
404 { |
404 { |
405 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
405 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
406 if ((current_unit->mode == UNITMODE_OFF) && (mode != UNITMODE_OFF)) { |
406 if ((current_unit->mode == UNITMODE_OFF) && (mode != UNITMODE_OFF)) { |
407 current_unit->mqtt_flag |= MQTT_FLAG_BIRTH; |
407 current_unit->mqtt_flag |= MQTT_FLAG_BIRTH; |
408 } else if ((current_unit->mode != UNITMODE_OFF) && (mode == UNITMODE_OFF)) { |
|
409 current_unit->mqtt_flag |= MQTT_FLAG_DEATH; |
|
410 } |
408 } |
411 syslog(LOG_NOTICE, "Mode from %s to %s via panel interface", UNITMODE[current_unit->mode], UNITMODE[mode]); |
409 syslog(LOG_NOTICE, "Mode from %s to %s via panel interface", UNITMODE[current_unit->mode], UNITMODE[mode]); |
412 current_unit->mode = mode; |
410 current_unit->mode = mode; |
413 /* Allways turn everything off after a mode change */ |
411 /* Allways turn everything off after a mode change */ |
414 current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0; |
412 current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0; |