Smart Wi-Fi thermostat for smart buildings