Revoved old temperature sensors read errors workaround.

Thu, 09 May 2019 19:42:33 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 09 May 2019 19:42:33 +0200
changeset 596
e3d3cde32847
parent 595
d7342a8e7f4d
child 597
93667d842c9b

Revoved old temperature sensors read errors workaround.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Thu May 09 17:20:58 2019 +0200
+++ b/thermferm/devices.c	Thu May 09 19:42:33 2019 +0200
@@ -27,7 +27,6 @@
 #include "xutil.h"
 
 
-extern int		debug;
 extern sys_config	Config;
 extern int		my_shutdown;
 
@@ -313,8 +312,6 @@
 		    disableTransmit();
 		    piLock(LOCK_DEVICES);
 		    syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc);
-		    if (debug)
-			fprintf(stdout, "RC433 command %s rc=%d\n", buf, rc);
                     device->value = value;
 		    device->timestamp = time(NULL);
 		    piUnlock(LOCK_DEVICES);
@@ -363,8 +360,6 @@
 			(strcmp((char *)"SimFan"   , device->address) == 0) || (strcmp((char *)"SimLight" , device->address) == 0)) {
 			if (value != device->value) {
 			    syslog(LOG_NOTICE, "SIM %s value=%d", device->address, value);
-			    if (debug)
-			    	fprintf(stdout, "SIM %s value=%d\n", device->address, value);
 			}
 			device->value = value;
 			device->timestamp = time(NULL);
--- 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