Thank you @adwsystems, It is getting clear now how the loop function should be structured. @wvmarle , i bought the ESP-8266 just to send the data from the sensors to a web server that i can access anywhere anytime. It was before i realized it all could be done without the arduino itself. About the relays, it is very important that they are reliable. That's why i've been thinking about instead of connecting them to the arduino, i use normal temporizers as i been doing and buy a luminosity sensor to just "check" is the light is on or off. I think it will be easier with the amount of skills i have by now.
I really wanna thank everybody for spendig your time to teach me.