   runTimerDoLightOff();
 
   pirValue = digitalRead(pir);
+  if ( oldpirValue != pirValue ) {
+    pirSent = HIGH;
+    oldpirValue = pirValue;
+  }
 
   payload = "{\"Humidity\":";
   payload += h;


  lastRelayActionmillis = millis();
  oldrelaystatus = relaystatus ;
  //relayIsReady = LOW;    
}

void getdht22temp()

IPAddress time_server = MQTT_SERVER;

// pin
//#define pir 13
//#define DHTPIN 14
#define pir 16
#define DHTPIN 2
#define RELAYPIN 4
#define TOPBUTTONPIN 5

// DHT22
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

// OTHER
#define REPORT_INTERVAL 9500 // in msec
