thermferm/devices.c

changeset 715
f5d85af156ab
parent 714
24749c296a50
child 716
5c30c8ef83a8
--- a/thermferm/devices.c	Tue Apr 30 17:26:41 2024 +0200
+++ b/thermferm/devices.c	Wed May 01 14:38:37 2024 +0200
@@ -41,18 +41,6 @@
 extern const char	DEVDIR[7][11];
 
 
-#ifdef USE_SIMULATOR
-
-extern int	SIMcooling;
-extern int	SIMheating;
-extern int	SIMfan;
-extern int	SIMlight;
-
-#endif
-
-
-void devices_ws(void);
-
 
 /*
  * Since kernel version 4 there is a module, and a dtoverlay so that the
@@ -389,6 +377,28 @@
 }
 
 
+int device_present(char *address, int present)
+{
+    devices_list        *device;
+
+    if (address == NULL || present < DEVPRESENT_UNDEF || present > DEVPRESENT_ERROR) {
+	return -1;
+    }
+
+    for (device = Config.devices; device; device = device->next) {
+	if (! strcmp(address, device->address)) {
+	    if (device->present != present) {
+	    	device->present = present;
+		device->timestamp = time(NULL);
+		return 1;
+	    }
+	    return 0;
+	}
+    }
+    return -1;
+}
+
+
 /*
  * Return json data for one device.
  */

mercurial