diff -r 362c4700937e -r 86496d2bc4bb thermferm/thermferm.c --- a/thermferm/thermferm.c Sat Jan 19 22:07:42 2019 +0100 +++ b/thermferm/thermferm.c Sun Jan 20 13:34:09 2019 +0100 @@ -1402,6 +1402,8 @@ if (((unit->beer_temperature - unit->air_temperature) / 1000.0) < (unit->prof_peak_rel - 0.5)) { unit->prof_primary_done = time(NULL); syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (cooler mode)", unit->profile_name); + if (! unit->event_msg) + unit->event_msg = xstrcpy((char *)"Primary peak"); } } else { /* @@ -1411,6 +1413,8 @@ if ((unit->beer_temperature / 1000.0) < (unit->prof_peak_abs - 0.5)) { unit->prof_primary_done = time(NULL); syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (free rise mode)", unit->profile_name); + if (! unit->event_msg) + unit->event_msg = xstrcpy((char *)"Primary peak"); } } } @@ -1497,6 +1501,8 @@ unit->prof_percent = 100; syslog(LOG_NOTICE, "Profile `%s' is done", unit->profile_name); unit->mqtt_flag |= MQTT_FLAG_DATA; + if (! unit->event_msg) + unit->event_msg = xstrcpy((char *)"Profile finished"); } break; @@ -1685,7 +1691,6 @@ pub_domoticz_output(unit->heater_idx, unit->heater_state); if (unit->heater_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1699,7 +1704,6 @@ pub_domoticz_output(unit->heater_idx, unit->heater_state); if (unit->heater_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1723,7 +1727,6 @@ pub_domoticz_output(unit->cooler_idx, unit->cooler_state); if (unit->cooler_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1737,7 +1740,6 @@ pub_domoticz_output(unit->cooler_idx, unit->cooler_state); if (unit->cooler_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1765,7 +1767,6 @@ pub_domoticz_output(unit->fan_idx, unit->fan_state); if (unit->fan_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1779,7 +1780,6 @@ pub_domoticz_output(unit->fan_idx, unit->fan_state); if (unit->fan_address) { unit->mqtt_flag |= MQTT_FLAG_DATA; - unit->mqtt_flag |= MQTT_FLAG_DLOG; } } } @@ -1854,13 +1854,6 @@ publishDDeath(unit); unit->mqtt_flag &= ~MQTT_FLAG_DEATH; } - if (unit->mqtt_flag & MQTT_FLAG_DLOG) { - publishDLog(unit); - if (unit->event_msg) - free(unit->event_msg); - unit->event_msg = NULL; - unit->mqtt_flag &= ~MQTT_FLAG_DLOG; - } } /* @@ -1908,15 +1901,9 @@ snprintf(use_fan, 39, "NA"); snprintf(room_temp, 39, "NA"); - if (unit->mode == UNITMODE_BEER) { - snprintf(target_lo, 39, "%.1f", unit->beer_set); - snprintf(target_hi, 39, "%.1f", unit->beer_set); - } else if (unit->mode == UNITMODE_FRIDGE) { - snprintf(target_lo, 39, "%.1f", unit->fridge_set); - snprintf(target_hi, 39, "%.1f", unit->fridge_set); - } else if (unit->mode == UNITMODE_PROFILE) { - snprintf(target_lo, 39, "%.1f", unit->prof_target_lo); - snprintf(target_hi, 39, "%.1f", unit->prof_target_hi); + if ((unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_PROFILE)) { + snprintf(target_lo, 39, "%.1f", unit->PID_heat->SetP); + snprintf(target_hi, 39, "%.1f", unit->PID_cool->SetP); } if (unit->heater_address) { @@ -1950,17 +1937,15 @@ logger(filename, buf); free(filename); filename = NULL; + + publishDLog(unit); + if (unit->event_msg) + free(unit->event_msg); + unit->event_msg = NULL; } } minutes++; - if ((minutes % 5) == 0) { - for (unit = Config.units; unit; unit = unit->next) { - if (unit->mode != UNITMODE_OFF) { - unit->mqtt_flag |= MQTT_FLAG_DLOG; - } - } - } if (minutes == 60) { minutes = 0; /* @@ -2006,7 +1991,7 @@ device_out(unit->light_address, unit->light_state); if (unit->mode != UNITMODE_OFF) { /* - * If unit ia active, publish we are dying. + * If unit is active, publish we are dying. */ unit->mqtt_flag = MQTT_FLAG_DATA; publishDData(unit);