thermferm/thermferm.c

changeset 557
ae17042a6d39
parent 556
c2ee7f9a069e
child 561
fcfc3dbe85fa
equal deleted inserted replaced
556:c2ee7f9a069e 557:ae17042a6d39
77 void sendRCswitch(char *, int); 77 void sendRCswitch(char *, int);
78 void stopRCswitch(void); 78 void stopRCswitch(void);
79 #endif 79 #endif
80 80
81 81
82 #ifdef HAVE_MOSQUITTO_H
83 82
84 extern int mqtt_qos; 83 extern int mqtt_qos;
85 extern int mqtt_last_mid; 84 extern int mqtt_last_mid;
86 extern int mqtt_last_mid_sent; 85 extern int mqtt_last_mid_sent;
87 extern int mqtt_mid_sent; 86 extern int mqtt_mid_sent;
90 extern int mqtt_status; 89 extern int mqtt_status;
91 extern int mqtt_use; 90 extern int mqtt_use;
92 extern struct mosquitto *mosq; 91 extern struct mosquitto *mosq;
93 extern char *state; 92 extern char *state;
94 93
95 #endif
96 94
97 95
98 void help(void) 96 void help(void)
99 { 97 {
100 fprintf(stdout, "mbsePi-apps thermferm v%s starting\n\n", VERSION); 98 fprintf(stdout, "mbsePi-apps thermferm v%s starting\n\n", VERSION);
1000 my_shutdown = my_reboot = FALSE; 998 my_shutdown = my_reboot = FALSE;
1001 if (lockprog((char *)"thermferm")) { 999 if (lockprog((char *)"thermferm")) {
1002 syslog(LOG_NOTICE, "Can't lock"); 1000 syslog(LOG_NOTICE, "Can't lock");
1003 return 1; 1001 return 1;
1004 } 1002 }
1005 #ifdef HAVE_MOSQUITTO_H
1006 mqtt_connect(); 1003 mqtt_connect();
1007 #endif
1008 1004
1009 if ((rc = devices_detect())) { 1005 if ((rc = devices_detect())) {
1010 syslog(LOG_NOTICE, "Detected %d new devices", rc); 1006 syslog(LOG_NOTICE, "Detected %d new devices", rc);
1011 wrconfig(); 1007 wrconfig();
1012 } 1008 }
1102 if (unit->mode != UNITMODE_OFF) { 1098 if (unit->mode != UNITMODE_OFF) {
1103 initlog(unit->product_code, unit->product_name); 1099 initlog(unit->product_code, unit->product_name);
1104 } 1100 }
1105 } 1101 }
1106 printf("Units started\n"); 1102 printf("Units started\n");
1107 #ifdef HAVE_MOSQUITTO_H
1108 publishDBirthAll(); 1103 publishDBirthAll();
1109 printf("Birth all done\n"); 1104 printf("Birth all done\n");
1110 1105
1111 for (unit = Config.units; unit; unit = unit->next) { 1106 for (unit = Config.units; unit; unit = unit->next) {
1112 if (unit->mode != UNITMODE_OFF) { 1107 if (unit->mode != UNITMODE_OFF) {
1114 publishDLog(unit); 1109 publishDLog(unit);
1115 free(unit->event_msg); 1110 free(unit->event_msg);
1116 unit->event_msg = NULL; 1111 unit->event_msg = NULL;
1117 } 1112 }
1118 } 1113 }
1119 #endif
1120 1114
1121 #ifdef HAVE_WIRINGPI_H 1115 #ifdef HAVE_WIRINGPI_H
1122 piLock(LOCK_LCD); 1116 piLock(LOCK_LCD);
1123 #endif 1117 #endif
1124 lcd_buf_write(1, (char *)" ThermFerm "); 1118 lcd_buf_write(1, (char *)" ThermFerm ");
1240 /* 1234 /*
1241 * If TH(B) changed. or if 5 minutes without 1235 * If TH(B) changed. or if 5 minutes without
1242 * update, send the NDATA message. 1236 * update, send the NDATA message.
1243 */ 1237 */
1244 if (updateHT || (now > (ndata + 300))) { 1238 if (updateHT || (now > (ndata + 300))) {
1245 #ifdef HAVE_MOSQUITTO_H
1246 publishNData(false, 0); 1239 publishNData(false, 0);
1247 #endif
1248 ndata = now; 1240 ndata = now;
1249 } 1241 }
1250 1242
1251 LCDunit = 0; 1243 LCDunit = 0;
1252 for (unit = Config.units; unit; unit = unit->next) { 1244 for (unit = Config.units; unit; unit = unit->next) {
1266 * Maximum error is 40 degrees for now. 1258 * Maximum error is 40 degrees for now.
1267 */ 1259 */
1268 deviation = 40000; 1260 deviation = 40000;
1269 if ((unit->air_temperature == 0) || 1261 if ((unit->air_temperature == 0) ||
1270 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { 1262 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) {
1271 #ifdef HAVE_MOSQUITTO_H
1272 if (unit->air_temperature != temp) { 1263 if (unit->air_temperature != temp) {
1273 unit->mqtt_flag |= MQTT_FLAG_DATA; 1264 unit->mqtt_flag |= MQTT_FLAG_DATA;
1274 pub_domoticz_temp(unit->air_idx, temp); 1265 pub_domoticz_temp(unit->air_idx, temp);
1275 } 1266 }
1276 #endif
1277 unit->air_temperature = temp; 1267 unit->air_temperature = temp;
1278 unit->air_state = 0; 1268 unit->air_state = 0;
1279 } else { 1269 } else {
1280 syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); 1270 syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp);
1281 } 1271 }
1290 rc = device_in(unit->beer_address, &temp); 1280 rc = device_in(unit->beer_address, &temp);
1291 if (rc == DEVPRESENT_YES) { 1281 if (rc == DEVPRESENT_YES) {
1292 deviation = 40000; 1282 deviation = 40000;
1293 if ((unit->beer_temperature == 0) || 1283 if ((unit->beer_temperature == 0) ||
1294 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { 1284 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) {
1295 #ifdef HAVE_MOSQUITTO_H
1296 if (unit->beer_temperature != temp) { 1285 if (unit->beer_temperature != temp) {
1297 unit->mqtt_flag |= MQTT_FLAG_DATA; 1286 unit->mqtt_flag |= MQTT_FLAG_DATA;
1298 pub_domoticz_temp(unit->beer_idx, temp); 1287 pub_domoticz_temp(unit->beer_idx, temp);
1299 } 1288 }
1300 #endif
1301 unit->beer_temperature = temp; 1289 unit->beer_temperature = temp;
1302 unit->beer_state = 0; 1290 unit->beer_state = 0;
1303 } else { 1291 } else {
1304 syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); 1292 syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp);
1305 } 1293 }
1314 rc = device_in(unit->chiller_address, &temp); 1302 rc = device_in(unit->chiller_address, &temp);
1315 if (rc == DEVPRESENT_YES) { 1303 if (rc == DEVPRESENT_YES) {
1316 deviation = 40000; 1304 deviation = 40000;
1317 if ((unit->chiller_temperature == 0) || 1305 if ((unit->chiller_temperature == 0) ||
1318 (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) { 1306 (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) {
1319 #ifdef HAVE_MOSQUITTO_H
1320 if (unit->chiller_temperature != temp) { 1307 if (unit->chiller_temperature != temp) {
1321 unit->mqtt_flag |= MQTT_FLAG_DATA; 1308 unit->mqtt_flag |= MQTT_FLAG_DATA;
1322 pub_domoticz_temp(unit->chiller_idx, temp); 1309 pub_domoticz_temp(unit->chiller_idx, temp);
1323 } 1310 }
1324 #endif
1325 unit->chiller_temperature = temp; 1311 unit->chiller_temperature = temp;
1326 unit->chiller_state = 0; 1312 unit->chiller_state = 0;
1327 } else { 1313 } else {
1328 syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp); 1314 syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp);
1329 } 1315 }
1342 if (rc == DEVPRESENT_YES) { 1328 if (rc == DEVPRESENT_YES) {
1343 if (temp) { 1329 if (temp) {
1344 if (unit->door_state == 0) { 1330 if (unit->door_state == 0) {
1345 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); 1331 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias);
1346 unit->door_state = 1; 1332 unit->door_state = 1;
1347 #ifdef HAVE_MOSQUITTO_H
1348 pub_domoticz_output(unit->door_idx, unit->door_state); 1333 pub_domoticz_output(unit->door_idx, unit->door_state);
1349 unit->mqtt_flag |= MQTT_FLAG_DATA; 1334 unit->mqtt_flag |= MQTT_FLAG_DATA;
1350 #endif
1351 } 1335 }
1352 } else { 1336 } else {
1353 if (unit->door_state) { 1337 if (unit->door_state) {
1354 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); 1338 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias);
1355 unit->door_state = 0; 1339 unit->door_state = 0;
1356 #ifdef HAVE_MOSQUITTO_H
1357 pub_domoticz_output(unit->door_idx, unit->door_state); 1340 pub_domoticz_output(unit->door_idx, unit->door_state);
1358 unit->mqtt_flag |= MQTT_FLAG_DATA; 1341 unit->mqtt_flag |= MQTT_FLAG_DATA;
1359 #endif
1360 } 1342 }
1361 /* 1343 /*
1362 * If unit is active and the door is open 1344 * If unit is active and the door is open
1363 */ 1345 */
1364 if (unit->mode != UNITMODE_NONE) { 1346 if (unit->mode != UNITMODE_NONE) {
1380 if (rc == DEVPRESENT_YES) { 1362 if (rc == DEVPRESENT_YES) {
1381 if (temp) { 1363 if (temp) {
1382 if (unit->psu_state == 0) { 1364 if (unit->psu_state == 0) {
1383 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); 1365 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias);
1384 unit->psu_state = 1; 1366 unit->psu_state = 1;
1385 #ifdef HAVE_MOSQUITTO_H
1386 pub_domoticz_output(unit->psu_idx, unit->psu_state); 1367 pub_domoticz_output(unit->psu_idx, unit->psu_state);
1387 unit->mqtt_flag |= MQTT_FLAG_DATA; 1368 unit->mqtt_flag |= MQTT_FLAG_DATA;
1388 #endif
1389 } 1369 }
1390 } else { 1370 } else {
1391 if (unit->psu_state) { 1371 if (unit->psu_state) {
1392 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias); 1372 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias);
1393 unit->psu_state = 0; 1373 unit->psu_state = 0;
1394 #ifdef HAVE_MOSQUITTO_H
1395 pub_domoticz_output(unit->psu_idx, unit->psu_state); 1374 pub_domoticz_output(unit->psu_idx, unit->psu_state);
1396 unit->mqtt_flag |= MQTT_FLAG_DATA; 1375 unit->mqtt_flag |= MQTT_FLAG_DATA;
1397 #endif
1398 } 1376 }
1399 unit->alarm_flag |= ALARM_FLAG_PSU; 1377 unit->alarm_flag |= ALARM_FLAG_PSU;
1400 } 1378 }
1401 } else { 1379 } else {
1402 unit->psu_state = 1; 1380 unit->psu_state = 1;
1747 } else { 1725 } else {
1748 int power = round(unit->PID_heat->OutP); 1726 int power = round(unit->PID_heat->OutP);
1749 if (unit->heater_state != power) { 1727 if (unit->heater_state != power) {
1750 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); 1728 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power);
1751 unit->heater_state = power; 1729 unit->heater_state = power;
1752 #ifdef HAVE_MOSQUITTO_H
1753 pub_domoticz_output(unit->heater_idx, unit->heater_state); 1730 pub_domoticz_output(unit->heater_idx, unit->heater_state);
1754 if (unit->heater_address) { 1731 if (unit->heater_address) {
1755 unit->mqtt_flag |= MQTT_FLAG_DATA; 1732 unit->mqtt_flag |= MQTT_FLAG_DATA;
1756 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1733 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1757 } 1734 }
1758 #endif
1759 } 1735 }
1760 } 1736 }
1761 } else { 1737 } else {
1762 if (unit->heater_wait > 0) { 1738 if (unit->heater_wait > 0) {
1763 unit->heater_wait--; 1739 unit->heater_wait--;
1764 } else { 1740 } else {
1765 if (unit->heater_state) { 1741 if (unit->heater_state) {
1766 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); 1742 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias);
1767 unit->heater_state = 0; 1743 unit->heater_state = 0;
1768 #ifdef HAVE_MOSQUITTO_H
1769 pub_domoticz_output(unit->heater_idx, unit->heater_state); 1744 pub_domoticz_output(unit->heater_idx, unit->heater_state);
1770 if (unit->heater_address) { 1745 if (unit->heater_address) {
1771 unit->mqtt_flag |= MQTT_FLAG_DATA; 1746 unit->mqtt_flag |= MQTT_FLAG_DATA;
1772 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1747 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1773 } 1748 }
1774 #endif
1775 } 1749 }
1776 } 1750 }
1777 } 1751 }
1778 if (unit->door_state) { 1752 if (unit->door_state) {
1779 device_out(unit->heater_address, unit->heater_state); 1753 device_out(unit->heater_address, unit->heater_state);
1789 } else { 1763 } else {
1790 int power = round(unit->PID_cool->OutP); 1764 int power = round(unit->PID_cool->OutP);
1791 if (unit->cooler_state != power) { 1765 if (unit->cooler_state != power) {
1792 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); 1766 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power);
1793 unit->cooler_state = power; 1767 unit->cooler_state = power;
1794 #ifdef HAVE_MOSQUITTO_H
1795 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); 1768 pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
1796 if (unit->cooler_address) { 1769 if (unit->cooler_address) {
1797 unit->mqtt_flag |= MQTT_FLAG_DATA; 1770 unit->mqtt_flag |= MQTT_FLAG_DATA;
1798 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1771 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1799 } 1772 }
1800 #endif
1801 } 1773 }
1802 } 1774 }
1803 } else { 1775 } else {
1804 if (unit->cooler_wait > 0) { 1776 if (unit->cooler_wait > 0) {
1805 unit->cooler_wait--; 1777 unit->cooler_wait--;
1806 } else { 1778 } else {
1807 if (unit->cooler_state) { 1779 if (unit->cooler_state) {
1808 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); 1780 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias);
1809 unit->cooler_state = 0; 1781 unit->cooler_state = 0;
1810 #ifdef HAVE_MOSQUITTO_H
1811 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); 1782 pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
1812 if (unit->cooler_address) { 1783 if (unit->cooler_address) {
1813 unit->mqtt_flag |= MQTT_FLAG_DATA; 1784 unit->mqtt_flag |= MQTT_FLAG_DATA;
1814 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1785 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1815 } 1786 }
1816 #endif
1817 } 1787 }
1818 } 1788 }
1819 } 1789 }
1820 if (unit->door_state) { 1790 if (unit->door_state) {
1821 device_out(unit->cooler_address, unit->cooler_state); 1791 device_out(unit->cooler_address, unit->cooler_state);
1838 unit->fan_wait++; 1808 unit->fan_wait++;
1839 } else { 1809 } else {
1840 if (! unit->fan_state) { 1810 if (! unit->fan_state) {
1841 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); 1811 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias);
1842 unit->fan_state = 100; 1812 unit->fan_state = 100;
1843 #ifdef HAVE_MOSQUITTO_H
1844 pub_domoticz_output(unit->fan_idx, unit->fan_state); 1813 pub_domoticz_output(unit->fan_idx, unit->fan_state);
1845 if (unit->fan_address) { 1814 if (unit->fan_address) {
1846 unit->mqtt_flag |= MQTT_FLAG_DATA; 1815 unit->mqtt_flag |= MQTT_FLAG_DATA;
1847 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1816 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1848 } 1817 }
1849 #endif
1850 } 1818 }
1851 } 1819 }
1852 } else { 1820 } else {
1853 if (unit->fan_wait > 0) { 1821 if (unit->fan_wait > 0) {
1854 unit->fan_wait--; 1822 unit->fan_wait--;
1855 } else { 1823 } else {
1856 if (unit->fan_state) { 1824 if (unit->fan_state) {
1857 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); 1825 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias);
1858 unit->fan_state = 0; 1826 unit->fan_state = 0;
1859 #ifdef HAVE_MOSQUITTO_H
1860 pub_domoticz_output(unit->fan_idx, unit->fan_state); 1827 pub_domoticz_output(unit->fan_idx, unit->fan_state);
1861 if (unit->fan_address) { 1828 if (unit->fan_address) {
1862 unit->mqtt_flag |= MQTT_FLAG_DATA; 1829 unit->mqtt_flag |= MQTT_FLAG_DATA;
1863 unit->mqtt_flag |= MQTT_FLAG_DLOG; 1830 unit->mqtt_flag |= MQTT_FLAG_DLOG;
1864 } 1831 }
1865 #endif
1866 } 1832 }
1867 } 1833 }
1868 } 1834 }
1869 device_out(unit->fan_address, unit->fan_state); 1835 device_out(unit->fan_address, unit->fan_state);
1870 } 1836 }
1920 #endif 1886 #endif
1921 1887
1922 /* 1888 /*
1923 * Publish MQTT messages set in flag 1889 * Publish MQTT messages set in flag
1924 */ 1890 */
1925 #ifdef HAVE_MOSQUITTO_H
1926 if (unit->mqtt_flag) { 1891 if (unit->mqtt_flag) {
1927 if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { 1892 if (unit->mqtt_flag & MQTT_FLAG_BIRTH) {
1928 publishDBirth(unit); 1893 publishDBirth(unit);
1929 unit->mqtt_flag &= ~MQTT_FLAG_BIRTH; 1894 unit->mqtt_flag &= ~MQTT_FLAG_BIRTH;
1930 } else { 1895 } else {
1943 free(unit->event_msg); 1908 free(unit->event_msg);
1944 unit->event_msg = NULL; 1909 unit->event_msg = NULL;
1945 unit->mqtt_flag &= ~MQTT_FLAG_DLOG; 1910 unit->mqtt_flag &= ~MQTT_FLAG_DLOG;
1946 } 1911 }
1947 } 1912 }
1948 #endif
1949 1913
1950 /* 1914 /*
1951 * Handle changed alarms 1915 * Handle changed alarms
1952 */ 1916 */
1953 if (unit->alarm_flag != unit->alarm_last) { 1917 if (unit->alarm_flag != unit->alarm_last) {
2080 * Turn everything off 2044 * Turn everything off
2081 */ 2045 */
2082 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0; 2046 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0;
2083 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 2047 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
2084 device_out(unit->heater_address, unit->heater_state); 2048 device_out(unit->heater_address, unit->heater_state);
2085 #ifdef HAVE_MOSQUITTO_H
2086 pub_domoticz_output(unit->heater_idx, unit->heater_state); 2049 pub_domoticz_output(unit->heater_idx, unit->heater_state);
2087 #endif
2088 device_out(unit->cooler_address, unit->cooler_state); 2050 device_out(unit->cooler_address, unit->cooler_state);
2089 #ifdef HAVE_MOSQUITTO_H
2090 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); 2051 pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
2091 #endif
2092 device_out(unit->fan_address, unit->fan_state); 2052 device_out(unit->fan_address, unit->fan_state);
2093 #ifdef HAVE_MOSQUITTO_H
2094 pub_domoticz_output(unit->fan_idx, unit->fan_state); 2053 pub_domoticz_output(unit->fan_idx, unit->fan_state);
2095 #endif
2096 device_out(unit->light_address, unit->light_state); 2054 device_out(unit->light_address, unit->light_state);
2097 #ifdef HAVE_MOSQUITTO_H
2098 if (unit->mode != UNITMODE_OFF) { 2055 if (unit->mode != UNITMODE_OFF) {
2099 /* 2056 /*
2100 * If unit ia active, publish we are dying. 2057 * If unit ia active, publish we are dying.
2101 */ 2058 */
2102 unit->mqtt_flag = MQTT_FLAG_DATA; 2059 unit->mqtt_flag = MQTT_FLAG_DATA;
2105 unit->event_msg = xstrcpy((char *)"Shutdown"); 2062 unit->event_msg = xstrcpy((char *)"Shutdown");
2106 publishDLog(unit); 2063 publishDLog(unit);
2107 free(unit->event_msg); 2064 free(unit->event_msg);
2108 unit->event_msg = NULL; 2065 unit->event_msg = NULL;
2109 } 2066 }
2110 #endif
2111 syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]); 2067 syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]);
2112 } 2068 }
2113 2069
2114 usleep(100000); 2070 usleep(100000);
2115 #ifdef HAVE_MOSQUITTO_H
2116 mqtt_disconnect(); 2071 mqtt_disconnect();
2117 #endif
2118 2072
2119 syslog(LOG_NOTICE, "Out of loop"); 2073 syslog(LOG_NOTICE, "Out of loop");
2120 2074
2121 /* 2075 /*
2122 * Give threads time to cleanup 2076 * Give threads time to cleanup

mercurial