A system for automatic setup and control of Lighting, Heating Ventilation and Air Conditioning systems comprising a set of occupancy detectors and at least one controller where the controller determines various aspects of the building control based on the input of the occupancy detectors.