diff -r c2ee7f9a069e -r ae17042a6d39 thermferm/thermferm.c --- a/thermferm/thermferm.c Wed Aug 01 22:27:58 2018 +0200 +++ b/thermferm/thermferm.c Thu Aug 02 12:20:06 2018 +0200 @@ -79,7 +79,6 @@ #endif -#ifdef HAVE_MOSQUITTO_H extern int mqtt_qos; extern int mqtt_last_mid; @@ -92,7 +91,6 @@ extern struct mosquitto *mosq; extern char *state; -#endif void help(void) @@ -1002,9 +1000,7 @@ syslog(LOG_NOTICE, "Can't lock"); return 1; } -#ifdef HAVE_MOSQUITTO_H mqtt_connect(); -#endif if ((rc = devices_detect())) { syslog(LOG_NOTICE, "Detected %d new devices", rc); @@ -1104,7 +1100,6 @@ } } printf("Units started\n"); -#ifdef HAVE_MOSQUITTO_H publishDBirthAll(); printf("Birth all done\n"); @@ -1116,7 +1111,6 @@ unit->event_msg = NULL; } } -#endif #ifdef HAVE_WIRINGPI_H piLock(LOCK_LCD); @@ -1242,9 +1236,7 @@ * update, send the NDATA message. */ if (updateHT || (now > (ndata + 300))) { -#ifdef HAVE_MOSQUITTO_H publishNData(false, 0); -#endif ndata = now; } @@ -1268,12 +1260,10 @@ deviation = 40000; if ((unit->air_temperature == 0) || (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { -#ifdef HAVE_MOSQUITTO_H if (unit->air_temperature != temp) { unit->mqtt_flag |= MQTT_FLAG_DATA; pub_domoticz_temp(unit->air_idx, temp); } -#endif unit->air_temperature = temp; unit->air_state = 0; } else { @@ -1292,12 +1282,10 @@ deviation = 40000; if ((unit->beer_temperature == 0) || (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { -#ifdef HAVE_MOSQUITTO_H if (unit->beer_temperature != temp) { unit->mqtt_flag |= MQTT_FLAG_DATA; pub_domoticz_temp(unit->beer_idx, temp); } -#endif unit->beer_temperature = temp; unit->beer_state = 0; } else { @@ -1316,12 +1304,10 @@ deviation = 40000; if ((unit->chiller_temperature == 0) || (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) { -#ifdef HAVE_MOSQUITTO_H if (unit->chiller_temperature != temp) { unit->mqtt_flag |= MQTT_FLAG_DATA; pub_domoticz_temp(unit->chiller_idx, temp); } -#endif unit->chiller_temperature = temp; unit->chiller_state = 0; } else { @@ -1344,19 +1330,15 @@ if (unit->door_state == 0) { syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); unit->door_state = 1; -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->door_idx, unit->door_state); unit->mqtt_flag |= MQTT_FLAG_DATA; -#endif } } else { if (unit->door_state) { syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); unit->door_state = 0; -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->door_idx, unit->door_state); unit->mqtt_flag |= MQTT_FLAG_DATA; -#endif } /* * If unit is active and the door is open @@ -1382,19 +1364,15 @@ if (unit->psu_state == 0) { syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); unit->psu_state = 1; -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->psu_idx, unit->psu_state); unit->mqtt_flag |= MQTT_FLAG_DATA; -#endif } } else { if (unit->psu_state) { syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias); unit->psu_state = 0; -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->psu_idx, unit->psu_state); unit->mqtt_flag |= MQTT_FLAG_DATA; -#endif } unit->alarm_flag |= ALARM_FLAG_PSU; } @@ -1749,13 +1727,11 @@ if (unit->heater_state != power) { syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); unit->heater_state = power; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } else { @@ -1765,13 +1741,11 @@ if (unit->heater_state) { syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); unit->heater_state = 0; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } @@ -1791,13 +1765,11 @@ if (unit->cooler_state != power) { syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); unit->cooler_state = power; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } else { @@ -1807,13 +1779,11 @@ if (unit->cooler_state) { syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); unit->cooler_state = 0; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } @@ -1840,13 +1810,11 @@ if (! unit->fan_state) { syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); unit->fan_state = 100; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } else { @@ -1856,13 +1824,11 @@ if (unit->fan_state) { syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); unit->fan_state = 0; -#ifdef HAVE_MOSQUITTO_H 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; } -#endif } } } @@ -1922,7 +1888,6 @@ /* * Publish MQTT messages set in flag */ -#ifdef HAVE_MOSQUITTO_H if (unit->mqtt_flag) { if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { publishDBirth(unit); @@ -1945,7 +1910,6 @@ unit->mqtt_flag &= ~MQTT_FLAG_DLOG; } } -#endif /* * Handle changed alarms @@ -2082,19 +2046,12 @@ unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0; unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; device_out(unit->heater_address, unit->heater_state); -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->heater_idx, unit->heater_state); -#endif device_out(unit->cooler_address, unit->cooler_state); -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->cooler_idx, unit->cooler_state); -#endif device_out(unit->fan_address, unit->fan_state); -#ifdef HAVE_MOSQUITTO_H pub_domoticz_output(unit->fan_idx, unit->fan_state); -#endif device_out(unit->light_address, unit->light_state); -#ifdef HAVE_MOSQUITTO_H if (unit->mode != UNITMODE_OFF) { /* * If unit ia active, publish we are dying. @@ -2107,14 +2064,11 @@ free(unit->event_msg); unit->event_msg = NULL; } -#endif syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]); } usleep(100000); -#ifdef HAVE_MOSQUITTO_H mqtt_disconnect(); -#endif syslog(LOG_NOTICE, "Out of loop");