diff -r db997a04fde3 -r 4f34271cf1e7 thermferm/devices.c --- a/thermferm/devices.c Tue Aug 05 16:24:17 2014 +0200 +++ b/thermferm/devices.c Tue Aug 05 21:33:06 2014 +0200 @@ -38,16 +38,21 @@ devices_list *device; char buf[40]; int i, rc; + time_t now; if (uuid == NULL) return 0; - if (debug) - fprintf(stdout, "device_out(%s, %d)\n", uuid, value); + now = time(NULL); for (device = Config.devices; device; device = device->next) { if (strcmp(uuid, device->uuid) == 0) { - if (value != device->value) { + /* + * Execute command if different then the old value. But also + * every 2 minutes because commands can get lost of devices were + * disconnected, or with radio problems. + */ + if ((value != device->value) || (((int)now - (int)device->timestamp) > 120)) { #ifdef HAVE_WIRINGPI_H rc = 0; @@ -81,6 +86,7 @@ } } } + return 0; }