Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.

Sun, 10 Jul 2022 14:33:13 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 10 Jul 2022 14:33:13 +0200
changeset 614
389097dc665d
parent 613
163fcb0914e2
child 615
33a5b63e86d7

Version 0.9.11. Removed lcd debug message after 7 years. Added setup for alternative beer sensor. If the main sensor is gone, the alternative will be used.

.hgignore file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
kicad/ThermFerm.pro file | annotate | diff | comparison | revisions
thermferm/lcd-buffer.c file | annotate | diff | comparison | revisions
thermferm/rdconfig.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
tools/init.slackware file | annotate | diff | comparison | revisions
www-thermferm/units.php file | annotate | diff | comparison | revisions
--- a/.hgignore	Fri May 28 14:25:56 2021 +0200
+++ b/.hgignore	Sun Jul 10 14:33:13 2022 +0200
@@ -13,6 +13,7 @@
 mash/mash
 brewco/brewco
 brewpanel/brewpanel
+kicad/ThermFerm.pro
 
 syntax: glob
 *.o
--- a/configure	Fri May 28 14:25:56 2021 +0200
+++ b/configure	Sun Jul 10 14:33:13 2022 +0200
@@ -661,7 +661,6 @@
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -735,7 +734,6 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE}'
@@ -988,15 +986,6 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1134,7 +1123,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1287,7 +1276,6 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -2047,9 +2035,9 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.9.10"
-COPYRIGHT="Copyright (C) 2014-2020 Michiel Broek, All Rights Reserved"
-CYEARS="2014-2020"
+VERSION="0.9.11"
+COPYRIGHT="Copyright (C) 2014-2022 Michiel Broek, All Rights Reserved"
+CYEARS="2014-2022"
 
 
 
--- a/configure.ac	Fri May 28 14:25:56 2021 +0200
+++ b/configure.ac	Sun Jul 10 14:33:13 2022 +0200
@@ -8,9 +8,9 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.9.10"
-COPYRIGHT="Copyright (C) 2014-2020 Michiel Broek, All Rights Reserved"
-CYEARS="2014-2020"
+VERSION="0.9.11"
+COPYRIGHT="Copyright (C) 2014-2022 Michiel Broek, All Rights Reserved"
+CYEARS="2014-2022"
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
 AC_SUBST(COPYRIGHT)
--- a/kicad/ThermFerm.pro	Fri May 28 14:25:56 2021 +0200
+++ b/kicad/ThermFerm.pro	Sun Jul 10 14:33:13 2022 +0200
@@ -1,4 +1,4 @@
-update=vr 28 mei 2021 13:36:53 CEST
+update=za 29 mei 2021 11:55:01 CEST
 version=1
 last_client=kicad
 [general]
--- a/thermferm/lcd-buffer.c	Fri May 28 14:25:56 2021 +0200
+++ b/thermferm/lcd-buffer.c	Sun Jul 10 14:33:13 2022 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2014-2015
+ * Copyright (C) 2014-2022
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -115,7 +115,6 @@
 	    current_offset += Config.lcd_rows;
 	else
 	    current_offset = 0;
-	syslog(LOG_NOTICE, "lcd_buf_step(KEY_DOWN) current_lines=%d current_offset=%d", current_lines, current_offset);
 	lcd_buf_show();
     }
     if (key == KEY_UP) {
@@ -123,7 +122,6 @@
 	    current_offset -= Config.lcd_rows;
 	else
 	    current_offset = (current_lines - Config.lcd_rows);
-	syslog(LOG_NOTICE, "lcd_buf_step(KEY_UP) current_lines=%d current_offset=%d", current_lines, current_offset);
 	lcd_buf_show();
     }
 }
--- a/thermferm/rdconfig.c	Fri May 28 14:25:56 2021 +0200
+++ b/thermferm/rdconfig.c	Sun Jul 10 14:33:13 2022 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2014-2019
+ * Copyright (C) 2014-2022
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -275,6 +275,9 @@
 		xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state);
 		xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature);
 		xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_IDX", "%d", tmp3->beer_idx);
