thermferm/thermferm.c

changeset 596
e3d3cde32847
parent 594
1904badedf8f
child 597
93667d842c9b
--- a/thermferm/thermferm.c	Thu May 09 17:20:58 2019 +0200
+++ b/thermferm/thermferm.c	Thu May 09 19:42:33 2019 +0200
@@ -1009,7 +1009,7 @@
     time_t		now, last = (time_t)0, ndata = (time_t)0;;
     units_list		*unit;
     prof_step		*step;
-    int			row, rc, run = 1, seconds = 0, minutes = 0, temp, deviation;
+    int			row, rc, run = 1, seconds = 0, minutes = 0, temp;
     int			run_seconds, run_minutes, run_hours, tot_minutes, key;
     struct tm		*tm;
 #ifndef HAVE_WIRINGPI_H
@@ -1271,26 +1271,12 @@
 		if (unit->air_address) {
 		    rc = device_in(unit->air_address, &temp);
 		    if (rc == DEVPRESENT_YES) {
-			/*
-			 * It is possible to have read errors or extreme values.
-			 * This can happen with bad connections so we compare the
-			 * value with the previous one. If the difference is too
-			 * much, we don't send that value. That also means that if
-			 * the next value is ok again, it will be marked invalid too.
-			 * Maximum error is 40 degrees for now.
-			 */
-			deviation = 40000;
-			if ((unit->air_temperature == 0) ||
-			    (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) {
-			    if (unit->air_temperature != temp) {
-				unit->mqtt_flag |= MQTT_FLAG_DATA;
-				pub_domoticz_temp(unit->air_idx, temp);
-			    }
-			    unit->air_temperature = temp;
-			    unit->air_state = 0;
-			} else {
-			    syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp);
+			if (unit->air_temperature != temp) {
+			    unit->mqtt_flag |= MQTT_FLAG_DATA;
+			    pub_domoticz_temp(unit->air_idx, temp);
 			}
+			unit->air_temperature = temp;
+			unit->air_state = 0;
 		    } else if (rc == DEVPRESENT_ERROR) {
 			unit->air_state = 1;
 		    } else {
@@ -1301,18 +1287,12 @@
 		if (unit->beer_address) {
 		    rc = device_in(unit->beer_address, &temp);
 		    if (rc == DEVPRESENT_YES) {
-			deviation = 40000;
-			if ((unit->beer_temperature == 0) ||
-			    (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) {
-			    if (unit->beer_temperature != temp) {
-				unit->mqtt_flag |= MQTT_FLAG_DATA;
-				pub_domoticz_temp(unit->beer_idx, temp);
-			    }
-    			    unit->beer_temperature = temp;
-			    unit->beer_state = 0;
-			} else {
-			    syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp);
+			if (unit->beer_temperature != temp) {
+			    unit->mqtt_flag |= MQTT_FLAG_DATA;
+			    pub_domoticz_temp(unit->beer_idx, temp);
 			}
+    			unit->beer_temperature = temp;
+			unit->beer_state = 0;
 		    } else if (rc == DEVPRESENT_ERROR) {
 			unit->beer_state = 1;
 		    } else {
@@ -1323,18 +1303,12 @@
 		if (unit->chiller_address) {
 		    rc = device_in(unit->chiller_address, &temp);
 		    if (rc == DEVPRESENT_YES) {
-			deviation = 40000;
-			if ((unit->chiller_temperature == 0) ||
-			    (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) {
-			    if (unit->chiller_temperature != temp) {
-				unit->mqtt_flag |= MQTT_FLAG_DATA;
-				pub_domoticz_temp(unit->chiller_idx, temp);
-			    }
-			    unit->chiller_temperature = temp;
-			    unit->chiller_state = 0;
-			} else {
-			    syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp);
+			if (unit->chiller_temperature != temp) {
+			    unit->mqtt_flag |= MQTT_FLAG_DATA;
+			    pub_domoticz_temp(unit->chiller_idx, temp);
 			}
+			unit->chiller_temperature = temp;
+			unit->chiller_state = 0;
 		    } else if (rc == DEVPRESENT_ERROR) {
 			unit->chiller_state = 1;
 		    } else {

mercurial