1271 if (unit->air_address) { |
1271 if (unit->air_address) { |
1272 rc = device_in(unit->air_address, &temp); |
1272 rc = device_in(unit->air_address, &temp); |
1273 if (rc == DEVPRESENT_YES) { |
1273 if (rc == DEVPRESENT_YES) { |
1274 if (unit->air_temperature != temp) { |
1274 if (unit->air_temperature != temp) { |
1275 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1275 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1276 // pub_domoticz_temp(unit->air_idx, temp); |
|
1277 } |
1276 } |
1278 unit->air_temperature = temp; |
1277 unit->air_temperature = temp; |
1279 unit->air_state = 0; |
1278 unit->air_state = 0; |
1280 } else if (rc == DEVPRESENT_ERROR) { |
1279 } else if (rc == DEVPRESENT_ERROR) { |
1281 unit->air_state = 1; |
1280 unit->air_state = 1; |
1291 rc = device_in(unit->beer_address2, &temp); |
1290 rc = device_in(unit->beer_address2, &temp); |
1292 } |
1291 } |
1293 if (rc == DEVPRESENT_YES) { |
1292 if (rc == DEVPRESENT_YES) { |
1294 if (unit->beer_temperature != temp) { |
1293 if (unit->beer_temperature != temp) { |
1295 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1294 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1296 // pub_domoticz_temp(unit->beer_idx, temp); |
|
1297 } |
1295 } |
1298 unit->beer_temperature = temp; |
1296 unit->beer_temperature = temp; |
1299 unit->beer_state = 0; |
1297 unit->beer_state = 0; |
1300 } else if (rc == DEVPRESENT_ERROR) { |
1298 } else if (rc == DEVPRESENT_ERROR) { |
1301 unit->beer_state = 1; |
1299 unit->beer_state = 1; |
1307 if (unit->chiller_address) { |
1305 if (unit->chiller_address) { |
1308 rc = device_in(unit->chiller_address, &temp); |
1306 rc = device_in(unit->chiller_address, &temp); |
1309 if (rc == DEVPRESENT_YES) { |
1307 if (rc == DEVPRESENT_YES) { |
1310 if (unit->chiller_temperature != temp) { |
1308 if (unit->chiller_temperature != temp) { |
1311 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1309 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1312 // pub_domoticz_temp(unit->chiller_idx, temp); |
|
1313 } |
1310 } |
1314 unit->chiller_temperature = temp; |
1311 unit->chiller_temperature = temp; |
1315 unit->chiller_state = 0; |
1312 unit->chiller_state = 0; |
1316 } else if (rc == DEVPRESENT_ERROR) { |
1313 } else if (rc == DEVPRESENT_ERROR) { |
1317 unit->chiller_state = 1; |
1314 unit->chiller_state = 1; |
1328 if (rc == DEVPRESENT_YES) { |
1325 if (rc == DEVPRESENT_YES) { |
1329 if (temp) { |
1326 if (temp) { |
1330 if (unit->door_state == 0) { |
1327 if (unit->door_state == 0) { |
1331 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); |
1328 syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); |
1332 unit->door_state = 1; |
1329 unit->door_state = 1; |
1333 // pub_domoticz_output(unit->door_idx, unit->door_state); |
|
1334 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1330 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1335 } |
1331 } |
1336 } else { |
1332 } else { |
1337 if (unit->door_state) { |
1333 if (unit->door_state) { |
1338 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); |
1334 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); |
1339 unit->door_state = 0; |
1335 unit->door_state = 0; |
1340 // pub_domoticz_output(unit->door_idx, unit->door_state); |
|
1341 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1336 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1342 } |
1337 } |
1343 /* |
1338 /* |
1344 * If unit is active and the door is open |
1339 * If unit is active and the door is open |
1345 */ |
1340 */ |
1362 if (rc == DEVPRESENT_YES) { |
1357 if (rc == DEVPRESENT_YES) { |
1363 if (temp) { |
1358 if (temp) { |
1364 if (unit->psu_state == 0) { |
1359 if (unit->psu_state == 0) { |
1365 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); |
1360 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); |
1366 unit->psu_state = 1; |
1361 unit->psu_state = 1; |
1367 // pub_domoticz_output(unit->psu_idx, unit->psu_state); |
|
1368 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1362 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1369 } |
1363 } |
1370 } else { |
1364 } else { |
1371 if (unit->psu_state) { |
1365 if (unit->psu_state) { |
1372 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); |
1373 unit->psu_state = 0; |
1367 unit->psu_state = 0; |
1374 // pub_domoticz_output(unit->psu_idx, unit->psu_state); |
|
1375 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1368 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1376 } |
1369 } |
1377 unit->alarm_flag |= ALARM_FLAG_PSU; |
1370 unit->alarm_flag |= ALARM_FLAG_PSU; |
1378 } |
1371 } |
1379 } else { |
1372 } else { |
1714 } else { |
1707 } else { |
1715 int power = round(unit->PID_heat->OutP); |
1708 int power = round(unit->PID_heat->OutP); |
1716 if (unit->heater_state != power) { |
1709 if (unit->heater_state != power) { |
1717 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); |
1710 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); |
1718 unit->heater_state = power; |
1711 unit->heater_state = power; |
1719 // pub_domoticz_output(unit->heater_idx, unit->heater_state); |
|
1720 if (unit->heater_address) { |
1712 if (unit->heater_address) { |
1721 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1713 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1722 } |
1714 } |
1723 } |
1715 } |
1724 } |
1716 } |
1727 unit->heater_wait--; |
1719 unit->heater_wait--; |
1728 } else { |
1720 } else { |
1729 if (unit->heater_state) { |
1721 if (unit->heater_state) { |
1730 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); |
1722 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); |
1731 unit->heater_state = 0; |
1723 unit->heater_state = 0; |
1732 // pub_domoticz_output(unit->heater_idx, unit->heater_state); |
|
1733 if (unit->heater_address) { |
1724 if (unit->heater_address) { |
1734 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1725 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1735 } |
1726 } |
1736 } |
1727 } |
1737 } |
1728 } |
1750 } else { |
1741 } else { |
1751 int power = round(unit->PID_cool->OutP); |
1742 int power = round(unit->PID_cool->OutP); |
1752 if (unit->cooler_state != power) { |
1743 if (unit->cooler_state != power) { |
1753 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); |
1744 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); |
1754 unit->cooler_state = power; |
1745 unit->cooler_state = power; |
1755 // pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
|
1756 if (unit->cooler_address) { |
1746 if (unit->cooler_address) { |
1757 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1747 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1758 } |
1748 } |
1759 } |
1749 } |
1760 } |
1750 } |
1763 unit->cooler_wait--; |
1753 unit->cooler_wait--; |
1764 } else { |
1754 } else { |
1765 if (unit->cooler_state) { |
1755 if (unit->cooler_state) { |
1766 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); |
1756 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); |
1767 unit->cooler_state = 0; |
1757 unit->cooler_state = 0; |
1768 // pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
|
1769 if (unit->cooler_address) { |
1758 if (unit->cooler_address) { |
1770 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1759 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1771 } |
1760 } |
1772 } |
1761 } |
1773 } |
1762 } |
1790 unit->fan_wait++; |
1779 unit->fan_wait++; |
1791 } else { |
1780 } else { |
1792 if (! unit->fan_state) { |
1781 if (! unit->fan_state) { |
1793 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); |
1782 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); |
1794 unit->fan_state = 100; |
1783 unit->fan_state = 100; |
1795 // pub_domoticz_output(unit->fan_idx, unit->fan_state); |
|
1796 if (unit->fan_address) { |
1784 if (unit->fan_address) { |
1797 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1785 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1798 } |
1786 } |
1799 } |
1787 } |
1800 } |
1788 } |
1803 unit->fan_wait--; |
1791 unit->fan_wait--; |
1804 } else { |
1792 } else { |
1805 if (unit->fan_state) { |
1793 if (unit->fan_state) { |
1806 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); |
1794 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); |
1807 unit->fan_state = 0; |
1795 unit->fan_state = 0; |
1808 // pub_domoticz_output(unit->fan_idx, unit->fan_state); |
|
1809 if (unit->fan_address) { |
1796 if (unit->fan_address) { |
1810 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1797 unit->mqtt_flag |= MQTT_FLAG_DATA; |
1811 } |
1798 } |
1812 } |
1799 } |
1813 } |
1800 } |