Method for automatically controlling at least one device of a building by means of a building management system and building management system