diff -r b2265c7e5707 -r 819553a2b97e thermferm/devices.c --- a/thermferm/devices.c Wed Apr 17 19:54:56 2024 +0200 +++ b/thermferm/devices.c Thu Apr 18 14:20:19 2024 +0200 @@ -51,6 +51,9 @@ #endif +void devices_ws(void); + + /* * Since kernel version 4 there is a module, and a dtoverlay so that the * temperature and humidity can simply read from the /sys filesystem. @@ -287,6 +290,7 @@ syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc); device->value = value; device->timestamp = time(NULL); + devices_ws(); // pthread_mutex_unlock(&mutexes[LOCK_DEVICES]); return rc; } @@ -299,8 +303,11 @@ if (strncmp(device->address, (char *)"3a", 2) == 0) { syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); // pthread_mutex_lock(&mutexes[LOCK_DEVICES]); - device->value = (value == 0) ? 0 : 1; - device->timestamp = time(NULL); + if (device->value != (value == 0) ? 0 : 1) { + device->value = (value == 0) ? 0 : 1; + device->timestamp = time(NULL); + devices_ws(); + } // pthread_mutex_unlock(&mutexes[LOCK_DEVICES]); } } @@ -311,17 +318,18 @@ (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); + device->value = value; + device->timestamp = time(NULL); + if (strcmp((char *)"SimCooler", device->address) == 0) + SIMcooling = value; + if (strcmp((char *)"SimHeater", device->address) == 0) + SIMheating = value; + if (strcmp((char *)"SimFan", device->address) == 0) + SIMfan = value; + if (strcmp((char *)"SimLight", device->address) == 0) + SIMlight = value; + devices_ws(); } - device->value = value; - device->timestamp = time(NULL); - if (strcmp((char *)"SimCooler", device->address) == 0) - SIMcooling = value; - if (strcmp((char *)"SimHeater", device->address) == 0) - SIMheating = value; - if (strcmp((char *)"SimFan", device->address) == 0) - SIMfan = value; - if (strcmp((char *)"SimLight", device->address) == 0) - SIMlight = value; } } #endif