Better door and 12 volt detection and logging

Thu, 12 May 2016 21:43:07 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 12 May 2016 21:43:07 +0200
changeset 503
003c20125212
parent 502
0e2c58f8eb78
child 504
862de87f9f89

Better door and 12 volt detection and logging

thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/thermferm.c	Wed May 11 14:47:27 2016 +0200
+++ b/thermferm/thermferm.c	Thu May 12 21:43:07 2016 +0200
@@ -1282,7 +1282,6 @@
 		/*
 		 * Unit door state, default is closed.
 		 */
-		unit->door_state = 1;
 		if (unit->door_address) {
 		    rc = device_in(unit->door_address, &temp);
 		    if (rc == DEVPRESENT_YES) {
@@ -1299,13 +1298,16 @@
 				mqtt_publish_str(unit->alias, (char *)"door", (char *)"open");
 			    }
 			}
+		    } else {
+			unit->door_state = 1;
 		    }
+		} else {
+		    unit->door_state = 1;
 		}
 
 		/*
-		 * Unit PSU state, default power is ok
+		 * Unit PSU state
 		 */
-		unit->psu_state = 1;
 		if (unit->psu_address) {
 		    rc = device_in(unit->psu_address, &temp);
 		    if (rc == DEVPRESENT_YES) {
@@ -1322,7 +1324,14 @@
 				mqtt_publish_str(unit->alias, (char *)"12volt", (char *)"off");
 			    }
 			}
+		    } else {
+			unit->psu_state = 1;
 		    }
+		} else {
+		    /*
+		     * No state available, assume Ok.
+		     */
+		    unit->psu_state = 1;
 		}
 
 		/*

mercurial