+		if (tmp3->beer_address2) {
+		    xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS2", "%s", tmp3->beer_address2);
+		}
 	    }
 	    if (tmp3->chiller_address) {
 		xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_ADDRESS", "%s", tmp3->chiller_address);
@@ -644,6 +647,9 @@
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS"))) {
 	    unit->beer_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS2"))) {
+            unit->beer_address2 = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+        }
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_STATE"))) {
 	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	    if (sscanf((const char *)key, "%d", &ival) == 1)
--- a/thermferm/server.c	Fri May 28 14:25:56 2021 +0200
+++ b/thermferm/server.c	Sun Jul 10 14:33:13 2022 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2008-2020
+ * Copyright (C) 2008-2022
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -1210,6 +1210,9 @@
 		if (current->beer_address)
 		    free(current->beer_address);
 		current->beer_address = NULL;
+		if (current->beer_address2)
+                    free(current->beer_address2);
+                current->beer_address2 = NULL;
 		if (current->chiller_address)
 		    free(current->chiller_address);
 		current->chiller_address = NULL;
@@ -1270,6 +1273,9 @@
 		if (current->beer_address)
 		    free(current->beer_address);
 		current->beer_address = NULL;
+		if (current->beer_address2)
+                    free(current->beer_address2);
+                current->beer_address2 = NULL;
 		if (current->chiller_address)
 		    free(current->chiller_address);
 		current->chiller_address = NULL;
@@ -1393,7 +1399,7 @@
 	unit->product_code = xstrcpy((char *)"FAKE0000");
 	unit->product_name = xstrcpy(param);
 	unit->alias = xstrcpy(an);
-	unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = unit->cooler_address = \
+	unit->air_address = unit->beer_address = unit->beer_address2 = unit->chiller_address = unit->heater_address = unit->cooler_address = \
 			    unit->fan_address = unit->door_address = unit->light_address = \
 			    unit->psu_address = unit->profile_uuid = unit->profile_name = NULL;
 	unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
@@ -1488,6 +1494,7 @@
 		srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0);
 		srv_send((char *)"AIR_IDX,%d", unit->air_idx);
 		srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address));
+		srv_send((char *)"BEER_ADDRESS2,%s", MBSE_SS(unit->beer_address2));
 		srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]);
 		srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0);
 		srv_send((char *)"BEER_IDX,%d", unit->beer_idx);
@@ -1670,6 +1677,20 @@
 				    unit->beer_address = NULL;
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
 
