1269 if (unit->air_address) { |
1269 if (unit->air_address) { |
1270 rc = device_in(unit->air_address, &temp); |
1270 rc = device_in(unit->air_address, &temp); |
1271 if (rc == DEVPRESENT_YES) { |
1271 if (rc == DEVPRESENT_YES) { |
1272 if (unit->air_temperature != temp) { |
1272 if (unit->air_temperature != temp) { |
1273 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1273 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1274 pub_domoticz_temp(unit->air_idx, temp); |
1274 // pub_domoticz_temp(unit->air_idx, temp); |
1275 } |
1275 } |
1276 unit->air_temperature = temp; |
1276 unit->air_temperature = temp; |
1277 unit->air_state = 0; |
1277 unit->air_state = 0; |
1278 } else if (rc == DEVPRESENT_ERROR) { |
1278 } else if (rc == DEVPRESENT_ERROR) { |
1279 unit->air_state = 1; |
1279 unit->air_state = 1; |
1285 if (unit->beer_address) { |
1285 if (unit->beer_address) { |
1286 rc = device_in(unit->beer_address, &temp); |
1286 rc = device_in(unit->beer_address, &temp); |
1287 if (rc == DEVPRESENT_YES) { |
1287 if (rc == DEVPRESENT_YES) { |
1288 if (unit->beer_temperature != temp) { |
1288 if (unit->beer_temperature != temp) { |
1289 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1289 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1290 pub_domoticz_temp(unit->beer_idx, temp); |
1290 // pub_domoticz_temp(unit->beer_idx, temp); |
1291 } |
1291 } |
1292 unit->beer_temperature = temp; |
1292 unit->beer_temperature = temp; |
1293 unit->beer_state = 0; |
1293 unit->beer_state = 0; |
1294 } else if (rc == DEVPRESENT_ERROR) { |
1294 } else if (rc == DEVPRESENT_ERROR) { |
1295 unit->beer_state = 1; |
1295 unit->beer_state = 1; |
1301 if (unit->chiller_address) { |
1301 if (unit->chiller_address) { |
1302 rc = device_in(unit->chiller_address, &temp); |
1302 rc = device_in(unit->chiller_address, &temp); |
1303 if (rc == DEVPRESENT_YES) { |
1303 if (rc == DEVPRESENT_YES) { |
1304 if (unit->chiller_temperature != temp) { |
1304 if (unit->chiller_temperature != temp) { |
1305 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1305 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1306 pub_domoticz_temp(unit->chiller_idx, temp); |
1306 // pub_domoticz_temp(unit->chiller_idx, temp); |
1307 } |
1307 } |
1308 unit->chiller_temperature = temp; |
1308 unit->chiller_temperature = temp; |
1309 unit->chiller_state = 0; |
1309 unit->chiller_state = 0; |
1310 } else if (rc == DEVPRESENT_ERROR) { |
1310 } else if (rc == DEVPRESENT_ERROR) { |
1311 unit->chiller_state = 1; |
1311 unit->chiller_state = 1; |
1322 if (rc == DEVPRESENT_YES) { |
1322 if (rc == DEVPRESENT_YES) { |
1323 if (temp) { |
1323 if (temp) { |
1324 if (unit->door_state == 0) { |
1324 if (unit->door_state == 0) { |
1325 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); |
1325 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); |
1326 unit->door_state = 1; |
1326 unit->door_state = 1; |
1327 pub_domoticz_output(unit->door_idx, unit->door_state); |
1327 // pub_domoticz_output(unit->door_idx, unit->door_state); |
1328 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1328 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1329 } |
1329 } |
1330 } else { |
1330 } else { |
1331 if (unit->door_state) { |
1331 if (unit->door_state) { |
1332 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); |
1332 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); |
1333 unit->door_state = 0; |
1333 unit->door_state = 0; |
1334 pub_domoticz_output(unit->door_idx, unit->door_state); |
1334 // pub_domoticz_output(unit->door_idx, unit->door_state); |
1335 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1335 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1336 } |
1336 } |
1337 /* |
1337 /* |
1338 * If unit is active and the door is open |
1338 * If unit is active and the door is open |
1339 */ |
1339 */ |
1356 if (rc == DEVPRESENT_YES) { |
1356 if (rc == DEVPRESENT_YES) { |
1357 if (temp) { |
1357 if (temp) { |
1358 if (unit->psu_state == 0) { |
1358 if (unit->psu_state == 0) { |
1359 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); |
1359 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); |
1360 unit->psu_state = 1; |
1360 unit->psu_state = 1; |
1361 pub_domoticz_output(unit->psu_idx, unit->psu_state); |
1361 // pub_domoticz_output(unit->psu_idx, unit->psu_state); |
1362 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1362 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1363 } |
1363 } |
1364 } else { |
1364 } else { |
1365 if (unit->psu_state) { |
1365 if (unit->psu_state) { |
1366 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias); |
1366 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias); |
1367 unit->psu_state = 0; |
1367 unit->psu_state = 0; |
1368 pub_domoticz_output(unit->psu_idx, unit->psu_state); |
1368 // pub_domoticz_output(unit->psu_idx, unit->psu_state); |
1369 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1369 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1370 } |
1370 } |
1371 unit->alarm_flag |= ALARM_FLAG_PSU; |
1371 unit->alarm_flag |= ALARM_FLAG_PSU; |
1372 } |
1372 } |
1373 } else { |
1373 } else { |
1708 } else { |
1708 } else { |
1709 int power = round(unit->PID_heat->OutP); |
1709 int power = round(unit->PID_heat->OutP); |
1710 if (unit->heater_state != power) { |
1710 if (unit->heater_state != power) { |
1711 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); |
1711 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); |
1712 unit->heater_state = power; |
1712 unit->heater_state = power; |
1713 pub_domoticz_output(unit->heater_idx, unit->heater_state); |
1713 // pub_domoticz_output(unit->heater_idx, unit->heater_state); |
1714 if (unit->heater_address) { |
1714 if (unit->heater_address) { |
1715 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1715 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1716 } |
1716 } |
1717 } |
1717 } |
1718 } |
1718 } |
1721 unit->heater_wait--; |
1721 unit->heater_wait--; |
1722 } else { |
1722 } else { |
1723 if (unit->heater_state) { |
1723 if (unit->heater_state) { |
1724 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); |
1724 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); |
1725 unit->heater_state = 0; |
1725 unit->heater_state = 0; |
1726 pub_domoticz_output(unit->heater_idx, unit->heater_state); |
1726 // pub_domoticz_output(unit->heater_idx, unit->heater_state); |
1727 if (unit->heater_address) { |
1727 if (unit->heater_address) { |
1728 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1728 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1729 } |
1729 } |
1730 } |
1730 } |
1731 } |
1731 } |
1744 } else { |
1744 } else { |
1745 int power = round(unit->PID_cool->OutP); |
1745 int power = round(unit->PID_cool->OutP); |
1746 if (unit->cooler_state != power) { |
1746 if (unit->cooler_state != power) { |
1747 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); |
1747 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); |
1748 unit->cooler_state = power; |
1748 unit->cooler_state = power; |
1749 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
1749 // pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
1750 if (unit->cooler_address) { |
1750 if (unit->cooler_address) { |
1751 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1751 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1752 } |
1752 } |
1753 } |
1753 } |
1754 } |
1754 } |
1757 unit->cooler_wait--; |
1757 unit->cooler_wait--; |
1758 } else { |
1758 } else { |
1759 if (unit->cooler_state) { |
1759 if (unit->cooler_state) { |
1760 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); |
1760 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); |
1761 unit->cooler_state = 0; |
1761 unit->cooler_state = 0; |
1762 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
1762 // pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
1763 if (unit->cooler_address) { |
1763 if (unit->cooler_address) { |
1764 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1764 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1765 } |
1765 } |
1766 } |
1766 } |
1767 } |
1767 } |
1784 unit->fan_wait++; |
1784 unit->fan_wait++; |
1785 } else { |
1785 } else { |
1786 if (! unit->fan_state) { |
1786 if (! unit->fan_state) { |
1787 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); |
1787 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); |
1788 unit->fan_state = 100; |
1788 unit->fan_state = 100; |
1789 pub_domoticz_output(unit->fan_idx, unit->fan_state); |
1789 // pub_domoticz_output(unit->fan_idx, unit->fan_state); |
1790 if (unit->fan_address) { |
1790 if (unit->fan_address) { |
1791 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1791 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1792 } |
1792 } |
1793 } |
1793 } |
1794 } |
1794 } |
1797 unit->fan_wait--; |
1797 unit->fan_wait--; |
1798 } else { |
1798 } else { |
1799 if (unit->fan_state) { |
1799 if (unit->fan_state) { |
1800 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); |
1800 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); |
1801 unit->fan_state = 0; |
1801 unit->fan_state = 0; |
1802 pub_domoticz_output(unit->fan_idx, unit->fan_state); |
1802 // pub_domoticz_output(unit->fan_idx, unit->fan_state); |
1803 if (unit->fan_address) { |
1803 if (unit->fan_address) { |
1804 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1804 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1805 } |
1805 } |
1806 } |
1806 } |
1807 } |
1807 } |
1842 if (unit->prof_state != PROFILE_OFF) { |
1842 if (unit->prof_state != PROFILE_OFF) { |
1843 LCDspL = unit->prof_target_lo; |
1843 LCDspL = unit->prof_target_lo; |
1844 LCDspH = unit->prof_target_hi; |
1844 LCDspH = unit->prof_target_hi; |
1845 } |
1845 } |
1846 } |
1846 } |
1847 if ((seconds == 60) && ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_PROFILE))) { |
1847 // if ((seconds == 60) && ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_PROFILE))) { |
|
1848 // unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
1849 // } |
|
1850 if (seconds == 60) { |
1848 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1851 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1849 } |
1852 } |
1850 #ifdef HAVE_WIRINGPI_H |
1853 #ifdef HAVE_WIRINGPI_H |
1851 piLock(LOCK_LCD); |
1854 piLock(LOCK_LCD); |
1852 #endif |
1855 #endif |