Hmmm, well spotted @marvin7
I looked at the code on an iPad and was focussing on the temperature reading code and the delays on the main loop. The bits that were missing didn’t jump out at me!
@wolph42 take a look at the code I posted in this thread:
You’ll need to change the GPIO numbers (I think the Sonoff switch is connected to GPIO0) and once it’s working then you could add-in the temperature and humidity code from your existing sketch.