+			    } else if (strcmp(kwd, (char *)"BEER_ADDRESS2") == 0) {
+                                if (val && unit->beer_address2 && (strcmp(val, unit->beer_address2)))
+                                    syslog(LOG_NOTICE, "Fermenter unit %s beer address alt `%s' to `%s'", unit->uuid, unit->beer_address2, val);
+                                if (unit->beer_address2) {
+                                    device_count(FALSE, unit->beer_address2);
+                                    free(unit->beer_address2);
+                                }
+                                if (val) {
+                                    unit->beer_address2 = xstrcpy(val);
+                                    device_count(TRUE, unit->beer_address2);
+                                } else
+                                    unit->beer_address2 = NULL;
+                                unit->mqtt_flag |= MQTT_FLAG_DATA;
+
 			    } else if (val && (strcmp(kwd, (char *)"BEER_IDX") == 0)) {
 				if (sscanf(val, "%d", &ival) == 1) {
 				    if (unit->beer_idx != ival)
--- a/thermferm/thermferm.c	Fri May 28 14:25:56 2021 +0200
+++ b/thermferm/thermferm.c	Sun Jul 10 14:33:13 2022 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2014-2021
+ * Copyright (C) 2014-2022
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -1286,6 +1286,10 @@
 
 		if (unit->beer_address) {
 		    rc = device_in(unit->beer_address, &temp);
+		    if ((rc == DEVPRESENT_NO) && unit->beer_address2) {
+			/* Read alternative sensor */
+			rc = device_in(unit->beer_address2, &temp);
+		    }
 		    if (rc == DEVPRESENT_YES) {
 			if (unit->beer_temperature != temp) {
 			    unit->mqtt_flag |= MQTT_FLAG_DATA;
--- a/thermferm/thermferm.h	Fri May 28 14:25:56 2021 +0200
+++ b/thermferm/thermferm.h	Sun Jul 10 14:33:13 2022 +0200
@@ -155,6 +155,7 @@
     int			air_temperature;	/* Air temperature in C * 1000	*/
     int			air_idx;		/* Domoticz idx			*/
     char		*beer_address;		/* DS18B20 address		*/
+    char		*beer_address2;		/* Alternative sensor address	*/
     int			beer_state;		/* 0=ok, 1=missing, 2=error 	*/
     int			beer_temperature;	/* Beer temperature in C * 1000	*/
     int			beer_idx;		/* Domoticz idx			*/
--- a/tools/init.slackware	Fri May 28 14:25:56 2021 +0200
+++ b/tools/init.slackware	Sun Jul 10 14:33:13 2022 +0200
@@ -2,7 +2,7 @@
 #
 # thermferm init script for Slackware.
 #
-# Copyright 2021 Michiel Broek, the Netherlands.
+# Copyright 2022 Michiel Broek, the Netherlands.
 
 PIDFILE=/var/run/thermferm.pid
 
@@ -29,7 +29,7 @@
 
   restart)
     $0 stop
-    sleep 1
+    sleep 2
     $0 start
     ;;
 
--- a/www-thermferm/units.php	Fri May 28 14:25:56 2021 +0200
+++ b/www-thermferm/units.php	Sun Jul 10 14:33:13 2022 +0200
@@ -65,7 +65,7 @@
     }
 
     unset($_POST['UUID']);
-    unset($_POST['roductName']);
+    unset($_POST['ProductName']);
     unset($_POST['key']);
     unset($_POST['command']);
     load('units.php');
@@ -97,6 +97,7 @@
 	$cmd[] = "AIR_IDX,".$_POST['AirIdx'];
 	$cmd[] = "BEER_ADDRESS,".$_POST['BeerAddress'];
 	$cmd[] = "BEER_IDX,".$_POST['BeerIdx'];
+	$cmd[] = "BEER_ADDRESS2,".$_POST['BeerAddress2'];
 	$cmd[] = "CHILLER_ADDRESS,".$_POST['ChillerAddress'];
 	$cmd[] = "CHILLER_IDX,".$_POST['ChillerIdx'];
 	$cmd[] = "HEATER_ADDRESS,".$_POST['HeaterAddress'];
@@ -451,6 +452,26 @@
 		$outstr .= '        <td class="editfield"><input type="text" name="BeerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "BEER_ADDRESS2") {
+                $outstr .= '       <tr class="editor">'.PHP_EOL;
+                $outstr .= '        <td class="editname">Beer Sensor Address (alt)</td>'.PHP_EOL;
+                $outstr .= '        <td colspan="3" class="editfield"><select name="BeerAddress2">'.PHP_EOL;
+                $outstr .= '         <option value="">Not Assigned</option>'.PHP_EOL;
+                if (startsWith($devices[0], "212")) {
+                    $j = 1;
+                    while (1) {
+                        if (strcmp($devices[$j], ".") == 0)
+                            break;
+                        $g = explode(",", $devices[$j]);
+                        if ($g[5] == "IN_ANALOG") {
+                            ($f[1] == $g[0]) ? $se = " selected" : $se = "";
+                            $outstr .= '         <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
+                        }
+                        $j++;
+                    }
+                }
+                $outstr .= '        </select></td></tr>'.PHP_EOL;
+            }
 
 	    if ($f[0] == "CHILLER_ADDRESS") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;

mercurial