On the macroscopic properties of discrete media with nearly periodic microstructures