Problem when I call callback function and temperature

I already post same problem on stackoverflow, but I have no answers for my problem jet. So maybe you guys can help me with my problem.

In arduino I wrote a first program with my DS18B20 sensor, which is displaying temperature in openHAB over MQTT procotol. Second program is the same thing (openhab, mqtt) just switch lamp, meaning that when I press the switch, the lamp or LED turns on or off over callback function in Arduino. Separately both programs works just fine, but when I am trying to join them together it doesn’t work as I would like. Seems to me, that the problem is with loop function. When I press switch ON or OFF, sometimes (rarely) I can turn lamp on or off. So my question is…what is wrong? Is it problem with loop, because arduino can’t procede two things in the loop in the same time? Can it be solved, I really don’t know what to do next. Please help me and thanks in advance!
I was testing some more and realize that whatever I write in loop function (besides my “client.loop();”, which is callback function) it stop working.
I have code for both programs here stackoverflow theme of my problem
Any suggestion at all will be very appreciated!

Not an answer to your question, but: you may take a look at ESPEasy firmware, DS18B20 and Switches - and many, many more devices - are supported through an nice GUI and MQTT is included.
Works very reliable with openHAB …

Edit: upps, you are working with an Arduino, not an ESP8266 …